Pre-requisite
1. Java JDK (This demo uses JDK version 1.7.0_67)
Make sure the JAVA_HOME system environment variable points to the JDK. Make sure the java executable’s directory is in the PATH environment variable, i.e., %JAVA_HOME%\bin.
2. Make sure you have installed Hadoop on your cluster, please refer my post to install the same Installing Hadoop in fully Distributed mode
Installing And Configuring Hbase
Assumptions –
For the purpose of clarity and ease of expression, I’ll be assuming that we are setting up a cluster of 2 nodes with IP Addresses
10.10.10.1 - Hmaster 10.10.10.2 – HRegion Server
And in my case Hmaster is also a NameNode and Region Server is DataNode.
1. Download hbase-1.1.4-bin.tar.gz from http://www.apache.org/dyn/closer.cgi/hbase/ and extract to some path in your computer. Now I am calling hbase installation root as $HBASE_INSTALL_DIR.
2. Edit the file /etc/hosts on the master machine and add the following lines.
10.10.10.1 master 10.10.10.2 slave
Note: Run the command “ping master”. This command is run to check whether the master machine ip is being resolved to actual ip not localhost ip.
3. As we are using hadoop installed machines so we have already setup passwordless-ssh.
4. Open the file $HBASE_INSTALL_DIR/conf/hbase-env.sh and set the $JAVA_HOME.
export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_67
5. Configure Hbase
Case I- When HBase manages the Zookeeper ensemble
Open the file $HBASE_INSTALL_DIR/conf/hbase-env.sh set the HBASE_MANAGES_ZK to true to indicate that HBase is supposed to manage the zookeeper ensemble internally.
export HBASE_MANAGES_ZK=true
Open the file $HBASE_INSTALL_DIR/conf/hbase-site.xml and add the following properties.
<configuration> <property> <name>hbase.master</name> <value><master-hostname>:60000</value> </property> <property> <name>hbase.rootdir</name> <value>hdfs://<master-hostname>:9000/hbase</value> </property> <property> <name>hbase.cluster.distributed</name> <value>true</value> </property> </configuration>
Case II- When HBase manages the Zookeeper ensemble externally
Open the file $HBASE_INSTALL_DIR/conf/hbase-env.sh –
export HBASE_MANAGES_ZK=false
For this configuration add two more properties in hbase-site.xml
<property>
<name>hbase.zookeeper.property.clientPort</name>
<value>2181</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value><master-hostname></value>
</property>
Note:-In our case, Zookeeper and hbase master both are running in same machine.
6. Edit the /conf/regionservers file on all the hbase cluster nodes. Add the hostnames of all the region server nodes. For eg.
10.10.10.2
7. Repeat same procedure for all the masters and region servers.
Start and Stop Hbase cluster
8. Starting the Hbase Cluster
Before starting hbase cluster start zookeeper if it externally managed .Go to <zookeeper_home>/bin
./zkServer.sh start
we have need to start the daemons only on the hbase-master machine, it will start the daemons in all regionserver machines.
Execute the following command to start the hbase cluster.
$HBASE_INSTALL_DIR/bin/start-hbase.sh
Note:-
At this point, the following Java processes should run on hbase-master machine.
xxx@master:$jps 14143 Jps 14007 HquorumPeer/QuorumPeerMain(if zookeeper managed externally) 14066 Hmaster 9561 SecondaryNameNode 9133 NameNode 9783 ResourceManager
and the following java processes should run on hbase-regionserver machine.
23026 HRegionServer 23171 Jps 9311 DataNode 9966 NodeManager
9. Starting the hbase shell:-
$HBASE_INSTALL_DIR/bin/hbase shell HBase Shell; enter 'help<RETURN>' for list of supported commands. Type "exit<RETURN>" to leave the HBase Shell Version 1.1.4, r14c0e77956f9bb4c6edf0378474264843e4a82c3, Wed Mar 16 21:18:26 PDT 2016 hbase(main):001:0> hbase(main):001:0>create 't1','f1' 0 row(s) in 1.2910 seconds hbase(main):002:0>
Note: – If table is created successfully, then everything is running fine.
10. Stoping the Hbase Cluster:-
Execute the following command on hbase-master machine to stop the hbase cluster.
$HBASE_INSTALL_DIR/bin/stop-hbase.sh
On top of hbase we can install Apache Phoenix , which is a SQL layer on Hbase. For installation of phoenix you can refer my post Installing Phoenix – A step by step tutorial