1, Thrift Introduction Thrift is a scalable, cross-lingual service development framework developed by Fackbook, which has been open source and joined the Apache project. Thrift main function is: through the custom interface definition Language (IDL), you can create RPC-based client and service-side service code. The generation of the service code is implemented through the thrift built-in code generator. Thrift's cross-language body now, it can generate C + +, Java, Python, PHP, Ruby, Erlang, Perl, Haskell, C #, Cocoa, JavaScript, node. js, Smalltalk, OCaml , Delphi and other language code, and they can communicate transparently.
2. Why use thrift? As we all know, PHP because of the development cycle is fast, easy to deploy, easy to use, community active and very popular, but there are drawbacks, PHP did not get some large open source software support, such as Hbase,cassandra, so this time, will use thrift as the intermediary, to unify the Java and other server and PHP client communication, thrift just based on the configuration file to generate the inherent format of the code framework, do not use the servers, really provide services through the framework of Java and other code written.
3, install thrift, I am ready to use Java write server, so need to install a series of Java environment
1) Install Java Environment installation download jdk-7u79-linux-x64_0.rpm Install
RPM-IVH jdk-7u79-linux-x64_0.rpm
Environment variable Configuration
Export Java_home=/usr/java/jdk1.7.0_79export path= $JAVA _home/bin: $PATHexport classpath=.: $JAVA _home/lib/dt.jar:$ Java_home/lib/tools.jar
2) Install Ant
Mkdir/usr/antcd/usr/antwget-c HTTP://MIRROR.BIT.EDU.CN/APACHE//ANT/BINARIES/APACHE-ANT-1.9.6-BIN.TAR.GZTAR-ZVXF Apache-ant-1.9.6-bin.tar.gzexport ant_home=/usr/ant/apache-ant-1.9.6export path= $ANT _home/bin: $PATH
3) Update Bison to 2.5 or later
wget http://ftp.gnu.org/gnu/bison/bison-2.5.1.tar.gztar xvf bison-2.5.1.tar.gzcd bison-2.5.1./configure--prefix=/ Usrmakesudo make Install
4) Install autoconf, need more than 2.65 version
wget Http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gztar xvf autoconf-2.69.tar.gzcd autoconf-2.69./configure-- Prefix=/usrmakesudo make Install
5) [non-must] upgrade g++, need 4.2 version above, if it is, do not upgrade g++, Judge method g++-V
Wget-c HTTP://FTP.TSUKUBA.WIDE.AD.JP/SOFTWARE/GCC/RELEASES/GCC-4.8.1/GCC-4.8.1.TAR.GZTAR-ZVXF GCC-4.8.1.TAR.GZCD Gcc-build-4.8.1./contrib/download_prerequisites./configure--enable-checking=release--enable-languages=c,c++-- Disable-multilibmake-j4make INSTALLCP gcc-build-4.8.1/prev-x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/ Libstdc++.so.6.0.18/usr/lib ln-sf/usr/lib/libstdc++.so.6.0.18/usr/lib64/libstdc++.so.6
6) Install Thrift
Wget-c HTTP://ARCHIVE.APACHE.ORG/DIST/THRIFT/0.9.0/THRIFT-0.9.0.TAR.GZCD thrift-0.9.0./configure--with-ruby=no-- With-javamakemake Install
Execute thrift-version on the command line to view the version number, shown below to succeed.
The next article will introduce Java server-side and PHP client coding tutorials, if there is a problem welcome criticism to testify:)
Reference: http://thrift.apache.org/docs/BuildingFromSourcehttp://dongxicheng.org/search-engine/ thrift-framework-intro/http://blog.csdn.net/yang1982_0907/article/details/38461127
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Thrift Basic Tutorial (i) Installation Chapter