pyhive-thrift传输异常:读取0字节

fkvaft9z  于 2021-06-26  发布在  Hive
关注(0)|答案(0)|浏览(265)

我正在尝试使用dbapi(异步)示例通过python(pyhive0.5,python2.7)连接到在docker容器内运行的hiveserver-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图像是这样的(tag:mysql\u 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服务器
启动mysql服务: service mysqld start 切换到目录/usr/local/hive: cd $HIVE_HOME 启动配置单元元存储服务器: nohup bin/hive --service metastore & 启动配置单元服务器2: hive --service hive-server2 (请注意,thrift服务器端口已在中更改为10001。) /usr/local/hive/conf/hive-site.xml )
发射直线炮弹: beeline 将直线外壳与hive server-2连接: !connect jdbc:hive2://localhost:10001/default;transportMode=http;httpPath=cliservice 我已经试过以下几件事了,但运气不好
将Python2.7.3作为docker容器内的默认python版本(原始默认值为Python2.6.6,Python2.7.3安装在容器内,但不是默认值)
将配置单元服务器端口更改为其默认值:10000
试图通过在容器中运行相同的python脚本来连接hive服务器(仍然会出现相同的错误)

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题