gpt4 book ai didi

python - 使用 python 连接到 Hbase 失败

转载 作者:可可西里 更新时间:2023-11-01 14:30:23 27 4
gpt4 key购买 nike

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

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

# before first use:
connection.open()
print(connection.tables())

报错如下

print(connection.tables()) Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python2.7/dist-packages/happybase/connection.py", line 242, in tables names = self.client.getTableNames() File "/usr/local/lib/python2.7/dist-packages/thriftpy/thrift.py", line 198, in _req return self._recv(_api) File "/usr/local/lib/python2.7/dist-packages/thriftpy/thrift.py", line 210, in _recv fname, mtype, rseqid = self._iprot.read_message_begin() File "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.7Hbase 版本 1.1帮助我理解这个问题。除了 happybase 之外,还有什么更好的方法可以连接到 Hbase

谢谢

最佳答案

谢谢提问,我也遇到了同样的问题,网上没有找到答案。不确定我们是否是唯一遇到此问题的人。

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

/usr/hdp/current/hbase-master/bin/hbase-daemon.sh 启动节俭

如果 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())

自动连接到hbase

import happybase

c = happybase.Connection('127.0.0.1',9090)
print(c.tables())

作为替代方案,您可以使用 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>

希望对您有所帮助,
阿莫德

关于python - 使用 python 连接到 Hbase 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43473472/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com