您好,登錄后才能下訂單哦!
1、生成 python用的thrift模塊
thrift --gen py /src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift
(該路徑是從hbase的源代碼文件中來的)
這樣會在當前路徑生成一個gen-py路徑
2、安裝
cd gen-py/hbase
python *.py build
python *.py install
cd ..
cp-rhbase/usr/lib/python2.6/site-packages/
3、測試
python
from thrift import Thrift
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol
from hbase import Hbase
from hbase.ttypes import *
transport = TSocket.TSocket('192.168.137.101',9090)
transport = TTransport.TBufferedTransport(transport)
protocol = TBinaryProtocol.TBinaryProtocol(transport)
client = Hbase.Client(protocol)
transport.open()
scan = TScan()
tableName = 'ttable'
id = client.scannerOpenWithScan(tableName, scan, None)
result1 = client.scannerGetList(id, 10)
print result1
4、不要忘記啟動thrift守護進程
./bin/hbase-daemon.sh start thrift
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。