软件环境:
linux系统: CentOS6.7
Hadoop版本: 2.6.5
zookeeper版本: 3.4.8
</br>
主机配置:
一共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
</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.检验是否在zookeeper上注册
- 先启动第一部需要服务高可用的主机上的HiveServer2服务
sh $HIVE_HOME/bin/hiveserver2
- 再启动第二部需要服务高可用的主机上的HiveServer2服务
sh $HIVE_HOME/bin/hiveserver2
- 在zookeeper所在的主机上查看
sh $ZK_HOME/bin/zkCli.sh
ls /
</br>
</br>
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服务:
sh $HIVE_HOME/bin/beeline
(2)在beeline中输入以下连接指令:
!connect jdbc:hive2://m3:2181,m4:2181,m5:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2_zk
(3)如没使用HiveServer2服务高可用是,则连接beeline使用下列指令:
!connect jdbc:hive2://m1
</br>
</br>
</br>