hadoop - HIVE HA 通过 zookeeper (JDBC)

标签 hadoop jdbc hive

非常感谢您的帮助,谢谢! 我通过 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>

当我使用直线时:

 !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

最佳答案

修改后尝试使用。 我就这样成功了。

[你]

jdbc:hive2://zk=hadoopcluster01:2181,hadoopcluster02:2181/hiveserver2

[我的建议]

jdbc:hive2://zk=hadoopcluster01:2181/hiveserver2,hadoopcluster02:2181/hiveserver2

关于hadoop - HIVE HA 通过 zookeeper (JDBC),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33646972/

相关文章:

hadoop - 为什么 hive 不能识别在选择部分命名的别名?

java - 尝试使用 Java 运行 PL/SQL 脚本

java - 如何通过 Android 中的 asynctask 从 Hashmap 获取输出?

hadoop - Cloudera CDH4 上的 Accumulo - 启动组件时拒绝访问

hadoop - 在 hadoop Map reduce 中读取带有工作表的 Excel 文件

java - 用于Spark提交的本地或远程jar

hadoop - 在java代码中找到hive-site.xml的位置

java - 在Java中使用用户名和密码创建数据库

Hive,不支持将表文件格式从 orc 更改为 parquet?

apache-spark - 在单元测试中使用 TestHiveContext/HiveContext