简体   繁体   English

python无法连接hiveserver2

[英]python cannot connect hiveserver2

I have tried use the example on https://cwiki.apache.org/confluence/display/Hive/Setting+Up+HiveServer2 but gets the following errors:我曾尝试使用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

Here is the hive log:这是配置单元日志:

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)

Does anyone can help solve the problem?有没有人可以帮助解决问题? Thank you very much.非常感谢。

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

You are missing some dependencies, make sure you install cyrus-sasl-devel and cyrus-sasl-gssapi :您缺少一些依赖项,请确保安装cyrus-sasl-develcyrus-sasl-gssapi

On an RHEL-based distro:在基于 RHEL 的发行版上:

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

... or on a Debian-based distro: ...或在基于 Debian 的发行版上:

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

Per @KenKennedy, also add the libsasl2-modules-gssapi-mit package if using GSSAPI for authentication.根据@KenKennedy,如果使用 GSSAPI 进行身份验证,还要添加libsasl2-modules-gssapi-mit包。

1 In hive-site.xml, set configuration as below: 1 在 hive-site.xml 中,设置如下配置:

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

2 pyhs2 program codes changes as below: 2 pyhs2 程序代码变化如下:

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

Please note that username and password cannot be empty, add any username and password when connects to pyhs2请注意用户名和密码不能为空,连接pyhs2时添加任何用户名和密码

Setting up following environment variable worked for me:设置以下环境变量对我有用:

SASL_PATH=/usr/lib/x86_64-linux-gnu/sasl2 

This is for Ubuntu这是针对 Ubuntu 的

The above answers don't work in my case, I've also tried others.以上答案在我的情况下不起作用,我也尝试过其他答案。 Finally, I've solved my problem (no idea if it works for you).最后,我解决了我的问题(不知道它是否适合你)。

Just execute只需执行

export LD_LIBRARY_PATH=/usr/lib64:/usr/local/lib:$LD_LIBRARY_PATH

before running your script.在运行脚本之前。

My original LD_LIBRARY_PATH is /usr/local/lib:/usr/lib64我原来的LD_LIBRARY_PATH/usr/local/lib:/usr/lib64

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM