5. Creating Highly-Available HBase Tables

HBase tables are not highly available by default. To enable high availability, designate a table as HA during table creation.

Creating HA Tables with the HBase Java API

HBase application developers create highly available HBase tables programmatically, using the Java API, as shown in the following example:

HTableDescriptor htd = 
    new HTableDesscriptor(TableName.valueOf("test_table"));
htd.setRegionReplication(2);
...
admin.createTable(htd);

This example creates a table named test_table that is replicated to one secondary region. To replicate test_table to two secondary replicas, pass 3 as a parameter to the setRegionReplication() method.

Creating HA Tables with the HBase Shell

Create HA tables using the HBase shell using the REGION_REPLICATION keyword. Valid values are 1, 2, and 3, indicating the total number of copies. The default value is 1.

The following example creates a table named t1 that is replicated to one secondary replica:

    CREATE 't1', 'f1', {REGION_REPLICATION => 2}

To replicate t1 to two secondary regions, set REGION_REPLICATION to 3:

    CREATE 't1', 'f1', {REGION_REPLICATION => 3}