PyHive Thrift传输exception:读取0个字节

我想通过使用DB-API(asynchronous)示例通过python(PyHive 0.5,python 2.7)连接到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图像是(标签: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容器中启动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. 发射直线shell: beeline
  6. 使用Hive server-2 !connect jdbc:hive2://localhost:10001/default;transportMode=http;httpPath=cliservice shell: !connect jdbc:hive2://localhost:10001/default;transportMode=http;httpPath=cliservice

我已经尝试了以下的东西没有任何运气

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