HBase——Snapshot(快照)
一. 基于Hbase snapshot数据快速备份方法1)创建快照(查看快照->查看快照snapshot命令相关参数->创建快照—>查看快照)查看snapshothbase(main):002:0> list_snapshotsSNAPSHOTTABLE + CREATION TIME0 row(s) in 0.0290 seconds查看help
·
一. 基于Hbase snapshot数据快速备份方法
1)创建快照(查看快照->查看快照snapshot命令相关参数->创建快照—>查看快照)
查看snapshot
hbase(main):002:0> list_snapshots
SNAPSHOT TABLE + CREATION TIME
0 row(s) in 0.0290 seconds
查看help:
hbase(main):003:0> snapshot
ERROR: wrong number of arguments (0 for 2)
Here is some help for this command:
Take a snapshot of specified table. Examples:
hbase> snapshot 'sourceTable', 'snapshotName'
hbase> snapshot 'namespace:sourceTable', 'snapshotName', {SKIP_FLUSH => true}
创建snapshot 例子:
hbase(main):004:0> snapshot 'emp','emp_snapshot'
0 row(s) in 0.3730 seconds
hbase(main):005:0> list_snapshots
SNAPSHOT TABLE + CREATION TIME
emp_snapshot emp (Wed May 16 09:44:53 +0800 2018)
1 row(s) in 0.0190 seconds
=> ["emp_snapshot"]
2)删除并查看快照
hbase(main):006:0> delete_snapshot 'emp_snapshot'
0 row(s) in 0.0390 seconds
hbase(main):007:0> list_snapshots
SNAPSHOT TABLE + CREATION TIME
0 row(s) in 0.0040 seconds
=> []
3)基于快照,clone一个新表
hbase(main):011:0> clone_snapshot 'emp_snapshot','new_emp'
0 row(s) in 0.5290 seconds
hbase(main):013:0> scan 'new_emp'
ROW COLUMN+CELL
1 column=personal data:city, timestamp=1526269334560, value=hyderabad
1 column=personal data:name, timestamp=1526269326929, value=raju
1 column=professional data:designation, timestamp=1526269345044, value=manager
1 column=professional data:salary, timestamp=1526269352605, value=50000
1 row(s) in 0.1050 seconds
hbase(main):014:0> desc 'new_emp'
Table new_emp is ENABLED
new_emp
COLUMN FAMILIES DESCRIPTION
{NAME => 'personal data', BLOOMFILTER => 'ROW', VERSIONS => '1', IN_MEMORY => 'false', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', COMPRESSION => 'NONE', MIN_VERSIONS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATION_SCOPE
=> '0'}
{NAME => 'professional data', BLOOMFILTER => 'ROW', VERSIONS => '1', IN_MEMORY => 'false', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', COMPRESSION => 'NONE', MIN_VERSIONS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATION_S
COPE => '0'}
2 row(s) in 0.0370 seconds
4)基于快照恢复表(原hbase表emp需要删除)
hbase(main):027:0> list
TABLE
new_emp
t1
test
3 row(s) in 0.0130 seconds
=> ["new_emp", "t1", "test"]
hbase(main):028:0> list_snapshots
SNAPSHOT TABLE + CREATION TIME
emp_snapshot emp (Wed May 16 09:45:25 +0800 2018)
1 row(s) in 0.0130 seconds
=> ["emp_snapshot"]
hbase(main):029:0> restore_snapshot 'emp_snapshot'
0 row(s) in 0.3700 seconds
hbase(main):030:0> list
TABLE
emp
new_emp
t1
test
4 row(s) in 0.0240 seconds
=> ["emp", "new_emp", "t1", "test"]
5)基于快照将数据导出到另外一个集群中的本地文件中
利用mapreduce job将emp_snapshot这个snapshot 导出到本地目录usr/hdp/2.5.3.0-37/hbase/hbasedata
hbase org.apache.hadoop.hbase.snapshot.ExportSnapshot -snapshot 'emp_snapshot' -copy-to file:usr/hdp/2.5.3.0-37/hbase/hbasedata -mappers 16
6)基于快照将数据导出到另外一个集群中的hdfs上
hbase org.apache.hadoop.hbase.snapshot.ExportSnapshot -snapshot 'emp_snapshot' -copy-to hdfs:///hbase/bak_emp_snapshot -mappers 16
更多推荐
已为社区贡献1条内容
所有评论(0)