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 Apache Hive installation part.

Installation process-

  1. Installation of Hive
  2. Hive shell commands

How to Install Hive

Step 1) Downloading and Installing Hive

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.

Download and Install HIVE

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

Download and Install HIVE

Click on the bin file and downloading will start.

Download and Install HIVE

Step 2) Extracting the tar file.

Go to the downloaded Tar file location ->extract the tar file by using the following command

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

Installation and Configuration of HIVE and MYSQL

Step 3) Different Configuration properties to be placed 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 and MYSQL

  • 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

Installation and Configuration of 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

Installation and Configuration of HIVE and MYSQL

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

Installation and Configuration of HIVE and MYSQL

Step 4) Creating Hive directories in Hadoop:

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

Installation and Configuration of 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.

Installation and Configuration of HIVE and MYSQL

Step 5) Getting into Hive shell by entering '. /hive' command as shown in below.

Installation and Configuration of 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

Installation and Configuration of HIVE and MYSQL

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:

 

YOU MIGHT LIKE: