从Python和happybase / Thrift连接到Hbase [英] Connect to Hbase from Python and happybase / Thrift

查看:2111
本文介绍了从Python和happybase / Thrift连接到Hbase的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已安装Cloudera Manager Express 5.9.0安装HBase,Thrift服务器在VirtualBox vm中的CentOS 7.3上的端口9090上运行。



请帮忙弄清楚为什么我无法通过happybase成功连接,或者帮助确定下一步追求的步骤。



我是一名经验丰富的Java程序员,学习Python。我有使用本地接口从Java使用Hbase的经验,尽管不是在这个特定的环境中。




  • 我已验证我可以使用hbase shell创建表,插入数据等。

  • 我已验证9090(thrift)正在侦听并接受连接。

  • 我认为我已验证Thrift服务器使用与happybase连接参数相同的协议/传输设置运行。



几乎直接从happybase howto :

 导入happybase 

connection = happybase.Connection(host ='localhost',port = 9090 ,'transport'='buffered',protocol ='compact')

connection.create_table('mytable',
{'cf1':dict(max_versions = 10),
' cf2':dict(max_versions = 1,block_cache_enabled = False),
'cf3':dict(),#use defaults
}

错误讯息,我找不到很好的参考:

  [root @ data1〜]#python testhbase.py 
Traceback(最近一次调用最后一次):
在< module>文件中,第10行的文件testhbase.py 'cf3':dict(),#使用默认值
在create_table
文件/ build / bdist.linux-x86_64 / egg / happybase / connection.py,行311,/ usr / lib64 / python2.7 / site-packages / thriftpy / thrift.py,第198行,在_req中返回self._recv(_api)
文件/usr/lib64/python2.7/site-packages/thriftpy/thrift。 py,第210行,在_recv fname,mtype,rseqid = self._iprot.read_message_begin()
文件/usr/lib64/python2.7/site-packages/thriftpy/protocol/compact.py,行147,在read_message_begin%proto_id)
thriftpy.protocol.exc.TProtocolException:TProtocolException(type = 4)
[root @ data1〜]#

我在端口9095上运行Thift web服务管理器,它报告:

  HBase版本1.2.0-cdh5.9.0,rUnknown HBase版本和修订
Thrift Impl类型threadpool Thrift服务器选择的Thrift RPC引擎实现类型
Compact Protocol true Thrift RPC引擎使用紧凑协议
Framed Transpo rt false Thrift RPC引擎使用框架传输

非常感谢任何帮助。谢谢。

解决方案

我猜你没有使用支持的thrift守护进程版本。

你确定使用了thrift 1(不是thrift2)守护进程,有正确的协议和传输吗?


I have installed Cloudera Manager Express 5.9.0 installed HBase, with Thrift server running on port 9090 on CentOS 7.3 in a VirtualBox vm.

Please help in figuring out why I am unable to successfully interface via happybase, or help identify next steps to pursue.

I am an experienced Java programmer, learning Python. I have experience using Hbase from Java using the native interface, although not in this specific environment.

  • I have validated that I can use hbase shell to create tables, insert data, etc.
  • I have validated that 9090 (thrift) is listening and accepting connections.
  • I think I have validated that the Thrift server is running with the same protocol/transport settings as the happybase connection parameters.

Python Script taken virtually directly from happybase howto:

import happybase

connection = happybase.Connection(host='localhost',port=9090,transport='buffered', protocol='compact')

connection.create_table('mytable',
    {'cf1': dict(max_versions=10),
     'cf2': dict(max_versions=1, block_cache_enabled=False),
     'cf3': dict(),  # use defaults
    }
)

Error Message, which I can't find great reference for:

[root@data1 ~]# python testhbase.py
Traceback (most recent call last):
  File "testhbase.py", line 10, in <module> 'cf3': dict(),  # use defaults
  File "build/bdist.linux-x86_64/egg/happybase/connection.py", line 311, in create_table
  File "/usr/lib64/python2.7/site-packages/thriftpy/thrift.py", line 198, in _req return self._recv(_api)
  File "/usr/lib64/python2.7/site-packages/thriftpy/thrift.py", line 210, in _recv fname, mtype, rseqid = self._iprot.read_message_begin()
  File "/usr/lib64/python2.7/site-packages/thriftpy/protocol/compact.py", line 147, in read_message_begin % proto_id)
thriftpy.protocol.exc.TProtocolException: TProtocolException(type=4)
 [root@data1 ~]#

I have Thift web service manager running on port 9095 which reports:

HBase Version   1.2.0-cdh5.9.0, rUnknown    HBase version and revision
Thrift Impl Type    threadpool  Thrift RPC engine implementation type chosen by this Thrift server
Compact Protocol    true    Thrift RPC engine uses compact protocol
Framed Transport    false   Thrift RPC engine uses framed transport

Any help is greatly appreciated. Thank you.

解决方案

i guess you are not using the supported version of the thrift daemon.

are you sure the thrift 1 (not thrift2) daemon is used, with the right protocol and transport?

这篇关于从Python和happybase / Thrift连接到Hbase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