1

I am struggling with beeline connection to hive server. On my server (with name Sun, all the operation on this server), In the hive folder, I can start beeline as ./bin/beeline and then connect to hive: !connect jdbc:hive2://, then I am successfully connected to my hive and I can run hive-sql statement.

However, when I tried ./bin/beeline -u jdbc:hive2://localhost:10000 -n hive -p mypassword, I can not connect to hive directly, with error message "Error: Could not open client transport with JDBC Uri: jdbc:hive2://localhost:10000"

I have tried to follow many posts (e.g. beeline cannot connect to hive2server, Connecting to Hive using Beeline, Cannot connect to beeline hive2) and I still can not find a solution. Why I can not connect with localhost:10000 (or its the IP of this Sun machine)?

Has anyone any idea why I have such error and how to solve it?

hadoop@Sun:/opt/apache-hive-3.1.2-bin$ ./bin/beeline
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/apache-hive-3.1.2-bin/lib/log4j-slf4j-impl- 
2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/lib/hadoop-3.2.2/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Beeline version 3.1.2 by Apache Hive
beeline> !connect jdbc:hive2://
Connecting to jdbc:hive2://
Enter username for jdbc:hive2://: hive
Enter password for jdbc:hive2://: ****
21/06/14 23:02:10 [main]: WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Hive Session ID = ae2fb753-de6d-4522-b128-770b1c358c8b
21/06/14 23:02:11 [main]: WARN session.SessionState: METASTORE_FILTER_HOOK will be ignored, since hive.security.authorization.manager is set to instance of HiveAuthorizerFactory.
Connected to: Apache Hive (version 3.1.2)
Driver: Hive JDBC (version 3.1.2)
Transaction isolation: TRANSACTION_REPEATABLE_READ
0: jdbc:hive2://> show databases;
OK
+----------------+
| database_name  |
+----------------+
| default        |
| testwimp       |
| wimp           |
+----------------+
3 rows selected (1.978 seconds)
0: jdbc:hive2://> !connect jdbc:hive2://localhost:10000
Connecting to jdbc:hive2://localhost:10000
Enter username for jdbc:hive2://localhost:10000: hive
Enter password for jdbc:hive2://localhost:10000: ****
21/06/14 23:02:57 [main]: WARN jdbc.HiveConnection: Failed to connect to localhost:10000
Could not open connection to the HS2 server. Please check the server URI and if the URI is correct, then ask the administrator to check the server status.
Error: Could not open client transport with JDBC Uri: jdbc:hive2://localhost:10000: java.net.ConnectException: Connection refused (Connection refused) (state=08S01,code=0)
0: jdbc:hive2://>
XYZ
  • 352
  • 5
  • 19
  • have you checked this one out? https://community.cloudera.com/t5/Support-Questions/Hive-JDBC-Could-not-open-client-transport-with-JDBC-Uri/td-p/101772 – linusRian Jun 15 '21 at 04:44
  • @linusRian, I saw this post, but I do not understand, changing the port number from 10000 to 100001? – XYZ Jun 15 '21 at 06:50
  • It seems that this issue is an open bug that has not been completely solved:https://issues.apache.org/jira/browse/HIVE-14410 – XYZ Jun 15 '21 at 07:06
  • Not just the port number ,the url with transportMode and httpPath added to it,which is mentioned in the above link. jdbc:hive2://:/;transportMode=http;httpPath= – linusRian Jun 15 '21 at 07:30
  • @linusRian, I do not think this is the answer I am looking for. 1st, the httpPath/http_endpoint is not a property in the hive-site.xml file. 2nd, even I tried with such additional information, it still have same error message. 3rd, connecting directly by "jdbc:hive2://localhost:10000" works for many other people without the need specifying the http mode. (I am sure on my Linux server, I am using ssl instead of http mode). – XYZ Jun 15 '21 at 08:00
  • @`Yu Xiang` sorry that it couldn't solve the problem. Good to know that you were able to solve the problem with the answer listed below :) – linusRian Jun 19 '21 at 06:46

1 Answers1

0

There is a detailed answer here:

https://www.programmersought.com/article/93495333620/

In summary, check hiverserver2 is started and the port number 10000 is open.

XYZ
  • 352
  • 5
  • 19