码迷,mamicode.com
首页 > 其他好文 > 详细

Thrift0.9.2 安装

时间:2015-04-11 21:09:19      阅读:242      评论:0      收藏:0      [点我收藏+]

标签:

环境:CentOS6.5    HBase0.98.11    thrift0.9.2

1.下载解压
[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.gz
2.安装依赖环境
yum -y install automake libtool flex bison pkgconfig gcc-c++ boost-devel libevent-devel zlib-devel python-devel ruby-devel openssl-devel
3.升级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 install
4.安装
[root@hadoop1 thrift-0.9.2]# ./configure --with-lua=no && make && make install
5.验证安装是否成功
[root@hadoop1 thrift-0.9.2]# thrift -version
Thrift version 0.9.2
6.下载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.gz
7.创建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]# ls
gen-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 ~]$ jps
21095 NameNode
21334 JobTracker
21250 SecondaryNameNode
21746 HQuorumPeer
22362 Jps
22220 ThriftServer
21966 HRegionServer
21809 HMaster
9.创建测试脚本
[grid@hadoop1 test]$ vim test.py

#! /usr/bin/python
#coding=utf-8
import sys
sys.path.append(‘/usr/lib64/python2.6/site-packages/‘)
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.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‘]


Thrift0.9.2 安装

标签:

原文地址:http://my.oschina.net/zc741520/blog/399049

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!