Tomcat JVM参数配置和自启动配置
在【#!/bin/sh】下面添加以下内容:
#vi catalina.sh
exportJAVA_OPTS="-server -Xms2048m -Xmx2048m -Xss1024K -XX:PermSize=512m -XX:MaxPermSize=512m"
exportJAVA_OPTS="-server -Xms2048m -Xmx2048m -Xss1024K -XX:PermSize=512m -XX:MaxPermSize=512m"
#自启动脚本
vi /etc/init.d/tomcat
#!/bin/bash
#chkconfig:2345 20 90
#description:tomcat
#processname:tomcat
TOMCAT_HOME=/opt/tomcat
JAVA_HOME=/usr/java/jdk1.7.0_71
RETVAL=0
checkjava(){
if [ -z "$JAVA_HOME" ]; then
export JAVA_HOME=/usr/java/jdk1.7.0_71
fi
echo $JAVA_HOME
}
start(){
checkjava
checkrun
if [ $RETVAL -eq 0 ]; then
echo "Starting tomcat"
su - root -c "$TOMCAT_HOME/bin/startup.sh start"
touch /var/lock/subsys/tomcat
else
echo "tomcat allready running"
fi
}
stop(){
checkjava
checkrun
if [ $RETVAL -eq 1 ]; then
echo "Shutting down tomcat"
su - root -c "$TOMCAT_HOME/bin/shutdown.sh"
rm -f /var/lock/subsys/tomcat
else
echo "Tomcat is stoped"
fi
checkrun
}
restart(){
stop
start
}
checkrun(){
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
RETVAL=1
return $RETVAL
else
RETVAL=0
return $RETVAL
fi
}
status(){
checkrun
if [ $RETVAL -eq 1 ]; 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
echo "check Tomcat status end."
}
case $1 in
start)
#su - root /opt/tomcat/bin/startup.sh start;;
start;;
stop)
stop;;
restart)
restart;;
status)
status;;
*)echo "require start|restart|stop|status" ;;
esac
--修改为可执行文件
chmod +x /etc/init.d/tomcat
--添加服务
chkconfig --add tomcat
--开启自动
chkconfig tomcat on
chkconfig tomcat on
--查看是否添加成功
chkconfig --list|grep tomcat
--启动
service tomcat start
--停止
service tomcat stop
--重启
service tomcat restart
--检看状态
service tomcat status