概述
A集群HBase中有个表testTableCopy, 要将其复制到B集群的HBase中。
使用HBase表复制工具./hbase org.apache.hadoop.hbase.mapreduce.CopyTable
1root@host:/tstar/hbase/bin-->./hbase org.apache.hadoop.hbase.mapreduce.CopyTable 2Usage: CopyTable [general options] [--starttime=X] [--endtime=Y] [--new.name=NEW] [--peer.adr=ADR] <tablename> 3 4Options: 5 rs.class hbase.regionserver.class of the peer cluster 6 specify if different from current cluster 7 rs.impl hbase.regionserver.impl of the peer cluster 8 startrow the start row 9 stoprow the stop row 10 starttime beginning of the time range (unixtime in millis) 11 without endtime means from starttime to forever 12 endtime end of the time range. Ignored if no starttime specified. 13 versions number of cell versions to copy 14 new.name new table's name 15 peer.adr Address of the peer cluster given in the format 16 hbase.zookeeer.quorum:hbase.zookeeper.client.port:zookeeper.znode.parent 17 families comma-separated list of families to copy 18 To copy from cf1 to cf2, give sourceCfName:destCfName. 19 To keep the same name, just give "cfName" 20 all.cells also copy delete markers and deleted cells 21 bulkload Write input into HFiles and bulk load to the destination table 22 23Args: 24 tablename Name of the table to copy 25 26Examples: 27 To copy 'TestTable' to a cluster that uses replication for a 1 hour window: 28 $ bin/hbase org.apache.hadoop.hbase.mapreduce.CopyTable --starttime=1265875194289 --endtime=1265878794289 --peer.adr=server1,server2,server3:2181:/hbase --families=myOldCf:myNewCf,cf2,cf3 TestTable 29For performance consider the following general options: 30-Dhbase.client.scanner.caching=100 31-Dmapred.map.tasks.speculative.execution=false
准备
- 工具必须在A集群HBase master节点上进行;
- 在A集群HBase master节点上须要配置B集群HBase的相关主机名到hosts中,原则上是zookeeper及HBase相关节点主机名;
- 在B集群HBase中预先建好复制的目标表,目标表的表名可以和原始的表名,目标表的列族名和来源表的列族名,可以不同;
执行复制
./hbase -Dhbase.root.logger=INFO,RFA -Dhbase.log.dir=/tmp -Dhbase.log.file=copytable.log org.apache.hadoop.hbase.mapreduce.CopyTable --peer.adr=test61,test62,test63:2181:/hbase --families=1 "tstar:testTableCopy"