Tech Blog

Ajith Vijayan Tech Blog

Tag: single node installation

HBase Installation on Linux Machine

Apache HBase is a distributed, scalable, bigdata store.Actually it is the Hadoop database.Apache HBase is the subproject of the Apache Hadoop project and is used to provide real-time read and write access to your bigdata.HBase runs on top of HDFS(Hadoop Distributed File System).

Before installing HBase, we have to install Hadoop and zookeeper.The zookeeper cluster act as a coordination service for entire HBase cluster.For Single node HBase installation, the zookeeper is installed and started automatically.

For HBase development, selecting Hadoop version is very critical. The Hadoop version should be compactable with HBase version. Here we are using HBase-0.94.x, HBase requires hadoop-1.0.3 at a minimum.

Basic Prerequisites

This section lists required services and some required system configuration.

Software’s required

  • java JDK

As of now the recommended and tested versions of java for Hadoop and HBase installation include

Oracle jdk 1.6(u 20,21,26,28,31)

Hadoop requires java1.6+. It is built and tested on Oracle java, which is the only “supported” JVM.

  • The latest stable version of Hadoop 1.x.x( here we are using the current stable version of hadoop-1.0.3)
  • The latest stable version of HBase-0.9x.x( here we are using the current stable version of HBase-0.94.x)

Before Installing HBase, we have to install Hadoop and Zookeeper.

Installing HBase

HBase is a Distributed, non-relational and open source database. One of the key value store type database is HBase which runs over Hadoop architecture and Hdfs file system.

Step 1:  Copy the HBase tar in a particular location and untar it.We are using hbase-0.94.x.tar.gz

cd /home/hduser/Utilities

tar -xzvf hbase-0.94.x.tar.gz

Step 2: Edit the /home/hduser/Utilities/hbase/conf/hbase-env.sh and define the $JAVA_HOME

nano /hbase/conf/hbase-env.sh

HBASE_MANAGES_ZK needs to be set as ‘true’ to use zookeeper.If it is set as false, HBase will not consider zookeeper.

export HBASE_MANAGES_ZK=true

Step 3: Edit the hbase-site.xml

A typical hbase-site.xml is given below

[code lang="shell"]

<configuration>

<property>

<name>hbase.rootdir</name>

<value>hdfs://localhost:54310/hbase</value>

</property>

<property>

<name>hbase.cluster.distributed </name>

<value>true</value>
</property>

<property>

<name>hbase.zookeeper.quorum</name>

<value><ipaddress of the zookeeper installed system></value>

</property>

<property>

<name>hbase.master</name>

<value>172.22.91.40:60000</value>

<description>The host and port that HBase master runs</description>

</property>

</configuration>

[/code]

The Value of ‘hbase.rootdir’ is the hostname and port number of system where namenode is running.(The port number should be same as that of core-site.xml, where namenode is running)

