Hbase Installation on Mac

ASHWANI SINGH
2 min readSep 26, 2021

--

Source: https://wallpaperaccess.com/full/2068772.jpg

1. Overview

HBase is a Hadoop project which is an Open Source, distributed Hadoop database which has its genesis in the Google’sBigtable. Its programming language is Java. Also, it is a high availability database that exclusively runs on top of the HDFS.
HBase is located in the upper layer of HDFS, providing storage downwards and computing upwards.

2. Pre-Requisite

  1. You have homebrew installed. For directions on installing homebrew, see http://brew.sh/
  2. You have Java installed and Java home configured properly, see
    https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
    https://stackoverflow.com/questions/22842743/how-to-set-java-home-environment-variable-on-mac-os-x-10-9
  3. You have installed a Zookeeper. For direction on installing, see https://formulae.brew.sh/formula/zookeeper

3. Install Hadoop

3.1 Install Hadoop with brew.

$ brew install hadoop.

3.2 Hadoop Configuration changes.

$ vi /usr/local/Cellar/hadoop/<hadoop version>/libexec/etc/hadoop/hadoop-env.sh
export HADOOP_OPTS=”$HADOOP_OPTS -Djava.net.preferIPv4Stack=true -Djava.security.krb5.realm= -Djava.security.krb5.kdc=”
$vi /usr/local/Cellar/hadoop/<hadoop version>/libexec/etc/hadoop/core-site.xml.
#Add the following properties to the <configuration> block:
<property>
<name>hadoop.tmp.dir</name>
<value>/usr/local/Cellar/hadoop/hdfs/tmp</value>
<description>A base for other temporary directories.</description>
</property>
<property>
<name>fs.default.name</name>
<value>hdfs://localhost:9000</value>
</property>
$vi /usr/local/Cellar/hadoop/<hadoop version>/libexec/etc/hadoop/mapred-site.xml
#Add the following property to the <configuration> block:
<property>
<name>mapred.job.tracker</name>
<value>localhost:9010</value>
</property>
$vi /usr/local/Cellar/hadoop/<hadoop version>/libexec/etc/hadoop/hdfs-site.xml
#Add the following property to the <configuration> block:
<property>
<name>dfs.replication</name>
<value>1</value>
</property>

3.3 Format the HDFS with the following command.

$ hdfs namenode -format

3.4 Start Hadoop with the relevant bash script.

/usr/local/Cellar/hadoop/<hadoop version>/sbin:$ sh start-all.sh

4. Install Hbase

4.1 Install HBase with brew.

 $ brew install hbase

4.2 Hbase Configuration changes.

$ vi /usr/local/Cellar/hbase/<hbase version>/libexec/conf/hbase-site.xml 
#Edit the following property in the <configuration> block.
#Note: Change port to 2182, if zookeeper is already installed #individually without hbase and hadoop.
<property>
<name>hbase.rootdir</name>
<value>hdfs://localhost:9000/hbase</value>
</property>
<name>hbase.zookeeper.property.clientPort</name>
<value>2182</value>
</property>

4.3 Start Hbase with the relevant bash script.

/usr/local/Cellar/hbase/<hbase version>/bin: $ sh start-hbase.sh

4.4 Log can be found in below directory path.

/usr/local/Cellar/hbase/<hbase version>/logs/

5. Verify Installation

5.1 Connect to Hbase shell.

$ hbase shell

5.2 Create Table with name “books” and with column family “info” (book information)

create 'books', 'info';
list; list all tables present

5.3 Let’s insert 3 column qualifies (genres, author, publisher) and the associated values into the first row (row1).

put 'books', 'row1', 'info:genres', 'Accounting'put 'books', 'row1', 'info:author', 'Martin'put 'books', 'row1', 'info:publisher', 'BookStand'

5.4 Scan a Table (i.e. Query a Table) that returns all columns in the books table.

scan 'books'

Note: Before starting HBase, start Hadoop. Please find below order of restart of Hbase and Hadoop
a) /usr/local/Cellar/hbase/<hbase version>/bin: $sh stop-hbase.sh
b) /usr/local/Cellar/hbase/<hbase version>/sbin: $sh stop-dfs.sh
c) /usr/local/Cellar/hbase/<hbase version>/sbin: $sh start-dfs.sh
d) /usr/local/Cellar/hbase/<hbase version>/bin: $sh start-hbase.sh

6. Conclusion

In this article, we have covered step by step guide to install HBase on Mac.
Tap the 👏 button and follow if you find this article gripping. Leave your comments if you find any issue in setting up or any required details are missing.

--

--

ASHWANI SINGH

Software Engineer | Backend Developer | NITK Surathkal | ISC BHU