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.
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. IMAGE1
Select the Latest version of Hive. (In my current case it is hive – 3.1.2)
Click on the bin file and downloading will start.
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
Step 3) Different Configuration properties to be placed in Apache Hive.
In this step, we are going to do two things
- Placing Hive Home path in bashrc file
- Placing Hadoop Home path location in hive-config.sh
- Mention Hive Pathin ~/.bashrc
- 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
Code to be placed in bashrc
export HIVE_HOME="/home/guru99hive/apache-hive-1.2.0-bin" export PATH=$PATH:$HIVE_HOME/bin
- 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
Mention the HADOOP_HOME Path in hive-config.sh file as shown in below ( HADOOP_HOME Path)
Step 4) Creating Hive directories in Hadoop:
To communicate with Hadoop, we need to create directories in Hadoop as shown below.
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.
Step 5) Getting into Hive shell by entering '. /hive' command as shown in below.
Here we are going to create sample table using Hive shell command "create" with column names.
Sample Code for creating data base in Hive
From the above screen shot we can observe the following:
- 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 ', '
- 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 ',';