Tomcat调优

1、启用线程池及配置

        maxThreads="500" minSpareThreads="100" prestartminSpareThreads="true" />


2、NIO配置

cd /usr/local/tomcat7/conf

vim server.conf


3、APR配置

1)下载并安装APR lib

http://apr.apache.org/download.cgi

wget http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.5.2.tar.gz
wget http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.5.4.tar.gz
wget http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-iconv-1.2.1.tar.gz

tar xzf apr-1.5.2.tar.gz
tar xzf apr-iconv-1.2.1.tar.gz
tar xzf apr-util-1.5.4.tar.gz

cd apr-1.5.2
vim configure    29605行(避免出现:rm: cannot remove `libtoolT': No such file or directory )
把RM='$RM'改为RM='$RM  -f'

./configure && make && make install

cd ../apr-util-1.5.4
./configure --with-apr=/usr/local/apr && make && make install

cd ../apr-iconv-1.2.1
./configure --with-apr=/usr/local/apr && make && make install

2)下载openssl并安装

wget http://www.openssl.org/source/openssl-1.0.1e.tar.gz
tar xzf openssl-1.0.1e.tar.gz
cd openssl-1.0.1e

./config --prefix=/usr/local/openssl-1.0.1e -fPIC && make && make install

3)编译安装tomcat-native.tar.gz

cd /usr/local/tomcat7/bin/
tar xzf tomcat-native.tar.gz
cd tomcat-native-1.1.33-src/jni/native/
./configure --with-apr=/usr/local/apr/bin/apr-1-config --with-ssl=/usr/local/openssl-1.0.1e && make && make install

4)配置Tomcat

cd /usr/local/tomcat7/conf/
vim server.xml

修改 Connector节点中protocal="org.apache.coyote.http11.Http11AprProtocol", 同时将  设置成off(如果不配置SSL访问的话)

5)将apr lib路径加入到java.library.path中

vim /usr/local/tomcat7/bin/daemon.sh

在CATALINA_OPTS中增加-Djava.library.path=/usr/local/apr/lib  (使用LD_LIBRARY_PATH的方法无效)

重启Tomcat, 可以看到

Feb 08, 2017 1:42:48 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: Loaded APR based Apache Tomcat Native library 1.1.33 using APR version 1.5.2.
Feb 08, 2017 1:42:48 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent

你可能感兴趣的:(JDK,Centos,jvm,tomcat)