我尝试使用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')我以前在python2.7上用过它,它工作正常,现在当我移动到3.6版本时,它停止了。
编辑:我深入研究了一下,thrift_sasl似乎无法识别'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")
~\Anaconda3\envs\py36\lib\site-packages\impala\dbapi.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
~\Anaconda3\envs\py36\lib\site-packages\impala\hiveserver2.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:
~\Anaconda3\envs\py36\lib\site-packages\thrift_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 ')发布于 2021-03-17 15:56:53
我也遇到了这个错误。唯一的解决方案是删除sasl并使用纯sasl。
我的要求:
thrift-sasl==0.4.2
pure-sasl==0.6.2
impyla==0.16.3对于Windows,没有安装sasl,因此可以正常工作,但在Linux机器上,需要删除它(在thrift_sasl中拉起),否则,通过sasl连接的工厂在impyla库中不能正常工作。
它还允许您消除错误: TProtocolException No protocol version标头
我的体会是:
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()https://stackoverflow.com/questions/63740156
复制相似问题