19.9 C
Texas

How To Install HBase on Ubuntu 18.04

Today we will learn that how we can Install HBase on our Ubuntu 18.04 system. HBase has two modes.

  • Standalone Mode
  • Pseudo-Distributed Mode

Let’s move towards the Installation

Step 1: Download & Install HBase

Download the stable release of HBase for production use.

VER="1.4.12"
wget http://apache.mirror.gtcomm.net/hbase/stable/hbase-$VER-bin.tar.gz
- Advertisement -

Extract the downloaded archive.

tar xvf hbase-$VER-bin.tar.gz

Now, use the given command to move file to /usr/local/HBase/ directory.

sudo mv hbase-$VER/ /usr/local/HBase/

Update your $PATH value

cat <<EOF | sudo tee /etc/profile.d/hadoop_java.sh
export JAVA_HOME=$(dirname $(dirname $(readlink $(readlink $(which javac)))))
export HADOOP_HOME=/usr/local/hadoop
export HADOOP_HDFS_HOME=$HADOOP_HOME
export HADOOP_MAPRED_HOME=$HADOOP_HOME
export YARN_HOME=$HADOOP_HOME
export HADOOP_COMMON_HOME=$HADOOP_HOME
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
export HBASE_HOME=/usr/local/HBase
export PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$HBASE_HOME/bin
EOF

Update shell environment values.

$ source /etc/profile.d/hadoop_java.sh
$ echo $HBASE_HOME
/usr/local/HBase

Edit JAVA_HOME in shell script hbase-env.sh

$ sudo vim /usr/local/HBase/conf/hbase-env.sh
Set JAVA_HOME - Line 27
export JAVA_HOME=/usr/lib/jvm/java-8-oracle

Step 2: Configure HBase

You can find out all config files of HBase under /usr/local/HBase/conf .

We will do the configurations like we did for Hadoop.

hbase-site.xml

Set data directory to an appropriate location on this file

Option 1: Install HBase in Standalone Mode (Not Recommended)

All daemon will run in one jvm process so this is not recommended.

Make HBase root directory.

sudo mkdir -p /hadoop/HBase/HFiles
sudo mkdir -p /hadoop/zookeeper
sudo chown -R hadoop:hadoop /hadoop/

Edit the file.

sudo nano /usr/local/HBase/conf/hbase-site.xml

Do the same configuration

<configuration>
<property>
<name>hbase.rootdir</name>
<value>file:/hadoop/HBase/HFiles</value>
</property>

<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/hadoop/zookeeper</value>
</property>
</configuration>

Unless you configure the hbase.rootdir property, your data is stored in /tmp/

Start HBase

$ sudo su - hadoop
$ start-hbase.sh
running master, logging to /usr/local/HBase/logs/hbase-hadoop-master-hbase.out

Option 2: Install HBase in Pseudo-Distributed Mode (Recommended)

Pseudo-Distributed mode runs only on single host but each HBase daemon runs as a separate process.

Set values of HBase according to below to Install it.

<configuration>
<property>
<name>hbase.rootdir</name>
<value>hdfs://localhost:8030/hbase</value>
</property>

<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/hadoop/zookeeper</value>
</property>

<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<configuration>

Your data will be stored in HDFS in this setup.
Create Zookeeper directory by typing

sudo mkdir -p /hadoop/zookeeper
sudo chown -R hadoop:hadoop /hadoop/

Start HBase by using start-hbase.sh script in HBase bin directory.

$ sudo su - hadoop
$ start-hbase.sh
localhost: running zookeeper, logging to /usr/local/HBase/bin/../logs/hbase-hadoop-zookeeper-hbase.out
running master, logging to /usr/local/HBase/logs/hbase-hadoop-master-hbase.out
: running regionserver, logging to /usr/local/HBase/logs/hbase-hadoop-regionserver-hbase.out

See the HBase Directory in HDFS

hadoop fs -ls /hbase

Step 3: Managing HMaster & HRegionServer

HRegion server stores the data into StoreFiles as directed by the HMaster while HMaster server controls the HBase cluster.
Both servers can be started & stopped using the scripts local-master-backup.sh and local-regionserver.sh respectively.

$ local-master-backup.sh start 2 # Start backup HMaster
$ local-regionservers.sh start 3 # Start multiple RegionServers

HMaster uses two ports (16000 and 16010 by default). Due to port offset, HMaster uses ports 16002 and 16012

Run the given command to start 3 backup servers using ports 16002/16012 , 16003/16013, 16005/16015

$ local-master-backup.sh start 2 3 5

RegionServer requires two ports, default ports are 16020 & 16030.

To start additional RegionServers, running on sequential ports starting at 16022/16032 (base ports 16020/16030 plus 2)

$ local-regionservers.sh start 2 3 4 5

In order to stop , just replace the start with stop parameter. e.g;

$ local-regionservers.sh stop 5

Step 4: Starting HBase Shell

Hadoop & HBase should be running before you can use HBase shell. Type the following to start services.

start-all.sh
start-hbase.sh

Then use HBase shell

hbase shell

Stopping HBase

stop-hbase.sh

See our tutorial: How To Install Hadoop on Ubuntu 18.04

Congratulations! You’ve finished installing HBase on Ubuntu 18.04. To learn more about Hadoop & HBase visit Apache Hadoop Documentation & Apache HBase book.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article