假设Hive安装在“g”集群中。我无法访问黄金集群。我在“s”集群中做python开发工作。我可以从“s”集群访问配置单元并运行查询。在
我有下面的代码从运行在“s”集群中的Python脚本连接到Hive。在
some_table
是配置单元中已存在的表。我想执行一个简单的select * from some_table
命令来获得一些结果。在
import sys
sys.path.append("/usr/lib/hive/lib/py")
from hive_service import ThriftHive
from hive_service.ttypes import HiveServerException
from thrift import Thrift
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol
transport = TSocket.TSocket('what-ever-server', what-ever-port)
transport = TTransport.TBufferedTransport(transport)
protocol = TBinaryProtocol.TBinaryProtocol(transport)
client = ThriftHive.Client(protocol)
transport.open()
print "connect success"
client.execute("SELECT * FROM some_table")
print client.fetchAll()
print "executed"
但是在打印“connect success”之后,我得到了下面的错误。我假设连接是成功的。在
^{pr2}$我在这个代码里做错了什么?在使用服务器名和端口连接到配置单元时,我没有遇到任何错误,所以我假设那里一切正常,与配置单元的连接不是问题所在。在
经过进一步的研究后,我发现实际上是HiveServer2使用的端口号是10000。之后,我必须安装pyhs2才能正常工作。在
相关问题 更多 >
编程相关推荐