14

我有一个 CDH 5.3 实例。我通过首先启动 hive-metastore 然后从命令行启动 hive-server 来启动 hive-server2。在此之后,我使用直线连接到我的 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>

直线上的连接命令:

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

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

4

7 回答 7

15

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

于 2016-05-12T10:42:00.957 回答
2

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

 >hive --service hiverserver2 &

Hiverver2 的进程 ID 出现在控制台中。然后使用不同的终端重试从直线连接到配置单元:

 >beeline -u "jdbc:hive2://localhost:10000/default" -n <username> -p <password> -d "org.apache.hive.jdbc.HiveDriver"
于 2016-08-07T10:36:57.963 回答
2

在这种情况下,您的 hiveserver2 服务没有启动。请按照打击步骤检查和修复。step: 1.查看hive.log文件查看“Service:HiveServer2 is started”。

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.启动 hiveserver2 命令:./bin/hiveserver2

3.查看hive.log。如果能找到“Service:HiveServer2 is started.” 在 hive.log 中。然后通过直线连接 hiveserver2。

4.连接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
于 2016-09-09T07:52:58.713 回答
2

我在这里遇到了同样的问题。这仅仅是因为hiveserver2启动失败 - 错误不会显示在控制台中,而是显示在配置单元日志中。就我而言,配置单元日志位于/tmp/ubuntu/hive.log

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

于 2016-04-01T04:32:11.687 回答
0

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

于 2017-11-14T13:32:13.717 回答
0

请确保 hive2service 部署 IP。

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

于 2018-06-08T05:14:18.757 回答
0

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

beeline -u "jdbc:hive2://localhost:10000/default;user=user;password=*******" --verbose
于 2018-05-21T02:08:54.337 回答