In this post we discuss about hive installation in ubuntu

Hive :

Apache Hive is a data warehousing application built on top of Hadoop, it usually runs on the client and enables you to access your data with the help of Hive Query Language, which feels very similar to SQL.

Hive installation :

Install mysql in your pc and then install hive.

Install MySQL and Hive:

Step 1:

Install the MySQLserver.

$ sudo apt-get install mysql-server

hive installation,hive tutorial

# Enter your Password.

hive installation, hive tutorial

# mysql installed

hive installation, hive tutorial

# install mysql java connector

$ sudo apt-get install libmysql-java

hive installation, hive tutorial

# After the Installation completion we will get a screen like bellow figure.

hive installation, hive tutorial

Step 2 : copy mysql connector jar to hive/lib folder

copy the jar file mysql-connector-java-5.1.2.jar from the location /usr/share/java and paste the jar file into the location  $ HIVE_HOME/lib.

Step 3 :

Create the Initial database schema using the hive-schema-0.14.0.mysql.sql file ( or the file corresponding to your installed version of Hive) located in the $HIVE_HOME/scripts/metastore/upgrade/mysql directory.

# Go to mysql using the below command

$ mysql -u root –p

hive installation, hive tutorial

# Enter password : root

hive installation, hive tutorial

# mysql will opened

hive installation, hive tutorial

# create database

mysql> CREATE DATABASE metastore;

hive installation, hive tutorial

# change database to metastore

mysql> USE metastore;

hive installation, hive tutorial

# create initial database schema

mysql> SOURCE /home/geouser/apache-hive-1.2.1-bin/scripts /metastore/upgrade/mysql/hive-schema-0.14.0.mysql.sql;

Step 4 :

You also need a MySQL user account for Hive to use to access the metastore. It is very important to prevent this user account from creating or altering tables in the metastore database schema.

mysql> CREATE USER ‘hiveuser’@’%’ IDENTIFIED BY ‘hivepassword’;

mysql> GRANT all on *.* to ‘hiveuser’@localhost identified by ‘hivepassword’;

mysql> flush privileges;

Step 5 : Download hive

Download hive-1.2.1 and paste it to home and extract it.

Step 6 : Configure hive

Rename the file hive-en.sh.template to hive-env.sh from the location hive1.2.1/conf folder.

Step 7 :

Copy the following path and paste into “hive-env.sh

# java path

export JAVA_HOME=/usr/lib/jvm/java-8-oracle

# hadoop_home path

export HADOOP_HOME=/home/geouser/hadoop-2.7.1

# hive_config path

export HIVE_CONF_DIR=/home/geouser/apache-hive-1.2.1/conf

Step 8 :

Note : – hiveuser is the ConnectionUserName in hive-site.xml

Create hive-site.xml ( If not already present) in hive-1.2.1/conf. Put the following codes into the hive-site.xml file.

<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost/metastore_db?createDatabaseIfNotExist=true</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>geoinsys</value>
<description>user name for connecting to mysql server</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>hivepassword</value>
<description>password for connecting to mysql server</description>
</property>
</configuration>

Step 9 :

Open bashrc file and set the hive path and save it.

To open bashrc type the command in the terminal

$ sudo gedit .bashrc

hive installation, hive tutorial

# set the hive path.

export HIVE_HOME=$HOME/apache-hive-1.2.1-bin

export PATH= $HIVE_HOME/bin

hive installation, hive tutorial

Step 10 :

In terminal type hive ,it will open the hive query language.

hive installation, hive tutorial

hive installation completed.