Python Impyla连接。无法启动SASL。没有可用的机制
我正在尝试使用impyla连接到黑斑羚,每次我都会遇到这个错误Python Impyla连接。无法启动SASL。没有可用的机制,python,impala,sasl,impyla,Python,Impala,Sasl,Impyla,我正在尝试使用impyla连接到黑斑羚,每次我都会遇到这个错误 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 我正在使用
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 ')
ttTransportException回溯(最近一次调用)
在里面
7选择_offset=0
8.
---->9 connect=connect(host='azrudb7006.ra.rockwell.com',port=21050,database=db\u name,user=login,password=passwd,use\u ssl=True,auth\u mechanism=“LDAP”)
连接中的~\Anaconda3\envs\py36\lib\site packages\impala\dbapi.py(主机、端口、数据库、超时、使用ssl、ca证书、身份验证机制、用户、密码、kerberos服务名称、使用ldap、ldap用户、ldap密码、使用kerberos、协议、krb主机、使用http传输、http路径)
148 auth_机制=auth_机制,krb_主机=krb_主机,
149使用\u http\u传输=使用\u http\u传输,
-->150 http_路径=http_路径)
151返回hs2.HiveServer2Connection(服务,默认数据库)
152
连接中的~\Anaconda3\envs\py36\lib\site packages\impala\hiveserver2.py(主机、端口、超时、使用ssl、ca证书、用户、密码、kerberos服务名称、身份验证机制、krb主机、使用http传输、http路径)
823验证机制、用户、密码)
824
-->825运输公开
826协议=TBinaryProtocol(传输)
827如果为6.PY2:
~\Anaconda3\envs\py36\lib\site packages\thrift\u sasl\uuuu init\uuuuu.py处于打开状态(self)
94如果状态不在(self.OK,self.COMPLETE):
95提升TTTransportException(类型=TTTransportException.NOT_OPEN,
--->96消息=(“错误状态:%d(%s)”%(状态,有效负载)))
97如果状态==自我完成:
98休息
TTTransportException:错误状态:3(b“不支持的机制类型”)
我也遇到了这个错误。唯一的解决方案是删除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()