Cluster-A導出:
step1(導出到hdfs臨時目錄 /backup):
使用hbaseExport幫助: hbase org.apache.hadoop.hbase.mapreduce.Export help
正則rowKey前綴匹配導出: hbase --config /tmp/hbase-client-conf org.apache.hadoop.hbase.mapreduce.Export safeclound.tb_ammeter /backup/tb_ammeter 1 1531843200000 1532016000000 ^11611119,ELE_P,119,01,201904
step2(從hdfsget到本地磁盤):
hdfs dfs -get /backup/tb_ammmeter /root/export-backup
step3(scp到Cluster-B ):
scp /root/export-backup/tb_ammeter cluster.b:/root/import-backup
Cluster-B導入:
step1(將本地磁盤數(shù)據(jù)文件上傳至hdfs):
hdfs dfs -put?/root/export-backup/tb_ammeter /backup
step2(導入hbase表數(shù)據(jù)目錄):
hbase org.apache.hadoop.hbase.mapreduce.Import safeclound.tb_ammeter /backup/tb_ammeter
注:
1. 前提條件,兩個集群一定都要開啟yarn資源調(diào)度服務,實際上都是通過MR任務export/import的;
2. 其中--config /tmp/hbase-client-conf參數(shù)表示可以臨時指定hbase配置文件,默認可無需顯示指定,因本人是使用的阿里云的EMR3.2(客戶端配置存在bug),若不加--config直接使用配置將會報
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.hbase.ipc.controller.ServerRpcControllerFactory 的錯誤,EMR3.2錯誤解決請參考??阿里EMR3.2 hbase/phoenix配置BUG
源碼參考:org.apache.hadoop.hbase.mapreduce.Export 的rowKey的前綴匹配實現(xiàn)
