简体   繁体   English

python上的Hive Server 2错误与hiveserver2连接

[英]Hive Server 2 error on python connect with hiveserver2

I am using 我在用

Centos , Python2.7 , hive 2.1 ,Hadoop 2.7.2 ,pyHive Centos,Python2.7,hive 2.1,Hadoop 2.7.2,pyHive

here is code 这是代码

from pyhive import hive
from TCLIService.ttypes import TOperationState
cursor = hive.connect('localhost').cursor()
cursor.execute('SELECT * FROM my_awesome_data LIMIT 10', async=True)

#status = cursor.poll().operationState
#while status in (TOperationState.INITIALIZED_STATE, TOperationState.RUNNI$
#    logs = cursor.fetch_logs()
#    for message in logs:
#        print message

# If needed, an asynchronous query can be cancelled at any time with:
# cursor.cancel()

# status = cursor.poll().operationState

#print cursor.fetchall()

when I run python /usr/local/py/test5.py in terminal its showing .... 当我在终端中运行python /usr/local/py/test5.py时显示....

Traceback (most recent call last):
File "/usr/local/py/test5.py", line 3, in <module>
cursor = hive.connect('localhost').cursor()
File "/usr/local/lib/python2.7/site-packages/pyhive/hive.py", line 63, in connect
return Connection(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/pyhive/hive.py", line 104, in __init__
self._transport.open()
File "/usr/local/lib/python2.7/site-packages/thrift_sasl/__init__.py", line 80, in open
status, payload = self._recv_sasl_message()
File "/usr/local/lib/python2.7/site-packages/thrift_sasl/__init__.py", line 98, in _recv_sasl_message
header = read_all_compat(self._trans, 5)
File "/usr/local/lib/python2.7/site-packages/thrift_sasl/six.py", line 31, in <lambda>
read_all_compat = lambda trans, sz: trans.readAll(sz)
File "/usr/local/lib/python2.7/site-packages/thrift/transport/TTransport.py", line 58, in readAll
chunk = self.read(sz - have)
File "/usr/local/lib/python2.7/site-packages/thrift/transport/TSocket.py", line 120, in read
message='TSocket read 0 bytes')
thrift.transport.TTransport.TTransportException: TSocket read 0 bytes

Hive server error log showing after this... 在此之后显示Hive服务器错误日志...

ERROR [HiveServer2-Handler-Pool: Thread-41]: server.TThreadPoolServer (:()) - Thrift error occur$
org.apache.thrift.protocol.TProtocolException: Missing version in readMessageBegin, old client?
    at    org.apache.thrift.protocol.TBinaryProtocol.readMessageBegin(TBinaryProtocol.java:228)
    at org.apache.thrift.TBaseProcessor.process(TBaseProcessor.java:27)
    at org.apache.hive.service.auth.TSetIpAddressProcessor.process(TSetIpAddressProcessor.java:56)
    at org.apache.thrift.server.TThreadPoolServer$WorkerProcess.run(TThreadPoolServer.java:286)
    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)

Also I had tried pyhs2 getting same error 我也尝试过pyhs2得到同样的错误

what was going wrong ? 怎么了?

Thanks 谢谢

I hava solved this error with these versions : 我用这些版本解决了这个错误:

Centos 7 , Python2.7 , hive 2.1 ,Hadoop 2.7.3 and java java 1.7.0_91 Centos 7,Python2.7,Hive 2.1,Hadoop 2.7.3和Java Java 1.7.0_91

using impyla 使用impyla

its working for me. 它为我工作。

thrift.transport.TTransport.TTransportException: TSocket read 0 bytes thrift.transport.TTransport.TTransportException:TSocket读取0个字节

I had the same problem and solved it by 我有同样的问题,并通过解决

  1. Start hiveserver2 ( how to start hiveserver2 ) 启动hiveserver2( 如何启动hiveserver2
  2. Modify your port. 修改您的端口。 The default port is 10000 or you can change it to follow your hive_site.xml 默认端口是10000,或者您可以更改它以遵循您的hive_site.xml

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

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