Hive Installation
Posted on by Sumit KumarHive installation:
1.) search for apache hive-2.2.0 bin in google
and download zar file (latest bin.tar.gz file)
http://www-eu.apache.org/dist/hive/hive-2.2.0/
e.g. :- apache-hive-2.2.0-bin.tar.gz
or download hive from linux command as below:–
wget http://www-eu.apache.org/dist/hive/hive-2.2.0/apache-hive-2.2.0-bin.tar.gz
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
wget https://la-mirrors.evowise.com/mysql/Downloads/Connector-J/mysql-connector-java-5.1.45.tar.gz
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
================optional========================
{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 hive-env.sh.template to hive-env.sh
1. In hive-env.sh (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
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost/metastore_db?createDatabaseIfNotExist=true&autoReconnect=true&useSSL=false</value>
b) ConnectionUserName
<name>javax.jdo.option.ConnectionUserName</name>
<value>hiveuser</value>
c) ConnectionPassword
<name>javax.jdo.option.ConnectionPassword</name>
<value>hivepassword</value>
(d)
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
=============or copy paste below configuration into hive-site.xml==============
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost:3306/metastore?createDatabaseIfNotExist=true&useSSL=false</value>
<description>metadata is stored in a MySQL server</description>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
<description>MySQL JDBC driver class</description>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
<description>user name for connecting to mysql server</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>sumit</value>
<description>password for connecting to mysql server</description>
</property>
</configuration>
===========Note :-change UserName and Passoword===================
3. Replace following values in hive-site.xml
<property>
<name>hive.exec.local.scratchdir</name>
<value>/tmp/hive</value>
<description>Local scratch space for Hive jobs</description>
</property>
<property>
<name>hive.downloaded.resources.dir</name>
<value>/tmp/hive</value>
<description>Temporary local directory for added resources in the remote file system.</description>
</property>
========================optional=================================
<property>
<name>system:java.io.tmpdir</name>
<value>/tmp/hive/java</value>
</property>
<property>
<name>system:user.name</name>
<value>${user.name}</value>
</property>
==========================================================
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
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