Support Questions

Find answers, ask questions, and share your expertise

Error connecting to Kerberos using pyHive library

avatar
Contributor

Hi,
in a Unix environment, I get this error while connecting to Hive via Kerberos, using the library pyHive in a python script:

thrift.transport.TTransport.TTransportException: Could not start SASL: b'Error in sasl_client_start (-1) SASL(-1): generic failure: GSSAPI Error: Unspecified GSS failure. Minor code may provide more information (Server krbtgt/LOCAL.IT@EXAMPLE.IT not found in Kerberos database)'

I am able to connect to Kerberos using "kinit -kt user user.keytab", and also via Hive ODBC driver. I use the same krb5.conf file, with Default Realm = EXAMPLE.IT.

With kinit, I obtain, correctly:

Default principal: user@EXAMPLE.IT
Valid starting Expires Service principal
09/28/23 11:05:16 09/28/23 11:05:16 krbtgt/EXAMPLE.IT@EXAMPLE.IT

The error is only using pyHive library. In the error, the library uses the domain LOCAL.IT instead of the one specified in krb5.conf, that is EXAMPLE.IT

My connection in pyHive:

conn = hive.Connection(host="host.domain.it",
                       port=10000,
                       auth="KERBEROS",
                       database="db_123",
                       kerberos_service_name="hive")
Note that LOCAL.IT is equal to domain.it.

Can you help me?

Thank you

4 REPLIES 4

avatar
Super Collaborator

PyHive is not maintained by Cloudera, Can you use Impyla to connect to HiveServer2? It should work with HS2 also.

Ref: https://github.com/cloudera/impyla

avatar

Hi @andrea_pretotto 

Additionally, you can also choose to use PyODBC:

https://pypi.org/project/pyodbc/

together with the Cloudera Hive ODBC drivers:

https://cloudera.com/downloads/connectors/hive/odbc 

This should give the best compatibility with Hive.

Best regards

 Miklos

avatar
Contributor

Hi,

thank you for the answers.

@cravani unfortunately Impala is not used. About pyODBC, @mszurap , it sounds like the best option to adopt. We will work with this, and we will update you soon.

Best regards

Andrea

 

avatar
Community Manager

@andrea_pretotto Has the reply helped resolve your issue? If so, please mark the appropriate reply as the solution, as it will make it easier for others to find the answer in the future. Thanks.


Regards,

Diana Torres,
Community Moderator


Was your question answered? Make sure to mark the answer as the accepted solution.
If you find a reply useful, say thanks by clicking on the thumbs up button.
Learn more about the Cloudera Community: