Post

Install Hbase on Ubuntu in standalone mode

hbase

Hbase like any other NoSQL databases is a columnar NoSQL database, which works well with semi-structures as well as with structured data.

Following are the three modes of Hbase installation:

  1. Standalone mode
  2. Semi-distributed mode
  3. full distributed mode

Hbase works along with hadoop and uses Hadoop Distributed File System (HDFS) to store the data. Semi-distributed and distributed modes uses HDFS. Hbase can be configured to work with local file system by installing Hbase in standalone mode. Standalone mode is perfect for the individuals who wants to practice Hbase commands. It is strictly recommended to use Hbase along with Hadoop when dealing with distributed data and clusters.

As Hbase is programmed suing Java, it requires JDK to work.

Long way

Following are the steps to install Hbase in standalone mode: Let’s start with installing JDK.

  1. Head to the oracle site and download JDK file for Linux x64 (size around 170MB)
  2. Fire-up a terminal and navigate to the directory where downloaded file is present
  3. Copy the file to the location /usr/lib using following command
    1
    
     sudo cp <filename>.tar.gz /usr/lib/
    

    For example, assuming filename to be “jdk-8u102-linux-x64.tar.gz” then the command will look like sudo cp jdk-8u102.linux-x64.tar.gz /usr/lib/ (without quotes)

  4. Navigate to the directory /usr/lib
    1
    
     cd /usr/lib
    
  5. Extract the file using following command
    1
    
     sudo tar -xvf <filename>.tar.gz
    
  6. Do some cleaning by removing the compressed file
    1
    
     sudo rm <filename>.tar.gz
    

Now let’s begin with the actual installation of Hbase. For the tutorial purpose we are going to use the version “0.94.8” you can use whatever version of Hbase required just by replacing the filename in following commands.

  1. Head to the apache archives and download the Hbase package. For the tutorial purpose we are downloading the package “hbase-0.94.8.tar.gz”
  2. Fire-up a terminal and navigate to the directory where downloaded file is present
  3. Extract the file
    1
    
     tar -xvf hbase-0.94.8.tar.gz
    
  4. Do some cleaning by removing the compressed file
    1
    
     rm hbase-0.94.8.tar.gz
    
  5. Create a directory hbase at location /usr/lib
    1
    
     sudo mkdir /usr/lib/hbase
    
  6. Move the directory named hbase-0.94.8 to the location /usr/lib/hbase
    1
    
     sudo mv hbase-0.94.8 /usr/lib/hbase/hbase-0.94.8
    
  7. Let’s create directory structure for Hbase to use local filesystem to store the data
    1
    2
    3
    4
    5
    6
    7
    
     cd ~
            
     mkdir HBASE
            
     mkdir HBASE/hbase
            
     mkdir HBASE/zookeeper
    
  8. Navigate to the location “/usr/lib/hbase/hbase-0.94.8/conf”

    1
    
     cd /usr/lib/hbase/hbase-0.94.8/conf
    
  9. Now we need to add the information about the directory structure we created earlier.
    Note down path to your home directory using the following command

    1
    
     $HOME
    
  10. Open hbase-env.sh file using gedit and add following lines between tags <configuration> and </configuration>.

    1
    
    sudo gedit hbase-env.sh
    

    Remember to substitute path to your home directory wherever occurrences. Add the following lines

    1
    2
    3
    4
    5
    6
    7
    8
    9
    
    <property>
        <name>hbase.rootdir</name>
        <value>path_to_home/HBASE/hbase/</value>
    </property>
    
    <property>
        <name>hbase.zookeeper.property.dataDir</name>
        <value>path_to_home/HBASE/zookeeper/</value>
    </property>
    
  11. Navigate to the home directory and open .bashrc file

    1
    2
    3
    
    cd ~
        
    gedit .bashrc
    
  12. Add following lines to “.bashrc”

    1
    2
    
    export HBASE_HOME=/usr/lib/hbase/hbase-0.94.8   
    export PATH=$PATH:$HBASE_HOME/bin
    
  13. Open “hosts” file

    1
    
    sudo gedit /etc/hosts
    
  14. Change IP address 127.0.1.1 to 127.0.0.1

    If every thing is done perfectly then you are good to go. Use following commands in the terminal to work with Hbase

    To start Hbase - start-hbase.sh
    To get Hbase shell - hbase shell
    To stop Hbase - stop-hbase.sh

Short way

For those who don’t want to go through the above procedure, we have created an installation script which will carry out the entire installation on its own. Remember to enter your user password whenever prompted for.

Download the installation file from here and install using the following procedure

  1. Fire-up a terminal and navigate to the directory where the downloaded file is present
  2. Extract it

    1
    
    tar -xvf Project_hbase
    
  3. Navigate into “Project_hbase” directory

    1
    
    cd Project_hbase
    
  4. Begin installation by executing “install.sh” script

    1
    
    sh install.sh
    

If everything is done perfectly then you are good to go. Use above mentioned commands to start, stop and use Hbase

This post is licensed under CC BY 4.0 by the author.