文章目录
一、准备工作
1.1 准备两台装好Hbase的服务器
服务器名 | IP |
---|---|
server1 | 192.168.48.128 |
server4 | 192.168.48.131 |
1.2 Server1的Hbase创建一个带数据的table1表
创建table1表
hbase(main):012:0> create 'table1', 'tab1_id'
hbase(main):013:0> put 'table1','1','tab1_id:name','liuli'
hbase(main):014:0> put 'table1','2','tab1_id:id','1122'
查看结果
hbase(main):013:0> scan "table1"
1.3 目的
1、将server1的table1快照存至本地
2、server1的table1快照恢复至server4上
二、Server1创建快照
2.1 创建table1的快照
hbase(main):014:0> snapshot "table1","table1_bak"
Took 2.8525 seconds
查看快照
hbase(main):015:0> list_snapshots
[root@server1 ~]# hadoop dfs -ls /hbase/.hbase-snapshot
存在于hadoop目录空间中
2.2 将快照迁移到server4上
[root@server1 ~]# hbase org.apache.hadoop.hbase.snapshot.ExportSnapshot -snapshot table1_bak -copy-from hdfs://192.168.48.128:9000/hbase -copy-to hdfs://192.168.48.131:9000/hbase -mappers 20 -bandwidth 1024
查看server4上的快照
*2.3 将快照备份至本地(备份用)
hadoop dfs -get /hbase/table1_bak /data/table1_snapshot
本地/data目录内容
table1_snapshot目录内容
三、Server4还原快照
3.1 使用clone_snapshot生成新表还原
hbase(main):014:0> clone_snapshot "table1_bak","table1"
Took 1.5783 seconds
查看新表
hbase(main):015:0> scan "table1"