Hive擴展功能(五)--HiveServer2服務高可用

軟件環境:

linux系統: CentOS6.7
Hadoop版本: 2.6.5
zookeeper版本: 3.4.8


主機配置:

一共m1, m2, m3這五部機, 每部主機的用戶名都爲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




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>


2.檢驗是否在zookeeper上註冊

  1. 先啓動第一部須要服務高可用的主機上的HiveServer2服務
sh   $HIVE_HOME/bin/hiveserver2
  1. 再啓動第二部須要服務高可用的主機上的HiveServer2服務
sh   $HIVE_HOME/bin/hiveserver2
  1. 在zookeeper所在的主機上查看
sh $ZK_HOME/bin/zkCli.sh
ls  /




3.測試鏈接JDBC

JDBC鏈接的URL規範:

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
相關文章
相關標籤/搜索