Being a data-warehousing framework, a single session for Hive is not preferred. To solve this limitation of Embedded Metastore, a support for Local Metastore was developed. A separate database service runs as a process on same or remote machine. The Metastore service still runs in the same JVM within hive service. Before starting a Hive client, add the JDBC / ODBC driver libraries to the Hive lib folder. Follow below mentioned steps to configure Hive with local metastore:
1. Download the latest version of Hive from here.
2. Uncompress the package:
tar –xzvf apache-hive-0.13.1-bin.tar.gz
3. Add following to ~/.bash_profile
sudo nano ~/.bash_profile
export HIVE_HOME=/home/hduser/hive-0.13.1
export PATH=$PATH:$HIVE_HOME/bin
Where hduser is the user name and hive-0.13.1 is the hive directory extracted from tar.
4. Install a sql database like MySql on the same machine where you want to run Hive.
5. For ubuntu, MySql could be installed from here.
6. Hive need jdbc-mysql connector to connect to mysql metastore. Download the connector tar from here. Untar/Unzip the tar and copy the jdbc connector jar to Hive lib folder.
7. Create or Edit file hive-site.xml in conf folder of hive home. Add following entries to hive-site.xml
<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>root</value>
<description>user name for connecting to mysql server</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>root</value>
<description>password for connecting to mysql server</description>
</property>
</configuration>
7. Run hive from terminal:
hive