Enabling HiveServer2 high availability
To provide high availability or load balancing for HiveServer2, Hive provides a function called dynamic service discovery where multiple HiveServer2 instances can register themselves with Zookeeper. Instead of connecting to a specific HiveServer2 directly, clients connect to Zookeeper which returns a randomly selected registered HiveServer2 instance.
About this task
HiveServer2 instances register themselves with Zookeeper by adding a znode, which contains the actual host name and port of the HiveServer2 instance.
The znode has the following format:
/<hiveserver2_namespace>/serverUri=
<host:port>;version=<versionInfo>; sequence=<sequence_number>
Enabling dynamic service discovery
Procedure
Adding new HiveServer2 instances
Procedure
- From the Ambari web interface, click Hive, and then click .
- Select a host and then confirm. Then start the new HiveServer2
Client Connections
Procedure
JDBC/ODBC clients need to use the following connection string to connect to HiveServer2:
The JDBC/ODBC client connects to Zookeeper, which randomly returns a
<host>:<port> for a registered HiveServer2 instance. The client uses the
returned value to connect to a particular HiveServer2 instance directly to perform its work.
jdbc:hive2://<zookeeper_ensemble>/;serviceDiscoveryMode=zooKeeper;
zooKeeperNamespace=<hiveserver2_zookeeper_namespace>where
the following definitions apply:- <zookeeper_ensemble>
- A comma-separated list of ZooKeeper servers that form the ensemble, such as zk_host1:zk_port1,zk_host2:zk_port2,zk_host3:zk_port3.
- <hiveserver2_zookeeper_namespace>
- The namespace on Zookeeper under which HiveServer2 znodes are added. The namespace value is configured in hive.server2.zookeeper.name space.
jdbc:hive2://abc1209.abc.com:2181,abc1208.abc.com:2181,abc1210.abc.com:2181/;
serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2
If the HiveServer2 instance fails while the client is connected, the client session is terminated and there is no automatic fail-over to a new HiveServer2 instance.
Deregistering a HiveServer2 instance from Zookeeper
Procedure
Remove a HiveServer2 instance from Zookeeper by running the following commands to deregister
the server: