Thrift示例程序

Thrift是一个跨语言、高可用、高性能、轻量级的RPC框架

当然缺点也是比较明显,接口稍有改动就要重新生成代码,使用起来不是很方便

Linux Distribution:Ubuntu 14.04.4

Thrift:0.10.0

JDK:1.7.0_80


一,安装Thrift编译器

1,安装工具包和依赖库

由于使用ubuntu14,根据官方网站http://thrift.apache.org/docs/install/debian中的说明,安装工具包和依赖库的命令如下:

apt-get install automake bison flex g++ git libboost1.55-all-dev libevent-dev libssl-dev libtool make pkg-config

在安装之前需要使用apt-get update检索一下安装包列表,避免在安装过程中无法找到相应的安装包

由于最终会生成Java代码,还需安装最低JDK7和Ant

apt-get install openjdk-7-jdk-headless ant

如果系统版本较高,则需安装更高版本依赖库,如Ubuntu 16.04.2,就需要libboost1.58-all-dev及最低JDK8


2,安装编译器

从官网下载最新的压缩包thrift-0.10.0.tar.gz 

root@ubuntu:/home/sean# tar -zxf thrift-0.10.0.tar.gz 
root@ubuntu:/home/sean# cd thrift-0.10.0
root@ubuntu:/home/sean/thrift-0.10.0# ./configure --prefix=/usr/local/thrift
root@ubuntu:/home/sean/thrift-0.10.0# make
root@ubuntu:/home/sean/thrift-0.10.0# make install

安装结果如下

root@ubuntu:/usr/local/thrift# ll
total 24
drwxr-xr-x  6 root root 4096 Apr  6 19:16 ./
drwxr-xr-x 11 root root 4096 Apr  6 19:15 ../
drwxr-xr-x  2 root root 4096 Apr  6 19:15 bin/
drwxr-xr-x  3 root root 4096 Apr  6 19:15 include/
drwxr-xr-x  3 root root 4096 Apr  6 19:15 lib/
drwxr-xr-x  3 root root 4096 Apr  6 19:16 share/

如果感觉上面的过程太繁琐,可以使用apt-get直接安装Thrift编译器


                
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值