一、简介

1、语言库要求

因为thrift支持多语言。所以编译thrift源代码的过程中,会用到该语言的一些类库。如c++的boost、java的jdk等。

那么,在安装thrift过程中,须要对各种语言安装哪些类库和工具呢,官方对此有具体的介绍:

所需语言库和工具
C++ :Boost 1.33.1+ (必选),libevent (可选,用来创建非堵塞server) ,zlib (可选)
Java :Java 1.5+ (必选),Apache Ant (必选),Apache Ivy(必选),Apache Commons Lang,SLF4J(必选)
C#: Mono 1.2.4+ 或者 Visual Studio 2005+
Python: 2.4+(必选)
PHP: 5.0+(必选)
Ruby: 1.8+(必选)
Erlang: R12(必选)
Perl 5: Bit::Vector ,Class::Accessor
以上的语言库是看你详细须要thrift生成如何的语言,并非必须所有都安装。

2、支持的操作系统

thrift支持windows和linux两种操作系统

未尝试windows下的安装(考虑到普遍性和高效率,不建议使用windows安装thrift),下面是网上搜到windows下安装方法:

http://wiki.apache.org/thrift/ThriftInstallationWin32

http://blog.csdn.net/snowbirdfly/article/details/6746392

linux下安装,本人尝试过centos4和centos5,因为centos5自带的一些开发包版本号较高,和thrift环境比較吻合。建议使用centos5.

以下開始在centos5下安装thrift。let’s begin 。

二、安装环境

  1. 操作系统:centos5版本号以上操作系统
  2. 网络:有独立ip,能訪问外网
  3. 远程连接软件:SecureCRT

三、安装步骤

1、安装jdk

centos5自带的jdk版本号是1.6.0,符合thrift安装要求,可能须要加入环境变量。

环境变量加入方法:
vim /etc/profile此文件后面追加(路径因机而异):
JAVA_HOME=/usr/share/jdk1.5.0_16
CLASSPATH=./:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
LD_LIBRARY_PATH=/usr/lib
export PATH CLASSPATH JAVA_HOME LD_LIBRARY_PATH运行下面命令,使profile文件生效:
source /etc/profile

验证方法:

输入java -version看java版本号,须在1.5以上
输入javac,瞧见此命令的使用说明后。即验证jdk成功安装,否则,检查一下就哪个环节出了问题。

这个安装比較简单,不懂的地方能够參考: http://www.blogjava.net/esprit/archive/2006/01/18/28489.html

2、安装ant

  • 1、下载

从 http://ant.apache.org/bindownload.cgi 下载最新的tar包:apache-ant-1.8.3.tar.gz。

  • 2、安装

cd到/usr/local下,解压

[root@bogon san1156]# tar zxpvf apache-ant-1.8.3.tar.gz
[root@bogon san1156]# ln -s apache-ant-1.8.3 ant
  • 3、环境变量设置

将ANT_HOME设置到当前用户的.bash_profile文件

vi /root/.bash_profile
export ANT_HOME=/usr/local/ant
export PATH=/usr/local/ant/bin:$PATH
  • 4、測试

用ant命令測试执行情况

[root@bogon san1156]# ant
Buildfile: build.xml does not exist!
Build failed
[root@bogon san1156]# ant -version
Apache Ant(TM) version 1.8.3 compiled on February 26 2012

若出现以上内容。说明正常成功安装

否则,若出现这种错误:Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/tools/ant/launch/Launcher

这是linux系统默认安装了一些ant的lib。改动 /etc/ant.conf中 ANT_HOME=/usr/share/ant 为你正确安装ant的地址。如 /usr/local/ant

注:编译thriftproject要用到ant。thrift中的javaproject配置好了build.xml。故不须要手动改动此文件。

參考网址:http://blog.csdn.net/nivana999/article/details/6526961

3、安装ivy

  • 1、下载

下载apache ivy:http://labs.mop.com/apache-mirror//ant/ivy/2.2.0/apache-ivy-2.2.0-bin.tar.gz

  • 2、解压

