-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Hbase Essentials
By :

In fully distributed and pseudo-distributed modes, a HBase cluster has many components such as HBase Master, ZooKeeper, RegionServers, HDFS DataNodes, and so on, discussed as follows:
HBASE_MANAGES_ZK
variable in conf/hbase-env.sh
with the default value true
signifies that HBase is going to manage ZooKeeper. We can specify the ZooKeeper configuration in the native zoo.cfg
file or its values such as client, port, and so on directly in conf/hbase-site.xml
. It is advisable that you have an odd number of ZooKeeper ensembles such as one/three/five for more host failure tolerance. The following is an example of hbase-site.xml
with ZooKeeper settings:<property> <name>hbase.zookeeper.property.clientPort</name> <value>2222</value> </property> <property> <name>hbase.zookeeper.quorum</name> <value>ZooKeeperhost1, ZooKeeperhost2, ZooKeeperhost3<value> </property> <property> <name>hbase.zookeeper.property.dataDir</name> <value>/opt/zookeeper<value> </property>
conf
/regionservers
file with each region server on a separate line, and the start/stop of these region servers is controlled by the script files responsible for an HBase cluster's start/stop.Apart from the mentioned components, there are other considerations as well, such as hardware and software considerations, that are not within the scope of this book.
The backup HBase Master server and the additional region servers can be started in the pseudo-distributed mode using the utility provided bin directory as follows:
[root@localhost hbase-0.96.2-hadoop2]# bin/local-master-backup.sh 2 3
The preceding command will start the two additional HBase Master backup servers on the same box. Each HMaster server uses three ports (16010
, 16020
, and 16030
by default) and the new backup servers will be using ports 16012
/16022
/16032
and 16013
/16023
/16033
.
[root@localhost hbase-0.96.2-hadoop2]# bin/local-regionservers.sh start 2 3
The preceding command will start the two additional HBase region servers on the same box using ports 16202
/16302
.
Now that we have everything installed and running, let's start playing with it and try out a few commands to get a feel of HBase. HBase comes with a command-line interface that works for both local and distributed modes. The HBase shell is developed in JRuby and can run in both interactive (recommended for simple commands) and batch modes (recommended for running shell script programs). Let's start the HBase shell in the interactive mode as follows:
[root@localhost hbase-0.98.7-hadoop2]# bin/hbase shell
The preceding command gives the following output:
Type help
and click on return to see a listing of the available shell commands and their options. Remember that all the commands are case-sensitive.
The following is a list of some simple commands to get your hands dirty with HBase:
status
: This verifies whether HBase is up and running, as shown in the following screenshot:create '<table_name>', '<column_family_name>'
: This creates a table with one column family. We can use multiple column family names as well, as shown in the following screenshot:list
: This provides the list of tables, as shown in the following screenshot:put '<table_name>', '<row_num>', 'column_family:key', 'value'
: This command is used to put data in the table in a column family manner, as shown in the following screenshot. HBase is a schema-less database and provides the flexibility to store any type of data without defining it:get '<table_name>', '<row_num>'
: This command is used to read a particular row from the table, as shown in the following screenshot:scan '<table_name >'
: This scans the complete table and outputs the results, as shown in the following screenshot:delete '<table_name>', '<row_num>', 'column_family:key'
: This deletes the specified value, as shown in the following screenshot:describe '<table_name>'
: This describes the metadata information about the table, as shown in the following screenshot:drop '<table_name>'
: This command will drop the table. However, before executing this command, we should first execute disable '<tablename>'
, as shown in the following screenshot:Refer to the following link for more commands: http://wiki.apache.org/hadoop/Hbase/Shell
Change the font size
Change margin width
Change background colour