tomcat安装apr优化

APR是apache的一个linux操作系统级优化库,可以在tomcat中使用操作系统级native调用大大提高并发处理效率

先安装前置依赖:

yum install -y apr-devel openssl-devel gcc make expat-devel

 

https://mirrors.tuna.tsinghua.edu.cn/apache/apr/

下载最新apr-1.6.3.tar.gz  apr-util-1.6.1.tar.gz apr-iconv.x.x.tar.gz

解压apr-1.6.3.tar.gz到main下,cd进去

./configure --prefix=/main/apr

make && make install

 

然后解压 apr-util-1.6.1.tar.gz  cd进去:

./configure --prefix=/main/apr-util --with-apr=/main/apr/
make && make install

同上再安装一个apr-iconv.x.x.tar.gz

 

然后解压tomcat/bin目录下的tomcat-native-1.2.16.tar.gz并进入:

apache-tomcat-8.5.31/bin/tomcat-native-1.2.16-src/native

./configure --with-apr=/main/apr --with-java-home=/main/jdk1.8.0_172

再  make  && make install即可

 

加上lib目录:

JAVA_OPTS="$JAVA_OPTS -Djava.library.path=/main/lib"

或者

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/main/lib

 

tomcat配置文件,打开线程池:

    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
        maxThreads="1100" minSpareThreads="4"/>

设置protocol为:org.apache.coyote.http11.Http11AprProtocol

    <Connector executor="tomcatThreadPool"
               maxThreads="1000"
               URIEncoding="UTF-8"
               port="8080"
               protocol="org.apache.coyote.http11.Http11AprProtocol"
               connectionTimeout="20000"
               enableLookups="false"
               redirectPort="8443" />

启动后可以看到:

30-Jul-2018 11:06:10.016 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [/main/apache-tomcat-8.5.31/webapps/XXXXX.war] has finished in [22,366] ms
30-Jul-2018 11:06:10.023 信息 [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-apr-8080"]
30-Jul-2018 11:06:10.030 信息 [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
30-Jul-2018 11:06:10.043 信息 [main] org.apache.catalina.startup.Catalina.start Server startup in 22431 ms

 

  

 

posted @ 2018-07-30 11:08  大树的博客  Views(671)  Comments(0Edit  收藏  举报