Hive Installation

Posted on by Sumit Kumar

Hive Installation

Hive installation:

1.) search for apache hive-2.2.0 bin in google
and download zar file (latest bin.tar.gz file)

e.g. :- apache-hive-2.2.0-bin.tar.gz

or download hive from linux command as below:–


2.) extract file:
tar -xvf <filename>

e.g.:-tar -xvf apache-hive-2.2.0-bin.tar.gz

mv apache-hive-2.2.0-bin hive2

3.) download mysqlconnector by using below command


extract file :
tar -xvf mysql-connector-java-5.1.45.tar.gz

copy mysql-connector-java-5.1.45-bin.jar to lib directory in Hive

4.)go to hive2>>>>lib folder
Delete log4j-slf4j-impl-2.4.1.jar jar file from lib directory which is under apache-hive-2.2.0-bin (hive2)directory

5.) hdfs dfs -mkdir -p /user
hdfs dfs -mkdir -p /user/hive
hdfs dfs -mkdir -p /user/hive/warehouse

hdfs dfs -mkdir -p /tmp
hdfs dfs -mkdir -p /tmp/hive

6:- Change Dirctory Permissions

$hdfs dfs -chmod 777 /tmp/
$hdfs dfs -chmod 777 /user/hive/warehouse
$hdfs dfs -chmod 777 /tmp/hive

7.) install mysql:

sudo apt-get install mysql-server

8.) create database metastore

$ mysql -u root -p
{mysql> CREATE DATABASE metastore_db;
mysql> use metastore_db;

/* Now you need to run the script , for that you have to specify the location of script file on your system*/
mysql> SOURCE /home/aru/hive2/scripts/metastore/upgrade/mysql/hive-schema-0.14.0.mysql.sql;}
9:- Create Hiveuser and Hivepassword
mysql> CREATE USER ‘hiveuser’@’%’ IDENTIFIED BY ‘hivepassword’;
mysql> GRANT all on *.* to ‘hiveuser’@localhost identified by ‘hivepassword’;
mysql> flush privileges;

10 :- Get into conf directory under apache-hive-2.2.0-bin folder and rename hive-default.xml.template to hive-site.xml and to

1. In (append HADOOP_HOME at end of file)

export HADOOP_HOME=/home/aru/hadoop2

2. In hive-site.xml (/home/username/hive/conf)

Change following properties
a) ConnectionURL


b) ConnectionUserName
c) ConnectionPassword


=============or copy paste below configuration into hive-site.xml==============

<description>metadata is stored in a MySQL server</description>
<description>MySQL JDBC driver class</description>
<description>user name for connecting to mysql server</description>
<description>password for connecting to mysql server</description>

===========Note :-change UserName and Passoword===================

3. Replace following values in hive-site.xml

<description>Local scratch space for Hive jobs</description>
<description>Temporary local directory for added resources in the remote file system.</description>


Step 11:- Set Path in bashrc
$sudo gedit ~/.bashrc
Add these lines at end of file
export HIVE_HOME=/home/aru/hive2
export PATH=$PATH:$HIVE_HOME/bin:$HIVE_HOME/conf

exec bash

step 12 :- $schematool -initSchema -dbType mysql

Step 13 :- $hive

Note:–Before starting hive please verify , All hadoop services should up and running fine
sumit@hadoop:~$ jps

15521 NameNode
15850 NodeManager
15724 ResourceManager
19325 DataNode

About ATI Base Author: Sumit Kumar

Author of Hadoop tutorial View all posts by Sumit Kumar →

3 Responses to Hive Installation

john says:

Hi Sumit, Good article!
I have a question , we created a hdfs directory hdfs dfs -mkdir -p /user/hive/warehouse
but how does hive know tables must be stored in /user/hive/warehouse.

we didnt define this path anywhere in hive configuration if understood correctly

Sumit Kumar says:

Thanks John!

hive keep all such information as a property.
For hive check the value defined in property
hive.metastore.warehouse.dir. and whatever value is defined in hive.metastore.warehouse.dir property hive will create table in that path.
By default hive.metastore.warehouse.dir value is /user/hive/warehouse so hive create table in this path.
For below example:-
hive (default)> set hive.metastore.warehouse.dir;
hive (default)>
Hive will create table inside /app/ATI/HIVE/WAREHOUSE path.

you can set this as below:
hive (default)> set hive.metastore.warehouse.dir=/desired/directory

Hope I answered your query.

Navin Kumar says:

While installing mysql, it is asking for sudo password though I have not set that. How to find out that password.

Got Something To Say:

Your email address will not be published. Required fields are marked *



Planet Polaris

Website Support
website support at Planet Polaris