Copy Hbase table from one cluster to another

Listing Snapshots
$ ./bin/hbase shell
hbase> list_snapshots
Deleting Snapshots
$ ./bin/hbase shell
hbase> delete_snapshot 'myTableSnapshot-122112'
Clone a table from snapshot
$ ./bin/hbase shell
hbase> clone_snapshot 'myTableSnapshot-122112', 'myNewTestTable'
Restore a snapshot
$ ./bin/hbase shell
hbase> disable 'myTable'
hbase> restore_snapshot 'myTableSnapshot-122112'
Export to another cluster
$ hbase org.apache.hadoop.hbase.snapshot.ExportSnapshot -snapshot MySnapshot -copy-to hdfs:///srv2:8082/hbase -mappers 16
To export the snapshot and change the ownership of the files during the copy:
$ hbase org.apache.hadoop.hbase.snapshot.ExportSnapshot -snapshot MySnapshot -copy-to hdfs://srv2:8020/hbase -chuser MyUser -chgroup MyGroup -chmod 700 -mappers 16
To export from one remote cluster to another remote cluster, specify both 
-copy-from and -copy-to parameters. You could then reverse the direction to 
restore the snapshot back to the first remote cluster.
$ hbase org.apache.hadoop.hbase.snapshot.ExportSnapshot -snapshot snapshot-test -copy-from hdfs://machine1/hbase -copy-to hdfs://machine2/my-backup
To specify a different name for the snapshot on the target cluster, use the 
-target option.
$ hbase org.apache.hadoop.hbase.snapshot.ExportSnapshot -snapshot snapshot-test -copy-from hdfs://machine1/hbase -copy-to hdfs://machine2/my-backup -target <new-snapshot-name>

su - hbase

$ hbase shell
17/10/17 14:00:21 INFO Configuration.deprecation: hadoop.native.lib is deprecated. Instead, use io.native.lib.available
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 1.0.0-cdh5.5.1, rUnknown, Wed Dec  2 10:36:43 PST 2015

hbase(main):001:0> snapshot 'userprofile', 'snap_userprofile'
0 row(s) in 8.3040 seconds

$ hbase org.apache.hadoop.hbase.snapshot.ExportSnapshot -snapshot snap_userprofile -copy-to hdfs://<namenode>:8020/apps/hbase/data -mappers 16 -bandwidth 200


$ hbase org.apache.hadoop.hbase.snapshot.ExportSnapshot -snapshot snap_userprofile -copy-from hdfs://<namenode>:8020/hbase -copy-to hdfs://<namenode>:8020/apps/hbase/data -mappers 16 -bandwidth 200

$ hadoop fs -chown -R hbase:hadoop /apps/hbase/data/archive/data/default/
$ hadoop fs -chown -R hbase:hadoop /apps/hbase/data/.hbase-snapshot/

Data will be copied to:

hbase(main):001:0> list_snapshots
SNAPSHOT                                 TABLE + CREATION TIME
 snap_userprofile               userprofile (Tue Oct 17 14:01:12 +0530 2017)
1 row(s) in 0.1850 seconds

hbase(main):001:0> restore_snapshot 'snap_userprofile'

There are no comments yet

Leave a comment

Your email address will not be published. Required fields are marked *