Enabling High Availability for Hive Metastore

About this task

To enable High Availability for Hive Metastore.

Procedure

  1. Enable remote access to the underlying database from different nodes.
  2. 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>
  3. Restart Hive Metastore services on all nodes, where Hive Metastore services are installed.
  4. Restart all HiveServer2 instances.

Results

Enabling high availability for the Hive Metastore does not require changes to the 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
  1. Change the MySQL configuration:
    nano /etc/my.cnf
  2. Comment out the following properties:
    #bind-address   
    #skip-networking
    If these properties are not in my.cnf, you can skip editing my.cnf. Restart the MySQL server.
  3. Enable remote access for the underlying database by granting permissions in the underlying database. Connect to MySQL server from node3, and provide access to node1 and node2.
    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;
  4. Optionally, verify the connectivity to the MySQL server running on node3 from node1 and node2. For example, run the following commands:
    • On node1:
      mysql -h node3 -uroot -psecret
    • On node2:
      mysql -h node3 -uroot -psecret
  5. 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>
  6. 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>
  7. 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.