Impyla连接.无法启动SASL.没有可用的机制



我正试图使用impyla连接到impala,每次我都会收到这个错误

Could not start SASL: b'Error in sasl_client_start (-4) SASL(-4): no mechanism available: Unable to find a callback: 2'

我已安装:

impyla==0.16.2
thrift_sasl==0.4.2
thrift==0.13.0
thriftpy==0.3.9
thriftpy2==0.4.11

我正在使用进行连接

connect = connect(host=server, port=21050, user=login, password=passwd, use_ssl=True, auth_mechanism='LDAP')

我以前在python 2.7上使用过这个,它正在工作,现在当我转到3.6时,它停止了。

编辑:我又挖了一点,看起来节俭的asl没有识别"LDAP"身份验证

TTransportException                       Traceback (most recent call last)
<ipython-input-4-562dbef67d96> in <module>
7 select_offset = 0
8 
----> 9 connect = connect(host='azrudb7006.ra.rockwell.com', port=21050, database=db_name, user=login, password=passwd, use_ssl=True, auth_mechanism="LDAP")
~Anaconda3envspy36libsite-packagesimpaladbapi.py in connect(host, port, database, timeout, use_ssl, ca_cert, auth_mechanism, user, password, kerberos_service_name, use_ldap, ldap_user, ldap_password, use_kerberos, protocol, krb_host, use_http_transport, http_path)
148                           auth_mechanism=auth_mechanism, krb_host=krb_host,
149                           use_http_transport=use_http_transport,
--> 150                           http_path=http_path)
151     return hs2.HiveServer2Connection(service, default_db=database)
152 
~Anaconda3envspy36libsite-packagesimpalahiveserver2.py in connect(host, port, timeout, use_ssl, ca_cert, user, password, kerberos_service_name, auth_mechanism, krb_host, use_http_transport, http_path)
823                                 auth_mechanism, user, password)
824 
--> 825     transport.open()
826     protocol = TBinaryProtocol(transport)
827     if six.PY2:
~Anaconda3envspy36libsite-packagesthrift_sasl__init__.py in open(self)
94       if status not in (self.OK, self.COMPLETE):
95         raise TTransportException(type=TTransportException.NOT_OPEN,
---> 96           message=("Bad status: %d (%s)" % (status, payload)))
97       if status == self.COMPLETE:
98         break
TTransportException: Bad status: 3 (b'Unsupported mechanism type ')

我也遇到了这个错误。唯一的解决方案是去除sasl并使用纯sasl。

我的要求:

thrift-sasl==0.4.2
pure-sasl==0.6.2
impyla==0.16.3

对于Windows,sasl没有安装,因此可以毫无问题地工作,但在Linux机器上,它需要删除(在fract_sasl中拉起(,否则,通过sasl连接的工厂在impyla库中无法正常工作。

它还可以让你摆脱错误:TProtocolException无协议版本头

我的体会:

from impala.dbapi import connect
from impala.hiveserver2 import HiveServer2Connection
from config import Config

def init_connection():
auth_mechanism = 'PLAIN'
return connect(host=Config.HIVE_HOST,
port=Config.HIVE_PORT,
user=Config.HIVE_USER,
auth_mechanism=auth_mechanism)

class PyHive:
conn: HiveServer2Connection = init_connection()
def __init__(self):
self.cursor = self.conn.cursor()
def __enter__(self):
return self.cursor
def __exit__(self, exc_type, exc_val, exc_tb):
self.cursor.close()

最新更新