python hbase 报错by_【hbase】使用thrift with python 访问HBase
HBase 版本: 0.98.6
thrift 版本: 0.9.0
使用 thrift client with python 连接 HBase 报错:
1 Traceback (most recent call last):2 File "D:\workspace\Python\py\helloworld.py", line 27, in
3 tables =client.getTableNames()4 File "E:\mazhongsoft\python\lib\hbase\Hbase.py", line 788, ingetTableNames5 returnself.recv_getTableNames()6 File "E:\mazhongsoft\python\lib\hbase\Hbase.py", line 798, inrecv_getTableNames7 (fname, mtype, rseqid) =self._iprot.readMessageBegin()8 File "E:\mazhongsoft\python\lib\thrift\protocol\TBinaryProtocol.py", line 126, inreadMessageBegin9 sz =self.readI32()10 File "E:\mazhongsoft\python\lib\thrift\protocol\TBinaryProtocol.py", line 203, inreadI3211 buff = self.trans.readAll(4)12 File "E:\mazhongsoft\python\lib\thrift\transport\TTransport.py", line 58, inreadAll13 chunk = self.read(sz-have)14 File "E:\mazhongsoft\python\lib\thrift\transport\TTransport.py", line 155, inread15 self.__rbuf = StringIO(self.__trans.read(max(sz, self.DEFAULT_BUFFER)))16 File "E:\mazhongsoft\python\lib\thrift\transport\TSocket.py", line 94, inread17 raise TTransportException(‘TSocket read 0 bytes‘)18 thrift.transport.TTransport.TTransportException: None
查找原因,过程如下:
1) 客户端代码
1transport =TTransport.TBufferedTransport(TSocket(‘192.168.0.10‘, 9090))2 protocol =TBinaryProtocol.TBinaryProtocol(transport)3 client =Hbase.Client(protocol)4 transport.open()
2) hbase-site.xml 配置如下
1
2 hbase.regionserver.thrift.framed
3 true
4
5
6 hbase.regionserver.thrift.compact
7 true
8
3) thrift server日志如下:(/var/log/hbase/hbase-hbase-thrift-.log)
1 Wed Jan 14 14:54:43 CST 2015 Starting thrift on
2 core file size (blocks, -c) 03 data seg size (kbytes, -d) unlimited4 scheduling priority (-e) 05 file size (blocks, -f) unlimited6 pending signals (-i) 191956
7 max locked memory (kbytes, -l) unlimited8 max memory size (kbytes, -m) unlimited9 open files (-n) 32768
10 pipe size (512 bytes, -p) 8
11 POSIX message queues (bytes, -q) 819200
12 real-time priority (-r) 013 stack size (kbytes, -s) 10240
14 cpu time (seconds, -t) unlimited15 max user processes (-u) 1024
16 virtual memory (kbytes, -v) unlimited17 file locks (-x) unlimited18 INFO [main] util.VersionInfo: HBase 0.98.6-cdh5.3.0
19 INFO [main] util.VersionInfo: Subversion file:///data/jenkins/workspace/generic-package-rhel64-6-0/topdir/BUILD/hbase-0.98.6-cdh5.3.0 -r Unknown20 INFO [main] util.VersionInfo: Compiled by jenkins on Tue Dec 16 19:13:29 PST 2014
21 INFO [main] thrift.ThriftServerRunner: Using default thrift server type22 INFO [main] thrift.ThriftServerRunner: Using thrift server type threadpool23 INFO [main] impl.MetricsConfig: loaded properties from hadoop-metrics2-hbase.properties24 INFO [main] impl.MetricsSystemImpl: Scheduled snapshot period at 10second(s).25 INFO [main] impl.MetricsSystemImpl: HBase metrics system started26 INFO [main] mortbay.log: Logging to org.slf4j.impl.Log4jLoggerAdapter(org.mortbay.log) via org.mortbay.log.Slf4jLog27 INFO [main] http.HttpServer: Added global filter ‘safety‘ (class=org.apache.hadoop.http.HttpServer$QuotingInputFilter)
28 INFO [main] http.HttpServer: Added filter static_user_filter (class=org.apache.hadoop.http.lib.StaticUserWebFilter$StaticUserFilter) to context thrift29INFO [main] http.HttpServer: Added filter static_user_filter (class=org.apache.hadoop.http.lib.StaticUserWebFilter$StaticUserFilter) to context static30 INFO [main] http.HttpServer: Jetty bound to port 9095
31 INFO [main] mortbay.log: jetty-6.1.26.cloudera.4
32 INFO [main] mortbay.log: Started [email protected]:9095
33 DEBUG [main] thrift.ThriftServerRunner: Using compact protocol34 DEBUG [main] thrift.ThriftServerRunner: Using framed transport35 INFO [main] thrift.ThriftServerRunner: starting TBoundedThreadPoolServer on /0.0.0.0:9090; min worker threads=16, max worker threads=1000, max queued requests=1000
由以上红色文字部分可知,是因为thrift 的server端和client端的协议不匹配造成的。
解决方案有如下两个:
方案一:修改hbase-site.xml,禁用TFramedTransport和TCompactProtocol功能,即:
1
2 hbase.regionserver.thrift.framed
3 false
4
5
6 hbase.regionserver.thrift.compact
7 false
8
重启thrift 服务器: service hbase-thrift restart
方案二:修改客户端代码
1 transport = TFramedTransport(TSocket(‘192.168.0.10‘, 9090))2 protocol =TCompactProtocol.TCompactProtocol(transport)3 client =Hbase.Client(protocol)4 transport.open()
如果报错未找到TFramedTransport和TCompactProtocol,请查看/usr/lib/python2.6/site-packages/thrift目录下有没有protocol/TCompactProtocol.py文件,检查transport/TTransport.py文件中有没有类TFramedTransport。如果没有,可以在thrift官网下载源码包 thrift-0.9.2.tar.gz,用其中的lib/py/src/覆盖/usr/lib/python2.6/site-packages/thrift/目录即可。
原文:http://www.cnblogs.com/zhangningbo/p/4303422.html
python hbase 报错by_【hbase】使用thrift with python 访问HBase相关推荐
- python运行报错无法映射_2018-03-01跳一跳python实践
1.必须准备一个付费的开发者账号,否则https://github.com/facebook/WebDriverAgent下载的代码无法准确执行 2.报错,找不到对应UITest的APP image. ...
- rf运行python脚本报错_以root权限执行python时候脚本时候报错“ExtractionError: Can't extract file(s) to egg cache”...
错误日志: *** Operational MODE: preforking *** Traceback (most recent call last): File "./rf_automa ...
- python运行报错无法映射_科学网-Python GDAL 图像坐标,投影坐标,经纬度坐标 三者映射及运行错误解决-吴妍潼的博文...
题记: 写该博客是因为自己经常遇到这个问题,而我发现网络上关于这方面浏览量高的一些代码竟然都有误,每次照搬都被虐得很惨.有一些同志在某些博客下方留言说代码有问题,而博主没有回应,也没有更改错误.为了自 ...
- Hbase报错解决方法ERROR: KeeperErrorCode = NoNode for /hbase/master
步骤 今天搭建Hbase环境,遇到了此bug.一开始搭建hdfs的时候还是很顺利的,参考着别人的博客,一步一的做下去,最后可以正常启动.而在搭建HBase的时候遇到了一个很大的bug.但是造成该bug ...
- python 等号报错_Python学习----Python基础
Python基础 一.数据类型和变量 1.在Python中,等号=是赋值语句,可以把任意数据类型赋值给变量,同一个变量可以反复赋值,而且可以是不同类型的变量. 例如: a =520# a是整数prin ...
- [故障解决]图文:python启动报错:api-ms-win-crt-runtime-l1-1-0.dll丢失解决
python启动报错:api-ms-win-crt-runtime-l1-1-0.dll丢失解决 环境 Windows 7 SP1 x64 python3.6.1 报错 解决办法 1.下载VC red ...
- 【错误记录】执行 Python 程序报错 ( NameError: name ‘reload‘ is not defined )
文章目录 一.报错信息 二.解决方案 一.报错信息 在 Windows 的 cmd 命令行运行 python 脚本时 , 报如下错误 : 执行 python ApkTool.py -analyse - ...
- 【错误记录】PyCharm 运行 Python 程序报错 ( UnicodeDecodeError: ‘ascii‘ codec can‘t decode byte 0xe5 in positio )
文章目录 一.报错信息 二.解决方案 一.报错信息 PyCharm 运行 Python 程序报错 : D:\002_Project\011_Python\APK\venv\Scripts\python ...
- 【错误记录】PyCharm 运行 Python 程序报错 ( PEP 8: E402 module level import not at top of file )
文章目录 一.报错信息 二.解决方案 一.报错信息 PyCharm 运行 Python 程序报错 : PEP 8: E402 module level import not at top of fil ...
最新文章
- jq点击按钮打开和关闭弹出层,点击除了当前按钮以外的地方关闭弹出层
- 图解.net程序集赋予强名称
- 王者荣耀连接不上服务器最新赛季排名,王者荣耀新赛季连掉三段 初期不能打排位是有原因的...
- 中台不火,天理难容!
- [vscode] python debugging
- 创建自定义主机头的网站集
- 【狂神Mybatis笔记】配置解析
- 【OpenCV】分离多通道图像RGB的值
- 激光清洗的优点和实际案例
- 【Java设计模式】责任链模式
- 25张用Photoshop绘制的顶级图片
- Google ProtoBuf简介
- 【verilog】【Modelsim仿真】“XXX“already declared in this scope
- html如何让字体变形,jquery实现字体变形特效-css字体变成圆形
- 【错误解决】Spring JPA的错误及其解决方案
- M1-CORO-S7 MANIP Modeling of Manipulators(1)
- python 线程通信的几种方式_Python 线程、线程通信、多线程
- 用VBA做一个儿童识字,数字考察游戏(持续更新中)
- md本地免费编辑器推荐-marktext
- dll文件丢失了怎么恢复最为快捷?dll文件丢失为啥什么软件都打不开了?