[grid@hadoop1 ~]$ wget http://mirrors.cnnic.cn/apache/thrift/0.9.2/thrift-0.9.2.tar.gz[grid@hadoop1 ~]$ tar -zxf thrift-0.9.2.tar.gz2.安装依赖环境
yum -y install automake libtool flex bison pkgconfig gcc-c++ boost-devel libevent-devel zlib-devel python-devel ruby-devel openssl-devel3.升级bison版本到2.5
[grid@hadoop1 ~]$ http://ftp.gnu.org/gnu/bison/bison-2.5.tar.gz[grid@hadoop1 ~]$ tar -zxf bison-2.5.tar.gz[root@hadoop1 bison-2.5]# ./configure && make && make install4.安装
[root@hadoop1 thrift-0.9.2]# ./configure --with-lua=no && make && make install5.验证安装是否成功
[root@hadoop1 thrift-0.9.2]# thrift -versionThrift version 0.9.26.下载HBase源码包
[root@hadoop1 grid]# wget http://mirrors.cnnic.cn/apache/hbase/hbase-0.98.11/hbase-0.98.11-src.tar.gz[root@hadoop1 grid]# tar -zxf hbase-0.98.11-src.tar.gz7.创建python的hbase thrift接口文件
[root@hadoop1 grid]# cd hbase-0.98.11/hbase-thrift/src/main/resources/org/apache/hadoop/hbase/thrift[root@hadoop1 thrift]# thrift -gen py ./Hbase.thrift[root@hadoop1 thrift]# lsgen-py Hbase.thrift[root@hadoop1 thrift]# cp -r gen-py/hbase/ /usr/lib64/python2.6/site-packages/8.依次启动hadoop、hbase、thrift
[grid@hadoop1 bin]$ sh start-all.sh[grid@hadoop1 ~]$ sh start-hbase.sh[grid@hadoop1 ~]$ hbase thrift -p 9090 start[grid@hadoop1 ~]$ jps21095 NameNode21334 JobTracker21250 SecondaryNameNode21746 HQuorumPeer22362 Jps22220 ThriftServer21966 HRegionServer21809 HMaster9.创建测试脚本
[grid@hadoop1 test]$ vim test.py#! /usr/bin/python#coding=utf-8import syssys.path.append('/usr/lib64/python2.6/site-packages/')from thrift import Thriftfrom thrift.transport import TSocketfrom thrift.transport import TTransportfrom thrift.protocol import TBinaryProtocolfrom hbase import Hbasefrom hbase.ttypes import *transport = TSocket.TSocket('192.168.0.104', 9090)transport = TTransport.TBufferedTransport(transport)protocol = TBinaryProtocol.TBinaryProtocol(transport)client = Hbase.Client(protocol)transport.open()print(client.getTableNames())10.测试
[grid@hadoop1 test]$ python test.py['member']