Connecting to Hive via Beeline using Kerberos keytab
Asked Answered
V

2

6

Is it possible to connect to Hive via beeline using (kerberos) keytab file similar to the approach used for JDBC at

https://cwiki.apache.org/confluence/display/Hive/HiveServer2+Clients#HiveServer2Clients-UsingKerberoswithaPre-AuthenticatedSubject

PS : beeline does support connecting on a kerberos secured hive server with username and password. But I am looking for a way to connect it with a keytab file. http://doc.mapr.com/display/MapR40x/Configuring+Hive+on+a+Secure+Cluster#ConfiguringHiveonaSecureCluster-UsingBeelinewithKerberos

Valorievalorization answered 2/7, 2015 at 23:6 Comment(1)
The second link, which you've pasted, shows how to do that. Path to keytab file should be passed in the hive-site.xml. Afterwards you connect by command: !connect jdbc:hive2://<hostname>:10000/default;principal=mapr/<FQDN@REALM>, where principal is a principalName present inside your keytab.Amidships
W
8

I think you cannot connect with keytab file into beeline but you can get ticket with keytab using kinit and then pass the hive server principal with the jdbc connection string of beeline to connect.

kinit -k -t keytab principal

Connection string to connect with beeline

!connect jdbc:hive2://hostname:10000/default;principal=hive/_HOST@REALM
Wart answered 3/7, 2015 at 5:13 Comment(3)
Kumar and @greenmarker : Thanks for the reply. But even after attempting with the above connection string, it still asks for the username and password. Am I missing something ?Valorievalorization
Just press enter two times. No need to enter any username and password.Wart
only need to change hostname:port _HOST@REALM -> this is not a parameter.Convent
S
1

It is a bug, but it is not a critical one.

Though you provided kerberos details, still it will ask you the username and password. You can just enter -> enter, it allows us to connect.

Example:

!connect jdbc:hive2://:10000/default;principal=hive/[email protected]

Connecting to jdbc:hive2://:10000/default;principal=hive/[email protected]

Enter username for jdbc:hive2://:10000/default;principal=hive/[email protected]: press enter

Enter password for jdbc:hive2://:10000/default;principal=hive/[email protected]: press enter

Connected to: Apache Hive (version 0.13.1-cdh5.3.7-SNAPSHOT)
Driver: Hive JDBC (version 0.13.1-cdh5.3.7-SNAPSHOT)
Transaction isolation: TRANSACTION_REPEATABLE_READ
Spent answered 3/9, 2015 at 7:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.