Hbase 数据迁移
可选方案对比
l 已验证方案操作说明:
n Export&import
u 导出命令及示例
hbase org.apache.hadoop.hbase.mapreduce.Export “表名” 文件路径
导出至本地文件系统:
./bin/hbase org.apache.hadoop.hbase.mapreduce.Export ‘default:tsdb-uid’ file:///tmp/tsdb-uid
./bin/hbase org.apache.hadoop.hbase.mapreduce.Export ‘default:tsdb’ file:///tmp/tsdb
导出至HDFS:
./bin/hbase org.apache.hadoop.hbase.mapreduce.Export ‘default:tsdb-uid’ /home/hdfs/tsdb-uid
./bin/hbase org.apache.hadoop.hbase.mapreduce.Export ‘default:tsdb’ /home/hdfs/tsdb
u 导入命令及示例
./bin/hbase org.apache.hadoop.hbase.mapreduce.Import “表名” 文件路径
./bin/hbase org.apache.hadoop.hbase.mapreduce.Import ‘tsdb_export’ file:///opt/iotplatform/1.6.6/0678/hbase/tsdb_export
./bin/hbase org.apache.hadoop.hbase.mapreduce.Import ‘tsdb_export’ /tmp/hbase/tsdb_export
n Snapshot
u 创建snapshot
hbase> snapshot ‘tsdb’, ‘tsdb_snapshot’
u 迁移snapshot
离线导出至本地文件系统:
./bin/hbase org.apache.hadoop.hbase.snapshot.ExportSnapshot -snapshot ‘tsdb_snapshot’ -copy-to file:///tmp/tsdb_snapshot
离线导入至HDFS:
./bin/hbase org.apache.hadoop.hbase.snapshot.ExportSnapshot -snapshot ‘tsdb_snapshot’ -copy-from file:///tmp/tsdb_snapshot -copy-to hdfs://172.17.194.18:8020/hbase -mappers 20 -bandwidth 20
在线迁移snapshot:
./bin/hbase org.apache.hadoop.hbase.snapshot.ExportSnapshot -snapshot ‘tsdb_snapshot’ -copy-from hdfs://172.20.32.134:8020/hbase -copy-to hdfs://172.17.194.18:8020/hbase -mappers 20 -bandwidth 20
u 从snapshot恢复表和数据
hbase> clone_snapshot ‘tsdb_snapshot’, ‘tsdb_snapshot’
n 暴力同步(非必要,不建议采用该方式,元数据修复操作较复杂且有风险):
u 文件备份同步略
u 元数据修复相关命令:
./bin/hbase hbck -j hbase-hbck2-1.1.0-SNAPSHOT.jar extraRegionsInMeta --fix default:tsdb-uid
./bin/hbase hbck -j hbase-hbck2-1.1.0-SNAPSHOT.jar addFsRegionsMissingInMeta default:tsdb-uid
./bin/hbase org.apache.hbase.HBCK2 bypass -r pid
./bin/hbase org.apache.hbase.HBCK2 assigns -o regionencodeid
./bin/hbase org.apache.hbase.HBCK2 unassigns regionencodeid