PyHive Thrift传输异常:读取0个字节

时间:2017-10-23 10:06:54

标签: python docker hive pyhive

我正在尝试通过python(PyHive 0.5,python 2.7)使用DB-API (asynchronous)示例

连接到在docker容器内运行的Hive server-2(从容器外部)
from pyhive import hive
conn = hive.connect(host='172.17.0.2', port='10001', auth='NOSASL')

但是,我收到了以下错误

Traceback (most recent call last):
  File "py_2.py", line 4, in <module>
    conn = hive.connect(host='172.17.0.2', port='10001', auth='NOSASL')
  File "/home/foodie/anaconda2/lib/python2.7/site-packages/pyhive/hive.py", line 64, in connect
    return Connection(*args, **kwargs)
  File "/home/foodie/anaconda2/lib/python2.7/site-packages/pyhive/hive.py", line 164, in __init__
    response = self._client.OpenSession(open_session_req)
  File "/home/foodie/anaconda2/lib/python2.7/site-packages/TCLIService/TCLIService.py", line 187, in OpenSession
    return self.recv_OpenSession()
  File "/home/foodie/anaconda2/lib/python2.7/site-packages/TCLIService/TCLIService.py", line 199, in recv_OpenSession
    (fname, mtype, rseqid) = iprot.readMessageBegin()
  File "/home/foodie/anaconda2/lib/python2.7/site-packages/thrift/protocol/TBinaryProtocol.py", line 148, in readMessageBegin
    name = self.trans.readAll(sz)
  File "/home/foodie/anaconda2/lib/python2.7/site-packages/thrift/transport/TTransport.py", line 60, in readAll
    chunk = self.read(sz - have)
  File "/home/foodie/anaconda2/lib/python2.7/site-packages/thrift/transport/TTransport.py", line 161, in read
    self.__rbuf = BufferIO(self.__trans.read(max(sz, self.__rbuf_size)))
  File "/home/foodie/anaconda2/lib/python2.7/site-packages/thrift/transport/TSocket.py", line 132, in read
    message='TSocket read 0 bytes')
thrift.transport.TTransport.TTransportException: TSocket read 0 bytes

我正在使用的docker镜像是this(标签:mysql_corrected)。 它运行以下服务(由jps命令输出)

992 Master
1810 RunJar
259 DataNode
2611 Jps
584 ResourceManager
1576 RunJar
681 NodeManager
137 NameNode
426 SecondaryNameNode
1690 RunJar
732 HistoryServer

我正在使用

启动容器
docker run -it -p 8088:8088 -p 8042:8042 -p 4040:4040 -p 18080:18080 -p 10002:10002 -p 10000:10000 -e 3306 -e 9084 -h sandbox -v /home/foodie/docker/w1:/usr/tmp/test rohitbarnwal7/spark:mysql_corrected bash

此外,我执行以下步骤在docker container

中启动Hive服务器
  1. 启动mysql服务:service mysqld start
  2. 切换到目录/ usr / local / hive:cd $HIVE_HOME
  3. 启动Hive Metastore服务器:nohup bin/hive --service metastore &
  4. 启动Hive服务器2:hive --service hive-server2(请注意,/usr/local/hive/conf/hive-site.xml中的thrift-server端口已更改为10001)
  5. 启动beeline shell:beeline
  6. 将beeline shell与Hive server-2连接:!connect jdbc:hive2://localhost:10001/default;transportMode=http;httpPath=cliservice
  7. 我已经尝试过以下事情而没有任何运气

    1. 将python 2.7.3作为默认的python版本在docker容器中(原始默认为python 2.6.6,python 2.7.3安装在容器内,但不是默认值)
    2. 将Hive服务器端口更改为“默认值:10000
    3. 尝试通过在容器内运行相同的python脚本来连接Hive服务器(它仍然会出现相同的错误)

0 个答案:

没有答案