tar -xzvf apache-ivy-2.2.0-bin.tar.gz

  • 3、安装

cp ivy-2.2.0.jar ANT_HOME/lib

  • 4、測试

cd 到 apache-ivy-2.2.0/src/example/hello-ivy,执行ant

假设看到:

BUILD SUCCESSFUL
Total time: 29 seconds

就代表欧了

4、部署其它语言环境

智能安装命令。此命令须要远程下载一些安装包。并自己主动安装。下载文件大小共计60M,时间依据你的下载速度而定。

sudo yum install automake libtool flex bison pkgconfig gcc-c++ boost-devel libevent-devel zlib-devel python-devel ruby-devel

官方说明: Installing the required packages on CentOS 5 http://wiki.apache.org/thrift/GettingCentOS5Packages

5、安装thrift

  • 1、下载thrift

http://mirror.bjtu.edu.cn/apache/thrift/0.8.0/thrift-0.8.0.tar.gz

  • 2、解压
tar -zxvf thrift-0.8.0.tar.gz
  • 3、编译
cd  thrift-0.8.0
./configure
make
make install
  • 4、測试

在命今行内输入thrift。假设有提示命令用法。证明能够了。

假设提示命令不可用。请接着本文向下看,对症下药,方可药到病除。

四、碰到的问题和解决方法

事无巨细,再简单的事情。做起来往往也不是一帆风顺,更何况是部署强大的thrift系统了。
只是,经历过风雨,才干见到最灿烂的彩虹!仅仅有经受了层层不绝的bug磨练,才干锻炼出程序猿这颗坚强勇敢的心!

1、Error: libcrypto required

  • 1、错误信息:在安装thrift过程中,运行./configure。报错Error: libcrypto required
  • 2、解决方法:请安装libssl-dev
  • 3、实施步骤:

yum install openssl openssl-devel libmcrypt libmcrypt-devel curl-devel

此命令自己主动下载安装程序,并安装,可谓快捷方便。纯傻瓜式操作

  • 4、參考网址:http://hi.baidu.com/ubuntu2me/blog/item/bcea4709fca3a1dd62d98693.html

2、Building Java Library ........ : no

  • 1、安装目的:thrift支持多语言环境,可谓难能可贵,而java和c++又是两大语种。缺少不论什么一个都是遗憾。故,搭建thrift最少支持两种语言。这里选择java、c++和python。
  • 2、错误信息:在安装thrift过程中,运行./configure。报语言环境时,结果是Building Java Library ........ : no。显然非吾等所愿。
Building code generators ..... :
Building C++ Library ......... : yes
Building C (GLib) Library .... : no
Building Java Library ........ : no
Building C# Library .......... : no
Building Python Library ...... : yes
Building Ruby Library ........ : no
Building Haskell Library ..... : no
Building Perl Library ........ : no
Building PHP Library ......... : yes
Building Erlang Library ...... : no
Building Go Library .......... : no
Building TZlibTransport ...... : yes
Building TNonblockingServer .. : yes
  • 3、解决方法:在同级文件夹下,more config.log,查看不支持java环境的根本原因。

事实上,原因也无非是安装jdk、ant或者ivy不成功导致。

本人安装是碰到的问题是:

configure:16550: checking for javac and java
Running "javac configtest_ax_javac_and_java.java"
Running "java configtest_ax_javac_and_java"
Exception in thread "main" java.lang.NoClassDefFoundError: configtest_ax_javac_and_java
Running "kaffe configtest_ax_javac_and_java"
./configure: line 16569: kaffe: command not found
Running "jikes configtest_ax_javac_and_java.java"
./configure: line 16562: jikes: command not found
Running "gcj -C configtest_ax_javac_and_java.java"
Running "java configtest_ax_javac_and_java"
Exception in thread "main" java.lang.NoClassDefFoundError: configtest_ax_javac_and_java
Running "kaffe configtest_ax_javac_and_java"
./configure: line 16569: kaffe: command not found
configure:16583: result: no

此问题的解决,不要去找configtest_ax_javac_and_java.java这个是否存在,由于找半天也找不到。

这样的错误往往是环境变量classpath配置有问题,须要在classpath前面加入“./:”,默认从同级文件夹下找javaproject文件。

3、java.util.zip.ZipException: error in opening zip file

  • 1、错误信息:在编译thriftproject时。运行make命令。报如上的错误。具体信息例如以下:
Making all in java
make[3]: Entering directory `/home/san1156/soft/thrift-0.8.0/lib/java'
/usr/local/ant/bin/ant
Buildfile: /home/san1156/soft/thrift-0.8.0/lib/java/build.xmlsetup.init:mvn.ant.tasks.check:proxy:mvn.ant.tasks.download:[get] Getting: http://repo1.maven.org/maven2/org/apache/maven/maven-ant-tasks/2.1.3/maven-ant-tasks-2.1.3.jar[get] To: /home/san1156/soft/thrift-0.8.0/lib/java/build/tools/maven-ant-tasks-2.1.3.jar[get] Not modified - so not downloadedmvn.init:
Unable to obtain resource from /home/san1156/soft/thrift-0.8.0/lib/java/build/tools/maven-ant-tasks-2.1.3.jar: java.util.zip.ZipException: error in opening zip file[typedef] Unable to obtain resource from /home/san1156/soft/thrift-0.8.0/lib/java/build/tools/maven-ant-tasks-2.1.3.jar: [typedef] java.util.zip.ZipException: error in opening zip file[typedef]     at java.util.zip.ZipFile.open(Native Method)[typedef]     at java.util.zip.ZipFile.<init>(ZipFile.java:127)[typedef]     at java.util.jar.JarFile.<init>(JarFile.java:135)[typedef]     at java.util.jar.JarFile.<init>(JarFile.java:99)[typedef]     at org.apache.tools.ant.AntClassLoader.getResourceURL(AntClassLoader.java:1006)[typedef]     at org.apache.tools.ant.AntClassLoader$ResourceEnumeration.findNextResource(AntClassLoader.java:149)[typedef]     at org.apache.tools.ant.AntClassLoader$ResourceEnumeration.<init>(AntClassLoader.java:110)[typedef]     at org.apache.tools.ant.AntClassLoader.findResources(AntClassLoader.java:953)[typedef]     at org.apache.tools.ant.AntClassLoader.getNamedResources(AntClassLoader.java:922)[typedef]     at org.apache.tools.ant.loader.AntClassLoader5.getResources(AntClassLoader5.java:56)[typedef]     at org.apache.tools.ant.taskdefs.Definer.resourceToURLs(Definer.java:375)[typedef]     at org.apache.tools.ant.taskdefs.Definer.execute(Definer.java:267)[typedef]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)[typedef]     at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)[typedef]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)[typedef]     at java.lang.reflect.Method.invoke(Method.java:597)[typedef]     at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)[typedef]     at org.apache.tools.ant.Task.perform(Task.java:348)[typedef]     at org.apache.tools.ant.Target.execute(Target.java:392)[typedef]     at org.apache.tools.ant.Target.performTasks(Target.java:413)[typedef]     at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)[typedef]     at org.apache.tools.ant.Project.executeTarget(Project.java:1368)[typedef]     at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)[typedef]     at org.apache.tools.ant.Project.executeTargets(Project.java:1251)[typedef]     at org.apache.tools.ant.Main.runBuild(Main.java:811)[typedef]     at org.apache.tools.ant.Main.startAnt(Main.java:217)[typedef]     at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)[typedef]     at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)[typedef] Could not load definitions from resource org/apache/maven/artifact/ant/antlib.xml. It could not be found.BUILD FAILED
/home/san1156/soft/thrift-0.8.0/lib/java/build.xml:267: Problem: failed to create task or type antlib:org.apache.maven.artifact.ant:remoteRepository
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
No types or tasks have been defined in this namespace yetThis appears to be an antlib declaration.
Action: Check that the implementing library exists in one of:-/usr/local/ant/lib-/root/.ant/lib-a directory added on the command line with the -lib argumentTotal time: 0 seconds
make[3]: *** [all-local] Error 1
make[3]: Leaving directory `/home/san1156/soft/thrift-0.8.0/lib/java'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/san1156/soft/thrift-0.8.0/lib'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/san1156/soft/thrift-0.8.0'
make: *** [all] Error 2

2、处理方法: It could be related to log4j. http://stackoverflow.com/questions/325202/java-util-zip-zipexception-error-in-opening-zip-file

另外,thrift官网要求java必须安装SLF4J,故,基本确定是未安装SLF4J导致。

4、安装SLF4J、log4j

  • 1、下载

官网上下载apache-log4j-1.2.16.tar.gz、slf4j-1.6.4.tar.gz

下载地址各自是: http://mirror.bjtu.edu.cn/apache/logging/log4j/1.2.16/apache-log4j-1.2.16.tar.gz

http://www.slf4j.org/dist/slf4j-1.6.4.tar.gz

  • 2、安装

将须要的jar包放到运行位置,操作例如以下:

须要的jar包:log4j-1.2.16.jar、slf4j-api-1.6.4.jar、slf4j-log4j12-1.6.4.jar

指定位置:/home/san1156/soft/jdk1.6.0_30/lib/。也就是jdk的classpath路径。

  • 3、clean中间文件

因为报错的时候产生了一些暂时文件。须要运行

[root@localhost thrift-0.8.0]# make clean

或者

[root@localhost java]# cd /home/san1156/soft/thrift-0.8.0/lib/java
[root@localhost java]# ant clean
  • 4、又一次编译。
[root@localhost thrift-0.8.0]# make

或者

[root@localhost java]# cd /home/san1156/soft/thrift-0.8.0/lib/java
[root@localhost java]# ant
运行通过,说明java环境木有问题
以上问题和解决方法,是本人编译过程中所总结,希望对后来者实用
假设不幸,你碰到的问题,这里没有述及,能够联系本人一块探讨

五、其它软件的安装方法

  • 1、centos boost install

http://blog.163.com/solylee@126/blog/static/171823157201101811587203/

http://hi.baidu.com/lbxthinker/blog/item/527b88ca1d8002f253664f68.html

(centos应用程序有自己的boost,点击更新就可以完毕安装,就是版本号较低)

  • 2、gcc download

http://gcc.gnu.org/mirrors.html

  • 3、gcc安装(未装)

http://zhidao.baidu.com/question/1251827.html

  • 4、linux下JAVA安装。及Java环境变量配置

http://apps.hi.baidu.com/share/detail/3320416

  • 5、ant安装

http://blog.csdn.net/nivana999/article/details/6526961

export ANT_HOME=/home/san1156/soft/apache-ant-1.8.3
export PATH=/home/san1156/soft/apache-ant-1.8.3/bin:$PATH
改动/root/.bash_profile这个文件,后面加入上面的环境变量
校验ant方法:直接输入ant,提示须要build.xml文件
  • 6、linux下python的安装

http://www.cnblogs.com/ewyb/archive/2010/10/26/1861744.html

六、參考网址

官方文档:

编译安装thrift

http://wiki.apache.org/thrift/ThriftInstallation

Installing the required packages on CentOS 5

http://wiki.apache.org/thrift/GettingCentOS5Packages

Thrift安装介绍相关推荐

  1. Thrift框架介绍

    1.前言 Thrift是一个跨语言的服务部署框架,最初由Facebook于2007年开发,2008年进入Apache开源项目.Thrift通过一个中间语言(IDL, 接口定义语言)来定义RPC的接口和 ...

  2. php thrift 报错,thrift安装遇到的问题以及解决方法(必看篇)

    1. 必须安装boost.最新的稳定版是1.48.0. 1.1.先下载:http://sourceforge.NET/projects/boost/files/boost/1.48.0/ 选择tar. ...

  3. Scrapy安装介绍

    Scrapy安装介绍 一. Scrapy简介 Scrapy is a fast high-level screen scraping and web crawling framework, used ...

  4. Scrapy的安装介绍

    Scrapy的安装介绍 Scrapy框架官方网址:http://doc.scrapy.org/en/latest Scrapy中文维护站点:http://scrapy-chs.readthedocs. ...

  5. 三、安装cmake,安装resin ,tars服务,mysql 安装介绍,安装jdk,安装maven,c++ 开发环境安装...

    三.安装cmake,安装resin 2018年07月01日 21:32:05 youz1976 阅读数:308 开发环境说明: centos7.2 ,最低配置:1核cpu,2G内存,1M带宽 1.安装 ...

  6. ubuntu下针对php的thrift 安装折腾记录

    2019独角兽企业重金招聘Python工程师标准>>> 此安装针对php开发配置 按照官方的文档做法,会出现各种bug,总结正确的安装方法: STEP1: 安装必要的依赖插件: su ...

  7. 史上最详细的LXR安装介绍

    史上最详细的LXR安装介绍(Ubuntu14.04+Apache2.4.7) 简介: LXR (Linux Cross Reference)是一个通过交叉索引方便用户查看项目源代码的工具.项目地址:h ...

  8. 光收发器安装介绍,光纤收发器连接示意图解

    对于光纤布线来讲光纤收发器都是非常熟悉的产品了,在光纤网络中,我们常常会使用到光纤收发器,那么,在网络布线过程中光纤收发器该怎么连接呢?接下来飞畅科技的小编就来为大家介绍下光纤收发器安装以及连接图解, ...

  9. Spark集群安装介绍

    (1)初学者对于spark的几个疑问 http://aperise.iteye.com/blog/2302481 (2)spark开发环境搭建 http://aperise.iteye.com/blo ...

最新文章

  1. java构造方法何时被调用_构造方法何时被调用
  2. DatagridView内容自动换行和换行符换行
  3. 使用Harbor构建docker私有仓库
  4. 正则汇总 个人汇总 不断更新中
  5. 深入开展计算机设备保密检查,江西安远县检察院深入开展网络安全保密自查工作...
  6. vSAN 监测失败并显示错误:“未能生成 HTML 包:Gem::Package::TooLongFileName: (Failed to generate HTML bundle: Gem::Pac
  7. Hibernate 缓存机制(转)
  8. YOLOv5数据集标注工具
  9. 为什么人和人的差距这么大?
  10. LPC1788 IAP的实现及遇见的问题
  11. pip卸载旧版本后安装新版本(我是Python3)
  12. Windows命令行快速启动快捷方式
  13. 重载函数sroot3次,让它返回整数、长整数、双精度数的二次方根
  14. MySQL复制表结构、表数据的方法
  15. JavaScript:实现PigeonHoleSort鸽巢排序算法(附完整源码)
  16. pentaho report designer笔记
  17. PMP(第六版)中的合同总结
  18. iOS-仿网易云音乐控制器
  19. linux ifcfg-eth0文件丢失,Linux备份ifcfg-eth0文件致使的网络故障问题
  20. golang与python交互_Go语言的类IPython 交互式编程界面

热门文章

  1. 浅淡计算机网络安全管理论文,工程项目管理-浅谈计算机网络强化计算机网络安全管理的有益学术论文格式(2)-优度********网...
  2. 206367-33-1,抗菌肽pBD-1
  3. IP-Guard控制台的账号登录是否支持双因子认证?
  4. 点到直线距离公式的几种推导
  5. TNNLS | GNN综述:A Comprehensive Survey on Graph Neural Networks
  6. Android Tip : Android GestureDetector 手势识别 抬起 操作
  7. drupal安装chosen模块
  8. Idea 支持Windows7的版本
  9. discuz二次开发笔记
  10. 微软1G网盘注册方法