使用 python 连接到 Hbase 失败

Ano*_*p R 4 python hadoop hbase happybase

我正在尝试使用 python 示例代码连接到 Hbase

import happybase
connection = happybase.Connection(myhost,port, autoconnect=True)

# before first use:
connection.open()
print(connection.tables())
Run Code Online (Sandbox Code Playgroud)

这是给出如下错误

打印(connection.tables())回溯(最近一次调用最后一次):文件“”,第1行,在文件“/usr/local/lib/python2.7/dist-packages/happybase/connection.py”,第242行, 在表中名称 = self.client.getTableNames() 文件“/usr/local/lib/python2.7/dist-packages/thriftpy/thrift.py”,第 198 行,在 _req 中返回 self._recv(_api) 文件“ /usr/local/lib/python2.7/dist-packages/thriftpy/thrift.py”,第 210 行,在 _recv fname, mtype, rseqid = self._iprot.read_message_begin() 文件“thriftpy/protocol/cybin/cybin. pyx", line 439, in cybin.TCyBinaryProtocol.read_message_begin (thriftpy/protocol/cybin/cybin.c:6470) cybin.ProtocolError: No protocol version header

操作系统:Ubuntu 16.04 我使用的是 python 2.7 Hbase 版本 1.1 帮助我理解这个问题。除了happybase 有没有更好的方法连接到Hbase

谢谢

Amo*_*mod 6

感谢您提出问题,我确实遇到了同样的问题,互联网上没有答案。不确定我们是不是唯一一个做到这一点的人。

但这是我解决问题的方法,从错误中可以清楚地看出它与节俭有关,因此请检查以下内容

/usr/hdp/current/hbase-master/bin/hbase-daemon.sh start thrift

如果节俭没有运行!你可能需要开始节俭

/usr/hdp/current/hbase-master/bin/hbase-daemon.sh start thrift -p 9090 --infoport 9091

然后试试你的代码。

import happybase

c = happybase.Connection('127.0.0.1',9090, autoconnect=False)
c.open()
print(c.tables())
Run Code Online (Sandbox Code Playgroud)

自动连接到 hbase

import happybase

c = happybase.Connection('127.0.0.1',9090)
print(c.tables())
Run Code Online (Sandbox Code Playgroud)

作为替代方案,您可以使用starbase但它不再活跃,我相信为此您需要启动 rest API。 /usr/hdp/current/hbase-master/bin/hbase-daemon.sh start rest -p 8000 --inforport 8001 试试happybase,如果您遇到同样的问题,请告诉我们。

顺便说一句,我的测试是在 HDP2.5 上完成的

进一步参考:https : //github.com/wbolster/happybase/issues/161

除非你知道你在做什么,否则我不推荐

删除以下属性:从 hbase-site.xml [/etc/hbase/conf/hbase-site.xml]

<property>
  <name>hbase.regionserver.thrift.http</name>
  <value>true</value>
</property>
<property>
  <name>hbase.thrift.support.proxyuser</name>
  <value>true/value>
</property>
Run Code Online (Sandbox Code Playgroud)

希望这会
有所帮助,阿莫德