Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Cannot connect to beeline

avatar
Expert Contributor

I am trying to connect beeline from client system but I am not able to...

 

Beeline version 0.10.0-cdh4.5.0 by Apache Hive
beeline> !connect jdbc:hive2://hostname.com:10000 org.apache.hadoop.hive.jdbc.HiveDriver
scan complete in 6ms
Connecting to jdbc:hive2://hostname.com:10000
Enter password for jdbc:hive2://hostname.com:10000: ********
Error: Invalid URL: jdbc:hive2://hostname.com:10000 (state=08S01,code=0)

 

Am I missing anything here...Please advice..

 

Em Jay
1 ACCEPTED SOLUTION

avatar
Expert Contributor
This solved my problem....I was using the wrong syntax. Below is the right one...
!connect jdbc:hive2://hostname:10000/default;principal=hive/hostname@PRINCIPAL.COM
username and password blank....

Thanks for helping me out zhang...
Em Jay

View solution in original post

38 REPLIES 38

avatar
Expert Contributor
This solved my problem....I was using the wrong syntax. Below is the right one...
!connect jdbc:hive2://hostname:10000/default;principal=hive/hostname@PRINCIPAL.COM
username and password blank....

Thanks for helping me out zhang...
Em Jay

avatar
New Contributor

you can also connect to beeline directly from bash

beeline -u "jdbc:hive2://hostname:10000/;principal=hive/_HOST@PRINCIPAL.COM"

avatar
Expert Contributor

Hi,

 

I am able to connect to beeline like this

 

!connect jdbc:hive2://

 

But when i type

 

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

or !connect jdbc:hive2://hostname:10000/default

 

After giving the username and password
it gives me an error

 

Error: Could not open connection to jdbc:hive2://<host-name>:10000: java.net.ConnectException: Connection refused (state=08S01,code=0)

 

Any suggestions??

 

I am trying to connect with Cognos with this connection String but since it is not getting connected to beeline with ip and port,it is not allowing me to connect in cognos too but without giving ip and port,it works fine in beeline but still giving error in cognos.

 

The Properties in hive-site.xml i have set for hive 2 are:-

 

<property>
  <name>hive.server2.thrift.port</name>
  <value>10000</value>
  <description>Port number of HiveServer2 Thrift interface.
  Can be overridden by setting $HIVE_SERVER2_THRIFT_PORT</description>
</property>

<property>
  <name>hive.server2.thrift.bind.host</name>
  <value>Hostname</value>
  <description>Bind host on which to run the HiveServer2 Thrift interface.
  Can be overridden by setting $HIVE_SERVER2_THRIFT_BIND_HOST</description>
</property>

 

<property>
  <name>hive.metastore.uris</name>
  <value>thrift://hostname:9083</value>
  <description>Thrift uri for the remote metastore. Used by metastore client to connect to remote metastore.</description>
</property>



<property>
  <name>javax.jdo.option.ConnectionURL</name>
  <value>jdbc:mysql://localmachineIP:3306/metastore</value>
  <description>JDBC connect string for a JDBC metastore</description>
</property>


<property>
  <name>javax.jdo.option.ConnectionDriverName</name>
  <value>com.mysql.jdbc.Driver</value>
  <description>Driver class name for a JDBC metastore</description>
</property>

 

Any suggestions?

 

avatar
New Contributor

hi manikumar

 

are you solved the problem

 

i have the same problem , i cant write password , they told me error

 

please help me if ur code work send it to me

avatar
New Contributor

Thank you! I was struggling to connect with beeline, but this solution helped me

avatar
Explorer

[WORKED] 

beeline -u jdbc:hive2://HOSTNAME:10001

Replace HOSTNAME with ur hostname or ip.

 

My case:  CDH5.10.*

no Kerberos authentication

2 node cluster

centos 6.*

Google cloud VM instances

avatar
Explorer

I am facing the same issue. Please note that I have valid kinit token

 

 

Here is the output from klist command

Ticket cache: FILE:/tmp/krb5cc_10002
Default principal: dpugazhe@RUSH.EDU

Valid starting Expires Service principal
04/25/2018 06:27:16 04/25/2018 16:27:16 krbtgt/RUSH.EDU@RUSH.EDU
renew until 05/02/2018 06:27:16

 

 

Please find the connection string and output command.

 

 

