python无法连接hiveserver2

时间:2015-06-08 09:30:52

标签: python hive

我试过在https://cwiki.apache.org/confluence/display/Hive/Setting+Up+HiveServer2上使用示例 但得到以下错误:

/usr/lib/python2.7/dist-packages/pkg_resources.py:1031: UserWarning: /home/dsnadmin/.python-eggs is writable by group/others and vulnerable to attack when used with get_resource_filename. Consider a more secure location (set with .set_extraction_path or the PYTHON_EGG_CACHE environment variable).
  warnings.warn(msg, UserWarning)
Traceback (most recent call last):
  File "hs2.py", line 8, in <module>
    database='default') as conn:
  File "build/bdist.linux-x86_64/egg/pyhs2/__init__.py", line 7, in connect
  File "build/bdist.linux-x86_64/egg/pyhs2/connections.py", line 46, in __init__
  File "build/bdist.linux-x86_64/egg/pyhs2/cloudera/thrift_sasl.py", line 66, in open
thrift.transport.TTransport.TTransportException: Could not start SASL: Error in sasl_client_start (-4) SASL(-4): no mechanism available: No worthy mechs found

这是hive日志:

ERROR [HiveServer2-Handler-Pool: Thread-31]: server.TThreadPoolServer (TThreadPoolServer.java:run(296)) - Error occurred during processing of message.
java.lang.RuntimeException: org.apache.thrift.transport.TSaslTransportException: No data or no sasl data in the stream
        at org.apache.thrift.transport.TSaslServerTransport$Factory.getTransport(TSaslServerTransport.java:219)
        at org.apache.thrift.server.TThreadPoolServer$WorkerProcess.run(TThreadPoolServer.java:268)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.thrift.transport.TSaslTransportException: No data or no sasl data in the stream
        at org.apache.thrift.transport.TSaslTransport.open(TSaslTransport.java:328)
        at org.apache.thrift.transport.TSaslServerTransport.open(TSaslServerTransport.java:41)
        at org.apache.thrift.transport.TSaslServerTransport$Factory.getTransport(TSaslServerTransport.java:216)

有没有人可以帮忙解决问题?非常感谢你。

操作系统版本: Ubuntu 14.04.1
Hive版本:apache-hive-1.2.0
SASL版本:sasl-0.1.3
节俭版:节俭-0.9.1

3 个答案:

答案 0 :(得分:14)

您缺少某些依赖项,请务必安装cyrus-sasl-develcyrus-sasl-gssapi

在基于RHEL的发行版上:

sudo yum install cyrus-sasl-devel cyrus-sasl-gssapi cyrus-sasl-md5 cyrus-sasl-plain

...或基于Debian的发行版:

sudo apt-get install sasl2-bin libsasl2-2 libsasl2-dev libsasl2-modules

Per @KenKennedy,如果使用GSSAPI进行身份验证,还要添加libsasl2-modules-gssapi-mit包。

答案 1 :(得分:3)

1在hive-site.xml中,按以下方式设置配置:

<property>
   <name>hive.server2.authentication</name>
   <value>NOSASL</value>
</property>

2个pyhs2程序代码更改如下:

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

请注意,用户名和密码不能为空,连接到pyhs2时添加任何用户名和密码

答案 2 :(得分:0)

上述答案对我的案例不起作用,我也尝试过其他人。 最后,我已经解决了我的问题。(不知道它是否适合你)

执行

export LD_LIBRARY_PATH = / usr / lib64:/ usr / local / lib:$ LD_LIBRARY_PATH 在运行脚本之前。

我原来的LD_LIBRARY_PATH是/ usr / local / lib:/ usr / lib64