Configure the Default Database for HBase Clients
For Hbase version 1.1 and above, a default database configuration determines whether clients connect to HBase tables or MapR-DB tables. You can change the default setting for all Hbase clients or you can set the database for a particular job. This setting is ignored for HBase 0.98.12 client connections.
Set the Default Database using configure.sh
About this task
-defaultdb
parameter when you run configure.sh, it
automatically sets the default database using the following criteria: Criteria | Default Database |
---|---|
HBaseMaster or HBaseRegionServer is installed | HBase |
MapR DB client is installed and HBaseMaster or HBaseRegionServer are not installed | MapR-DB |
Procedure
-defaultdb
parameter to
explicitly set the default database to either maprdb
or
hbase
.
configure.sh -R -defaultdb maprdb
Set the Default Database using hbase-site.xml
About this task
mapr.hbase.default.db
property in the
hbase-site.xml to override the default database that is set for the cluster. Procedure
-
In the hbase-site.xml, edit the default value of mapr.hbase.default.db and
set it to either
hbase
ormaprdb
.For example:<property> <name>mapr.hbase.default.db</name> <value>hbase</value> </property>
- Copy the property to the hbase-site.xml on each node that runs Hbase including HBase client nodes.
Set the Database Type in the Job Configuration
Procedure
- To connect to MapR-DB tables:
Configuration conf = HBaseConfiguration.create(); conf.set("mapr.hbase.default.db", "maprdb"); Connection connection = ConnectionFactory.createConnection(conf); Table table = connection.getTable(<TABLE_NAME>);
- To connect to HBase tables:
Configuration conf = HBaseConfiguration.create(); conf.set("mapr.hbase.default.db","hbase"); Connection connection = ConnectionFactory.createConnection(conf); Table table = connection.getTable(<TABLE_NAME>);