【问题标题】:beeline not able to connect to hiveserver2直线无法连接到 hiveserver2
【发布时间】:2015-05-08 01:36:21
【问题描述】:

我有一个 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

当询问用户名和密码时,我只输入测试“用户”和“密码” 对于各自的值,然后它会引发错误。 任何帮助将不胜感激

【问题讨论】:

  • 分享你正在执行的直线命令?
  • 连接被拒绝异常的原因是 hiveserve2 守护进程没有运行。请检查 hiveserver2 守护进程日志
  • 我使用“sudo service hive-server2 start”命令启动了 hive-server2,它显示它已启动。

标签: hadoop hive cloudera cloudera-manager


【解决方案1】:

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

【讨论】:

  • 帮助很大!我的问题是,即使我设置了 NOSASL,我也没有输入auth=noSasl。谢谢!
【解决方案2】:

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

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

【讨论】:

    【解决方案3】:

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

     >hive --service hiverserver2 &
    

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

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

    【讨论】:

    • 也许检查一下:hive --service hiverserver2 &,有一个错字,而不是 hive --service hiveserver2 &
    【解决方案4】:

    在这种情况下,您的 hiveserver2 服务没有启动。请按照打击步骤检查和修复。 步: 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。 如果您可以找到“服务:HiveServer2 已启动”。在 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
    

    【讨论】:

      【解决方案5】:

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

      【讨论】:

        【解决方案6】:

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

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

        【讨论】:

          【解决方案7】:

          请确保 hive2service 部署 IP。

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

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2016-11-10
            • 2019-08-24
            • 2018-01-28
            • 2017-03-07
            • 1970-01-01
            • 2020-09-19
            • 1970-01-01
            • 2020-07-08
            相关资源
            最近更新 更多