Part-6 Installing HBase

In this article I will show you how to install HBase. I assume you have followed previous articles on how to install HDFS single node cluster. At minimum you need any HDP Platform (HDFS) running on your server.

http://hadooptutorials.info/2017/09/14/hadoop-installation-on-signle-node-cluster/

Download HBase tar.gz file from below official site
https://hbase.apache.org

cd ~/Downloads
wget http://apache.claz.org/hbase/stable/hbase-1.2.6-bin.tar.gz

Extract .tar.gz file

tar -zxvf hbase-1.2.6-bin.tar.gz

Create directory for HBase home.

mkdir -p /usr/lib/hbase

Move extracted folder to this directory

mv hbase-1.2.6 /usr/lib/hbase/

Edit Hbase configuration file

cd /usr/lib/hbase/hbase-1.2.6/conf
vi hbase-site.xml

Add below configurations. Adjust hbase.rootdir value as per your hadoop installation.

<configuration>
  <property>
    <name>hbase.rootdir</name>
    <value>hdfs://localhost:54310/hbase</value>
  </property>
  <property>
    <name>hbase.cluster.distributed</name>
    <value>true</value>
  </property>
  <property>
</configuration>

Edit hbase-env.sh file

vi hbase-env.sh

Set JAVA_HOME path inside hbase-env.sh. For example add below line in this file. Adjust path as per your Java installation directory.

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64

Make hbase-env.sh executable

chmod +x hbase-env.sh

Add HBASE_HOME variable in ~/.bashrc

vi ~/.bashrc

Add below line

export HBASE_HOME=/usr/lib/hbase/hbase-1.2.6

Reload environment variables

source ~/.bashrc

Start HBase Server

$HBASE_HOME/bin/start-hbase.sh

Installation complete. Now test hbase through shell

$HBASE_HOME/bin/hbase shell

It should give you hbase shell like below

HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 1.2.6, rUnknown, Mon May 29 02:25:32 CDT 2017
hbase(main):001:0>

Try few commands like ‘list’ and ‘create’

hbase(main):001:0> list
TABLE
0 row(s) in 0.1120 seconds
=> ["test"]

Create a table named test with a single column family named cf. Verify its creation by listing all tables and then insert some values.

hbase(main):003:0> create 'test', 'cf'
0 row(s) in 1.2200 seconds
hbase(main):003:0> list 'test'
..
1 row(s) in 0.0550 seconds
hbase(main):004:0> put 'test', 'row1', 'cf:a', 'value1'
0 row(s) in 0.0560 seconds
hbase(main):005:0> put 'test', 'row2', 'cf:b', 'value2'
0 row(s) in 0.0370 seconds
hbase(main):006:0> put 'test', 'row3', 'cf:c', 'value3'
0 row(s) in 0.0450 seconds

Above we inserted 3 values, one at a time. The first insert is at row1, column cf:a with a value of value1. Columns in HBase are comprised of a column family prefix — cf in this example — followed by a colon and then a column qualifier suffix (a in this case).

Verify the data insert by running a scan of the table as follows

hbase(main):007:0> scan 'test'
ROW        COLUMN+CELL
row1       column=cf:a, timestamp=1288380727188, value=value1
row2       column=cf:b, timestamp=1288380738440, value=value2
row3       column=cf:c, timestamp=1288380747365, value=value3
3 row(s) in 0.0590 seconds

For easy start/stop of Hbase service you can edit our standard start.sh and stop.sh to add below commands.

vi ~/start.sh

add below line,

$HBASE_HOME/bin/start-hbase.sh
vi ~/stop.sh

add below line

$HBASE_HOME/bin/stop-hbase.sh

Leave a Reply

Your email address will not be published. Required fields are marked *