tomcat多实例方案启动脚本

Posted Assion Yang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了tomcat多实例方案启动脚本相关的知识,希望对你有一定的参考价值。

 

批量启动

#!/bin/sh

BASE_PATH="/usr/local/tomcat8/tomcat-ins/"
bash $BASE_PATH/web1/tomcat.sh start&&
bash $BASE_PATH/web2/tomcat.sh start&&
bash $BASE_PATH/web3/tomcat.sh start

 

批量停止

#!/bin/bash

BASE_PATH="/usr/local/tomcat8/tomcat-ins"

bash $BASE_PATH/web1/tomcat.sh stop&&
bash $BASE_PATH/web2/tomcat.sh stop&&
bash $BASE_PATH/web3/tomcat.sh stop

 

批量重启

#!/bin/sh

BASE_PATH="/usr/local/tomcat8/tomcat-ins/"

bash $BASE_PATH/web1/tomcat.sh restart&&
bash $BASE_PATH/web2/tomcat.sh restart&&
bash $BASE_PATH/web3/tomcat.sh restart

 

单个实例脚本

#!/bin/sh

CUR_PATH=`dirname $0`
export JAVA_HOME="/usr/java/jdk1.8.0_131/"
export CATALINA_BASE="$CUR_PATH"
export CATALINA_HOME="/usr/local/tomcat8"

case $1 in
start)
bash $CATALINA_HOME/bin/startup.sh
;;
stop)
bash $CATALINA_HOME/bin/shutdown.sh
;;
restart)
bash $CATALINA_HOME/bin/shutdown.sh&&
bash $CATALINA_HOME/bin/startup.sh
;;
*)
echo"usage : $0 { start | stop | restart }"
;;
esac

 

服务脚本


#!/bin/bash
#
# kenny [email protected]
# /etc/rc.d/init.d/tomcat
# init script for tomcat precesses
#
# processname: tomcat
# description: tomcat is a j2se server
# chkconfig: 2345 86 16
# description: Start up the Tomcat servlet engine.

if [ -f /etc/init.d/functions ]; then
. /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
else
echo -e "/atomcat: unable to locate functions lib. Cannot continue."
exit -1
fi

RETVAL=$?
CATALINA_HOME="/usr/local/tomcat8"

case "$1" in
start)
if [ -f $CATALINA_HOME/bin/start.sh ];
then
echo $"Starting Tomcat"
$CATALINA_HOME/bin/start.sh
fi
;;
stop)
if [ -f $CATALINA_HOME/bin/stop.sh ];
then
echo $"Stopping Tomcat"
$CATALINA_HOME/bin/stop.sh
fi
;;
*)
echo $"Usage: $0 {start|stop}"
exit 1
;;
esac

exit $RETVAL

单个实例server.xml配置

 

以上是关于tomcat多实例方案启动脚本的主要内容,如果未能解决你的问题,请参考以下文章

Web服务器群集——TOMCAT单机多实例配置

SHELL小练习

MySQL 多实例启动脚本

Linux下Tomcat多实例部署配置

多实例MySQL启动脚本

多实例MySQL启动脚本