centos
yum install gcc-c++ python-devel.x86_64 cyrus-sasl-devel.x86_64
pip install pyhs2
ubuntu
sudo apt-get install libsasl2-dev libxml2-dev libxslt1-dev python-dev zlib1g-dev libevent-dev
sudo pip install lxml keyring keyrings.alt setuptools wheel
pip install --upgrade setuptools wheel keyring keyrings.alt
pip install six bit_array cython pyhs2 sasl thriftpy thrift_sasl
如果報錯:'TSocket' object has no attribute 'isOpen' 則是thrift-sasl的版本太高了(0.3.0),故將thrift-sasl的版本降級到0.2.1
pip install thrift-sasl==0.2.1 impyla
報錯:ThriftPy does not support generating module with path in protocol 'c'
主要是源碼在解析url的時候出現錯誤,解決方法如下:
修改windows端中的parser 代碼,筆者代碼位置如下: C:\ProgramData\Anaconda2\Lib\site-packages\thriftpy\parser
修改其中的488行爲如下情況:
#if url_scheme == '':
if len(url_scheme) <= 1:
然後重新運行即可。
報錯:thriftpy.transport.TTransportException: TTransportException(message="Could not start SASL: b'Error in sasl_client_start (-4) SASL(-4): no mechanism available: Unable to find a callback: 2'", type=1)
其中,authMechanism的值取決於hive-site.xml裏的配置
<name>hive.server2.authentication</name>
<value>NOSASL</value>
默認爲NONE,另外還可以爲’NOSASL’, ‘PLAIN’, ‘KERBEROS’, ‘LDAP’.
瞭解導auth_mechanism 這個參數的取值可以是:’NOSASL’, ‘PLAIN’, ‘KERBEROS’, ‘LDAP’.
需要查看hive的配置文件hive-site.xml裏面的取值,於是找到對應文件:
取值爲NONE,修改測試裏的參數:
from impala.dbapi import connect
conn = connect(host='*',port = 10000,auth_mechanism='NONE')
cur=conn.cursor()
cur.execute('SHOW databases;')
print(cur.fetchall())
cur.close()
conn.close()