日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python hbase 报错by_【hbase】使用thrift with python 访问HBase

發布時間:2024/9/3 python 63 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。