Snapshots commonly used commands

HBase Snapshots allow you to take a snapshot (you can use copy) for a table, it will not have a huge impact on the Region Servers, and copy it to resume operations when not include data copy. Export Snapshot to another cluster does not have an impact on Region Servers. Here to tell you how to use Snapshots feature

1. Turn snapshot support, version after 0.95+ is enabled by default, is turned off by default in 0.94.6+  

<property>
    <name>hbase.snapshot.enabled</name> <value>true</value> </property>

 

2. Establish a snapshot to the table, regardless of the table is enabled or disabled, this action does not copy data

$ ./bin/hbase shell 
hbase> snapshot 'myTable', 'myTableSnapshot-122112'

 

3. List the existing snapshot

$ ./bin/hbase shell 
hbase> list_snapshots

 

4. Delete Snapshot

$ ./bin/hbase shell 
hbase> delete_snapshot 'myTableSnapshot-122112'

 

5. generates a new snapshot from a table

$ ./bin/hbase shell 
hbase> clone_snapshot 'myTableSnapshot-122112', 'myNewTestTable'

 

6. restore data snapshot, it will need to disable the table, then recover

$ ./bin/hbase shell
hbase> disable 'myTable' 
hbase> restore_snapshot 'myTableSnapshot-122112'


Tip: Because backup (replication) is a system log level, and a snapshot of the file system level, when using the snapshot recovery, a copy of the will and master for different states, if you need to restore, you want to stop backing, and reset bootstrap.

If it is because of incorrect client behavior leads to data loss and the need to restore full table table is disabled, the snapshot can be used to generate a new table, new table and then copy the necessary data to the main table with them map-reduce.

 

7. Copy them to another cluster

This operation is executed hbase to use the account, and to have the temporary directory hbase account established (hbase.tmp.dir parameter control) in which hdfs

Using 16 mappers to copy the snapshot to a named MySnapshot among a cluster called the srv2

$ bin/hbase class org.apache.hadoop.hbase.snapshot.tool.ExportSnapshot -snapshot MySnapshot -copy-to hdfs://srv2:8020/hbase -mappers 16

Guess you like

Origin www.cnblogs.com/qfdy123/p/12176087.html