beeline> !connect jdbc:hive2://localhost:10000/default;principal=hive/_HOST@.RUSH.EDU
scan complete in 1ms
Connecting to jdbc:hive2://localhost:10000/default;principal=hive/_HOST@.RUSH.EDU
18/04/25 08:25:23 [main]: ERROR transport.TSaslTransport: SASL negotiation failure
javax.security.sasl.SaslException: GSS initiate failed [Caused by GSSException: No valid credentials provided (Mechanism level: Server not found in Kerberos database (7))]
at com.sun.security.sasl.gsskerb.GssKrb5Client.evaluateChallenge(GssKrb5Client.java:211)
at org.apache.thrift.transport.TSaslClientTransport.handleSaslStartMessage(TSaslClientTransport.java:94)
at org.apache.thrift.transport.TSaslTransport.open(TSaslTransport.java:271)
at org.apache.thrift.transport.TSaslClientTransport.open(TSaslClientTransport.java:37)
at org.apache.hadoop.hive.thrift.client.TUGIAssumingTransport$1.run(TUGIAssumingTransport.java:52)
at org.apache.hadoop.hive.thrift.client.TUGIAssumingTransport$1.run(TUGIAssumingTransport.java:49)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:422)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1917)
at org.apache.hadoop.hive.thrift.client.TUGIAssumingTransport.open(TUGIAssumingTransport.java:49)
at org.apache.hive.jdbc.HiveConnection.openTransport(HiveConnection.java:204)
at org.apache.hive.jdbc.HiveConnection.<init>(HiveConnection.java:169)
at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:105)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:208)
at org.apache.hive.beeline.DatabaseConnection.connect(DatabaseConnection.java:146)
at org.apache.hive.beeline.DatabaseConnection.getConnection(DatabaseConnection.java:211)
at org.apache.hive.beeline.Commands.connect(Commands.java:1526)
at org.apache.hive.beeline.Commands.connect(Commands.java:1421)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.hive.beeline.ReflectiveCommandHandler.execute(ReflectiveCommandHandler.java:52)
at org.apache.hive.beeline.BeeLine.execCommandWithPrefix(BeeLine.java:1135)
at org.apache.hive.beeline.BeeLine.dispatch(BeeLine.java:1174)
at org.apache.hive.beeline.BeeLine.execute(BeeLine.java:1010)
at org.apache.hive.beeline.BeeLine.begin(BeeLine.java:922)
at org.apache.hive.beeline.BeeLine.mainWithInputRedirection(BeeLine.java:518)
at org.apache.hive.beeline.BeeLine.main(BeeLine.java:501)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.hadoop.util.RunJar.run(RunJar.java:221)
at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
Caused by: GSSException: No valid credentials provided (Mechanism level: Server not found in Kerberos database (7))
at sun.security.jgss.krb5.Krb5Context.initSecContext(Krb5Context.java:770)
at sun.security.jgss.GSSContextImpl.initSecContext(GSSContextImpl.java:248)
at sun.security.jgss.GSSContextImpl.initSecContext(GSSContextImpl.java:179)
at com.sun.security.sasl.gsskerb.GssKrb5Client.evaluateChallenge(GssKrb5Client.java:192)
... 35 more
Caused by: KrbException: Server not found in Kerberos database (7)
at sun.security.krb5.KrbTgsRep.<init>(KrbTgsRep.java:70)
at sun.security.krb5.KrbTgsReq.getReply(KrbTgsReq.java:251)
at sun.security.krb5.KrbTgsReq.sendAndGetCreds(KrbTgsReq.java:262)
at sun.security.krb5.internal.CredentialsUtil.serviceCreds(CredentialsUtil.java:308)
at sun.security.krb5.internal.CredentialsUtil.acquireServiceCreds(CredentialsUtil.java:126)
at sun.security.krb5.Credentials.acquireServiceCreds(Credentials.java:458)
at sun.security.jgss.krb5.Krb5Context.initSecContext(Krb5Context.java:693)
... 38 more
Caused by: KrbException: Identifier doesn't match expected value (906)
at sun.security.krb5.internal.KDCRep.init(KDCRep.java:140)
at sun.security.krb5.internal.TGSRep.init(TGSRep.java:65)
at sun.security.krb5.internal.TGSRep.<init>(TGSRep.java:60)
at sun.security.krb5.KrbTgsRep.<init>(KrbTgsRep.java:55)
... 44 more
Unknown HS2 problem when communicating with Thrift server.
Error: Could not open client transport with JDBC Uri: jdbc:hive2://localhost:10000/default;principal=hive/_HOST@.RUSH.EDU: GSS initiate failed (state=08S01,code=0)

 

 

 

