Apache Thrift environment configuration

  • 2020-06-19 12:28:43
  • OfStack

Official documentation for Thrift installation address:

http://thrift.apache.org/docs/install/

When I saw that the windows installation required Cygwin or MinGW, I dropped the idea of configuring it in windows and went straight to the virtual machine and installed it with CentOS, which was easier to install using the 1 heap command than windows.

CentOS installation Thrift

Official document Address:

http://thrift.apache.org/docs/install/centos

Basically according to the official operation, you can proceed from 1 to the last group of commands, which is the following place:


Build and Install the Apache Thrift IDL Compiler
git clone https://git-wip-us.apache.org/repos/asf/thrift.git 
cd thrift 
./bootstrap.sh 
./configure  � with-lua=no 
make 
sudo make install

This step requires special attention. There are two options.

As the source code is downloaded here using git, you are currently using the latest version of the directory. At the time of writing this document on September 19, 2015, the following version of master is the latest version 1.0.0, which has not been released yet. Therefore, I suggest two ways:

The & # 61623; Use git checkout 0.9.2 to switch to the current released version 0.9.2 and continue

The & # 61623; Continue on the current master (unreleased 1.0.0 release)

Note: Downloading source code with git is time consuming, the fastest way is to download the specified version of the zip directly from the official download.

Personally, Since I discovered the problem only after the fact, I did it in the second case.

I personally recommend that you choose the stable version that has been released. If something goes wrong, maybe the following solution for situation 2 applies to situation 1 as well.

Continue on the current master (unreleased version 1.0.0)

Since I followed the official documentation directly and executed the above command in the case of master, 1 error occurred.

Before continuing with this last part above, you need to install 1 of the necessary dependencies. If these dependencies are not installed beforehand, the following error may occur:

make appears Error: TNonblockingServer.ES58en :41:33: error: event2/ es61EN_ES62en.h...

For errors like the one above, the solution is from the following address:

http://libevent.org/

Download libevent, I directly downloaded the latest version of ES72en-2.0.22-stable. tar. gz, this version can solve the above problems, other versions did not try.

After installation, if you have previously executed make, it is recommended that you clear the directory with git gc.

Then continue with the following:


./bootstrap.sh 
./configure  � with-lua=no 
make 
sudo make install

The installation should be complete without any problems under normal circumstances (do you fail to perform git gc?) .

Package the 1.0.0 version of jar package

Since 1.0.0 is not currently available, if you use version 0.9.2 there will be 1 error, so you will have to package it yourself manually.

To access the thrift/lib/Java directory, you need to configure jdk and ant first. Then open the terminal in this directory and execute the ant command.

After successful execution, the libthrift-1.0.0.jar and ES106en-1.0.0.pom files are visible in the build directory.

Here you need to manually modify the ES110en-1.0.0.pom file, which will < packaging > pom < /packaging > Instead of < packaging > jar < /packaging > If you do not change it to jar, you cannot import the local warehouse in the simplest way through the following command (jar package will not be uploaded when installing package type pom, so change it to jar, but the official package type is really weird pom, who can explain why ?) .
Copy these two files to the computer you want to use and install them to the local warehouse using the following command:


mvn install:install-file -Dfile=libthrift-1.0.0.jar -DpomFile=libthrift-1.0.0.pom

Once installed locally, in maven you can use:


<dependency>
  <groupId>org.apache.thrift</groupId>
  <artifactId>libthrift</artifactId>
  <version>1.0.0</version>
</dependency>

At this point, you're ready to start using thrift.

conclusion


Related articles: