[英]Connection to Hbase using python is failing
我正在尝试使用使用的python示例代码连接到Hbase
import happybase
connection = happybase.Connection(myhost,port, autoconnect=True)
# before first use:
connection.open()
print(connection.tables())
这给出了如下错误
print(connection.tables())Traceback(最近一次调用last):文件“”,第1行,在文件“/usr/local/lib/python2.7/dist-packages/happybase/connection.py”,第242行,在表names = 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“,第439行,在cybin.TCyBinaryProtocol.read_message_begin(thriftpy / protocol / cybin / cybin.c:6470)cybin.ProtocolError:无协议版本标题
操作系统:Ubuntu 16.04我使用的是python 2.7 Hbase版本1.1帮助我理解这个问题。除了happybase之外还有更好的方法可以连接到Hbase
谢谢
感谢您提出这个问题,我确实陷入了同样的问题,互联网上没有答案。 不确定我们是否是唯一一个打到这个与否的人。
但这里是我如何找出解决问题的方法,从错误中明确表示与thrift有关,所以请检查以下内容
/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())
自动连接到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>
希望这可以帮助,
阿莫德
您可以使用autoconnect = True
或使用connection.open()
显式启动它。 你不必一起做两件事。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.