1、生成 python用的thrift模塊
民權(quán)網(wǎng)站建設(shè)公司創(chuàng)新互聯(lián)建站,民權(quán)網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為民權(quán)成百上千提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\成都外貿(mào)網(wǎng)站建設(shè)要多少錢,請(qǐng)找那個(gè)售后服務(wù)好的民權(quán)做網(wǎng)站的公司定做!
thrift --gen py /src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift
(該路徑是從hbase的源代碼文件中來的)
這樣會(huì)在當(dāng)前路徑生成一個(gè)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、不要忘記啟動(dòng)thrift守護(hù)進(jìn)程
./bin/hbase-daemon.sh start thrift