HBase, a hadoop NoSQL database – Backup Process Explained

Hi Readers,

I am happy to post another blog post on how to take HBase backup of a HBase data/ tables in hortonworks sandbox 2.5.

Important:  You may get the following error in hbase shell.
ERROR: Can’t get master address from ZooKeeper; znode data == null
Just open ambari(Hortonworks Sandbox) / cloudera manager(Cloudera Sandbox) start the zookeeper service (or) HBase master to get rid of the above error.

I will help you to understand the different ways the backup can be taken for a HBase datasets.

Type 1 :

Export

HBase has a utility called Export, which is used to export the data of the HBase table to plain sequence files in the HDFS folder. A map reduce job gets created which will call the hbase cluster to get the data from specified table and write it to the hdfs folder.

You can export data from HBase table to

  • Local File System: It just copies into my hdfs rather than my local file system. So, from hdfs i need to move the part-m-00000 to local file system.
  • HDFS- It just copies to my hdfs.
[root@sandbox ~]# hbase org.apache.hadoop.hbase.mapreduce.Export "person" "/jthiyaga/"

where person is the table name in hbase and jose is local file system directory.

2017-03-22 17:12:53,304 INFO [main] util.RegionSizeCalculator: Calculating region sizes for table "person".
2017-03-22 17:12:54,034 INFO [main] client.ConnectionManager$HConnectionImplementation: Closing master protocol: MasterService
2017-03-22 17:12:54,034 INFO [main] client.ConnectionManager$HConnectionImplementation: Closing zookeeper sessionid=0x15af6c30f1e0017
2017-03-22 17:12:54,041 INFO [main] zookeeper.ZooKeeper: Session: 0x15af6c30f1e0017 closed
2017-03-22 17:12:54,041 INFO [main-EventThread] zookeeper.ClientCnxn: EventThread shut down
2017-03-22 17:12:54,639 INFO [main] mapreduce.JobSubmitter: number of splits:1
2017-03-22 17:12:54,679 INFO [main] Configuration.deprecation: io.bytes.per.checksum is deprecated. Instead, use dfs.bytes-per-checksum
2017-03-22 17:12:55,331 INFO [main] mapreduce.JobSubmitter: Submitting tokens for job: job_1490198811520_0001
2017-03-22 17:12:59,111 INFO [main] impl.YarnClientImpl: Submitted application application_1490198811520_0001
2017-03-22 17:12:59,311 INFO [main] mapreduce.Job: The url to track the job: http://sandbox.hortonworks.com:8088/proxy/application_1490198811520_0001/
2017-03-22 17:12:59,316 INFO [main] mapreduce.Job: Running job: job_1490198811520_0001
2017-03-22 17:14:17,273 INFO [main] mapreduce.Job: Job job_1490198811520_0001 running in uber mode : false

Import

You can also import the data from local filesystem. A map reduce job gets created which will call the import the data from hdfs folder to the existing hbase table.

[root@sandbox ~]# hbase org.apache.hadoop.hbase.mapreduce.Import "person" "/jthiyaga/"
2017-03-22 17:27:56,304 INFO [main] impl.TimelineClientImpl: Timeline service address: http://sandbox.hortonworks.com:8188/ws/v1/timeline/
2017-03-22 17:27:56,434 INFO [main] client.RMProxy: Connecting to ResourceManager at sandbox.hortonworks.com/172.17.0.2:8050
2017-03-22 17:27:56,776 INFO [main] client.AHSProxy: Connecting to Application History server at sandbox.hortonworks.com/172.17.0.2:10200
2017-03-22 17:28:06,379 INFO [main] input.FileInputFormat: Total input paths to process : 1
2017-03-22 17:28:06,605 INFO [main] mapreduce.JobSubmitter: number of splits:1
2017-03-22 17:28:07,507 INFO [main] mapreduce.JobSubmitter: Submitting tokens for job: job_1490198811520_0002
2017-03-22 17:28:09,156 INFO [main] impl.YarnClientImpl: Submitted application application_1490198811520_0002
2017-03-22 17:28:09,546 INFO [main] mapreduce.Job: The url to track the job: http://sandbox.hortonworks.com:8088/proxy/application_1490198811520_0002/
2017-03-22 17:28:09,551 INFO [main] mapreduce.Job: Running job: job_1490198811520_0002
2017-03-22 17:28:47,656 INFO [main] mapreduce.Job: Job job_1490198811520_0002 running in uber mode : false
2017-03-22 17:28:47,878 INFO [main] mapreduce.Job: map 0% reduce 0%
2017-03-22 17:29:11,169 INFO [main] mapreduce.Job: map 100% reduce 0

Type 2:

CopyTable

The copytable will directly write the data into an existing HBase table. This can be done in same cluster or a remote cluster.

Both cluster should be online in order to make this done.

[root@sandbox jthiyaga]# hbase org.apache.hadoop.hbase.mapreduce.CopyTable --new.name=personNew person

where person is existing table (with data) and personNew is a table which i have created. The copytable will copy data from person to personNew table. Behind the scenes a mapreduce job will run.

Type 3:

Snapshots

The above types needs the following:

  • a fast reliable network connection to connect the remote cluster.

You can also use Snapshots to have less performance impact on your cluster.

Type 4:

Cluster Shutdown

Simple, easy but not recommended type of HBase data backup. As you need to shutdown the HBase cluster to stop data write to the cluster.

Just open hbase-site.xml. The following shows your table and data are being saved at this location ‘hdfs dfs -ls /apps/hbase/data

<property>
 <name>hbase.rootdir</name>
 <value>hdfs://sandbox.hortonworks.com:8020/apps/hbase/data</value>
 </property>

The following shows the personNew table which i have imported using Import option.

[root@sandbox conf]# hdfs dfs -ls /apps/hbase/data/data/default
Found 6 items
drwxr-xr-x - hbase hdfs 0 2016-09-13 10:59 /apps/hbase/data/data/default/ATLAS_ENTITY_AUDIT_EVENTS
drwxr-xr-x - hbase hdfs 0 2017-03-20 16:16 /apps/hbase/data/data/default/MyStream
drwxr-xr-x - hbase hdfs 0 2016-09-13 10:59 /apps/hbase/data/data/default/atlas_titan
drwxr-xr-x - hbase hdfs 0 2016-09-13 11:09 /apps/hbase/data/data/default/iemployee
drwxr-xr-x - hbase hdfs 0 2017-03-20 17:27 /apps/hbase/data/data/default/person
drwxr-xr-x - hbase hdfs 0 2017-03-22 17:38 /apps/hbase/data/data/default/personNew
[root@sandbox conf]# hdfs dfs -ls /apps/hbase/data/data/default/personNew
Found 3 items
drwxr-xr-x - hbase hdfs 0 2017-03-22 17:38 /apps/hbase/data/data/default/personNew/.tabledesc
drwxr-xr-x - hbase hdfs 0 2017-03-22 17:38 /apps/hbase/data/data/default/personNew/.tmp
drwxr-xr-x - hbase hdfs 0 2017-03-22 17:38 /apps/hbase/data/data/default/personNew/59acfc94838d84a3f1810efaacda0da8

Thanks for reading this post. Subscribe my blog for  some awesome posts.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s