avatar
New Contributor

You can use "beeline -u jdbc:hive2://"

It will connect to hive2. This is the best way to talk to hive using beeline. You don't need to specify any other things. Please let me know if this works for all who wants to use hive through beeline command.

Beeline.JPG

avatar
New Contributor

I can connect with "beeline -u jdbc:hive2://"

[20:28 hadoop@Cavin-Y7000 hive]$ beeline -u jdbc:hive2://
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/hive/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/hadoop/share/hadoop/hdfs/lib/log4j-slf4j-impl-2.10.0.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]
Connecting to jdbc:hive2://
20/10/24 20:30:27 [main]: WARN conf.HiveConf: HiveConf of name hive.server2.connection.host does not exist
Hive Session ID = 4977083b-4d07-4ff0-930f-7afb9e214933
20/10/24 20:30:28 [main]: WARN session.SessionState: METASTORE_FILTER_HOOK will be ignored, since hive.security.authorization.manager is set to instance of HiveAuthorizerFactory.
20/10/24 20:30:29 [main]: WARN metastore.ObjectStore: datanucleus.autoStartMechanismMode is set to unsupported value null . Setting it to value: ignored
20/10/24 20:30:30 [main]: WARN DataNucleus.MetaData: Metadata has jdbc-type of null yet this is not valid. Ignored
20/10/24 20:30:30 [main]: WARN DataNucleus.MetaData: Metadata has jdbc-type of null yet this is not valid. Ignored
20/10/24 20:30:30 [main]: WARN DataNucleus.MetaData: Metadata has jdbc-type of null yet this is not valid. Ignored
20/10/24 20:30:30 [main]: WARN DataNucleus.MetaData: Metadata has jdbc-type of null yet this is not valid. Ignored
20/10/24 20:30:30 [main]: WARN DataNucleus.MetaData: Metadata has jdbc-type of null yet this is not valid. Ignored
20/10/24 20:30:30 [main]: WARN DataNucleus.MetaData: Metadata has jdbc-type of null yet this is not valid. Ignored
20/10/24 20:30:31 [main]: WARN DataNucleus.MetaData: Metadata has jdbc-type of null yet this is not valid. Ignored
20/10/24 20:30:31 [main]: WARN DataNucleus.MetaData: Metadata has jdbc-type of null yet this is not valid. Ignored
20/10/24 20:30:31 [main]: WARN DataNucleus.MetaData: Metadata has jdbc-type of null yet this is not valid. Ignored
20/10/24 20:30:31 [main]: WARN DataNucleus.MetaData: Metadata has jdbc-type of null yet this is not valid. Ignored
20/10/24 20:30:31 [main]: WARN DataNucleus.MetaData: Metadata has jdbc-type of null yet this is not valid. Ignored
20/10/24 20:30:31 [main]: WARN DataNucleus.MetaData: Metadata has jdbc-type of null yet this is not valid. Ignored
Connected to: Apache Hive (version 3.1.2)
Driver: Hive JDBC (version 3.1.2)
Transaction isolation: TRANSACTION_REPEATABLE_READ
Beeline version 3.1.2 by Apache Hive
0: jdbc:hive2://>

 

but when I use "beeline -u jdbc:hive2://localhost:10000/default" I got this error:

 

[20:26 hadoop@Cavin-Y7000 hive]$ ./bin/beeline -u jdbc:hive2://localhost:10000
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/hive/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/hadoop/share/hadoop/hdfs/lib/log4j-slf4j-impl-2.10.0.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]
Connecting to jdbc:hive2://localhost:10000
20/10/24 20:28:38 [main]: WARN jdbc.HiveConnection: Failed to connect to localhost:10000
Unknown HS2 problem when communicating with Thrift server.
Error: Could not open client transport with JDBC Uri: jdbc:hive2://localhost:10000: Invalid status 16 (state=08S01,code=0)
Beeline version 3.1.2 by Apache Hive

 it's very confusing for me for several days, and I cannot just use "jdbc:hive2://" within java code, it will give me the same error as using "beeline -u jdbc:hive2://localhost:10000/default" in command line