【问题标题】:Impyla connection. Cannot start SASL. No mechanism availableImpyla 连接。无法启动 SASL。没有可用的机制
【发布时间】:2020-09-04 11:19:06
【问题描述】:

我正在尝试使用 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 时它停止了。

编辑: 我正在挖掘更多,似乎 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 ')

【问题讨论】:

    标签: python impala sasl impyla


    【解决方案1】:

    我也遇到了这个错误。唯一的解决方案是删除 sasl 并使用 pure-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 header

    我的认识:

    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()
    

    【讨论】:

      猜你喜欢
      • 2015-09-23
      • 2020-04-13
      • 1970-01-01
      • 1970-01-01
      • 2016-11-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多