tomcat 优化

  • A+
所属分类:Tomcat

安装apr来提高tomcat 的可伸缩性和性能

cd /usr/local/

1  下载apr 和 apr-util最新版

wget  http://apache.fayea.com/apache-mirror//apr/apr-1.5.0.tar.gz 

wget  http://apache.fayea.com/apache-mirror//apr/apr-util-1.5.3.tar.gz

 

2  解压文件

tar -zxvf apr-1.5.0.tar.gz 

tar -zxvf aor-util-1.5.3.tar.gz

3 安装apr和apr-util

cd apr-1.5.0 

./configure --prefix=/usr/local/apr 

make 

make install 

cd .. 

cd apr-util-1.5.3 

./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr 

make 

make insatll

4  安装 tomcat-native

cd /usr/local/tomcat/bin
tar -zxvf tomcat-native.tar.gz
cd tomcat-native-1.1.29-src/jni/native
./configure --with-apr=/usr/local/apr --with-java-  home=/usr/java/jdk1.7.0_25
make
make install

 

5 设置 apr 的环境变量

vi /etc/profile   

#在文本的最后面添加以下内容 

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

#使profile生效, 

source /etc/profile

6 启动tomcat并查看catalina.out

./startup.sh 

cat catalina.out

出现 :org.apache.catalina.core.AprLifecycleListener.init Loaded APR based Apache Tomcat Native library 1.1.29 using APR version 1.5.0.

则apr安装成功

 也可以 用rpm包 进行  rpm -ivh apr apr-devel apr-util

 

1.yum -y install apr apr-devel apr-util  make gcc(一般make,gcc都已安装)
2.cd /usr/local/tomcat*/bin    tar zxvf tomcat-native-1.1.20-src.tar.gz  cd tomcat-native-1.1.20-src/jni/native    ./configure --prefix=/usr/local/apr --with-apr=/usr/bin/apr-1-config make   make install
3.vim tomcat*/bin/catalina.sh在# ----- Execute The Requested Command -----------------------------------------下加入CATALINA_OPTS="-Djava.library.path=/usr/local/apr/lib"或者export LD_LIBRARY_PATH=/usr/local/apr/lib
4.此次参数为借鉴之前公司性能优化过参数vim tomcat6/conf/server.xml    <Connector            port="8021" protocol="org.apache.coyote.http11.Http11AprProtocol" minSpareThreads="20" maxSpareThreads="100" maxThreads="2000" acceptCount="1000" maxKeepAliveRequests="-1" keepAliveTimeout="5000" enableLookups="false" emptySessionPath="true" compression="on" compressionMinSize="2048" noCompressionUserAgents="gozilla, traviata"        compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain" connectionTimeout="20000"    maxHttpHeaderSize="1048576" />
5.重启tomcat

 

修改 tomcat 为 shudown.sh 关闭 进程

在bin目录下找到下面文件
vim catalina.sh
在RGDIR=`dirname "$PRG"`这一行加入以下内容
if [ -z "$CATALINA_PID" ]; then
CATALINA_PID=$PRGDIR/CATALINA_PID
cat $CATALINA_PID
fi

# stop failed. Shutdown port disabled? Try a normal kill.
if [ $? != 0 ]; then
if [ ! -z "$CATALINA_PID" ]; then
echo "The stop command failed. Attempting to signal the process to stop through OS signal."
kill -15 `cat "$CATALINA_PID"` >/dev/null 2>&1
rm -f "$CATALINA_PID" >/dev/null 2>&1------------------------增加内容
fi
fi

vim shudown.sh
在shutdown.sh文件最后一行
把exec "$PRGDIR"/"$EXECUTABLE" stop "$@"
改为exec "$PRGDIR"/"$EXECUTABLE" stop -force "$@"

 

 

 

 

相关连接:https://www.cnblogs.com/zishengY/p/7101616.html?utm_source=itdadao&utm_medium=referral

  • 我的微信
  • 这是我的微信扫一扫
  • weinxin
  • 我的微信公众号
  • 我的微信公众号扫一扫
  • weinxin
ssh
  • 版权声明:本站原创文章,于2017年10月31日18:12:27,由 发表,共 2593 字。
  • 转载请注明:tomcat 优化 | abyun

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: