In Hbase, you can create different namespaces as per your requirements. You can think namespace as schema in relational database. When you create HBase tables without specifying namespace then tables will be available in “default” namespace. In this article, we will check steps to migrate HBase tables from default to another namespace with some examples.
HBase Snapshots
You can INSERT (single value at a time) data into tables that is present in another namespace using HBase PUT command. But, you can’t use the HBase put command to copy entire table to another namespace.
HBase supports the concept called ‘snapshot’, you can create snapshot of the existing table in the default namespace and then clone that in required namespace.
Related reading:
- How to Rename HBase Table?
- Read HBase Tables using scan shell command and examples
- Insert data using HBase shell put Command and Examples
- Hbase Namespace Commands and Examples
HBase Create Table Snapshot
Below is the syntax for creating namespace in HBase:
HBase Create Table Snapshot Example
Below example demonstrates the HBase table snapshot creation:
Steps to Migrate HBase Tables from Default to another Namespace
You can follow below steps to copy Hbase table from default namespace to another namespace:
Step1: Create Snapshot of HBase table
You need to create snapshot to be migrated or copy to different namespace. You must disable the table and then create snapshot.
Step2: Clone Snapshot to new Namespace with same or different table names
Once table snapshot is created you can clone the snapshot to new namespace.
Step3: Use Scan Command to Verify Table in New namespace
Check the migrated table with scan command.
Step4: Delete Snapshot
Once the table is migrated, you must delete the HBase table snapshot.
Step5: Drop Original Table
The last step would be to drop original HBase table that you just migrated to new namespace.