軟件環(huán)境:
linux系統(tǒng): CentOS6.7
Hadoop版本: 2.6.5
zookeeper版本: 3.4.8
</br>
主機(jī)配置:
一共m1, m2, m3這三部機(jī), 每部主機(jī)的用戶名都為centos
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
</br>
</br>
1.編輯hive-site.xml文件
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>
</br>
2.檢驗(yàn)是否在zookeeper上注冊(cè)
- 先啟動(dòng)第一部需要服務(wù)高可用的主機(jī)上的HiveServer2服務(wù)
sh $HIVE_HOME/bin/hiveserver2
- 再啟動(dòng)第二部需要服務(wù)高可用的主機(jī)上的HiveServer2服務(wù)
sh $HIVE_HOME/bin/hiveserver2
- 在zookeeper所在的主機(jī)上查看
sh $ZK_HOME/bin/zkCli.sh
ls /
</br>
</br>
3.測(cè)試連接JDBC
JDBC連接的URL規(guī)范:
jdbc:hive2://<zookeeper quorum>/<dbName>;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=nameSpace
語(yǔ)法解析:
<zookeeper quorum> # 為Zookeeper的集群鏈接串,如zkNode1:2181,zkNode2:2181,zkNode3:2181
<dbName> # 為Hive數(shù)據(jù)庫(kù)(可不填, 默認(rèn)為default)
serviceDiscoveryMode=zooKeeper # 指定模式為zooKeeper
zooKeeperNamespace=nameSpace # 指定ZK中的nameSpace,即參數(shù)hive.server2.zookeeper.namespace所定義银伟,在hive-site.sh中定義為hiveserver2_zk
測(cè)試連接:
(1)啟動(dòng)beeline服務(wù):
sh $HIVE_HOME/bin/beeline
(2)在beeline中輸入以下連接指令:
!connect jdbc:hive2://m3:2181,m4:2181,m5:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2_zk
(3)如沒(méi)使用HiveServer2服務(wù)高可用是,則連接beeline使用下列指令:
!connect jdbc:hive2://m1
</br>
</br>
</br>