How to Configure HiveMetastore HA and Load Balancing for HiveServer2

Assumtions: You have already Installed and Configured Hive Metastore and Hive Server2

  1. Select Hive Services -> configuration
  2. Select Scope -> Hive Metastore Server and category -> Advanced.
  3. Locate the Hive Metastore Delegation Token Store property. or search for it by typing its name in the search box.
  4. select org.apache.hadoop.hive.thrift.DBTokenStore click save changes
hiveserver2 configuraton cloudera

Now go to Yarn – Resource Pools section

  1. Click on instance tab and add role instance.
  2. Click the text field under hive metastore server.
  3. Click on Select Hosts for Hive Metastore Server.
add hive metastore host cloudera
  1. Click Finish. You should now see new hosts added as the Hive Metastore Server.
  2. Re-start the stale configurations

Test HA set up for Hive Meta Store:

SSH to any Gateway. Connect to Hiveserver2 using Beeline.

hive server2 connect beeline

Now from CM, select first Hive Metastore Server and stop the connection.

stop hive server from cloudera to HA
hive server2 connect beeline

Now stop second hive Metastore server. This command should fail which is normal.

stop both hive server cloudera
beeline not able to connect hiveserver

Confiure Load balancing for HiverServer2:

Add couple of You should now see new hosts added as HiveServer2.

  1. Go to the Hive service.
  2. Click the Configuration tab -> Scope > HiveServer2 and Category -> Advanced
  3. Locate the HiveServer2 advanced Snippet property or search for it by typing its name in the Search box.
hive server2 proxy setup cloudera

Now connect HiveServer2 through Zookeeper.

               
beeline -u "jdbc:hive2://dn1:2181,dn2:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2"



                
  
             
connect hive server2 beeline load balancer