直线无法连接到hiveserver2

问题描述 投票:9回答:7

我有一个CDH 5.3实例。我首先启动hive-metastore,然后从命令行启动hive-server,启动hive-server2。在此之后我使用beeline连接到我的hive-server2,但显然它不能这样。

Could not open connection to jdbc:hive2://localhost:10000: java.net.ConnectException: Connection refused (state=08S01,code=0)

另一个问题,我试图看看hive-server2是否正在侦听端口10000.我做了“sudo netstat -tulpn | grep :10000”,但没有一个应用程序出现。我还在hive-site.xml中添加了以下属性,但无济于事。为什么它不会出现在netstat上?

<property>
   <name>hive.server2.thrift.port</name>
   <value>10000</value>
   <description>TCP port number to listen on, default 10000</description>
 </property>

beeline上的connect命令:

!connect jdbc:hive2://localhost:10000 org.apache.hive.jdbc.HiveDriver

当被要求输入用户名和密码时,我只需输入相应值的测试“user”和“password”,然后它就会抛出错误。任何帮助将不胜感激

hadoop hive cloudera cloudera-manager
7个回答
9
投票

Hive从具有各种模式的客户端连接到直线。

1.嵌入式模式:服务器和客户端都在同一台机器上运行。无需TCP连接。

 If hive.server2.authentication is "NONE" in HIVE_HOME/conf/hive-site.xml then connect beeline with below url

Connection URL:
               !connect jdbc:hive2://

2.远程模式:它支持多个客户端在以下身份验证方案的帮助下执行查询。

认证方案:

i.)SASL Authentication:

   If value of "hive.server2.authentication" property in HIVE_HOME/conf/hive-site.xml to be set as "SASL" then connect hive beeline with below url

   Beeline URL:
             !connect jdbc:hive2://<host>:<port>/<db>

ii.)NOSASL Authentication:
   If "hive.server2.authentication" is nosasl then connect the beeline like below.
   Beeline URL:

             !connect jdbc:hive2://<host>:<port>/<db>;auth=noSasl

希望这对你有所帮助

参考文献:

https://docs.hortonworks.com/HDPDocuments/HDP2/HDP-2.3.2/bk_dataintegration/content/beeline-vs-hive-cli.html


2
投票

我在这里遇到了同样的问题。这只是因为hiveserver2无法启动 - 错误不会出现在控制台中,而是出现在hive日志中。在我的例子中,蜂巢日志位于/tmp/ubuntu/hive.log

您可能有不同的原因导致hive-server2无法启动,但绝对值得查看此日志文件。


2
投票

在这种情况下,您的hiveserver2服务未启动。请按照打击步骤进行检查和修复。步骤:1。查看hive.log文件,检查“服务:HiveServer2是否已启动”。

1) find / -name hive.log
2) vim hive.log
  in hive.log file ,if you can not find "Service:HiveServer2 is started.",then prove hiveserver2 is not started.

2.start hiveserver2命令:./ bin / hiveserver2

3.see hive.log。如果你能找到“服务:HiveServer2已启动”。在hive.log中。然后通过beeline连接hiveserver2。

4.connect hiveserver2 ./bin/beeline!connect jdbc:hive2:// localhost:10000

5.信息可以出现。

Beeline version 1.2.1 by Apache Hive
beeline> !connect jdbc:hive2://localhost:10000
Connecting to jdbc:hive2://localhost:10000
Enter username for jdbc:hive2://localhost:10000: root
Enter password for jdbc:hive2://localhost:10000: ******
Connected to: Apache Hive (version 1.2.1)
Driver: Hive JDBC (version 1.2.1)
Transaction isolation: TRANSACTION_REPEATABLE_READ

1
投票

以下对我有用。如果您是第一次安装并配置了配置单元并尝试从直连连接,请确保在当前终端中使用以下命令启动配置单元服务

 >hive --service hiverserver2 &

Hiverver2的进程ID出现在控制台中。然后使用不同的终端重新从beeline连接到hive:

 >beeline -u "jdbc:hive2://localhost:10000/default" -n <username> -p <password> -d "org.apache.hive.jdbc.HiveDriver"

0
投票

您必须在hive-site.xml中使用hiveserver2用户名和密码进行检查,默认用户名(匿名)和密码(匿名),否则只需输入enter而不提供密码和用户名。


0
投票

尝试使用详细选项,以便您可以看到更多详细信息......

beeline -u "jdbc:hive2://localhost:10000/default;user=user;password=*******" --verbose

0
投票

请确保hive2service部署IP。

我遇到同样的问题,我使用cloudera服务器ip(XXX.42)连接hive2服务;但实际上,hive thrift服务(hive2service)在其他机器上被驱逐(XXX.41)。

© www.soinside.com 2019 - 2024. All rights reserved.