Tomcat Native 这个项目可以让 Tomcat 使用 Apache 的 apr 包来处理包括文件和网络IO操作,以提升性能。Tomcat Native 是利用 APR 来提升Tomcat性能的本地API。
软件下载地址:http://tomcat.apache.org/download-native.cgi
或者在二进制版本包内的bin目录下软件相关的包。建议使用比较新一些的版本,有一个版本有bug,网上搜索一下就知道。
安装环境需求:
Development Tools 需要安装这个组的包
apr apr-devel
openssl相关包
安装过程:
查询是否安装Development Tool
[root@zonghe ~]# yum grouplist Loaded plugins: fastestmirror Setting up Group Process Loading mirror speeds from cached hostfile addons Installed Groups: Development Libraries Development Tools 需要安装这个组的包 Dialup Networking Support
查看安装那些apr包
[root@zonghe ~]# rpm -qa|grep apr apr-1.2.7-11.el5_6.5 apr-1.2.7-11.el5_6.5 apr-util-1.2.7-11.el5_5.2 apr-util-1.2.7-11.el5_5.2
查看安装那些openssl包
[root@zonghe ~]# rpm -qa|grep openssl openssl-0.9.8e-20.el5 openssl-devel-0.9.8e-20.el5 openssl-devel-0.9.8e-20.el5 openssl-0.9.8e-20.el5
经查看发现少了apr-devel包,直接yum安装
[root@zonghe ~]# yum install apr-devel Loaded plugins: fastestmirror Existing lock /var/run/yum.pid: another copy is running as pid 28125. Another app is currently holding the yum lock; waiting for it to exit... The other application is: yum Memory : 19 M RSS (236 MB VSZ) Started: Thu Jun 27 00:46:45 2013 - 00:41 ago State : Sleeping, pid: 28125 Loading mirror speeds from cached hostfile Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package apr-devel.i386 0:1.2.7-11.el5_6.5 set to be updated ---> Package apr-devel.x86_64 0:1.2.7-11.el5_6.5 set to be updated --> Finished Dependency Resolution Dependencies Resolved ===================================================================================================================== Package Arch Version Repository Size ===================================================================================================================== Installing: apr-devel i386 1.2.7-11.el5_6.5 base 233 k apr-devel x86_64 1.2.7-11.el5_6.5 base 238 k Transaction Summary ===================================================================================================================== Install 2 Package(s) Upgrade 0 Package(s) Total download size: 471 k Is this ok [y/N]: y Downloading Packages: (1/2): apr-devel-1.2.7-11.el5_6.5.i386.rpm | 233 kB 00:00 (2/2): apr-devel-1.2.7-11.el5_6.5.x86_64.rpm | 238 kB 00:00 --------------------------------------------------------------------------------------------------------------------- Total 12 kB/s | 471 kB 00:40 Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing : apr-devel 1/2 Installing : apr-devel 2/2 Installed: apr-devel.i386 0:1.2.7-11.el5_6.5 apr-devel.x86_64 0:1.2.7-11.el5_6.5 Complete!
安装native (我使用的是tomcat二进制包bin目录下的包)
[root@zonghe bin]# pwd /usr/local/tomcat6/bin [root@zonghe bin]# ls bootstrap.jar commons-daemon-native.tar.gz setclasspath.sh tomcat-juli.jar version.sh catalina.bat cpappend.bat shutdown.bat tomcat-native.tar.gz catalina.sh digest.bat shutdown.sh tool-wrapper.bat catalina-tasks.xml digest.sh startup.bat tool-wrapper.sh commons-daemon.jar setclasspath.bat startup.sh version.bat [root@zonghe bin]# tar zxf tomcat-native.tar.gz [root@zonghe bin]# ls bootstrap.jar commons-daemon-native.tar.gz setclasspath.sh tomcat-juli.jar version.bat catalina.bat cpappend.bat shutdown.bat tomcat-native-1.1.22-src version.sh catalina.sh digest.bat shutdown.sh tomcat-native.tar.gz catalina-tasks.xml digest.sh startup.bat tool-wrapper.bat commons-daemon.jar setclasspath.bat startup.sh tool-wrapper.sh [root@zonghe bin]# cd tomcat-native-1.1.22-src/ CHANGELOG.txt jni/ KEYS LICENSE NOTICE README.txt [root@zonghe bin]# cd tomcat-native-1.1.22-src/jni/native/ [root@zonghe native]# ./configure --with-apr=/usr --with-ssl checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking target system type... x86_64-unknown-linux-gnu checking for a BSD-compatible install... /usr/bin/install -c checking for working mkdir -p... yes Tomcat Native Version: 1.1.22 checking for chosen layout... tcnative checking for APR... yes setting CC to "gcc" setting CPP to "gcc -E" checking for JDK location (please wait)... /usr/local/jdk1.6.0_43 from environment checking Java platform... checking Java platform... checking for sablevm... NONE adding "-I/usr/local/jdk1.6.0_43/include" to TCNATIVE_PRIV_INCLUDES checking os_type directory... linux adding "-I/usr/local/jdk1.6.0_43/include/linux" to TCNATIVE_PRIV_INCLUDES checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking for OpenSSL library... using openssl from /usr/lib and /usr/include checking OpenSSL library version... ok checking for OpenSSL DSA support... yes setting TCNATIVE_LDFLAGS to "-lssl -lcrypto" adding "-DHAVE_OPENSSL" to CFLAGS setting TCNATIVE_LIBS to "" setting TCNATIVE_LIBS to " /usr/lib64/libapr-1.la -lpthread -ldl" configure: creating ./config.status config.status: creating tcnative.pc config.status: creating Makefile config.status: executing default commands [root@zonghe bin]#make && make install
更新共享库
[root@zonghe native]# echo "/usr/local/apr/lib" >> /etc/ld.so.conf [root@zonghe native]# ldconfig
检查是否安装好
[root@zonghe native]# ldconfig -v|grep native libtcnative-1.so.0 -> libtcnative-1.so.0.1.22
到此,tomcat native已经安装完成
转载于:https://blog.51cto.com/ontheway2015/1243024