Python 连接到HiveServer2时,impyla挂起
我正在用Python编写一些ETL流,在这个过程中,部分使用了Hive。Cloudera的impyla客户端,根据,与黑斑羚和蜂巢一起工作 根据我的经验,客户为黑斑羚工作,但在我尝试连接到蜂巢时挂断:Python 连接到HiveServer2时,impyla挂起,python,hive,Python,Hive,我正在用Python编写一些ETL流,在这个过程中,部分使用了Hive。Cloudera的impyla客户端,根据,与黑斑羚和蜂巢一起工作 根据我的经验,客户为黑斑羚工作,但在我尝试连接到蜂巢时挂断: from impala.dbapi import connect conn = connect(host='host_running_hs2_service', port=10000, user='awoolford', password='Bzzzzz') cursor = conn.curs
from impala.dbapi import connect
conn = connect(host='host_running_hs2_service', port=10000, user='awoolford', password='Bzzzzz')
cursor = conn.cursor() <- hangs here
cursor.execute('show tables')
results = cursor.fetchall()
print results
由于Hive和Python是如此常用的技术,我很想知道是否有其他人遇到过这个问题,如果有,您是如何解决的
版本:
- 蜂巢1.1.0-cdh5.5.1
- Python 2.7.11 | Anaconda 2.3.0
- 红帽6.7
from pyhive import hive
conn = hive.Connection(host="host_running_hs2_service", port=10000, username="awoolford")
cursor = conn.cursor()
cursor.execute("SHOW TABLES")
for table in cursor.fetchall():
print table
我不知道为什么Impyla客户端不起作用,但至少我们可以继续前进。将以下块添加到
/etc/hive/conf/hive site.xml
为我解决了问题:
/path/to/bin/hive --service hiveserver2 --hiveconf hive.server2.authentication=NOSASL
from impala.dbapi import connect
conn = connect(host='host_running_hs2_service', port=10000, user='awoolford', password='Bzzzzz', auth_mechanism='NOSASL')
cursor = conn.cursor()
cursor.execute('show tables')
results = cursor.fetchall()
print results
<property>
<name>hive.server2.authentication</name>
<value>NOSASL</value>
</property>
hive.server2.1身份验证
诺萨尔
感谢@ozw1z5rd的评论为我指明了正确的方向 但当我键入“from pyhive import hive”时出错。错误为“ImportError:没有名为builtins的模块”。python可能在Pyhive包中找不到hive.py。我该怎么办?我已经解决了这个进口问题。对于那些面对它的人:是的,这对我来说很有效:--hiveconf-hive.server2.authentication=nosal。在我的配置中,身份验证被设置为“无”。我看到当一个不安全的客户端试图连接到一个安全的服务器时,会发生这种“永远挂起”的情况。在这种情况下,服务器端处理程序线程可能会在处理来自客户端的消息时崩溃,然后才能发送任何内容。因此,客户机将无限期地等待。
<property>
<name>hive.server2.authentication</name>
<value>NOSASL</value>
</property>