hive jdbc connection refused

hive jdbc 连接时抛异常:

Exception in thread "main" java.sql.SQLException: Could not open client transport with JDBC Uri: jdbc:hive2://192.168.206.128:10000/default: java.net.ConnectException: Connection refused: connect
     at org.apache.hive.jdbc.HiveConnection.openTransport(HiveConnection.java:215)
     at org.apache.hive.jdbc.HiveConnection.<init>(HiveConnection.java:163)
     at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:105)
     at java.sql.DriverManager.getConnection(DriverManager.java:571)
     at java.sql.DriverManager.getConnection(DriverManager.java:215)
     at HelloHive.main(HelloHive.java:17)
Caused by: org.apache.thrift.transport.TTransportException: java.net.ConnectException: Connection refused: connect
     at org.apache.thrift.transport.TSocket.open(TSocket.java:187)
     at org.apache.thrift.transport.TSaslTransport.open(TSaslTransport.java:266)
     at org.apache.thrift.transport.TSaslClientTransport.open(TSaslClientTransport.java:37)
     at org.apache.hive.jdbc.HiveConnection.openTransport(HiveConnection.java:190)
     ... 5 more
Caused by: java.net.ConnectException: Connection refused: connect
     at java.net.DualStackPlainSocketImpl.connect0(Native Method)
     at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
     at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
     at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
     at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
     at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
     at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
     at java.net.Socket.connect(Socket.java:579)
     at org.apache.thrift.transport.TSocket.open(TSocket.java:182)
     ... 8 more
 
解决方法:
1. 检查hive server2是否启动:
    netstat -anp |grep 10000
2. 检查conf/hive-site.xml 下的配置是否正确:
    <configuration>
      <property> 
       <name>hive.server2.thrift.port</name> 
      <value>10000</value> 
    </property>
    <property>
       <name>hive.server2.thrift.bind.host</name>
       <value>192.168.206.128</value>
     </property>
    </configuration>

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。