linux yum apr,CentOS安装、配置APR和tomcat

APR:Apache Portable Run-time libraries,Apache可移植运行库

在早期的Apache版本中,应用程序本身必须能够处理各种具体操作系统平台的细节,并针对不同的平台调用不同的处理函数。随着Apache的进一步开发,Apache组织决定将这些通用的函数独立出来并发展成为一个新的项目。这样,APR的开发就从Apache中独立出来,Apache仅仅是使用APR而已。

Tomcat Native:这个项目可以让 Tomcat 使用 Apache 的 apr 包来处理包括文件和网络IO操作,以提升性能。

官网介绍:

The Apache Tomcat Native Library is an optional component for use with Apache Tomcat that allows Tomcat to use certain native resources for performance, compatibility, etc.

(大概意思是Tomcat可以利用一些native资源来提高性能和兼容性。)

Specifically, the Apache Tomcat Native Library gives Tomcat access to the Apache Portable Runtime (APR) library's network connection (socket) implementation and random-number generator.

(具体来说是利用了APR库中的网络连接实现和随机数生成器。)

Features of the APR connector:

Non-blocking I/O for Keep-Alive requests (between requests)

Uses OpenSSL for TLS/SSL capabilities (if supported by linked APR library)

FIPS 140-2 support for TLS/SSL (if supported by linked OpenSSL library)

Linux下,Tomcat启用APR需要三个组件:

apr

apr-util

tomcat-native.tar.gz(Tomcat自带,在bin目录下)

1、查看是否已经安装了apr和apr-util

# rpm -qa apr

apr-1.4.8-3.el7.x86_64

# rpm -qa apr-util

apr-util-1.5.2-6.el7.x86_64

2、查看是否有最新版的apr和apr-util

# yum list | grep apr

apr.x86_64                              1.4.8-3.el7                    @anaconda

apr-util.x86_64                         1.5.2-6.el7                    @anaconda

3、如果还没安装,用yum安装:

# yum install apr-devel apr apr-util

4、安装tomcat-native:

搜索tomcat-native安装包:

# yum list | grep tomcat-native

如果已经存在,直接安装:

# yum install tomcat-native

……

正在安装    : tomcat-native-1.1.30-1.el7.x86_64        1/1

验证中      : tomcat-native-1.1.30-1.el7.x86_64         1/1

已安装:

tomcat-native.x86_64 0:1.1.30-1.el7

完毕!

查看是否安装成功:

# rpm -qa tomcat-native

tomcat-native-1.1.30-1.el7.x86_64

配置相关的全局变量:

# vi /etc/profile

添加:export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/apr/lib

# source /etc/profile

5、重启Tomcat,看看是否可以成功使用APR

如果一切正常:

APR启动:

[main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-apr-18080"]

[main] org.apache.catalina.startup.Catalina.start Server startup in13617ms

相比NIO模式的启动,速度快了一些(~15%):

NIO启动:

[main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-18080"]

[main] org.apache.catalina.startup.Catalina.start Server startup in15671ms

如果发现异常log,比如:

06-Aug-2015 14:46:04.949 SEVERE [main] org.apache.catalina.core.AprLifecycleListener.init An incompatible version 1.1.30 of the APR based Apache Tomcat Native library is installed, while Tomcat requires version 1.1.32

说明系统自带的tomcat-native版本太低。

删除:

# yum erase tomcat-native

用yum检查有没有最新版:

# yum update tomcat-native

如果yum找不到最新版,则下载或从Tomcat/bin中解压安装。

从Tomcat/bin目录中,解压tomcat-native.tar.gz文件:

# tar -zxvf tomcat-native.tar.gz

得到文件夹:tomcat-native-1.1.33-src

# cd tomcat-native-1.1.33-src/jni/native/

# ./configure --with-apr=/usr/local/apr    (官网中例子的其他参数不需要,会自动找到)

# make && make install

参考:

官网的安装指导:http://tomcat.apache.org/native-doc/

Tomcat Connector三种运行模式(BIO, NIO, APR)的比较和优化:http://blog.csdn.net/clementad/article/details/47045673

(原创文章,转载请注明转自Clement-Xu的博客)

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值