由于我安装了anaconda,所以conda下载的包和pip下载的包可能导致冲突,使用conda list查看包,我这里为了干净,将conda可能重复的全部卸载了
conda uninstall sasl conda uninstall thrift_sasl conda uninstall thrift conda uninstall pyhive2.安装工具包
由于我是在windows环境下的conda环境,不能直接pip install sasl,就算安装上也不能使用,先到这里【https://www.lfd.uci.edu/~gohlke/pythonlibs/】下载win对应sasl的.whl安装文件到本地
下载我python3.8对应的版本:
就保存到本地桌面吧:
cd到桌面目录安装:
pip install wheel pip install sasl-0.3.1-cp38-cp38-win_amd64.whl
其他包正常安装即可:
pip install thrift pip install thrift_sasl pip install pyhive3.测试
from pyhive import hive
conn = hive.Connection(host='node001',port=10000,username='hive')
cursor = conn.cursor()
cursor.execute('show tables')
for result in cursor.fetchall():
print(result)
如果要连接kerberos认证的hive:
conn = hive.Connect(host='XXXX',port=10000,auth='KERBEROS',kerberos_service_name="hive")4.错误解决 4.1 sasl报错:
thrift.transport.TTransport.TTransportException: Could not start SASL: b’Error in sasl_client_start (-4) SASL(-4): no mechanism available: Unable to find a callback: 2’
用everything找到saslPLAIN.dll文件,并复制到C:CMUbinsasl2目录下,这个目录自行创建。
使用hive用户,报hive没有/tmp目录权限错误,具体错误懒得回去截图了,给/tmp目录授权给所有用户,反正是我自己玩,没关系
hadoop fs -chmod -R 777 /tmp
还有一点是之前我已经修改了core-site.xml配置
vim $HADOOP_HOME/etc/hadoop/sore-site.xml
添加配置
hadoop.proxyuser.root.hosts * hadoop.proxyuser.root.groups *



