Pre-requisites:
Installation:
Step 1: Download the latest Hive tarball from the downloads page.
Step 2: Extract the downloaded tarball (Assumption: The tarball is downloaded in $HOME)
tar -xvf /home/username/apache-hive-x.y.z-bin.tar.gz
Step 3: Update the environment file (~/.bashrc
)
export HIVE_HOME=/home/username/apache-hive-x.y.z-bin
export PATH=$HIVE_HOME/bin:$PATH
source the file to set the new environment variables.
source ~/.bashrc
Step 4: Download the JDBC connector for mysql from here and extract it.
tar -xvf mysql-connector-java-a.b.c.tar.gz
The extracted directory contains the connector jar file mysql-connector-java-a.b.c.jar
. Copy it to the lib
of $HIVE_HOME
cp mysql-connector-java-a.b.c.jar $HIVE_HOME/lib/
Configuration:
Create the hive configuration file hive-site.xml
under $HIVE_HOME/conf/
directory and add the following metastore related properties.
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost/hive_meta</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>mysqluser</value>
<description>username to use against metastore database</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>mysqlpass</value>
<description>password to use against metastore database</description>
</property>
<property>
<name>datanucleus.autoCreateSchema</name>
<value>false</value>
</property>
<property>
<name>datanucleus.fixedDatastore</name>
<value>true</value>
</property>
</configuration>
Update the values of MySQL "username" and "password" accordingly in the properties.
Create the Metastore Schema:
The metastore schema scripts are available under $HIVE_HOME/scripts/metastore/upgrade/mysql/
Login to MySQL and source the schema,
mysql -u username -ppassword
mysql> create database hive_meta;
mysql> use hive_meta;
mysql> source hive-schema-x.y.z.mysql.sql;
mysql> exit;
Starting Metastore:
hive --service metastore
To run it in background,
nohup hive --service metastore &
Starting HiveServer2: (Use if required)
hiveserver2
To run it in background,
nohup hiveserver2 metastore &
Note: These executables are available under $HIVE_HOME/bin/
Connect:
Use either hive
, beeline
or Hue to connect with Hive.
Hive CLI is deprecated, using Beeline or Hue is recommended.
Additional Configurations for Hue:
Update this value in $HUE_HOME/desktop/conf/hue.ini
[beeswax]
hive_conf_dir=/home/username/apache-hive-x.y.z-bin/conf