How to Install hive?

How to Install hive?

March 12, 2018 0 By Nitikesh Pattanayak

Download hive from :  or 

After download use the below command:

tar zxvf apache-hive-0.14.0-bin.tar.gz

Copy the files to “/usr/local”, so that any user can access hive.

mv apache-hive-0.14.0-bin /usr/local/hive

Setting up environment for Hive:

You can set up the Hive environment by appending the following lines to ~/.bashrc file:

export HIVE_HOME=/usr/local/hive

export PATH=$PATH:$HIVE_HOME/bin

export CLASSPATH=$CLASSPATH:/usr/local/Hadoop/lib/*:.

export CLASSPATH=$CLASSPATH:/usr/local/hive/lib/*:.


Configuring Hive:


$ cd $HIVE_HOME/conf

$ cp

Modify the file by adding  the line:

export HADOOP_HOME=/usr/local/Hadoop


Now Hive installation has been done. To store the data from Hive, we need one Data Store. Here we are using Apache Derby for our Data Store.

$ cd ~

$ wget

$ tar zxvf db-derby-

$ mv db-derby- /usr/local/derby

$ export DERBY_HOME=/usr/local/derby

$ export PATH=$PATH:$DERBY_HOME/bin

$ export CLASSPATH=$CLASSPATH:$DERBY_HOME/lib/derby.jar:$DERBY_HOME/lib/derbytools.jar

$ source ~/.bashrc

$ mkdir $DERBY_HOME/data

$ cd $HIVE_HOME/conf

$ cp hive-default.xml.template hive-site.xml


Modify hive-site.xml and add the lines between the <configuration> and </configuration> tags:




<value>jdbc:derby://localhost:1527/metastore_db;create=true </value>

<description>JDBC connect string for a JDBC metastore </description>



Create a file named and append the following lines into it:


javax.jdo.PersistenceManagerFactoryClass = org.jpox.PersistenceManagerFactoryImpl

org.jpox.autoCreateSchema = false

org.jpox.validateTables = false

org.jpox.validateColumns = false

org.jpox.validateConstraints = false

org.jpox.storeManagerType = rdbms

org.jpox.autoCreateSchema = true

org.jpox.autoStartMechanismMode = checked

org.jpox.transactionIsolation = read_committed

javax.jdo.option.DetachAllOnCommit = true

javax.jdo.option.NontransactionalRead = true

javax.jdo.option.ConnectionDriverName = org.apache.derby.jdbc.ClientDriver

javax.jdo.option.ConnectionURL = jdbc:derby://hadoop1:1527/metastore_db;create = true

javax.jdo.option.ConnectionUserName = APP

javax.jdo.option.ConnectionPassword = mine


Verifying Hive Installation

Before running Hive, you need to create the /tmp folder and a separate Hive folder in HDFS. Here, we use the /user/hive/warehouse folder. You need to set write permission for these newly created folders as shown below:

chmod g+w

Now set them in HDFS before verifying Hive. Use the following commands:

$ $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

The following commands are used to verify Hive installation:

$ bin/hive

On successful installation of Hive, you get to see the following response:

Logging initialized using configuration in jar:file:/home/hadoop/hive-0.9.0/lib/hive-common-0.9.0.jar!/ 
Hive history file=/tmp/hadoop/hive_job_log_hadoop_201312121621_1494929084.txt

The following sample command is executed to display all the tables:

hive> show tables; 
Time taken: 2.798 seconds