Activities

July 2008
M T W T F S S
« Jun   Aug »
 123456
78910111213
14151617181920
21222324252627
28293031  

How to run mulitple Tomcat instance on the same server

I am listing the steps to  archive the goal

1, Step 1: Install the Tomcat files

2, Make directories for each instance

3. Editing the server.xml

Tomcat  using  2 major port one for listening http request and another for listening shutdown port

in here i put tomcat installation on /usr/local/tomcat5.5.9 folder

now I am going to edit server.xml inside the conf folder

vi /usr/local/tomcat5.5.9 folder/conf/server.xml

Find the entry

a, <Server port=”8001″ shutdown=”SHUTDOWN”> and changed the server port to any unused port

b, <!– Define a non-SSL HTTP/1.1 Connector on port 8080 –>
<Connector port=”9000″ maxHttpHeaderSize=”8192″  Change the Connector port to any unused port which tomcat listen

Again  restart the tomcat and check the that it is listening in the connector port by

!, telnet localhost   <connector port >  if it is opend a blank window it work

2, exicute $ netstat -nlp| grep  :”<connector port> .If it shows any result it’s working

Now you can start to depoly  the website.

I recommended that always to use tomcat as a backend server for Apache. You can use proxy pass module for  this functionality in apache. It also included in my previous  blog in Apache category.

################ Tomcat start up scripts ###########

# This is the init script for starting up the
#  Jakarta Tomcat server
#
# chkconfig: 345 91 10
# description: Starts and stops the Tomcat daemon.
#

# Source function library.
. /etc/rc.d/init.d/functions

# Get config.
. /etc/sysconfig/network

# Check that networking is up.
[ “${NETWORKING}” = “no” ] && exit 0

tomcat=/usr/local/jakarta-tomcat-5.5.9
startup=$tomcat/bin/startup.sh
shutdown=$tomcat/bin/shutdown.sh
export JAVA_HOME=/usr/java/jdk1.5.0_06

start(){
echo -n $”Starting Tomcat service: ”
#daemon -c
$startup
RETVAL=$?
echo
}

stop(){
action $”Stopping Tomcat service: ” $shutdown
RETVAL=$?
echo
}

restart(){
stop
start
}

# See how we were called.
case “$1″ in
start)
start
;;
stop)
stop
;;
status)
# This doesn’t work 😉
status tomcat
;;
restart)
restart
;;
*)
echo $”Usage: $0 {start|stop|status|restart}”
exit 1
esac

exit 0
####### end of scripts ########
How to   use this scripts

1, open in any editor and  change the path of java and  Tomcat install location

2, Move the scripts to the /etc/init.d

3, Give execute permission to the scripts, #chmod  755 /etc/init.d/tomcatd  and then execute the scripts for the testing. Eg: # ./etc/init.d/tomcat start

4, Setting runlevel and added it to system service list by # chkconfig –add /etc/init.d/tomcatd

5. Setting the tomcat  should be run at start up by #chkconfig tomcatd   on

That’s it

Liju

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>