Using the Tomcat Native Library
Purpose
The Tomcat Native Library is a local library provided by Tomcat. It aims to improve the response speed, throughput, and concurrent processing capability of Tomcat by using the local efficient network I/O, OpenSSL, and optimized thread and synchronization mechanism. The following uses the built-in Tomcat of Spring Boot as an example to describe how to deploy and use the Tomcat Native Library on the Kunpeng server.
Procedure
To deploy and use the Tomcat Native Library on the Kunpeng server, perform the following steps:
- Install the dependency packages.
1yum install apr apr-devel apr-util openssl openssl-devel
- Download the Tomcat Native Library source package.Select a Tomcat Native Library version based on the Tomcat version. You can search for the recommended Tomcat Native Library version based on Changelog of Tomcat. The version 1.2.35 is used as an example.
1 2 3
cd /home wget https://archive.apache.org/dist/tomcat/tomcat-connectors/native/1.2.35/source/tomcat-native-1.2.35-src.tar.gz --no-check-certificate tar -zxvf tomcat-native-1.2.35-src.tar.gz
- Compile and install the Tomcat Native Library.
1 2 3 4 5
cd tomcat-native-1.2.35-src/native/ ./configure --with-java-home=$JAVA_HOME --prefix=/home/tomcat-test-01/bin make -j make install mv /home/tomcat-test-01/bin/lib/* /home/tomcat-test-01/bin
Modify the following parameters as required:
- --with-java-home specifies the Java root path.
- --prefix specifies the installation directory of the Tomcat Native Library files. /home/tomcat-test-01/bin is used as an example. Change it as required.
The library files can also be installed in a custom path. If so, ensure that the LD_LIBRARY_PATH environment variable is configured so that the application can find the library files. You can run the following command to configure LD_LIBRARY_PATH:
1export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:Custom_path
- Check the installation result.
1ll /home/tomcat-test-01/binIf the corresponding library files are displayed in the command output, the installation is successful.

- Verify that Tomcat can use the Tomcat Native Library.
Start the Spring Boot web service.
1 2
cd /home/tomcat-test-01 java -jar target/tomcat-test-01-0.0.1-SNAPSHOT.jar
If the command output contains information about using the Tomcat Native Library, Tomcat successfully uses the Tomcat Native Library.
