user1586205
user1586205

Reputation: 283

How to copy an existing hbase table

I have a Hbase table X and I want to create an exact copy of it and name it Y. Could someone let me know how it is possible?

Thanks

Upvotes: 25

Views: 31955

Answers (7)

Arnon Rotem-Gal-Oz
Arnon Rotem-Gal-Oz

Reputation: 25909

Assuming you want to copy the table on the same cluster you can use HBase snapshots in the hbase shell you can

snapshot 'sourceTable', 'sourceTable-snapshot'
clone_snapshot 'sourceTable-snapshot', 'newTable'

Upvotes: 37

Pratik Patil
Pratik Patil

Reputation: 3753

CopyTable command is very handy to replicate HBase Tables. Use it in the following way:

hbase org.apache.hadoop.hbase.mapreduce.CopyTable --new.name=Y X;

Upvotes: 7

Joker
Joker

Reputation: 96

In hbase shell check version;

hbase(main):001:0> version
0.90.4, r1150278, Sun Jul 24 15:53:29 PDT 2011

if older version of 0.94.6 then you should use mapredeuce jobs. snapshots are available since 0.94.6 if it is above, you may use toby941 answer or you can use one of these

A)

./hbase org.apache.hadoop.hbase.mapreduce.CopyTable
Usage: CopyTable [--rs.class=CLASS] [--rs.impl=IMPL] [--starttime=X] [--endtime=Y] [--new.name=NEW] [--peer.adr=ADR] <tablename>

B-1)

./hbase org.apache.hadoop.hbase.mapreduce.Export
Usage: Export [-D <property=value>]* <tablename> <outputdir> [<versions> [<starttime> [<endtime>]]]

B-2) then import with whatever name you want

./hbase org.apache.hadoop.hbase.mapreduce.Import
Usage: Import <tablename> <inputdir>

Upvotes: 1

AkD
AkD

Reputation: 437

Snapshot methodology may not work if you are on older version of hbase https://issues.apache.org/jira/browse/HBASE-8742 . In that case you may have to manually copy hbase schema and then apply snapshot or better to upgrade to fixed version.

Upvotes: 0

toby941
toby941

Reputation: 378

use hbase shell
1. make sure you enbale snapshot in hbase-site.xml

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

2. hbase> snapshot 'x' ,'snapshot_x'
3. hbase> clone_snapshot 'snapshot_x' ,'another_x'

Upvotes: 3

Kamal D
Kamal D

Reputation: 11

this will work..

hbase org.apache.hadoop.hbase.mapreduce.Export tableA /hbase_export/tableA

hbase org.apache.hadoop.hbase.mapreduce.Import /hbase_export/tableA tableAcopy

Upvotes: 0

Praveen Sripati
Praveen Sripati

Reputation: 33495

According to the HBase documentations here (1, 2) are the options.

Upvotes: 0

Related Questions