How to Install HIVE on Ubuntu (Download & Setup Guide)

Prior to Apache Hive installation we require dedicated Hadoop installation, up and running with all the Hadoop daemons.

For Installation of Hadoop check this link

Once all the Hadoop daemons are working fine, just start installation of Hive part.

HIVE Installation process-

  1. Installation of Hive
  2. Hive shell commands

How to Install Hive on Ubuntu

Below is a step by step process on how to install Hive in Ubuntu:

Step 1) Download and Install Hive on Ubuntu

For downloading Hive stable setup refer Apache URL as mentioned below

http://www.apache.org/dyn/closer.cgi/hive/. Go to the URL and select the apache mirror download link.

How to Download HIVE

Select the Latest version of Hive setup. (In my current case it is hive – 3.1.2)

Downloading HIVE

Click on the bin file and downloading will start.

Downloading HIVE

Step 2) Extract the tar file

Go to the downloaded Tar file location ->extract the tar file by using the following command to install Hive Ubuntu on your system

tar –xvf  apache-hive-3.1.2-bin.tar.gz

Installation and Configuration of HIVE and MYSQL

Step 3) Place different configuration properties in Apache Hive

In this step, we are going to do two things

  1. Placing Hive Home path in bashrc file
  2. Placing Hadoop Home path location in hive-config.sh
  1. Mention Hive Pathin ~/.bashrc

Installation and Configuration of HIVE

  • Open the bashrc file as shown in above screenshot
  • Mention Hive home path i.e., HIVE_HOME path in bashrc file and export it as shown in below

How to Install and Configure HIVE and MYSQL

Code to be placed in bashrc

export HIVE_HOME="/home/guru99hive/apache-hive-1.2.0-bin"
export PATH=$PATH:$HIVE_HOME/bin
  1. Exporting Hadoop path in Hive-config.sh (To communicate with the Hadoop eco system we are defining Hadoop Home path in hive config field)Open the hive-config.sh as shown in below

How to Install and Configure HIVE and MYSQL

Mention the HADOOP_HOME Path  in hive-config.sh file as shown in below  ( HADOOP_HOME Path)

Installing and Configuring HIVE and MYSQL

Step 4) Create Hive directories in Hadoop

To communicate with Hadoop, we need to create directories in Hadoop as shown below.

Installing and Configuring HIVE and MYSQL

Giving root permissions to create Hive folders in Hadoop. If it doesn’t throw any error message, then it means that Hadoop has successfully given permissions to Hive folders.

Steps to Install and Configure HIVE and MYSQL

Step 5) Enter into Hive shell

Getting into Hive shell by entering ‘. /hive’ command as shown in below.

Steps to Install and Configure HIVE and MYSQL

Hive shell commands

Here we are going to create sample table using Hive shell command “create” with column names.

Sample Code for creating data base in Hive

Example of Hive shell commands

From the above screen shot we can observe the following:

  1. Creation of Sample Table with column names in Hive
  • Here the table name is “product” with three column names product, pname, and price
  • The three column names denoted by their respective data type
  • All fields are terminated by coma ‘, ‘
  1. Displaying Hive Table information
  • Using “describe” command we can able to see the table information present in Hive
  • Here it is displaying column names with their respective data types present in table schema
  • At the end, it will display time to perform this command and number of rows it fetched

Sample Code for creating data base in Hive (For self check )

1) Create table product(product int, pname string, price float)

Row format delimited
Fields terminated by ',';

2)describe product: