Enabling Hive Metastore leader election

Enable dynamic leader election so that Hive Metastore (HMS) uses a Hive lock to elect a leader for housekeeping tasks instead of a statically configured host.

By default the HMS uses the dynamic election in Cloudera Runtime 7.3.2.10000. To elect the leader dynamically, set metastore.housekeeping.leader.election to lock and enable the supporting properties on all HMS instances so that a new leader can start the housekeeping tasks.

You have access to the Cloudera Manager Hive Metastore configuration.

  1. Set the following property in the Hive Metastore Server Advanced Configuration Snippet (Safety Valve) for hive-site.xml:
    metastore.housekeeping.leader.election=lock
  2. Set the following properties to true on all HMS instances to support high availability for leader election:
    metastore.compactor.initiator.on=true
    metastore.housekeeping.threads.on=true
    metastore.compactor.cleaner.on=true
  3. Optional: To track leadership changes, set metastore.housekeeping.leader.auditTable to the name of a Hive table.

    HMS creates the table automatically if it does not exist.

  4. Save the changes and restart the Hive Metastore service.

HMS instances compete for a Hive lock to elect the leader, and a new leader is elected automatically if the current leader stops responding.