we have to create a folder in hdfs to store HBase data( This folder should mention in ‘hbase.rootdir’ value

hadoop fs -ls /

hadoop fs -mkdir /hbase

For multinode HBase installation,the property ‘hbase.zookeeper.quorum’ is important.the property is used to identify the zookeeper installed system.

  • To start HBase daemons

/home/hduser/Utilities/hbase/bin/start-hbase.sh

  • To stop HBase daemons

/home/hduser/Utilities/hbase/bin/stop-hbase.sh

The default UI port of HBase is 60010.The UI of HBase can view by

http://<IP address of the system :60010>

Hadoop Single Node Installation

step 1: Extracting Hadoop tarball

We are creating a user home for Hadoop installation.Here we are using ‘/home/hduser/Utilities’ as user home.You need to extract the tarball in this location and change the permissions recursively on the extracted directory.

Here we are using hadoop-1.0.3.tar

mkdir -p /home/hduser/Utilities

cd /home/hduser/Utilities

sudo tar -xzvf hadoop-1.0.3.tar.gz

sudo chown -R hduser:hadoop hadoop-1.0.3

step 2:Configuring Hadoop on environment variables

We are adding HADOOP_HOME as environment variables on bash.bashrc files.By doing this Hadoop commands can access every user.

sudo nano /etc/bash.bashrc

Append the following lines to add HADOOP_HOME to PATH.

#set HADOOP_HOME

export HADOOP_HOME=/home/hduser/Utilities/hadoop-1.0.3

export PATH=$HADOOP_HOME/bin:$PATH

step 3: Configuring java for Hadoop

sudo nano /home/hduser/Utilities/hadoop-1.0.3/conf/hadoop-env.sh

JAVA_HOME will be commented by default.Edit the value for JAVA_HOME with your installation path and uncomment the line.The bin folder should not contain this JAVA_HOME path.

# The Java implementation to use.

export JAVA_HOME=<absolute path to java directory>

Step 4:Configuring Hadoop properties

In Hadoop, we have three configuration files core-site.xml,mapred-site.xml,hdfs-site.xml present in HADOOP_HOME/conf directory.

  Editing the Configuration files

1. Core-site.xml

hadoop.tmp.dir’ , the directory specified by this property is used to store file system Meta information by namenode and block information by datanode.By default two directories by the name and data will be created in the mp dir.We need to ensure that ‘hduser’ has sufficient permission on the newly provided ‘hadoop.tmp.dir‘. We are configuring it to ‘/home/hduser/app/hadoop/tmp’.

The property ‘fs.default.name’ is required to provide the hostname and port of  the namenode.Creating the directory and changing the ownership and permission to ‘hduser’

cd /home/hduser/Utilities

sudo mkdir -p /app/hadoop/tmp

sudo chown hduser:hadoop /app/hadoop/tmp

sudo chmod 755 /app/hadoop/tmp

Setting ownership and permission is very important.If you forget this, you will get into some exceptions while formatting the namenode.

Open the core-site.xml, you can see empty configuration tags.Add the following lines between the configuration tags.

sudo nano /home/hduser/Utilities/hadoop-1.0.3/conf/core-site.xml

[code lang=”shell”]
<configuration>
<property>
<name>hadoop.tmp.dir</name>
<value>/home/hduser/Utilities/app/hadoop/tmp</value>
<description>A base for other temporary directories.<description>
</property>
<name>fs.default.name</name>
<value>hdfs://<hostname/Ip address of the system where namenode is installed>:54310</value>
<description>The name of the default file system</description>
<property> </configuration>
[/code]

2. hdfs-site.xml

It is used for file systems and storage.In the hdfs-site.xml, add the following property between the configuration tags.

sudo nano /home/hduser/Utilities/hadoop-1.0.3/conf/hdfs-site.xml

[code lang=”shell”]
<configuration>
<property>
<name>dfs.replication<name>
<value>1</value>
<description>Default block replication</description>
<property> </configuration>
[/code]

3.mapred-site.xml

This is used for processing.In the mapred-site.xml, we need to provide the hostname and port for jobtracker as tasktracker would be using this for their communication.

sudo nano /home/hduser/Utilities/hadoop-1.0.3/conf/mapred-site.xml

[code lang=”shell”]
<configuration>
<property>
<name>mapred.job.tracker</name>
<value>hostname/ipaddress of the system where jobtracker is installed>:54311</value>
<description>The host and port that the mapreduce jobtracker runs</description>
</property> </configuration>
[/code]

Step 5: Formatting Namenode

Before starting the hdfs daemons like Namenode for the first time, it is mandatory that you format the Namenode.This is only for the first run.For subsequent runs, the formatting of namenode will lose all data.Be careful not to format an already running cluster,even if you need to restart the namenode daemon.

Namenode can be formatted as

/home/hduser/Utilities/hadoop/bin/hadoop namenode -format

Step 6: Starting Hadoop Daemons

/home/hduser/Utilities/hadoop-1.0.3/bin/start-all.sh

This will run all the hadoop daemons namenode,datanode, secondarynamenode, jobtracker and tasktracker.

For stopping Hadoop daemons

we are using the command

 /home/hduser/Utilities/hadoop-1.0.3/bin/stop-all.sh

This will stop all the Hadoop daemons.Only jps is showing after stopping the Hadoop daemons.