感谢您的帮助,谢谢! 我通过zookeeper使用Hive HA,这是我的hive-site.xml(HA部分):
<property>
<name>hive.server2.support.dynamic.service.discovery</name>
<value>true</value>
</property>
<property>
<name>hive.server2.zookeeper.namespace</name>
<value>hiveserver2</value>
</property>
<property>
<name>hive.zookeeper.quorum</name>
<value>hadoopcluster01:2181,hadoopcluster02:2181</value>
</property>
<property>
<name>hive.zookeeper.client.port</name>
<value>2181</value>
</property>
当我使用beeline时:
!connect jdbc:hive2://hadoopcluster01:2181,hadoopcluster02:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2
它完美无缺!
当我使用cloudera jdbc(v:2.5.15)连接到单个hiveserver2时:
Class.forName("com.cloudera.hive.jdbc41.HS2Driver");
DriverManager.getConnection("jdbc:hive2://hadoopcluster01:10000", prop);
它完美无缺!
但是当我尝试通过jdbc连接到zookeeper时:
Class.forName("com.cloudera.hive.jdbc41.HS2Driver");
DriverManager.getConnection("jdbc:hive2://zk=hadoopcluster01:2181,hadoopcluster02:2181/hiveserver2", prop);
不行:
[2015-11-11 09:35:29.426] boot - 5832 INFO [main] --- ZooKeeper: Initiating client connection, connectString=hadoopcluster01:2181 sessionTimeout=3000 watcher=com.cloudera.hive.hivecommon.api.ZookeeperDynamicDiscovery$1@74455848
[2015-11-11 09:35:29.426] boot - 5832 INFO [main-SendThread(hadoopcluster01.nebu.local:2181)] --- ClientCnxn: Opening socket connection to server hadoopcluster01.nebu.local/192.168.99.71:2181. Will not attempt to authenticate using SASL (unknown error)
[2015-11-11 09:35:29.426] boot - 5832 INFO [main] --- ZooKeeper: Initiating client connection, connectString=hadoopcluster02:2181 sessionTimeout=3000 watcher=com.cloudera.hive.hivecommon.api.ZookeeperDynamicDiscovery$1@4e7912d8
[2015-11-11 09:35:29.426] boot - 5832 INFO [main-SendThread(hadoopcluster01.nebu.local:2181)] --- ClientCnxn: Socket connection established to hadoopcluster01.nebu.local/192.168.99.71:2181, initiating session
[2015-11-11 09:35:29.426] boot - 5832 INFO [main-SendThread(hadoopcluster02.nebu.local:2181)] --- ClientCnxn: Opening socket connection to server hadoopcluster02.nebu.local/192.168.99.72:2181. Will not attempt to authenticate using SASL (unknown error)
[2015-11-11 09:35:29.426] boot - 5832 INFO [main-SendThread(hadoopcluster02.nebu.local:2181)] --- ClientCnxn: Socket connection established to hadoopcluster02.nebu.local/192.168.99.72:2181, initiating session
[2015-11-11 09:35:29.426] boot - 5832 INFO [main-SendThread(hadoopcluster01.nebu.local:2181)] --- ClientCnxn: Session establishment complete on server hadoopcluster01.nebu.local/192.168.99.71:2181, sessionid = 0x150f58353570006, negotiated timeout = 6000
[2015-11-11 09:35:29.457] boot - 5832 INFO [main-SendThread(hadoopcluster02.nebu.local:2181)] --- ClientCnxn: Session establishment complete on server hadoopcluster02.nebu.local/192.168.99.72:2181, sessionid = 0x250f582c7990001, negotiated timeout = 6000
[2015-11-11 09:35:29.457] boot - 5832 INFO [main] --- ZooKeeper: Session: 0x250f582c7990001 closed
[2015-11-11 09:35:29.457] boot - 5832 INFO [main-EventThread] --- ClientCnxn: EventThread shut down
java.sql.SQLException: [Cloudera][HiveJDBCDriver](500170) Error occured while setting up Zookeeper Dynamic Discovery: [Cloudera][HiveJDBCDriver]Error Occured Connecting to ZooKeeper: At: hadoopcluster01:2181 With Error Message: Path length must be > 0..
at com.cloudera.hive.hivecommon.api.ZooKeeperEnabledExtendedHS2Factory.createClient(Unknown Source)
at com.cloudera.hive.hivecommon.core.HiveJDBCCommonConnection.connect(Unknown Source)
at com.cloudera.hive.hive.core.HiveJDBCConnection.connect(Unknown Source)
at com.cloudera.hive.jdbc.common.BaseConnectionFactory.doConnect(Unknown Source)
at com.cloudera.hive.jdbc.common.AbstractDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:208)
at com.nebu.nldpconnection.main.NLDPConnectionTest.getConnection(NLDPConnectionTest.java:81)
at com.nebu.nldpconnection.main.NLDPConnectionTest.run(NLDPConnectionTest.java:214)
at org.springframework.boot.SpringApplication.runCommandLineRunners(SpringApplication.java:677)
at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:695)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:321)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:952)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:941)
Caused by: com.cloudera.hive.support.exceptions.GeneralException: [Cloudera][HiveJDBCDriver](500170) Error occured while setting up Zookeeper Dynamic Discovery: [Cloudera][HiveJDBCDriver]Error Occured Connecting to ZooKeeper: At: hadoopcluster01:2181 With Error Message: Path length must be > 0..
... 14 more
答案 0 :(得分:0)
修改后尝试使用它。 我成功了。
[您]
JDBC:hive2:// ZK = hadoopcluster01:2181,hadoopcluster02:2181 / hiveserver2
[我的建议]
JDBC:hive2:// ZK = hadoopcluster01:2181 / hiveserver2,hadoopcluster02:2181 / hiveserver2