Installation Steps for Hive

Hive is a SQL Database which uses various servers like thrift, Derby, MySQL to maintain
the metastore.
Here in this setup MySQL server is configured as a base to maintain the metastore of Hive.


SSH :
-------

 - ssh-keygen -t rsa -P ""
 - cat $HOME/.ssh/id_rsa.pub >> $HOME/.ssh/authorized_keys
 - # ssh-add -l # Not Working the run the command
 - ssh localhost
  1.  Needed Software’s - Java ,Hadoop,MySql Server


Before Installing Hive you make sure all the dependent Software's are correctly Installed .If it is not Installed then you can Refer my Previous Blog to Install them.

After Successfully Installing the Softwares correctly!!!!


Download Hive from below Repository: https://archive.apache.org/dist/hive

The following steps are required for installing Hive on your PC. Let us assume the Hive archive is downloaded onto the /Downloads directory .

Here, we download Hive archive named “ap
ache-hive-2.3.0-bin.tar.gz".

The following command is used to verify the download and extract the hive archive.
 tar -xzvf apache-hive-2.3.0-bin.tar.gz -C /usr/local/hive

Configuring bashrc profile for root user:
You can set up the Hive environment by adding the following lines to ~/.bashrc file:
$ vim ~/.bashrc
Configure the path and home variable according to the installation and directory structured followed,


Here, in this setup.
export HIVE_HOME=/usr/local/hive
export PATH=$PATH:$HIVE_HOME/bin/

Once You add these lines to bashrc dont forget to source or else the path will not be reflected correctly.
$ source ~/.bashrc

Configuring Hive:
To configure Hive with Hadoop, you need to edit the hive-env.sh file, which is placed in the $HIVE_HOME/conf directory. The following commands redirect to Hive config folder and copy the template file:
$ cd $HIVE_HOME/conf$ cp hive-env.sh.template hive-env.sh
Edit the hive-env.sh file by adding the following lines to it:Export HADOOP_HOME=/usr/local/hadoop
Hive installation is completed successfully. Now you require an external database server to configure Metastore.
We use Mysql database,To install run the command

sudo apt-get install mysql-server   (Ignore If Already Installed)
For Centos I have created a Separate Steps to follow in my previous Blog

Configuring MySql server with Hive User:

Login to MySql server as root usermysql -u root –pRoot@123
CREATE USER 'hiveuser'@'%' IDENTIFIED BY 'Hive@123';

GRANT all on *.* to 'hiveuser'@localhost identified by 'Hive@123';

flush privileges;

Create metastore in mysql

Login to MySQL server as hiveuser

mysql -u hiveuser -pHive@123
create database metastore_db_230;
use metastore_db_230;
source /usr/local/hive/scripts/metastore/upgrade/mysql/ hive-schema-2.3.0.mysql.sql;
exit;

Add MySQL Connector jar to hive library
File can be located in /usr/share/java/
Copy the jar from that location to Hive’s library folder
cp /usr/share/java/mysql-connector-java.jar /usr/local/hive/lib.

Configuration of hive:
Configure this file only if error message comes when trying to view tables/databases from hive database

cd 
usr/local/hive/bin/

vim hive
for f in ${SPARK_HOME}/jars/*.jar; do
CLASSPATH=${CLASSPATH}:$f;
doneConfiguration of Hive-site.xml/usr/local/hive/conf
Create a file named hive-site.xml and add the following
In above setup, hiveuser and password has been created, Use those information to configure hive in this
setup.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost:3306/metastore_db_230?createDatabaseIfNotExist=true&amp;u
seSSL=false</value>
<description>JDBC connect string for a JDBC metastore</description>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
<description>Driver class name for a JDBC metastore</description>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>hiveuser</value>
<description>username to use against metastore database</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>Hive@123</value>
<description>password to use against metastore database</description>
</property>
<property>
<name>hive.metastore.schema.verification</name>
<value>false</value>
<description>
</description>
</property>
<property>
<name>hive.metastore.schema.verification.record.version</name>
<value>true</value>
<description>
When true the current MS version is recorded in the VERSION table. If this is disabled
and verification is enabled the MS will be unusable.
</description>
</property>
<property>
<name>hive.execution.engine</name>
<value>mr</value>
<description>
Expects one of [mr, tez, spark].
Chooses execution engine. Options are: mr (Map reduce, default), tez, spark. While
MR remains the default engine for historical reasons, it is itself a historical engine
and is deprecated in Hive 2 line. It may be removed without further warning.
</description>
</property>
</configuration>

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:
$ cd $HIVE_HOME
$ bin/hive
On successful installation of Hive, you get to see the following response:

Logging initialized using configuration in jar:file:/usr/local/hive/lib/hive-common-0.9.0.jar!/hive-log4j.properties 

Hive history file=/tmp/hadoop/hive_job_log_hadoop_201312121621_1494929084.txt

………………….

hive>



Thanks,
Have Fun!!!!

Please Leave your Comment Below If you Have Any Clarifications Regarding Installations or Any Suggestions.

Comments

Post a Comment

Popular posts from this blog

Quick Setup Steps For Installing & Integrating Spark,Hive,Hadoop Processess Together !!!

Twitter Analysis Using R

Best Practices for Apache Hive Performance Tuning

Performance Improvement in Hive (Properties in HIVE -SITE.XML)

Installation Steps For MySql Server (version 5.7.23) For Centos

Facebook Data Analysis Using R

Installation Steps For Spark