Tuesday, September 8, 2009

Tomcat Automation

I am maintaining multiple tomcat servers and started automating environment as much as I can, like following.

1)Deploying applications to all servers
2)starting all tomcat servers
3) stoping all tomcat servers
4) checking the status of all tomcat servers.

As you know, Deploying war files across multiple servers consistently, is as much as difficult as
maintaining an unruly class room. Tomcat doesn't provide any means of distributed mechanism like websphere and weblogic application servers. So I am forced to use all unix commands.

One way to deploy application to all servers is, to deploy the application on one server and push same to all servers using rsync.

#!/bin/ksh
###
##
# rsync between host1 and host2 for only
##
###
echo "-------------------`date`----------------" >>/tmp/rsync.log
rsync -gloprtuv -e ssh --stats /usr/tomcat/webapps/ host2:/usr/tomcat/webapps 2>&1 >>/tmp/rsync.log

don't forget to enable password less logins between host1 and host2 by exchanging authorized keys.


2)starting/stoping all tomcat servers

to start and stop either you could do regular scripting "for host in host1,host2....do stopserver.sh
done" or dsh

dsh makes your script simple and easy.

export DSH_NODE_RSH=/usr/bin/ssh
export DSH_NODE_LIST=/usr/tomcatadm/nodes
dsh /usr/tomcat/bin/startup.sh
dsh /usr/tomcat/bin/shutdown.sh

No comments:

Post a Comment