Friday 17 February 2017

Hive 0.14 Installation & Configuration



Apache Hive is It is an Open Source data warehousing system. It is exclusively used to query and analyze huge data sets stored in theHadoop storage.Hive gives a SQL-like interface to query data stored in various databases and file systems that integrate with Hadoop.





Prerequisites

Java
Hadoop
Mysql or Any relational database.

Download and Installing Hive

Download Hive 0.14 using below command on /usr/local directory.
$ cd /usr/local
$sudo wget http://archive.apache.org/dist/hive/hive-0.14.0/apache-hive-0.14.0-bin.tar.gz
Unpack apache-hive-0.14.0-bin.tar.gz file
$ sudo tar -xvf apache-hive-0.14.0-bin.tar.gz
Rename apache-hive-0.14.0-bin to hive 
$ sudo mv apache-hive-0.14.0-bin hive

Setting up environment for Hive

Edit ~/.bashrc file for set up the Hive environment by appending the following lines.
$ sudo nano ~/.bashrc 
export HIVE_HOME=/usr/local/hive
export PATH=$HIVE_HOME/bin:$PATH
Reload the configuration file ~/.bashrc with the following command.
$ source ~/.bashrc
Copy hive-env.sh.template as hive-env.sh.
$ cd /usr/local/hive/conf
$ sudo cp hive-env.sh.template hive-env.sh
Edit the hive-env.sh file by appending the following line.
$ sudo nano hive-env.sh
Add the below line to hive-env.sh file.
export HADOOP_HOME=/usr/local/hadoop

Configure Mysql Database

Check mysql service running or not
$ sudo service mysqld status
If mysql service is not running then start the service
$ sudo service mysqld start
Note:You also need a MySQL separate 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.
Login with root user (administrator credential)
$ mysql -u root -p
$ Enter Password
Enter into Mysql database
Mysql>use mysql;
Creating New user
mysql> CREATE USER 'hiveuser'@'%' IDENTIFIED BY 'hive@123';
Grant privilege to New user
mysql> GRANT all on *.* to 'hiveuser'@localhost identified by 'hive@123';
flush privileges to New user
mysql> flush privileges;

Configuring Hive metastore with Mysql.

Configuring Metastore means specifying to Hive where the database is stored. You can do this by editing the hive-site.xml file, which is in the /usr/local/hive/conf directory.
Copy the template file as hive-site.xml using the following command

$ cd /usr/local/hive/conf
$ sudo cp hive-default.xml.template hive-site.xml
Edit hive-site.xml file using this command
$ sudo nano /usr/local/hive/conf/hive-site.xml
Before adding below properties, comment all existing properties within <Configuration></Configuration> tag.
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost/hivemetastore?createDatabaseIfNotExist=true</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>Mysql JDBC 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>
Download mysql-connector-java-5.1.28.jar to /usr/local/hive/lib/ folder
$ cd /usr/local/hive/lib
$sudo wget http://central.maven.org/maven2/mysql/mysql-connector-java/5.1.28/mysql-connector-java-5.1.28.jar
Change the ownership and permissions of the directory /usr/local/hive
$ sudo chown -R hdfs:hdfs /usr/local/hive
$ sudo chmod -R 755 /usr/local/hive

Check Hive Properly Installed

Check whether hive properly install or not (type hive and press Enter)
$ hive
It showing hive prompt
hive>
Also check in mysql whether hive database automatically created or not
$ mysql –u root –p
Enter Password admin@123
Showing created database
Mysql>show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| hivemetastore      |
| mysql              |
+--------------------+
.
Share:

0 comments:

Post a Comment

Total Pageviews

Lables

Powered by Blogger.

Followers