2015-04-09 11 views
8

वर्तमान में मेरे पास दो हबेस टेबल हैं (उन्हें tableA और tableB पर कॉल करें)। tableA में डेटा को एक ही चरण MapReduce नौकरी का उपयोग करके संसाधित किया जाता है और tableB पर सहेजा जाता है। वर्तमान में दोनों टेबल एक ही एचबीएस क्लस्टर पर रहते हैं। हालांकि, मुझे क्लस्टर पर tableB स्थानांतरित करने की आवश्यकता है।मैं एक एचबीएएस उदाहरण से कैसे पढ़ सकता हूं लेकिन दूसरे को लिख सकता हूं?

क्या एचडीएएस के अलग-अलग उदाहरणों से पढ़ने और लिखने के लिए हडोप में नौकरी को कम करने के लिए एक एकल चरण मानचित्र को कॉन्फ़िगर करना संभव है?

+0

आप इस प्रकार के नौकरी के लिए स्पार्क का उपयोग कर सकते हैं। – Tinku

उत्तर

3

यह संभव है, HBase के CopyTable MapReduce jobTableMapReduceUtil.initTableReducerJob() जो आप के मामले में एक विकल्प के quorumAddress सेट करने के लिए दूरदराज के समूहों को लिखने की ज़रूरत की अनुमति देता है का उपयोग करके यह करता है:

public static void initTableReducerJob(String table, Class<? extends TableReducer> reducer, org.apache.hadoop.mapreduce.Job job, Class partitioner, String quorumAddress, String serverClass, String serverImpl) 

quorumAddress - दूर स्थित समूह लिखने के लिए सेवा मेरे; hbase-site.xml में निर्दिष्ट क्लस्टर में आउटपुट के लिए डिफ़ॉल्ट शून्य है। पर एक वैकल्पिक रिमोट क्लस्टर के ज़ूकीपर को इकट्ठा करने के लिए स्ट्रिंग करें, तो डिफ़ॉल्ट के अलावा अन्य क्लस्टर लिखना कम होगा; जैसे क्लस्टर्स के बीच तालिकाओं की प्रतिलिपि बनाना, स्रोत होगा hbase-site.xml द्वारा निर्दिष्ट और इस पैरा में रिमोट क्लस्टर के पते होगा। पास करने के लिए प्रारूप विशेष है। पास :: जैसे सर्वर, सर्वर 2, सर्वर 3: 2181:/hbase।


एक अन्य विकल्प के बजाय संदर्भ के लिए लिख के दूरदराज के मेज पर लिखने के लिए अपने स्वयं के कस्टम कम करने को लागू करने की है। इसके साथ कुछ:

public static class MyReducer extends Reducer<Text, Result, Text, Text> { 

    protected Table remoteTable; 
    protected Connection connection; 

    @Override 
    protected void setup(Context context) throws IOException, InterruptedException { 
     super.setup(context); 
     // Clone configuration and provide a new quorum address for the remote cluster 
     Configuration config = HBaseConfiguration.create(context.getConfiguration()); 
     config.set("hbase.zookeeper.quorum","quorum1,quorum2,quorum3"); 
     connection = ConnectionFactory.createConnection(config); // HBase 0.99+ 
     //connection = HConnectionManager.createConnection(config); // HBase <0.99 
     remoteTable = connection.getTable("myTable".getBytes()); 
     remoteTable.setAutoFlush(false); 
     remoteTable.setWriteBufferSize(1024L*1024L*10L); // 10MB buffer 
    } 

    public void reduce(Text boardKey, Iterable<Result> results, Context context) throws IOException, InterruptedException { 
     /* Write puts to remoteTable */ 
    } 

    @Override 
    protected void cleanup(Context context) throws IOException, InterruptedException { 
     super.cleanup(context); 
     if (remoteTable!=null) { 
      remoteTable.flushCommits(); 
      remoteTable.close(); 
     } 
     if(connection!=null) { 
      connection.close(); 
     } 
    } 
} 
+0

उन लोगों से प्यार करना चाहिए जो मस्ती के लिए पूरी तरह से वैध उत्तरों को कम करता है। –

+0

एक कस्टम कमी का एक उदाहरण प्रदान करने के लिए धन्यवाद – slayton

संबंधित मुद्दे

 संबंधित मुद्दे