linux系統: CentOS6.7 Hadoop版本: 2.6.5 zookeeper版本: 3.4.8
192.168.179.201: m1 192.168.179.202: m2 192.168.179.203: m3 m1: Zookeeper, Namenode, DataNode, ResourceManager, NodeManager, Master, Worker m2: Zookeeper, Namenode, DataNode, ResourceManager, NodeManager, Worker m3: Zookeeper, DataNode, NodeManager, Worker
參考資料: http://lxw1234.com/archives/2016/05/675.htm
vi $HIVE_HOME/conf/hive-site.xml
<property> <name>spark.deploy.recoveryMode</name> <value>ZOOKEEPER</value> </property> <property> <name>hive.server2.support.dynamic.service.discovery</name> <value>true</value> </property> <property> <name>hive.server2.zookeeper.namespace</name> <value>hiveserver2_zk</value> </property> <property> <name>hive.zookeeper.quorum</name> <value>m1:2181,m2:2181,m3:2181</value> </property> <property> <name>hive.zookeeper.client.port</name> <value>2181</value> </property>
sh $HIVE_HOME/bin/hiveserver2
sh $HIVE_HOME/bin/hiveserver2
sh $ZK_HOME/bin/zkCli.sh
ls /
jdbc:hive2://<zookeeper quorum>/<dbName>;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=nameSpace
<zookeeper quorum> # 爲Zookeeper的集羣連接串,如zkNode1:2181,zkNode2:2181,zkNode3:2181 <dbName> # 爲Hive數據庫(可不填, 默認爲default) serviceDiscoveryMode=zooKeeper # 指定模式爲zooKeeper zooKeeperNamespace=nameSpace # 指定ZK中的nameSpace,即參數hive.server2.zookeeper.namespace所定義,在hive-site.sh中定義爲hiveserver2_zk
(1)啓動beeline服務:node
sh $HIVE_HOME/bin/beeline
(2)在beeline中輸入如下鏈接指令:linux
!connect jdbc:hive2://m3:2181,m4:2181,m5:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2_zk
(3)如沒使用HiveServer2服務高可用是,則鏈接beeline使用下列指令:數據庫
!connect jdbc:hive2://m1