一、前提要求
1、thrift
2、hbase-thrift
注:我通过pycharm安装
二、启动Hbase
cd /usr/local/hbase
./sbin/start-hbase.sh
三、连接访问
from thrift.transportimport TSocket, TTransport
from thrift.protocolimport TBinaryProtocol
from hbaseimport Hbase
# thrift 默认端口为9090
host ='localhost'
port ='9090'
socket = TSocket.TSocket(host, port)
socket.setTimeout(5000)
transport = TTransport.TBufferedTransport(socket)
protocol = TBinaryProtocol.TBinaryProtocol(transport)
client = Hbase.Client(protocol)
socket.open()