码迷,mamicode.com
首页 > 其他好文 > 详细

tomcat7 cpu 占用率过高调整

时间:2015-01-28 19:58:32      阅读:321      评论:0      收藏:0      [点我收藏+]

标签:

启动脚本将JAVA_OPTS参数设置:

vi  /etc/rc.d/init.d/tomcat

#!/bin/bash
# chkconfig: 2345 10 90
# description: Starts and Stops the Tomcat daemon.
 
export CATALINA_HOME=/usr/local/tomcat/apache-tomcat-7.0.53
export JAVA_HOME=/usr/java/jdk1.7.0_55
export JAVA_OPTS="-server   -Dfile.encoding=UTF-8   -Dcatalina.logbase=/home/webapp/logs/tomcat7   -Dnet.sf.ehcache.skipUpdateCheck=true   -XX:+DoEscapeAnalysis   -XX:+UseConcMarkSweepGC   -XX:+CMSClassUnloadingEnabled   -XX:+UseParNewGC   -XX:MaxPermSize=512m   -Xms1024m -Xmx2048m"
export PATH=$JAVA_HOME/bin:$PATH

TOMCAT_START=$CATALINA_HOME/bin/startup.sh 
TOMCAT_STOP=$CATALINA_HOME/bin/shutdown.sh 
 
# source function library. 
. /etc/rc.d/init.d/functions 
# check that networking is up. 
[ "${NETWORKING}" = "no" ] && exit 0 
# check for tomcat script 
if [ ! -f $CATALINA_HOME/bin/catalina.sh ]; then
         echo "Tomcat not valilable..." 
        exit 
fi 
start(){ 
        echo -n "Starting Tomcat: " 
        daemon $TOMCAT_START 
        echo 
        touch /var/lock/subsys/tomcat 
} 
stop(){ 
        ps ax --width=1000 | grep "[o]rg.apache.catalina.startup.Bootstrap start" | awk ‘{printf $1 " "}‘  | wc | awk ‘{print $2}‘ > /tmp/tomcat_process_count.txt 
        read line < /tmp/tomcat_process_count.txt 
        if [ $line -gt 0 ]; then 
                echo -n "tomcat ( pid " 
                ps ax --width=1000 | grep "org.apache.catalina.startup.Bootstrap start" | awk ‘{printf $1 " "}‘ 
                echo -n ") is running..." 
                echo 
                 
                echo -n $"Shutting down Tomcat: " 
                daemon $TOMCAT_STOP 
                rm -f /var/lock/subsys/tomcat.pid echo 
        else 
                echo "Tomcat is stopped" 
        fi 
         
         
} 
restart(){ 
        stop 
        start 
} 
status(){ 
        ps ax --width=1000 | grep "[o]rg.apache.catalina.startup.Bootstrap start" | awk ‘{printf $1 " "}‘  | wc | awk ‘{print $2}‘ > /tmp/tomcat_process_count.txt 
        read line < /tmp/tomcat_process_count.txt 
        if [ $line -gt 0 ]; then 
                echo -n "tomcat ( pid " 
                ps ax --width=1000 | grep "org.apache.catalina.startup.Bootstrap start" | awk ‘{printf $1 " "}‘ 
                echo -n ") is running..." 
                echo 
        else 
                echo "Tomcat is stopped" 
        fi 
} 
case "$1" in 
        start) 
                start ;; 
        stop) 
                stop ;; 
        restart) 
                stop 
                sleep 3 
                start ;; 
        status) 
                status ;; 
        *) 
                echo "Usage: tomcatd {start|stop|restart|status}" 
                exit 1 
esac 
exit 0


tomcat7 cpu 占用率过高调整

标签:

原文地址:http://my.oschina.net/u/221951/blog/372863

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!