使用hiveserver2连接python时出现配置单元服务器2错误

2w2cym1i  于 2021-06-02  发布在  Hadoop
关注(0)|答案(2)|浏览(397)

我正在使用
centos、python2.7、Hive2.1、Hadoop2.7.2、pyhive
这是密码

  1. from pyhive import hive
  2. from TCLIService.ttypes import TOperationState
  3. cursor = hive.connect('localhost').cursor()
  4. cursor.execute('SELECT * FROM my_awesome_data LIMIT 10', async=True)
  5. # status = cursor.poll().operationState
  6. # while status in (TOperationState.INITIALIZED_STATE, TOperationState.RUNNI$
  7. # logs = cursor.fetch_logs()
  8. # for message in logs:
  9. # print message
  10. # If needed, an asynchronous query can be cancelled at any time with:
  11. # cursor.cancel()
  12. # status = cursor.poll().operationState
  13. # print cursor.fetchall()

当我在终端运行python/usr/local/py/test5.py时,它显示。。。。

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

配置单元服务器错误日志在此之后显示。。。

  1. ERROR [HiveServer2-Handler-Pool: Thread-41]: server.TThreadPoolServer (:()) - Thrift error occur$
  2. org.apache.thrift.protocol.TProtocolException: Missing version in readMessageBegin, old client?
  3. at org.apache.thrift.protocol.TBinaryProtocol.readMessageBegin(TBinaryProtocol.java:228)
  4. at org.apache.thrift.TBaseProcessor.process(TBaseProcessor.java:27)
  5. at org.apache.hive.service.auth.TSetIpAddressProcessor.process(TSetIpAddressProcessor.java:56)
  6. at org.apache.thrift.server.TThreadPoolServer$WorkerProcess.run(TThreadPoolServer.java:286)
  7. at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
  8. at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
  9. at java.lang.Thread.run(Thread.java:745)

我也试过pyhs2得到同样的错误
出什么事了?
谢谢

p1tboqfb

p1tboqfb1#

我用这些版本解决了这个错误:
centos 7、python2.7、hive 2.1、hadoop 2.7.3和java 1.7.0\u91
使用impyla
对我有用。

oknrviil

oknrviil2#

thrift.transport.ttTransport.ttTransportException:tsocket读取0字节
我也遇到了同样的问题,用同样的方法解决了
启动hiveserver2(如何启动hiveserver2)
修改端口。默认端口为10000,或者您可以将其更改为遵循您的hive\u site.xml

相关问题