您的位置:首页 > 其它

HBase集群间不停服迁移数据

2016-04-25 15:08 399 查看
基本思路就是首先拷贝并复制snapshot到目的集群,然后开启两个集群间的数据实时同步,最后,将创建snapshot到开启数据同步之间的数据通过MR任务拷贝。

以表test_table为例: 

1、添加原集群到目标集群的replication关系,并在目标集群中建立与原集群相同的表;

2、通过snapshot把历史数据导入到从集群: 
在原集群执行以下指令: 
a、list_snapshots 
b、snapshot ‘test_table’, ‘test_table_snapshot' 
c、bin/hbase org.apache.hadoop.hbase.snapshot.ExportSnapshot -snapshot test_table_snapshot -copy-to
hdfs://yourdestination:9100/hbase -mappers 16 
在目标集群执行以下指令: 
a、disable ‘test_table' 
b、restore_snapshot ‘test_table_snapshot’ 
c、enable 'test_table' 

3、开启原表的replication 
原集群执行: 
alter ‘test_table’,{NAME=>’f’,REPLICATION_SCOP=>’1’} 

4、通过Export工具把快照和开启replication之间的数据导入到从表; 
在原集群执行以下指令: 
bin/hbase org.apache.hadoop.hbase.mapreduce.Export test_table hdfs://yourdestination:9100/import/test_table 1
1445961600000 1446048000000 
1:指定了版本数,与线上一致 
1445875200000 1445961600000:指定了起始时间戳 
在目标集群执行以下指令: 
bin/hbase org.apache.hadoop.hbase.mapreduce.Import test_table hdfs://yourdestination:9100/import/test_table 

注意事项: 
1、路径hdfs://yourdestination:9100/,端口是hdfs对外服务的端口,在hdfs-site.xml中配置,yourdestination是你目的集群中active
namenode的主机名
2、补充一点,第四部的Export工具将数据从源集群写入目标集群时是带着数据的时间戳一起写入的,因为存在这样的前提,所以保证了第四部补充数据时不会出现语义错误
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: