Linux环境下为Tomcat安装APR

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.3.2.tar.gz
  • apr-util-1.3.2.tar.gz

两个可以在 http://apache.mirror.phpchina.com/apr/ 找到。

  • tomcat-native.tar.gz 可以在tomcat/bin目录下找到。

安装 apr

wget http://apache.mirror.phpchina.com/apr/apr-1.3.2.tar.gz   
tar zxvf apr-1.3.2.tar.gz   
cd apr-1.3.2   
./configure   
make  
  • apr 默认安装在 /usr/local/apr

安装 apr-util

wget http://apache.mirror.phpchina.com/apr/apr-util-1.3.2.tar.gz   
tar zxvf apr-util-1.3.2.tar.gz   
cd apr-util-1.3.2   
./configure --with-apr=/usr/local/apr   
make  
make install  

安装 tomcat-native

cd /usr/local/tomcat-6.0.18/bin   
tar zxvf tomcat-native.tar.gz   
cd tomcat-native-1.1.14-src/jni/native   
./configure --with-apr=/usr/local/apr --with-java-home=/usr/java/jdk1.6.0_11   
make  
make install  

设置 apr 的环境变量:

vi /etc/profile

--后面添加以下内容

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

--使profile生效,

source /etc/profile

配置Tomcat

  • 修改tomcat配置conf/server.xml:
 <!--The connectors can use a shared executor, you can define one or more named thread pools-->
     <Executor name="tomcatThreadPool" namePrefix="catalina-exec-" maxThreads="800" minSpareThreads="400"/>
     <!-- A "Connector" represents an endpoint by which requests are received
          and responses are returned. Documentation at :
          Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
          Java AJP  Connector: /docs/config/ajp.html
          APR (HTTP/AJP) Connector: /docs/apr.html
          Define a non-SSL HTTP/1.1 Connector on port 8080
     -->
     <Connector port="80" executor="tomcatThreadPool" protocol="org.apache.coyote.http11.Http11AprProtocol" 
        connectionTimeout="20000" redirectPort="8443" enableLookups="false" acceptCount="1000"/>

修改为Http11AprProtocol 协议.

之后启动tomcat即可.

  • 遇到问题:

SEVERE: Failed to initialize the SSLEngine.
org.apache.tomcat.jni.Error: 70023: This function has not been implemented on this platform

请关闭SSL侦听,除非你有使用SSL,修改conf/server.xml

 <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="off" />
  • 压测结果:

webbench -c 4000 -t 30 http://10.103.10.140/workbench/index.jsp
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http://10.103.10.140/workbench/index.jsp
4000 clients, running 30 sec.

Speed=484340 pages/min, 2441573 bytes/sec.
Requests: 242170 susceed, 0 failed.

启动 tomcat 后,看日志:

bin/startup.sh   
head logs/catalina.out 

可以看到以下结果:

信息: Loaded APR based Apache Tomcat Native library 1.1.14. 2009-1-13 11:12:51 org.apache.catalina.core.AprLifecycleListener init
信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].

转载于:https://my.oschina.net/tensai/blog/3014837

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值