Hi there,
Apache HBase can be installed in the following three modes :
- Standalone mode
- Pseudo Distributed mode
- Fully Distributed mode
This blog is to setup HBase in standalone mode on your Ubuntu machine without any hassle. You can search for blogs on Pseudo Distributed or Fully Distributed mode installation of HBase on Findnerd.
Prerequisite for HBase installation
Use this reference to install Java on your machine
http://findnerd.com/account#url=/list/view/Install-Oracle-JDK-with-apt-get/2944/
Apache Zookeeper should be installed on machine, to know about Zookeeper follow this tutorial
http://findnerd.com/account/#url=/list/view/Apache-Zookeeper-installation-in-Ubuntu-for-Standalone-mode/20129/
Ensure that both are properly installed on your machine.
Installation part for Apache HBase.
Download a stable release form apache mirrors for HBase. In my case I downloaded hbase-1.1.5-bin.tar.gz to ~/Downloads.
Extract the downloaded package
tar -zxvfhbase-1.1.5-bin.tar.gz
Move the extracted package to a location of your choice, I picked /usr/local/hbase
sudo mv ~/Downloads/hbase-1.1.5/ /usr/local/hbase
Open your .bashrc file an append the hbase variables into it.
gedit ~/.bashrc
#hbase
export HBASE_HOME=/usr/local/hbase
export HBASE_CONF_DIR=$HBASE_HOME/conf
export HBASE_CLASS_PATH=$HBASE_CONF_DIR
export PATH=$HBASE_HOME/bin:$PATH
save your .bashrc and execute the source command on it.
source ~/.bashrc
Go to hbase's conf directory
cd /usr/local/hbase/conf/
Open hbase-env.sh and put your Java path here .
sudo gedit hbase-env.sh
remove comment on the Java Home variable and update your Java home path.
Now edit your hbase-site.xml
sudo gedit hbase-site.xml
put the following lines inside <configuration></configuration> tags.
//Set the path where you want HBase to store its file
<property>
<name>hbase.rootdir</name>
<value>file:///home/{username}/HBase/HFiles</value>
</property>
//set the path defined for zookeeper files earlier.
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/home/{username}/zookeeper</value>
</property>
now the stage is set and you only need to start HBase.
start-hbase.sh
to use hbase shell execute
start-hbase.sh
and HBase will provides Extensible jruby-based (JIRB) shell as a feature to execute some commands
Now i will create a table naming testTable
create 'testTable','info','content'
and its output will be
0 row(s) in 3.4630 seconds
=> Hbase::Table - testTable
to list all the table use list
list
its output will contain your newly created testTable
TABLE
blog
test
testTable
3 row(s) in 0.0730 seconds
=> ["blog", "test", "testTable"]
to put values inside your table
put 'testTable','row1','info:auther','Abhishek'
put 'testTable','row1','content:xyz','Abhishek'
put 'testTable','row2','content:xyz','abcd'
to scan your table
scan 'testTable'
and the response will be
ROW COLUMN+CELL
row1 column=content:xyz, timestamp=1464173663187, value=Abhishek
row1 column=info:auther, timestamp=1464173632288, value=Abhishek
row2 column=content:xyz, timestamp=1464173714201, value=abcd
2 row(s) in 0.0210 seconds
to exit from shell type exit and return
exit
to stop hbase
stop-hbase.sh
You can use the HBase GUI using the address http://localhost:16010/ while HBase server is running. A snapshot of HBase GUI is given here.
HBase Java API will be explained in further blogs.
Thanks,
1 Comment(s)