Reply
New Contributor
Posts: 1
Registered: ‎06-30-2017

How to use python connect impala with kerberos?

I wany to use python connect impala,and the cluster is kerberozied,I can use java jdbc successful ,and the settings like this :

 

UserGroupInformation.loginUserFromKeytab("username/mydomain.com@mydomain.COM","/usr/username.keytab");  

 

jdbc:impala://192.168.1.10:21050/default;AuthMech=1;KrbRealm='mydomain.com';KrbHostFQDN=hostalias;KrbServiceName=impala

 

I have try Impyla,but failed, it throws sasl can't start,how can i connect impala with python?

Posts: 454
Topics: 13
Kudos: 75
Solutions: 41
Registered: ‎09-02-2016

Re: How to use python connect impala with kerberos?

@yueyang

 

Pls try to add the below principal in your connection string, it 'may' help you

 

";principal=impala/hostname@REALM"

 

hostname - hostname where you have configured impala/hive

REALM - for your kerberos

Highlighted
Cloudera Employee
Posts: 276
Registered: ‎03-23-2015

Re: How to use python connect impala with kerberos?

Hi yueyang,

Can you please share your impyla source code and the error you are getting? That will help me understand why it failed.

Thanks
New Contributor
Posts: 1
Registered: ‎03-21-2018

Re: How to use python connect impala with kerberos?

I'm trying to establish connection to impala using python's impyla package. However I'm facing issues with the same.

 

Here is my connection code:

 

`from impala.dbapi import connect

conn = connect(host="****.dowcloud.com", port=21050, timeout=100000, use_ssl=True, auth_mechanism='GSSAPI', ca_cert='/opt/cloudera/security/pki/x509/truststore.pem', kerberos_service_name='impala/****.dowcloud.com@DOWCLOUD.COM', database='some value').cursor()`

 

I have the below dependencies installed:

`sasl==0.2.1

six==1.11.0

thrift==0.10.0

thrift-sasl==0.3.0

thriftpy==0.3.9

impala==0.2`

 

But I get the below error:

`AttributeError: 'TSSLSocket' object has no attribute 'isOpen'`

 

I then tried using thrift==0.9.3 and thrift-sasl==0.2.1

But it gives me:

`TTransportException: TTransportException(message="Could not connect to ('****.dowcloud.com', 21050)", type=1)`

However when I try connecting via impala shell I'm able to login:

`env -i impala-shell -i ****.dowcloud.com -d default -k --ssl --ca_cert=/opt/cloudera/security/pki/x509/truststore.pem`

 

Please help me with what I'm missing here. I have been trying for hours to establish a successful connection to impala.

Cloudera Employee
Posts: 276
Registered: ‎03-23-2015

Re: How to use python connect impala with kerberos?

Hi,

Have you checked on impala daemon side to see if there is any errors?

Based on:
https://github.com/cloudera/impyla/blob/master/impala/dbapi.py

kerberos_service_name should be "impala", not the full principal name.

If still does not help, I would suggest that you disable SSL for impala and test again using impyla to see if you can connect. This can isolate the issue to see if SSL is in play here.
Announcements