Configuring a remote MySQL database for the Hive Metastore


Step 1: Install and start MySQL 

    $ sudo apt-get install mysql-server

 

Step 2: Configure the MySQL Service and Connector

Install mysql-connector-java and symbolically link the file into    the /usr/lib/hive/lib/ directory. 

   $ sudo apt-get install libmysql-java
 
 $ ln -s /usr/share/java/libmysql-java.jar /usr/lib/hive/lib/libmysql-java.jar

Write the command, to set the MySQL root password :

 $ sudo /usr/bin/mysql_secure_installation 

 

[...]
Enter current password for root (enter for none):
OK, successfully used password, moving on...
[...]
Set root password? [Y/n] y
New password:
Re-enter new password:
Remove anonymous users? [Y/n] Y
[...]
Disallow root login remotely? [Y/n] N
[...]
Remove test database and access to it [Y/n] Y
[...]
Reload privilege tables now? [Y/n] Y
All done!
 
Step 3. Start mysql-server by following command: 
 
 $ mysql -u root -p
 
 

mysql> CREATE DATABASE metastore;
mysql>
USE metastore;
mysql>
SOURCE /usr/lib/hive/scripts/metastore/upgrade/mysql/hive-schema-0.10.0.mysql.sql;

 

Step 4: Configure the Metastore Service to Communicate with the MySQL Database :

This step shows the configuration properties you need to set in hive-site.xml to configure the metastore service to communicate with the MySQL database, and provides sample settings. 

<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://myhost/metastore</value>
<description>the URL of the MySQL database</description>
</property>

<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>

<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>hive</value>
</property>

<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>mypassword</value>
</property>

<property>
<name>datanucleus.autoCreateSchema</name>
<value>false</value>
</property>

<property>
<name>datanucleus.fixedDatastore</name>
<value>true</value>
</property>

<property>
<name>hive.metastore.uris</name>
<value>thrift://<n.n.n.n>:9083</value>
<description>IP address (or fully-qualified domain name) and port of the metastore host</description>
</property>

Popular Posts