我正在尝试从 hbase 使用 python 读取数据。我安装了 thrift,并生成了 gen-py 文件,然后将其移至 python lib:~/.local/lib/python2.7/site-packages/
hbase thrift 服务器位于 192.168.15.116:39090。是开始了。
我的代码在服务器 192.168.15.146 中。在这台机器上,我可以使用 hbase shell 命令来读取 hbase 数据。这是我的 Python 代码:
#! /usr/bin/env python
from thrift import Thrift
from thrift.transport import TSocket, TTransport
from thrift.protocol import TBinaryProtocol
from hbase import Hbase
transport = TSocket.TSocket('192.168.15.116', 39090)
transport.setTimeout(5000)
#transport = TTransport.TBufferedTransport(transport)
protocol = TBinaryProtocol.TBinaryProtocol(transport)
client = Hbase.Client(protocol)
transport.open()
print(client.getTableNames())
一切正常,但最后一行,这是错误:
Traceback (most recent call last):
File "test01.py", line 24, in <module>
client.getTableNames()
File "~/.local/lib/python2.7/site-packages/hbase/Hbase.py", line 788, in getTableNames
return self.recv_getTableNames()
File "~/.local/lib/python2.7/site-packages/hbase/Hbase.py", line 803, in recv_getTableNames
raise x
thrift.Thrift.TApplicationException: Internal error processing getTableNames
我用谷歌搜索但找不到解决此错误的方法,有人可以帮我吗?提前致谢!