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编译器