-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Apache Hive Cookbook
By :

We will now take a look at installing Hive along with all the prerequisites.
Let's download the stable version from one of the mirrors:
$ wget http://a.mbbsindia.com/hive/hive-1.2.1/apache-hive-1.2.1-bin.tar.gz
This can be achieved in three ways.
Once you have downloaded the Hive tar-ball
file, installing and setting up a Hive is pretty simple and straightforward. Extract the compressed tar:
$tar –xzvf apache-hive-1.2.1-bin.tar.gz
Export the location where Hive is extracted as the environment variable HIVE_HOME
:
$ cd apache-hive-1.2.1-bin $ export HIVE_HOME={{pwd}}
Hive has all its installation scripts in the $HIVE_HOME/bin
directory. Export this location to the PATH
environment variable so that you can run all scripts from any location directly from a command-line:
$ export PATH=$HIVE_HOME/bin:$PATH
Alternatively, if you want to set the Hive path permanently for the user, then make the entry of Hive environment variables in the .bashrc
or .bash_profile
files available or could be created in the user's home
folder:
~/.bash_profile
:export HIVE_HOME=/home/hduser/apache-hive-1.2.1-bin export PATH=$PATH:$HIVE_HOME/bin
hduser
is the name of user with which you have logged in and Hive-1.2.1 is the Hive
directory extracted from the tar
file.
Run Hive from a terminal:hive
Failed to start database 'metastore_db'
error.hive> SHOW TABLES; hive> CREATE TABLE sales(id INT, product String, age INT) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t';
/tmp/<usrename>
folder.Follow these steps to configure Hive with the local metastore. Here, we are using the MySQL database as a metastore:
~/.bash_profile
:export HIVE_HOME=/home/hduser/apache-hive-1.2.1-bin export PATH=$PATH:$HIVE_HOME/bin
Here, hduser
is the user name, and apache-hive-1.2.1-bin
is the Hive
directory extracted from the tar
file.
sudo apt-get install mysql-server
mysql-connector
jar. Download the latest mysql-connector jar from http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.35.tar.gz and copy it to the lib
folder of your Hive home
directory.hive-site.xml
, in the conf
folder of Hive and add the following entries to it:<configuration> <property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://localhost:3306/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>hduser</value> <description>user name for connecting to mysql server </description> </property> <property> <name>javax.jdo.option.ConnectionPassword</name> <value>passwd</value> <description>password for connecting to mysql server</description> </property> </configuration>
hive
There is a known "JLine
" jar conflict issue with Hadoop 2.6.0 and Hive 1.2.1. If you are getting the error "unable to load class jline.terminal
," you need to remove the older version of the jline
jar from the yarn
lib folder using the following command:
sudo rm -r $HADOOP_PREFIX/share/hadoop/yarn/lib/jline-0.9.94.jar
Follow these steps to configure Hive with a remote metastore.
tar –xzvf apache-hive-1.2.1-bin.tar.gz
~/.bash_profile
:sudo nano ~/.bash_profile export HIVE_HOME=/home/hduser/apache-hive-1.2.1-bin export PATH=$PATH:$HIVE_HOME/bin
Here, hduser
is the user name and apache-hive-1.2.1-bin
is the Hive
directory extracted from the tar
file.
sudo apt-get install mysql-server
mysql-connector
jar file. Download the latest mysql-connector
jar from http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.35.tar.gz and copy it to the lib
folder of your Hive home
directory.hive-site.xml
:<configuration> <property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://<ip_of_remote_host>:3306/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>hduser</value> <description>user name for connecting to mysql server </description> </property> <property> <name>javax.jdo.option.ConnectionPassword</name> <value>passwd</value> <description>password for connecting to mysql server</description> </property> </configuration>
bin/hive --service metastore &
hive
9083
:netstat -an | grep 9083
There is a known "JLine" jar conflict issue with Hadoop 2.6.0 and Hive 1.2.1. If you are getting the error "unable to load class jline.terminal," you need to remove the older version of jline jar from the yarn lib folder using the following command:
sudo rm -r $HADOOP_PREFIX/share/hadoop/yarn/lib/jline-0.9.94.jar
Change the font size
Change margin width
Change background colour