首页 > 代码库 > Tomcat 整合APR优化
Tomcat 整合APR优化
参考:http://blog.csdn.net/wangnan537/article/details/6155268
apr 与 tomcat-native 提供更好的伸缩性、性能和集成到本地服务器技术。
如果没有apr技术,启动tomcat 时出现如下提示:
信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/jdk1.6.0_06/jre/lib/i386/client:/usr/java/jdk1.6.0_06/jre/lib/i386:/usr/java/jdk1.6.0_06/jre/../lib/i386:/usr/java/packages/lib/i386:/lib:/usr/lib
按照官方说明需要:
- APR library
- OpenSSL libraries
openssl 可以用 yum install openssl-devel,apr还是下载*.gz来安装。
apr-1.5.1.tar.gz
apr-util-1.5.4.tar.gz
两个可以在 https://apr.apache.org/download.cgi找到。
tomcat-native.tar.gz 也可以在tomcat/bin目录下找到。
安装 apr
1 wget http://www.interior-dsgn.com/apache//apr/apr-1.5.1.tar.gz 2 tar zxvf apr-1.5.1.tar.gz 3 cd apr-1.5.1 4 ./configure 5 make 6 make install
apr 默认安装在 /usr/local/apr
安装 apr-util
wget http://www.interior-dsgn.com/apache//apr/apr-util-1.5.4.tar.gz tar zxvf apr-util-1.5.4.tar.gz cd apr-util-1.5.4 ./configure --with-apr=/usr/local/apr make make install
安装 tomcat-native
http://archive.apache.org/dist/tomcat/tomcat-connectors/native/1.1.32/source/tomcat-native-1.1.32-src.tar.gztar zxvf tomcat-native-1.1.32-src.tar.gz cd tomcat-native-1.1.32-src/jni/native/ ./configure --with-apr=/usr/local/apr --with-java-home=/usr/java/jdk1.7.0_71 (此处JAVA_HOME不知道,可echo $JAVA_HOME)make;make install
设置 apr 的环境变量:
1 vi /etc/profile 2 # 后面添加以下内容 3 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/apr/lib 4 # 使profile生效, 5 source /etc/profile
安装完成后
启动类似提示错误:INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/amd64/server:/usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/amd64:/usr/lib/jvm/java-6-sun-1.6.0.20/jre/../lib/amd64:/usr/lib64/xulrunner-addons:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
其实可以忽略这个错误参考(http://stackoverflow.com/questions/2231163/what-tomcat-native-library-should-i-be-using-in-production)
但是可以修改 tomcat 的启动 shell (startup.sh),在该文件中加入启动参数:
CATALINA_OPTS="$CATALINA_OPTS -Djava.library.path=/usr/local/apr/lib" 。
OK!
记录备忘!
Tomcat 整合APR优化