簡體   English   中英

使用python連接到Hbase失敗

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM