Enabling High Availability for Hive Metastore
About this task
To enable High Availability for Hive Metastore.
Procedure
- Enable remote access to the underlying database from different nodes.
-
Add all Metastore instances to
hive.metastore.uris
on all the nodes, as a list of comma-separated values.<property> <name>hive.metastore.uris</name> <value>thrift://<hostname1>:9083,thrift://<hostname2>:9083</value> </property>
- Restart Hive Metastore services on all nodes, where Hive Metastore services are installed.
- Restart all HiveServer2 instances.
Results
warden.hivemetastore.conf
file. Active-active
mode is not supported for Hive Metastore. Hence, there is one active instance of the
Hive Metastore service at any given point in time. The other instances of the Hive
Metastore service are in standby state.You can check the state of Hive Metastore service on the Control System.
Example
Suppose that Hive Metastore is installed on three nodes, node1, node2, node3, while MySQLServer is installed on node3, as given below.
IP Address | Host Name |
---|---|
192.168.33.11 | node1 |
192.168.33.12 | node2 |
192.168.33.13 | node3 |
- Change the MySQL configuration:
nano /etc/my.cnf
- Comment out the following properties:
If these properties are not in#bind-address #skip-networking
my.cnf
, you can skip editingmy.cnf
. Restart the MySQL server. - Enable remote access for the underlying database by granting permissions in the
underlying database. Connect to MySQL server from
node3
, and provide access tonode1
andnode2.
mysql> GRANT ALL PRIVILEGES ON metastore.* TO 'root'@'192.168.33.11' IDENTIFIED BY 'secret' WITH GRANT OPTION; mysql> GRANT ALL PRIVILEGES ON metastore.* TO 'root'@'192.168.33.12' IDENTIFIED BY 'secret' WITH GRANT OPTION; mysql> flush privileges;
- Optionally, verify the connectivity to the MySQL server running on
node3
fromnode1
andnode2
. For example, run the following commands:- On
node1
:mysql -h node3 -uroot -psecret
- On
node2
:mysql -h node3 -uroot -psecret
- On
- Add all Metastore instances to
hive.metastore.uris
on all nodes with the Hive instance:<property> <name>hive.metastore.uris</name> <value>thrift://192.168.33.11:9083,thrift://192.168.33.12:9083,thrift://192.168.33.13:9083 </value> </property>
- Restart Hive Metastore services on all nodes where Hive Metastore service is
installed and then all HiveServer2
instances.
maprcli node services -name hivemeta -action restart -nodes <comma-separated list of Hive Metastore nodes>
- Restart all HiveServer2
instances.
maprcli node services -name hs2 -action restart -nodes <comma-separated list of HiveServer2 nodes>
Check the status of Hive Metastore on the Control System. Following is a sample view of the Control System displaying the status of Hive Metastore.