There are quite a few HBase tutorials out there, but the reason I wanted to add another one was for two specific reasons:
1. To document the installation steps (HBase stand-alone mode) for my ready reference in future
2. To highlight the installation issues I faced and how I got around them so that anyone else facing the same can benefit.
Installation Steps
Download and install the latest version of Ubuntu from http://www.ubuntu.com/download
In my case I downloaded and installed Ubuntu 12.04.1 64-bit i.e. ubuntu-12.04.1-desktop-amd64.iso
Download and install Java SDK from http://www.oracle.com/technetwork/java/javase/downloads/index.html
Since Cloudera recommends JDK version 1.6.0_31 (https://ccp.cloudera.com/display/CDH4DOC/Java+Development+Kit+Installation)
I downloaded the same and installed it as follows:
root@ubuntu:~# mkdir /opt/java root@ubuntu:~# cd /opt/java/ root@ubuntu:/opt/java# chmod +x jdk-6u31-linux-x64.bin root@ubuntu:/opt/java# ./jdk-6u31-linux-x64.bin ... ... ... ... ... ... ... ... root@ubuntu:/opt/java# root@ubuntu:/opt/java# ls -lth jdk1.6.0_31/ total 19M -r--r--r-- 1 root root 4.7K Oct 6 14:32 register_zh_CN.html -r--r--r-- 1 root root 5.1K Oct 6 14:32 register.html -r--r--r-- 1 root root 6.5K Oct 6 14:32 register_ja.html drwxr-xr-x 7 root root 4.0K Oct 6 14:32 jre drwxr-xr-x 3 root root 4.0K Oct 6 14:32 lib drwxr-xr-x 7 root root 4.0K Jan 20 2012 db drwxr-xr-x 3 root root 4.0K Jan 20 2012 include drwxr-xr-x 9 root root 4.0K Jan 20 2012 sample drwxr-xr-x 10 root root 4.0K Jan 20 2012 demo drwxr-xr-x 4 root root 4.0K Jan 20 2012 man drwxr-xr-x 2 root root 4.0K Jan 20 2012 bin -r--r--r-- 1 root root 3.3K Jan 20 2012 COPYRIGHT -r--r--r-- 1 root root 40 Jan 20 2012 LICENSE -r--r--r-- 1 root root 115 Jan 20 2012 README.html -r--r--r-- 1 root root 165K Jan 20 2012 THIRDPARTYLICENSEREADME.txt -rw-r--r-- 1 root root 19M Jan 20 2012 src.zip root@ubuntu:/opt/java#
Set the JAVA_HOME environment variable
root@ubuntu:~# echo $JAVA_HOME root@ubuntu:~# root@ubuntu:~# vi .bashrc
Add the following lines, save and exit:
export JAVA_HOME=/opt/java/jdk1.6.0_31 export PATH=$JAVA_HOME/bin:$PATH
Check
root@ubuntu:~# source .bashrc root@ubuntu:~# echo $JAVA_HOME /opt/java/jdk1.6.0_31 root@ubuntu:~# root@ubuntu:~# java -version java version "1.6.0_31" Java(TM) SE Runtime Environment (build 1.6.0_31-b04) Java HotSpot(TM) 64-Bit Server VM (build 20.6-b01, mixed mode) root@ubuntu:~#
Configure the CDH repositories
root@ubuntu:~# mkdir /opt/hbase root@ubuntu:~# cd /opt/hbase/
Download http://archive.cloudera.com/cdh4/one-clickinstall/precise/amd64/cdh4-repository_1.0_all.deb into /opt/hbase
root@ubuntu:/opt/hbase# ls -lth total 4.0K -rw-r--r-- 1 root root 3.3K Oct 6 14:38 cdh4-repository_1.0_all.deb root@ubuntu:/opt/hbase# root@ubuntu:/opt/hbase# sudo dpkg -i cdh4-repository_1.0_all.deb Selecting previously unselected package cdh4-repository. (Reading database ... 140999 files and directories currently installed.) Unpacking cdh4-repository (from cdh4-repository_1.0_all.deb) ... Setting up cdh4-repository (1.0) ... gpg: keyring `/etc/apt/secring.gpg' created gpg: keyring `/etc/apt/trusted.gpg.d/cloudera-cdh4.gpg' created gpg: key 02A818DD: public key "Cloudera Apt Repository" imported gpg: Total number processed: 1 gpg: imported: 1 root@ubuntu:/opt/hbase#
Install HBase
root@ubuntu:/opt/hbase# sudo apt-get update Ign http://archive.cloudera.com precise-cdh4 InRelease Ign http://security.ubuntu.com precise-security InRelease Ign http://extras.ubuntu.com precise InRelease Get:1 http://archive.cloudera.com precise-cdh4 Release.gpg [198 B] Ign http://us.archive.ubuntu.com precise InRelease Ign http://us.archive.ubuntu.com precise-updates InRelease Ign http://us.archive.ubuntu.com precise-backports InRelease Hit http://extras.ubuntu.com precise Release.gpg Hit http://security.ubuntu.com precise-security Release.gpg Get:2 http://archive.cloudera.com precise-cdh4 Release [1,682 B] Hit http://us.archive.ubuntu.com precise Release.gpg Hit http://extras.ubuntu.com precise Release Hit http://security.ubuntu.com precise-security Release Get:3 http://archive.cloudera.com precise-cdh4/contrib Sources [6,382 B] Hit http://us.archive.ubuntu.com precise-updates Release.gpg Hit http://us.archive.ubuntu.com precise-backports Release.gpg Hit http://extras.ubuntu.com precise/main Sources Get:4 http://archive.cloudera.com precise-cdh4/contrib amd64 Packages [16.8 kB] Hit http://security.ubuntu.com precise-security/main Sources Hit http://us.archive.ubuntu.com precise Release Ign http://archive.cloudera.com precise-cdh4/contrib TranslationIndex Hit http://extras.ubuntu.com precise/main amd64 Packages Hit http://extras.ubuntu.com precise/main i386 Packages Hit http://us.archive.ubuntu.com precise-updates Release Ign http://extras.ubuntu.com precise/main TranslationIndex Hit http://us.archive.ubuntu.com precise-backports Release Ign http://archive.cloudera.com precise-cdh4/contrib Translation-en_US Ign http://archive.cloudera.com precise-cdh4/contrib Translation-en Ign http://extras.ubuntu.com precise/main Translation-en_US Ign http://extras.ubuntu.com precise/main Translation-en Hit http://us.archive.ubuntu.com precise/main Sources Hit http://us.archive.ubuntu.com precise/restricted Sources Hit http://us.archive.ubuntu.com precise/universe Sources Hit http://us.archive.ubuntu.com precise/multiverse Sources Hit http://us.archive.ubuntu.com precise/main amd64 Packages Hit http://security.ubuntu.com precise-security/restricted Sources Hit http://security.ubuntu.com precise-security/universe Sources Hit http://us.archive.ubuntu.com precise/restricted amd64 Packages Hit http://security.ubuntu.com precise-security/multiverse Sources Hit http://security.ubuntu.com precise-security/main amd64 Packages Hit http://security.ubuntu.com precise-security/restricted amd64 Packages Hit http://security.ubuntu.com precise-security/universe amd64 Packages Hit http://us.archive.ubuntu.com precise/universe amd64 Packages Hit http://security.ubuntu.com precise-security/multiverse amd64 Packages Hit http://security.ubuntu.com precise-security/main i386 Packages Hit http://security.ubuntu.com precise-security/restricted i386 Packages Hit http://us.archive.ubuntu.com precise/multiverse amd64 Packages Hit http://security.ubuntu.com precise-security/universe i386 Packages Hit http://security.ubuntu.com precise-security/multiverse i386 Packages Hit http://security.ubuntu.com precise-security/main TranslationIndex Hit http://security.ubuntu.com precise-security/multiverse TranslationIndex Hit http://security.ubuntu.com precise-security/restricted TranslationIndex Hit http://security.ubuntu.com precise-security/universe TranslationIndex Hit http://us.archive.ubuntu.com precise/main i386 Packages Hit http://security.ubuntu.com precise-security/main Translation-en Hit http://security.ubuntu.com precise-security/multiverse Translation-en Hit http://security.ubuntu.com precise-security/restricted Translation-en Hit http://us.archive.ubuntu.com precise/restricted i386 Packages Hit http://security.ubuntu.com precise-security/universe Translation-en Hit http://us.archive.ubuntu.com precise/universe i386 Packages Hit http://us.archive.ubuntu.com precise/multiverse i386 Packages Hit http://us.archive.ubuntu.com precise/main TranslationIndex Hit http://us.archive.ubuntu.com precise/multiverse TranslationIndex Hit http://us.archive.ubuntu.com precise/restricted TranslationIndex Hit http://us.archive.ubuntu.com precise/universe TranslationIndex Hit http://us.archive.ubuntu.com precise-updates/main Sources Hit http://us.archive.ubuntu.com precise-updates/restricted Sources Hit http://us.archive.ubuntu.com precise-updates/universe Sources Hit http://us.archive.ubuntu.com precise-updates/multiverse Sources Hit http://us.archive.ubuntu.com precise-updates/main amd64 Packages Hit http://us.archive.ubuntu.com precise-updates/restricted amd64 Packages Hit http://us.archive.ubuntu.com precise-updates/universe amd64 Packages Hit http://us.archive.ubuntu.com precise-updates/multiverse amd64 Packages Hit http://us.archive.ubuntu.com precise-updates/main i386 Packages Hit http://us.archive.ubuntu.com precise-updates/restricted i386 Packages Hit http://us.archive.ubuntu.com precise-updates/universe i386 Packages Hit http://us.archive.ubuntu.com precise-updates/multiverse i386 Packages Hit http://us.archive.ubuntu.com precise-updates/main TranslationIndex Hit http://us.archive.ubuntu.com precise-updates/multiverse TranslationIndex Hit http://us.archive.ubuntu.com precise-updates/restricted TranslationIndex Hit http://us.archive.ubuntu.com precise-updates/universe TranslationIndex Hit http://us.archive.ubuntu.com precise-backports/main Sources Hit http://us.archive.ubuntu.com precise-backports/restricted Sources Hit http://us.archive.ubuntu.com precise-backports/universe Sources Hit http://us.archive.ubuntu.com precise-backports/multiverse Sources Hit http://us.archive.ubuntu.com precise-backports/main amd64 Packages Hit http://us.archive.ubuntu.com precise-backports/restricted amd64 Packages Hit http://us.archive.ubuntu.com precise-backports/universe amd64 Packages Hit http://us.archive.ubuntu.com precise-backports/multiverse amd64 Packages Hit http://us.archive.ubuntu.com precise-backports/main i386 Packages Hit http://us.archive.ubuntu.com precise-backports/restricted i386 Packages Hit http://us.archive.ubuntu.com precise-backports/universe i386 Packages Hit http://us.archive.ubuntu.com precise-backports/multiverse i386 Packages Hit http://us.archive.ubuntu.com precise-backports/main TranslationIndex Hit http://us.archive.ubuntu.com precise-backports/multiverse TranslationIndex Hit http://us.archive.ubuntu.com precise-backports/restricted TranslationIndex Hit http://us.archive.ubuntu.com precise-backports/universe TranslationIndex Hit http://us.archive.ubuntu.com precise/main Translation-en Hit http://us.archive.ubuntu.com precise/multiverse Translation-en Hit http://us.archive.ubuntu.com precise/restricted Translation-en Hit http://us.archive.ubuntu.com precise/universe Translation-en Hit http://us.archive.ubuntu.com precise-updates/main Translation-en Hit http://us.archive.ubuntu.com precise-updates/multiverse Translation-en Hit http://us.archive.ubuntu.com precise-updates/restricted Translation-en Hit http://us.archive.ubuntu.com precise-updates/universe Translation-en Hit http://us.archive.ubuntu.com precise-backports/main Translation-en Hit http://us.archive.ubuntu.com precise-backports/multiverse Translation-en Hit http://us.archive.ubuntu.com precise-backports/restricted Translation-en Hit http://us.archive.ubuntu.com precise-backports/universe Translation-en Fetched 25.1 kB in 30s (827 B/s) Reading package lists... Done root@ubuntu:/opt/hbase# root@ubuntu:/opt/hbase# sudo apt-get install hbase hbase-master Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: bigtop-jsvc bigtop-utils hadoop hadoop-hdfs libopts25 ntp zookeeper Suggested packages: ntp-doc The following NEW packages will be installed: bigtop-jsvc bigtop-utils hadoop hadoop-hdfs hbase hbase-master libopts25 ntp zookeeper 0 upgraded, 9 newly installed, 0 to remove and 119 not upgraded. Need to get 70.1 MB of archives. After this operation, 82.3 MB of additional disk space will be used. Do you want to continue [Y/n]? Y Get:1 http://us.archive.ubuntu.com/ubuntu/ precise/main libopts25 amd64 1:5.12-0.1ubuntu1 [59.9 kB] Get:2 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main ntp amd64 1:4.2.6.p3+dfsg-1ubuntu3.1 [612 kB] Get:3 http://archive.cloudera.com/cdh4/ubuntu/precise/amd64/cdh/ precise-cdh4/contrib bigtop-jsvc amd64 0.4+352-1.cdh4.1.0.p0.29~precise-cdh4.1.0 [53.2 kB] Get:4 http://archive.cloudera.com/cdh4/ubuntu/precise/amd64/cdh/ precise-cdh4/contrib bigtop-utils all 0.4+352-1.cdh4.1.0.p0.28~precise-cdh4.1.0 [2,004 B] Get:5 http://archive.cloudera.com/cdh4/ubuntu/precise/amd64/cdh/ precise-cdh4/contrib zookeeper all 3.4.3+25-1.cdh4.1.0.p0.28~precise-cdh4.1.0 [4,087 kB] Get:6 http://archive.cloudera.com/cdh4/ubuntu/precise/amd64/cdh/ precise-cdh4/contrib hadoop all 2.0.0+541-1.cdh4.1.0.p0.27~precise-cdh4.1.0 [16.6 MB] Get:7 http://archive.cloudera.com/cdh4/ubuntu/precise/amd64/cdh/ precise-cdh4/contrib hadoop-hdfs all 2.0.0+541-1.cdh4.1.0.p0.27~precise-cdh4.1.0 [12.7 MB] Get:8 http://archive.cloudera.com/cdh4/ubuntu/precise/amd64/cdh/ precise-cdh4/contrib hbase all 0.92.1+154-1.cdh4.1.0.p0.23~precise-cdh4.1.0 [35.9 MB] Get:9 http://archive.cloudera.com/cdh4/ubuntu/precise/amd64/cdh/ precise-cdh4/contrib hbase-master all 0.92.1+154-1.cdh4.1.0.p0.23~precise-cdh4.1.0 [19.2 kB] Fetched 70.1 MB in 8min 41s (134 kB/s) Selecting previously unselected package libopts25. (Reading database ... 141003 files and directories currently installed.) Unpacking libopts25 (from .../libopts25_1%3a5.12-0.1ubuntu1_amd64.deb) ... Selecting previously unselected package ntp. Unpacking ntp (from .../ntp_1%3a4.2.6.p3+dfsg-1ubuntu3.1_amd64.deb) ... Selecting previously unselected package bigtop-jsvc. Unpacking bigtop-jsvc (from .../bigtop-jsvc_0.4+352-1.cdh4.1.0.p0.29~precise-cdh4.1.0_amd64.deb) ... Selecting previously unselected package bigtop-utils. Unpacking bigtop-utils (from .../bigtop-utils_0.4+352-1.cdh4.1.0.p0.28~precise-cdh4.1.0_all.deb) ... Selecting previously unselected package zookeeper. Unpacking zookeeper (from .../zookeeper_3.4.3+25-1.cdh4.1.0.p0.28~precise-cdh4.1.0_all.deb) ... Selecting previously unselected package hadoop. Unpacking hadoop (from .../hadoop_2.0.0+541-1.cdh4.1.0.p0.27~precise-cdh4.1.0_all.deb) ... Selecting previously unselected package hadoop-hdfs. Unpacking hadoop-hdfs (from .../hadoop-hdfs_2.0.0+541-1.cdh4.1.0.p0.27~precise-cdh4.1.0_all.deb) ... Selecting previously unselected package hbase. Unpacking hbase (from .../hbase_0.92.1+154-1.cdh4.1.0.p0.23~precise-cdh4.1.0_all.deb) ... Selecting previously unselected package hbase-master. Unpacking hbase-master (from .../hbase-master_0.92.1+154-1.cdh4.1.0.p0.23~precise-cdh4.1.0_all.deb) ... Processing triggers for ureadahead ... Processing triggers for man-db ... Setting up libopts25 (1:5.12-0.1ubuntu1) ... Setting up ntp (1:4.2.6.p3+dfsg-1ubuntu3.1) ... * Starting NTP server ntpd [ OK ] Setting up bigtop-jsvc (0.4+352-1.cdh4.1.0.p0.29~precise-cdh4.1.0) ... Setting up bigtop-utils (0.4+352-1.cdh4.1.0.p0.28~precise-cdh4.1.0) ... Setting up zookeeper (3.4.3+25-1.cdh4.1.0.p0.28~precise-cdh4.1.0) ... update-alternatives: using /etc/zookeeper/conf.dist to provide /etc/zookeeper/conf (zookeeper-conf) in auto mode. Setting up hadoop (2.0.0+541-1.cdh4.1.0.p0.27~precise-cdh4.1.0) ... update-alternatives: using /etc/hadoop/conf.empty to provide /etc/hadoop/conf (hadoop-conf) in auto mode. Setting up hadoop-hdfs (2.0.0+541-1.cdh4.1.0.p0.27~precise-cdh4.1.0) ... Setting up hbase (0.92.1+154-1.cdh4.1.0.p0.23~precise-cdh4.1.0) ... update-alternatives: using /etc/hbase/conf.dist to provide /etc/hbase/conf (hbase-conf) in auto mode. Setting up hbase-master (0.92.1+154-1.cdh4.1.0.p0.23~precise-cdh4.1.0) ... Starting Hadoop HBase master daemon: +======================================================================+ | Error: JAVA_HOME is not set and Java could not be found | +----------------------------------------------------------------------+ | Please download the latest Sun JDK from the Sun Java web site | | > http://java.sun.com/javase/downloads/ < | | | | HBase requires Java 1.6 or later. | | NOTE: This script will find Sun Java whether you install using the | | binary or the RPM based installer. | +======================================================================+ invoke-rc.d: initscript hbase-master, action "start" failed. dpkg: error processing hbase-master (--configure): subprocess installed post-installation script returned error exit status 1 Processing triggers for libc-bin ... ldconfig deferred processing now taking place Errors were encountered while processing: hbase-master E: Sub-process /usr/bin/dpkg returned an error code (1) root@ubuntu:/opt/hbase#
I got the above error the first time so I checked if JAVA_HOME is set properly.
root@ubuntu:/opt/hbase# echo $JAVA_HOME /opt/java/jdk1.6.0_31
Since it seems ok, I decided to directly set JAVA_HOME in the hbase-master script
root@ubuntu:/opt/hbase# vi /etc/init.d/hbase-master # Add this export JAVA_HOME=/opt/java/jdk1.6.0_31
Lets try installing again
root@ubuntu:/opt/hbase# sudo apt-get install hbase hbase-master Reading package lists... Done Building dependency tree Reading state information... Done hbase is already the newest version. hbase-master is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 119 not upgraded. 1 not fully installed or removed. After this operation, 0 B of additional disk space will be used. Do you want to continue [Y/n]? Y Setting up hbase-master (0.92.1+154-1.cdh4.1.0.p0.23~precise-cdh4.1.0) ... Starting Hadoop HBase master daemon: starting master, logging to /var/log/hbase/hbase-hbase-master-ubuntu.out hbase-master. root@ubuntu:/opt/hbase#
This time everything went well.
View the list of HBase configuration files.
root@ubuntu:/opt/hbase# ls -lth /etc/hbase/conf/ total 28K -rw-r--r-- 1 root root 1.1K Oct 30 12:06 hbase-site.xml -rw-r--r-- 1 root root 2.3K Sep 29 11:54 hadoop-metrics.properties -rw-r--r-- 1 root root 4.2K Sep 29 11:54 hbase-env.sh -rw-r--r-- 1 root root 2.2K Sep 29 11:54 hbase-policy.xml -rw-r--r-- 1 root root 2.5K Sep 29 11:54 log4j.properties -rw-r--r-- 1 root root 10 Sep 29 11:54 regionservers root@ubuntu:/opt/hbase# cat /etc/hbase/conf/regionservers localhost root@ubuntu:/opt/hbase#
Lets invoke the HBase shell and test.
root@ubuntu:/opt/hbase# hbase shell 12/10/06 15:07:20 WARN conf.Configuration: hadoop.native.lib is deprecated. Instead, use io.native.lib.available HBase Shell; enter 'help' for list of supported commands. Type "exit" to leave the HBase Shell Version 0.92.1-cdh4.1.0, rUnknown, Sat Sep 29 11:55:59 PDT 2012 hbase(main):001:0> status 1 servers, 0 dead, 3.0000 average load hbase(main):001:0> list TABLE 0 row(s) in 0.6370 seconds hbase(main):002:0> hbase(main):002:0> create 'table1','cf1' ^Croot@ubuntu:/opt/hbase# root@ubuntu:/opt/hbase#
Here I encountered the second issue. For some reason the HBase shell would hang.
After googling around for quite some time I found a fix.
Update the /etc/hosts file and ensure that there is no 127.0.1.1 that points to localhost and ubuntu
and comment out the ipv6 lines
root@ubuntu:/opt/hbase# vi /etc/hosts 192.168.38.137 hbase2 127.0.0.1 localhost ubuntu # The following lines are desirable for IPv6 capable hosts #::1 ip6-localhost ip6-loopback #fe00::0 ip6-localnet #ff00::0 ip6-mcastprefix #ff02::1 ip6-allnodes #ff02::2 ip6-allrouters
Also disable ipv6 as follows:
root@ubuntu:~# vi /etc/sysctl.conf
and add the following lines to the end of it:
# Abhi: Disable ipv6 net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1
Now restart the system
root@ubuntu:/opt/hbase# /etc/init.d/hbase-master restart Restarting Hadoop HBase master daemon: stopping master... Starting Hadoop HBase master daemon: starting master, logging to /var/log/hbase/hbase-hbase-master-ubuntu.out hbase-master. root@ubuntu:/opt/hbase#
Check if its running
root@ubuntu:/opt/hbase# jps 16353 Jps 15654 HMaster
Open the Hbase shell and lets play around with few commands
root@ubuntu:/opt/hbase# root@ubuntu:/opt/hbase# hbase shell 12/10/06 15:35:18 WARN conf.Configuration: hadoop.native.lib is deprecated. Instead, use io.native.lib.available HBase Shell; enter 'help' for list of supported commands. Type "exit" to leave the HBase Shell Version 0.92.1-cdh4.1.0, rUnknown, Sat Sep 29 11:55:59 PDT 2012 hbase(main):007:0* list TABLE 0 row(s) in 0.0040 seconds hbase(main):008:0> create 'table1','cf1' 0 row(s) in 1.0880 seconds hbase(main):009:0> list TABLE table1 1 row(s) in 0.0160 seconds hbase(main):010:0> scan 'table1' ROW COLUMN+CELL 0 row(s) in 0.0200 seconds hbase(main):012:0> put 'table1','row1','cf1:greeting','Hello' 0 row(s) in 0.0590 seconds hbase(main):013:0> put 'table1','row1','cf1:name','World' 0 row(s) in 0.0110 seconds hbase(main):014:0> scan 'table1' ROW COLUMN+CELL row1 column=cf1:greeting, timestamp=1349563833359, value=Hello row1 column=cf1:name, timestamp=1349563858582, value=World 1 row(s) in 0.0350 seconds hbase(main):016:0> get 'table1','row1' COLUMN CELL cf1:greeting timestamp=1349563833359, value=Hello cf1:name timestamp=1349563858582, value=World 2 row(s) in 0.0300 seconds hbase(main):017:0> put 'table1','row2','cf1:greeting','Hi' 0 row(s) in 0.0140 seconds hbase(main):018:0> put 'table1','row2','cf1:name','Abhi' 0 row(s) in 0.0080 seconds hbase(main):019:0> scan 'table1' ROW COLUMN+CELL row1 column=cf1:greeting, timestamp=1349563833359, value=Hello row1 column=cf1:name, timestamp=1349563858582, value=World row2 column=cf1:greeting, timestamp=1349563961204, value=Hi row2 column=cf1:name, timestamp=1349563973437, value=Abhi 2 row(s) in 0.0730 seconds hbase(main):020:0> get 'table1','row2' COLUMN CELL cf1:greeting timestamp=1349563961204, value=Hi cf1:name timestamp=1349563973437, value=Abhi 2 row(s) in 0.0080 seconds hbase(main):021:0>
You can open a browser and go to http://localhost:60010/ to access the HBase monitoring WebUI
Updated on October 31, 2012
Note: I have changed the hostname of my system from ‘ubuntu’ to ‘hbase2’
Set the HBase Root Directory
Although we are able to play around with HBase – create tables, put and get data etc. the data will get deleted once we restart the system as it is transient. In the stand-alone mode everything is executed within a single Java process and the data/files get stored under /tmp by default. Most OS clear /tmp on reboot thereby removing all the data. To make the data persistent we need to edit the hbase-site.xml file and set the root directory.
abhi@hbase2:~$ sudo mkdir /opt/hbase/data/ abhi@hbase2:~$ sudo chown -cRvf hbase:users /opt/hbase/data/ abhi@hbase2:~$ ls -lth /opt/hbase/ total 8.0K drwxr-xr-x 7 hbase users 4.0K Oct 30 12:47 data abhi@hbase2:~$ abhi@hbase2:~$ sudo vi /etc/hbase/conf/hbase-site.xml
<configuration> <property> <name>hbase.rootdir</name> <value>file:///opt/hbase/data</value> </property> </configuration>
Restart hbase-master.
abhi@hbase2:~$ sudo /etc/init.d/hbase-master restart
Now when you create tables and enter data, the data will persist even after system restart.
Lets create a table and enter data.
hbase(main):005:0> create 'users','info' 0 row(s) in 1.1180 seconds hbase(main):006:0> list TABLE users 1 row(s) in 0.0090 seconds hbase(main):007:0> put 'users','abhi','info:name','abhishek' 0 row(s) in 0.0660 seconds hbase(main):008:0> put 'users','abhi','info:age','30' 0 row(s) in 0.0110 seconds hbase(main):009:0> scan 'users' ROW COLUMN+CELL abhi column=info:age, timestamp=1351626512340, value=30 abhi column=info:name, timestamp=1351626501011, value=abhishek 1 row(s) in 0.0350 seconds hbase(main):010:0> flush 'users' 0 row(s) in 0.0750 seconds hbase(main):011:0>
Note: Always do a flush on your tables so that the data gets written as files in your filesystem.
In my next post we’ll see how HBase persists the data physically on the filesystem as files and directories.