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
JavaHadoop
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
|
$ sudo tar -xvf
apache-hive-0.14.0-bin.tar.gz
|
$ 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
|
$ source ~/.bashrc
|
$ cd /usr/local/hive/conf
$ sudo cp hive-env.sh.template hive-env.sh
|
$ sudo nano hive-env.sh
|
export HADOOP_HOME=/usr/local/hadoop
|
Configure Mysql Database
Check mysql service running or not
$ sudo service mysqld status
|
$ sudo service mysqld start
|
Login with root user (administrator credential)
$ mysql -u root -p
$ Enter Password
|
Mysql>use mysql;
|
mysql> CREATE USER
'hiveuser'@'%' IDENTIFIED BY 'hive@123';
|
mysql> GRANT all on *.* to
'hiveuser'@localhost identified by 'hive@123';
|
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
|
$ sudo nano
/usr/local/hive/conf/hive-site.xml
|
<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>
|
$ 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
|
$ 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
|
hive>
|
$ mysql –u root –p
Enter Password admin@123
|
Mysql>show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| hivemetastore |
| mysql |
+--------------------+
|
0 comments:
Post a Comment