Linux环境下Thrift的安装

官方给出的thrift安装依赖
Basic requirements
- A relatively POSIX-compliant *NIX system
- Cygwin or MinGW can be used on Windows (but there are better options, see below)
- g++ 4.2 (4.8 or later required for thrift compiler plug-in support)
- boost 1.53.0
- Runtime libraries for lex and yacc might be needed for the compiler.
Requirements for building from source
GNU build tools:
- autoconf 2.65
- automake 1.13
- libtool 1.5.24
pkg-config autoconf macros (pkg.m4)
lex and yacc (developed primarily with flex and bison)
libssl-dev
对于编译器GCC推荐使用4.8以上的版本,否则编译时可能抛出一些无法链接或者头文件找不到问题等。

在没有验证各种依赖版本的情况下,安装过程中出现了autoconf,g++,Bison,OpenSSL,Perl版本过低。这些问题的暴露过程大致是:

  • 在安装thrift前运行configure脚本时,发现语法分析器GNU Bison版本过低;
  • 在升级Bison时,发现OpenSSL版本过低;
  • 在升级OpenSSL时,发现Perl版本过低;
  • 在升级Perl时,发现g++版本过低

升级autoconf

# rpm -e --nodeps autoconf //卸载
解压安装包autoconf-2.69.tar.gz
# ./configure
# make & make install

在没有验证各种依赖版本的情况下,安装过程抛出的问题,及依次解决过程。
1. 在安装thrift前运行configure脚本时,发现语法分析器GNU Bison版本过低;

# ./configure
configure: error: Bison version 2.5 or higher must be installed on the system!

Bison是GNU项目的一种通用目的的分析器生成器。升级GNU Bison下载安装包bison-3.0.tar.gz。解压后在安装包根目录下的INSTALL文件中有详细的安装说明。基本安装方法如下:

# tar -zxvf bison-3.0.tar.gz
# cd bison-3.0
# ./configure
# make & make check
# make install & make installcheck

2. 在升级Bison时,发现OpenSSL版本过低;抛出异常如下:

src/thrift/transport/TSSLSocket.cpp:166: error: 'TLSv1_1_method' was not declared in this scope
src/thrift/transport/TSSLSocket.cpp:168: error: 'TLSv1_2_method' was not declared in this scope
src/thrift/transport/TSSLSocket.cpp: In member function 'void apache::thrift::transport::TSSLSocket::checkHandshake()':
src/thrift/transport/TSSLSocket.cpp:488: error: 'SSL_set_tlsext_host_name' was not declared in this scope

OpenSSL 是一个安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及SSL协议,并提供丰富的应用程序供测试或其它目的使用。

# rpm -qa|grep -i openssl  //当前系统的OpenSSL版本
openssl-0.9.8e-12.el5_4.6
openssl-devel-0.9.8e-12.el5_4.6

升级,官方安装包下载地址openssl-1.1.0f.tar.gz是目前支持的稳定版本。在解压后的安装包的根目录的INSTALL文件给出了安装步骤:

# ./config
# make
# make test
# make install

动态链接库没有加入默认环境:

# openssl version
openssl: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory
# locate libssl
/usr/local/lib64/libssl.so
/usr/local/lib64/libssl.so.1.1
# echo $LD_LIBRARY_PATH

通过以上两条命令可以发现,libssl的动态库被默认安装在”/usr/local/lib64/”,但是LD_LIBRARY_PATH环境变量中却没有该路径,因此我们选择在当前用户的环境变量中加上:

# vim ~/.bash_profile
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:/usr/local/lib64
# source ~/.bash_profile

3. 在升级OpenSSL时,发现Perl版本过低;
在安装OpenSSL时,运行config脚本会给出以其需要Perl v5.10.0以上的版本:
Perl v5.10.0 required–this is only v5.8.8
升级perl,下载当前稳定版本perl-5.26.1,安装方式如下:

# sh Configure -de
# make 
# make test 
# make install

ps:perl-5.26.1对于低版本的Centos有bug,更换安装包perl-5.10.1.tar.gz,以同样的方式进行安装

4. 在升级Perl时,发现g++版本过低,升级方法参见 Linux离线(手动)升级GCC-4.8

5. Thrift安装
安装的方法在安装包的README.md中都有说明

# tar -zxvf thrift-0.10.0.tar.gz

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

# ./configure
# make
# make install
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值