What is Apache Hive ? The Apache Hive data warehouse software facilitates querying and managing large datasets residing in distributed storage. Hive provides a mechanism to project structure onto this data and query the data using an SQL-like language called HiveQL. Read More on Official site

This how-to guide will help you to Install Apache Hive on CentOS/RHEL with Hadoop with easy steps.

Step 1: Install JAVA and Hadoop

Apache Hive required java 6 or later version. We also need to install hadoop first before installing apache hive on our system. Use below links to install them

Steps to Install JAVA on CentOS and RHEL 7/6/5
Steps to Install Hadoop on Linux

Step 2: Download Hive Archive

After configuring hadoop successfully on your linux system. lets start hive setup. First download latest hive source code and extract archive using following commands.

# cd /home/hadoop
# wget http://archive.apache.org/dist/hive/hive-0.12.0/hive-0.12.0-bin.tar.gz
# tar xzf hive-0.12.0-bin.tar.gz
# mv hive-0.12.0-bin hive
# chown -R hadoop hive

Step 3: Setup Environment Variables

After extracting hive archive file, switch to hadoop user and setup following environment variables.

# su - hadoop
$ export HADOOP_HOME=/home/hadoop/hadoop
$ export HADOOP_PREFIX=/home/hadoop/hadoop
$ export HIVE_HOME=/home/hadoop/hive
$ export PATH=$HIVE_HOME/bin:$PATH

Step 4: Start Hive

Before running hive we need to create /tmp and /user/hive/warehouse and set them chmod g+w in HDFS before create a table in Hive. Use the following commands.

$ cd /home/hadoop/hive
$ $HADOOP_HOME/bin/hadoop fs -mkdir /tmp
$ $HADOOP_HOME/bin/hadoop fs -mkdir /user/hive/warehouse
$ $HADOOP_HOME/bin/hadoop fs -chmod g+w /tmp
$ $HADOOP_HOME/bin/hadoop fs -chmod g+w /user/hive/warehouse

Lets start using hive using following command.

$ bin/hive

Logging initialized using configuration in jar:file:/home/hadoop/hive/lib/hive-common-0.12.0.jar!/hive-log4j.properties

Step 5: Create Demo Table and Test

At this stage you have successfully installed hive. Lets create a sample table using following command

hive>  CREATE TABLE demo1 (id int, name string);
Time taken: 6.565 seconds

Show the created tables with below command.

Time taken: 0.231 seconds, Fetched: 1 row(s)

Drop the table using below command.

hive> DROP TABLE demo1;
Time taken: 2.393 seconds

Read more about SQL operations on hive on apache hive official site.