CentOS6.5安装apr优化tomcat7性能

前言

Tomcat 连接器有三种方式: bio、nio 和 apr,三种方式性能差别很大,apr 的性能最优, bio 的性能最差。
Tomcat 7 使用的 Connector 默认就启用的 apr 协议,但需要系统安装 apr 库,否则就会使用 bio 方式。
如果系统没有安装apr,那么在启动tomcat的时候,catalina.out会打印出如下语句:

INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib

安装 apr 和 apr-util

如下网址找到apr最新版:http://apache.fayea.com/apr/

#download the latest version
cd /usr/local/
wget http://apache.fayea.com/apr/apr-1.5.2.tar.gz
wget http://apache.fayea.com/apr/apr-util-1.5.4.tar.gz

#unzip the package
tar -zxvf apr-1.5.2.tar.gz
tar -zxvf apr-util-1.5.4.tar.gz

#install the apr and apr-util
cd apr-1.5.2
./configure --prefix=/usr/local/apr
make 
make install 
cd .. 
cd apr-util-1.5.4
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr 
make 
make insatll

安装tomcat-native

在tomcat安装目录bin下面已经存在了对应版本的tomcat-native安装包了

#The package already in below path
cd /var/tomcat/tomcat-7/bin
tar -zxvf tomcat-native.tar.gz
cd tomcat-native-1.1.33-src/jni/native
./configure --with-apr=/usr/local/apr
make
make install

设置APR环境变量

vim /etc/profile   
#add below line to end of the file
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/apr/lib
#save the file and execute below to make effective
source /etc/profile

重启tomcat查看catalina.out日志

如果发现有下面的log说明APR启用成功

INFO: Loaded APR based Apache Tomcat Native library 1.1.33 using APR version 1.5.2.
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值