In previous versions of HiveServer2, a client would only be able to connect to one HiveServer2; if that one HiveServer2 failed or went down, production would be affected.
Since Pivotal Hadoop (PHD) version 3.0.1 with Ambari version 2.1.2, multiple HiveServer2 instances can register themselves with ZooKeeper and then the client can find a HiverServer2 via ZooKeeper. When a client requests an HiveServer2 instance, ZooKeeper returns one randomly-selected registered HiveServer2.
The High Availability (HA) feature for HiveServers is currently not documented in the PHD documentation, so this article will give an outline of the steps needed to enable HA for HiveServer2 in PHD 3.0 and will point to a Hortonworks document that gives further details.
- Select "Hive" in the Ambari service list.
- In Ambari's "Service action" menu, select "Add hiveserver2".
- Confirm the HIVE Metastore allows access from the new HiveServer2 host.
- Start the new HiveServer2 via Ambari.
- Restart ALL other relevant services as requested by Ambari.
- Update all clients to connect to the ZooKeeper ensemble rather than directly to the one HiveServer2 node.
For more detailed instructions, please refer to the Hortonworks documentation about HiveServer2 HA.
How to check HiveServer2 has registered with ZooKeeper correctly:
When the HiveServer2 registers with ZooKeeper, a new znode is created. To confirm that the configuration is set up correctly, the znode can be checked via the ZooKeeper CLI:
- Log into a node where ZooKeeper is installed.
- Run zkCli.sh to open a connection to ZooKeeper.
- In the ZooKeeper CLI, run "ls /hiveserver2":
[zk: localhost:2181(CONNECTED) 1] ls /hiveserver2
[zk: localhost:2181(CONNECTED) 2] quit
2016-03-01 10:56:00,543 - INFO [main:ZooKeeper@684] - Session: 0x1532d60dbea0006 closed
2016-03-01 10:56:00,543 - INFO [main-EventThread:ClientCnxn$EventThread@512] - EventThread shut down
As per the output listed above, the two nodes that are running HiveServer2 (node1 and node2) are registered in ZooKeeper which confirms that the HiveServer2 servers have registered correctly in ZooKeeper.