centos7 部署thrift

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos7 部署thrift相关的知识,希望对你有一定的参考价值。

安装部署thrift

下载thrift

wget http://mirrors.hust.edu.cn/apache/thrift/0.11.0/thrift-0.11.0.tar.gz  

解压thrift

tar -zxvf thrift-0.11.0.tar.gz  

将解压后的文件,移动到合适的目录下

在官方下载的tar包中已经有了configure脚本,  
如果是首次下载的源码文件没有configure脚本,需要使用bootstrap.sh自动生成。

进入thrift文件里

安装依赖

yum install -y install automake bison flex gcc gcc-c++ git libboost1.55 libevent-dev libssl-dev libtool make pkg-config

进行配置(两种方式吧)

  • ./configure (使用默认配置)
  • ./configure --with-cpp --with-boost --with-python --without-csharp --with-java --without-erlang --without-perl --with-php --without-php_extension --without-ruby --without-haskell --without-go

编译 安装

make && make install   

测试是否安装成功?

#thrift
Usage: thrift [options] file

Use thrift -help for a list of options 

安装过程报的问题

缺少automake-1.15 动态库?

wget ftp://mirrors.ustc.edu.cn/gnu/automake/automake-1.15.tar.xz
tar xf automake-1.15.tar.xz 
cd automake-1.15/
./configure && make && make install  

thrift例子

编写一个thrift文件 demo.thrift

namespace  java com.xej.thrift.demo
namespace  py thrift.demo
namespace  go com.xej.thrift.demo

service DemoService{
    void sayHello(1:string name);
}

生成java,py, go 类型的文件

thrift --gen java demo.thrift 
thrift --gen py demo.thrift
thrift --gen go demo.thrift

如果有相应的文件夹生成,说明没问题

以上是关于centos7 部署thrift的主要内容,如果未能解决你的问题,请参考以下文章

Thrift 代码分析

Thrift一Thrift安装部署

centos7安装thrift

RPC简介与Thrift框架

Thrift架构介绍

Apache Thrift 的使用