4

I am trying to connect to Hbase using python sample code used

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

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

which is giving error as follows

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

OS : Ubuntu 16.04 I am using python 2.7 Hbase Version 1.1 Help me to understand the issue.Is there any better way to connect to Hbase other than happybase

Thanks

Anoop R
  • 545
  • 3
  • 8
  • 19

2 Answers2

6

Thanks for asking the question, I did fall into the same issue, where there is no answer on the internet. Not sure are we the only one hitting to this or not.

But here is how I figured out to fix the issue, from the error its clear that its something to do with thrift, so check the following

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

if thrift is not running! you may need to start thrift

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

then try your code.

import happybase

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

Auto Connection to hbase

import happybase

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

As an alternative you an use starbase but its no longer active i belive for this you need to start rest API. /usr/hdp/current/hbase-master/bin/hbase-daemon.sh start rest -p 8000 --inforport 8001 Try the happybase and let us know if you are hitting to same issue.

BTW my testing was done on HDP2.5

Further reference: https://github.com/wbolster/happybase/issues/161

which i dont recommend unless you know what you are doing

remove the following property: from 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>

Hope this helps,
Amod

Amod
  • 636
  • 1
  • 8
  • 9
0

Either you do autoconnect = True or you start it explicitly using connection.open(). You don't have to do both together.

void
  • 2,403
  • 6
  • 28
  • 53