Python 2.6.6和hive连接问题?

时间:2016-11-08 07:59:03

标签: python hadoop hive

我有一个默认Python版本2.6.6和hive 1.2的VM。我已经成功安装了pyhs2。但是当我运行python脚本时,我得到以下错误。

File "test.py", line 7, in <module>
with pyhs2.connect(host='localhost', port=10000, authMechanism="PLAIN", user='hive', password='hive', database='xxxx') as conn:
File "/usr/lib/python2.6/site-packages/pyhs2/__init__.py", line 7, in connect
return Connection(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/pyhs2/connections.py", line 46, in __init__
transport.open()
File "/usr/lib/python2.6/site-packages/pyhs2/cloudera/thrift_sasl.py", line 55, in open
self._trans.open()
File "/usr/lib64/python2.6/site-packages/thrift/transport/TSocket.py", line 101, in open
message=message)
thrift.transport.TTransport.TTransportException: Could not connect to localhost:10000

在我的hive-site.xml中,我有以下配置。

<property>
  <name>hive.server2.authentication</name>
  <value>NONE</value>
</property>
<property>
  <name>javax.jdo.option.ConnectionUserName</name>
  <value>hive</value>
</property>
<property>
  <name>javax.jdo.option.ConnectionPassword</name>
  <value>hive</value>
</property>

当我使用以下脚本时:

with pyhs2.connect(host='localhost', port=10000, authMechanism="NONE", user='hive', password='hive', database='xxxx') as conn:

我收到以下错误:

NotImplementedError: authMechanism is either not supported or not implemented.

请帮忙!

请注意,客户端不允许我升级python版本或更改Hive中的身份验证机制。

提前致谢。

1 个答案:

答案 0 :(得分:0)

1)检查此https://github.com/BradRuderman/pyhs2/blob/master/pyhs2/connections.py

authMechanisms = set(['NOSASL', 'PLAIN', 'KERBEROS', 'LDAP'])

authMechanisms应该是其中之一

2)thrift.transport.TTransport.TTransportException: Could not connect to localhost:10000出错 键入netstat -a -n | grep 10000并检查服务是否正在侦听端口10000