화요일, 12월 10, 2024
HomeLinuxUbuntu Tomcat Multi Instance

Ubuntu Tomcat Multi Instance

Ubuntu Tomcat Multi Instance

1.tomcat download
http://mirror.apache-kr.org/tomcat/tomcat-7/v7.0.70/bin/apache-tomcat-7.0.70.tar.gz

mkdir -p /server
cd /server
wget http://mirror.apache-kr.org/tomcat/tomcat-7/v7.0.70/bin/apache-tomcat-7.0.70.tar.gz

2.tomcat 압축해제

tar xf apache-tomcat-7.0.70.tar.gz

3.link file 생성

ln -s apache-tomcat-7.0.70 tomcat

4.multi instance direcroty 생성

mkdir -p instance/instance1
mkdir -p instance/instance2

5.multi instance tomcat 필수 direcroty copy

cp -R tomcat/conf tomcat/logs tomcat/temp tomcat/webapps tomcat/work instance/instance1
cp -R tomcat/conf tomcat/logs tomcat/temp tomcat/webapps tomcat/work instance/instance2

6.multi instance tomcat bin direcroty 생성및 스크립트 생성

mkdir -p instance/instance1/bin
mkdir -p instance/instance2/bin

touch instance/instance1/bin/start.sh
touch instance/instance1/bin/stop.sh

touch instance/instance2/bin/start.sh
touch instance/instance2/bin/stop.sh

chmod 755 instance/instance1/bin/start.sh
chmod 755 instance/instance1/bin/stop.sh

chmod 755 instance/instance2/bin/start.sh
chmod 755 instance/instance2/bin/stop.sh

echo '#!/bin/sh' >> instance/instance1/bin/start.sh
 
echo 'export INSTANCE_NAME=instance1' >> instance/instance1/bin/start.sh
echo 'export CATALINA_HOME=/server/tomcat' >> instance/instance1/bin/start.sh
echo 'export CATALINA_BASE=/server/instance/$INSTANCE_NAME' >> instance/instance1/bin/start.sh
echo 'export CATALINA_PID=/server/instance/$INSTANCE_NAME/bin/tomcat.pid' >> instance/instance1/bin/start.sh
echo 'export CATALINA_OPTS="-Denv=product -Denv.servername=instance1"' >> instance/instance1/bin/start.sh

echo '$CATALINA_HOME/bin/startup.sh' >> instance/instance1/bin/start.sh


echo '#!/bin/sh' >> instance/instance1/bin/stop.sh
 
echo 'export INSTANCE_NAME=instance1' >> instance/instance1/bin/stop.sh
echo 'export CATALINA_HOME=/server/tomcat' >> instance/instance1/bin/stop.sh
echo 'export CATALINA_BASE=/server/instance/$INSTANCE_NAME' >> instance/instance1/bin/stop.sh
echo 'export CATALINA_PID=/server/instance/$INSTANCE_NAME/bin/tomcat.pid' >> instance/instance1/bin/stop.sh
 
echo '$CATALINA_HOME/bin/shutdown.sh' >> instance/instance1/bin/stop.sh

echo '#!/bin/sh' >> instance/instance2/bin/start.sh
 
echo 'export INSTANCE_NAME=instance2' >> instance/instance2/bin/start.sh
echo 'export CATALINA_HOME=/server/tomcat' >> instance/instance2/bin/start.sh
echo 'export CATALINA_BASE=/server/instance/$INSTANCE_NAME' >> instance/instance2/bin/start.sh
echo 'export CATALINA_PID=/server/instance/$INSTANCE_NAME/bin/tomcat.pid' >> instance/instance2/bin/start.sh
echo 'export CATALINA_OPTS="-Denv=product -Denv.servername=instance2"' >> instance/instance2/bin/start.sh
 
echo '$CATALINA_HOME/bin/startup.sh' >> instance/instance2/bin/start.sh


echo '#!/bin/sh' >> instance/instance2/bin/stop.sh
 
echo 'export INSTANCE_NAME=instance2' >> instance/instance2/bin/stop.sh
echo 'export CATALINA_HOME=/server/tomcat' >> instance/instance2/bin/stop.sh
echo 'export CATALINA_BASE=/server/instance/$INSTANCE_NAME' >> instance/instance2/bin/stop.sh
echo 'export CATALINA_PID=/server/instance/$INSTANCE_NAME/bin/tomcat.pid' >> instance/instance2/bin/stop.sh
 
echo '$CATALINA_HOME/bin/shutdown.sh' >> instance/instance2/bin/stop.sh

7.server.xml 수정

sed -i 's/port=\"8005\"/port=\"18005\"/g' instance/instance1/conf/server.xml
sed -i 's/port=\"8080\"/port=\"18080\"/g' instance/instance1/conf/server.xml
sed -i 's/port=\"8009\"/port=\"18009\"/g' instance/instance1/conf/server.xml
sed -i 's/redirectPort=\"8443\"/redirectPort=\"18443\"/g' instance/instance1/conf/server.xml


sed -i 's/port=\"8005\"/port=\"28005\"/g' instance/instance2/conf/server.xml
sed -i 's/port=\"8080\"/port=\"28080\"/g' instance/instance2/conf/server.xml
sed -i 's/port=\"8009\"/port=\"28009\"/g' instance/instance2/conf/server.xml
sed -i 's/redirectPort=\"8443\"/redirectPort=\"28443\"/g' instance/instance2/conf/server.xml

8.tomcat server start

/server/instance/instance1/bin/start.sh
/server/instance/instance2/bin/start.sh
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular