Debian下启用Tomcat APR运行模式


 

搭建环境:debian9,jdk8,tomcat8.5

参考:https://tomcat.apache.org/tomcat-8.5-doc/apr.html

 

APR运行模式是什么

APR从操作系统级别来解决异步的IO问题,大幅度的提高性能(但也依赖特定的操作系统), 比基于JAVA的BIO和NIO都强很多

tomcat8.5安装APR的最低要求:

Requirements:

  • APR 1.2+ development headers (libapr1-dev package)
  • OpenSSL 1.0.2+ development headers (libssl-dev package)
  • JNI headers from Java compatible JDK 1.4+jdk已经安装了)
  • GNU development environment (gcc, make)

这个最低要求不能信,实际的要求高得多.

安装apr,apr-util

查看debian的apr版本:dpkg -l libapr1-dev

本机不满足要求:

root@VM-98-192-debian:~# dpkg -l libapr1-dev

dpkg-query: no packages found matching libapr1-dev

 

安装:

apt install libapr1-dev

 

安装openSSL

查看debian自带的openssl版本:dpkg -l libssl-dev

本机不满足要求

root@VM-98-192-debian:~# dpkg -l libssl-dev

dpkg-query: no packages found matching libssl-dev

安装:

apt install libssl-dev

 

安装GNU开发环境

apt install gcc make

安装tcnative

到tomcat/bin目录下找到tomcat-native.tar.gz,解压后进入目录中安装

tar xzf /opt/apache-tomcat-8.5.32/bin/tomcat-native.tar.gz

cd tomcat-native-1.2.17-src/native

./configure && make && make install

 

安装成功

Libraries have been installed in:

/usr/local/apr/lib

 

启动tomcat时提示:

INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/local/jdk1.6.0_14/jre/lib/i386/server:/usr/local/jdk1.6.0_14/jre/lib/i386:/usr/local/jdk1.6.0_14/jre/../lib/i386:/usr/java/packages/lib/i386:/lib:/usr/lib

需要把APR可执行文件软链接到上述目录下中任意一个下.

建议用/usr/lib,简单方便.不用自己建目录

ls /usr/local/apr/lib

ln -s /usr/local/apr/lib/libtcnative-1.so.0.2.17 libtcnative-1.so

ln -s /usr/local/apr/lib/libtcnative-1.so.0.2.17 libtcnative-1.so.0

这样tomcat启动时,就可以读取到libtcnative-1了

此时重新启动tomcat,可以访问了.

cd /opt/apache-tomcat-8.5.32/bin

./shutdown.sh

./startup.sh    

查运行中的tomcat

ps -ef|grep tomcat

杀掉进程

kill -9 22329

可以看到tomcat已经在使用apr了.

 

 

相关