Support Questions

Find answers, ask questions, and share your expertise

Beeline connection throws error

avatar
Contributor

Transport mode: http

hive server 2 running port 10001, hive service check from ambari passed succesfully

url : "jdbc:hive2://hostname:port/default;transportMode=http;httppath=cliservice"

able to login through hive cli .

When i try with beeline i get an error saying

Error: Could not open client transport with JDBC Uri: jdbc:hive2://host:port/defaultt;transportMode=http;httpPath=cliservice: Could not create http connection to jdbc:hive2://host:port/default;transportMode=http;httpPath=cliservice. HTTP Response code: 401 (state=08S01,code=0)

Can some one please shed some light of what is happening here. How should i solve this. I checked hive server 2 logs but there is nothing related to this.

10 REPLIES 10

avatar

@pv poreddy

Is SSL enabled ?
Is this a Kerberized Cluster ?

If answer to any of the above questions is yes, then the connection url will change.

Also I hope you are pre-pending '!connect' before your connection URL in order to connect using beeling.

avatar
Master Mentor

@pv poreddy

The below output is for a keberized cluster you should replace the principal and REALM with the correct values derived from

$ klist -ket /etc/security/keytabs/hive.keytab
Keytab name: FILE:/etc/security/keytabs/hive.keytab
KVNO Timestamp         Principal
---- ----------------- --------------------------------------------------------
   1 12/28/16 22:25:31 hive-{hostname}@REALM.COM (des3-cbc-sha1)
   1 12/28/16 22:25:31 hive-{hostname}@REALM.COM (aes128-cts-hmac-sha1-96)
   1 12/28/16 22:25:31 hive-{hostname}@REALM.COM (arcfour-hmac)
   1 12/28/16 22:25:31 hive-{hostname}@REALM.COM (des-cbc-md5)
   1 12/28/16 22:25:31 hive-{hostname}@REALM.COM (aes256-cts-hmac-sha1-96)

To see if you grabbed a validate kerberos ticket

[hive@{hostname} ~]$ klist
Ticket cache: FILE:/tmp/krb5cc_507
Default principal: hive-{hostname}@REALM.COM
Valid starting     Expires            Service principal
12/28/16 22:57:11  12/29/16 22:57:11  krbtgt/REALM.COM@REALM.COM renew until 12/28/16 22:57:11
12/28/16 22:57:11  12/29/16 22:57:11  HTTP/{hostname}.REALM.COM@renew until 12/28/16 22:57:11
12/28/16 22:57:11  12/29/16 22:57:11  HTTP/{hostname}.REALM.COM@REALM.COM renew until 12/28/16 22:57:11

Then use the above to connect and just PRESS enter at the username and password prompt

Beeline version 1.2.1000.2.5.3.0-37 by Apache Hive
beeline> ! connect jdbc:hive2://test.com:10000/;principal=hive/test.com@REALM.COM
Connecting to jdbc:hive2://test.com:10000/;principal=hive/test.com@REALM.COM
Enter username for jdbc:hive2://test.com:10000/;principal=hive/test.com@REALM.COM:
Enter password for jdbc:hive2://test.com:10000/;principal=hive/test.com@REALM.COM:
Connected to: Apache Hive (version 1.2.1000.2.5.3.0-37)
Driver: Hive JDBC (version 1.2.1000.2.5.3.0-37)
Transaction isolation: TRANSACTION_REPEATABLE_READ
0: jdbc:hive2://test.com:10000/> show databases;
+----------------+--+
| database_name  |
+----------------+--+
| default        |
| moroto         |
| olum           |
+----------------+--+
3 rows selected (2.863 seconds)

You should now connect successfully otherwise in un kerberized environment

[hive@host~]$ beeline
....
.....
!connect jdbc:hive2://test.com:10000/<db> 

Cheers

avatar
Contributor

There is no kerberos and ssl is not enabled for my case. Please help me

avatar
Master Mentor

@pv poreddy

see my response !

avatar
Contributor

It did not help me, as my trnasport mode is http. my HS2 doesn't run on 10000.

avatar
Expert Contributor

Beeline connectivity working fine as below, if you gettitng error , kinldy share full work log for clear understanding ?

user@CENT:~> beeline
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/hdp/2.3.2.0-2950/spark/lib/spark-assembly-1.4.1.2.3.2.0-2950-hadoop2.7.1.2.3.2.0-2950.jar!/org/slf4j/impl/StaticLoggerBinder.class
SLF4J: Found binding in [jar:file:/usr/hdp/2.3.2.0-2950/hadoop/lib/slf4j-log4j12-1.7.10.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.slf4j.impl.Log4jLoggerFactory]
Beeline version 1.2.1.2.3.2.48-5 by Apache Hive


beeline> !connect jdbc:hive2://HDP(Hive server Name):10000
Connecting to jdbc:hive2://HDP:10000
Enter username for jdbc:hive2://HDP:10000: user
Enter password for jdbc:hive2://HDP:10000: Password
Connected to: Apache Hive (version 1.2.1.2.3.2.48-5)
Driver: Hive JDBC (version 1.2.1.2.3.2.48-5)
Transaction isolation: TRANSACTION_REPEATABLE_READ


0: jdbc:hive2://HDP:10000> use database;


avatar
Master Mentor

@pv poreddy

Here is a coonect string I just created in a non kerberized cluster.

Assumptions

hive host=bombay.new.com
Default port = 10000
Hive database= hive
Hive user =hive
Hive password =hive

Here you go

[hive@bombo ~]$ beeline
WARNING: Use "yarn jar" to launch YARN applications.
Beeline version 1.2.1.2.3.6.0-3796 by Apache Hive
beeline> !connect jdbc:hive2://bombay.new.com:10000/hive
Connecting to jdbc:hive2://bombay.new.com:10000/hive
Enter username for jdbc:hive2://bombo.new.com:10000/hive: hive
Enter password for jdbc:hive2://bombo.new.com:10000/hive: ****
Connected to: Apache Hive (version 1.2.1.2.3.6.0-3796)
Driver: Hive JDBC (version 1.2.1.2.3.6.0-3796)
Transaction isolation: TRANSACTION_REPEATABLE_READ
0: jdbc:hive2://bombo.uganda.com:10000/hive> show databases;
+----------------+--+
| database_name  |
+----------------+--+
| default        |
+----------------+--+
1 row selected (5.577 seconds)
0: jdbc:hive2://bombo.uganda.com:10000/hive>

So you should have a successful login

avatar
Master Mentor

@pv poreddy

Here are the different methods to connect.

Assumptions:

HS2 Host(s): test01.com and test02.com 
HS2 Binary Port: 10010
HS2 HTTP Port: 10011 
ZooKeeper Quorom: test01.com:2181,test02.com:2181:test03.com:2181 
HttpPath: cliservice HS2 
ZooKeeper Namespace: hiveserver2 
User: hiveuser 
Password: hivepswd 

NOTE: <db> is the database in the examples below and is optional. The leading slash '/' is required. WARNING: When using 'beeline' and specifying the connection url (-u) at the command line, be sure to quote the url.

Non-Secure Environments

Direct - Binary Transport Mode

beeline -n hiveuser -p hivepswd -u "jdbc:hive2://test01.com:10010/<db>" 

Direct - HTTP Transport Mode

beeline -n hiveuser -p hivepswd -u "jdbc:hive2://test01.com:10011/<db>;transportMode=http;httpPath=cliservice"

ZooKeeper - Binary Transport Mode

beeline -n hiveuser -p hivepswd -u "jdbc:hive2://test01.com:2181,test02.com:2181,test03.com:2181/<db>"

ZooKeeper - Http Transport Mode

beeline -n hiveuser -p hivepswd -u "jdbc:hive2://test01.com:2181,test02.com:2181,test03.com:2181/<db>;transportMode=http;httpPath=cliservice"

Alternate Connectivity

Thru Knox

jdbc:hive2://<knox_host>:8443/;ssl=true;sslTrustStore=/var/lib/knox/data/security/keystores/gateway.jks;trustStorePassword=<password>?hive.server2.transport.mode=http;hive.server2.thrift.http.path=gateway/<CLUSTER>/hive

Hope that helps

avatar
Master Mentor

@pv poreddy

I updated the thread did you check it out ?