1

I have 9 tomcat instances (fronted with apache and mod_jk) on a box which start with /etc/init.d/tomcatX scripts (where X is a [1-9] number). These scripts are simple:

#!/bin/sh
### BEGIN INIT INFO
# Required-Start: mysql
### END INIT INFO

case "$1" in
'start')
        /usr/local/tomcat5/bin/startup.sh
        touch /var/lock/subsys/tomcat5
        ;;
'stop')
        /usr/local/tomcat5/bin/shutdown.sh
        rm -f /var/lock/subsys/tomcat5
        ;;
*)
        echo "Usage: $0 { start | stop }"
        ;;
esac
exit 0

These services start on server reboot:

> chkconfig -l
...
tomcat1                   0:off  1:off  2:off  3:on   4:off  5:on   6:off
tomcat2                   0:off  1:off  2:off  3:on   4:off  5:on   6:off
tomcat3                   0:off  1:off  2:off  3:on   4:off  5:on   6:off
tomcat4                   0:off  1:off  2:off  3:on   4:off  5:on   6:off
tomcat5                   0:off  1:off  2:off  3:on   4:off  5:on   6:off
tomcat6                   0:off  1:off  2:off  3:on   4:off  5:on   6:off
tomcat7                   0:off  1:off  2:off  3:on   4:off  5:on   6:off
tomcat8                   0:off  1:off  2:off  3:on   4:off  5:on   6:off
tomcat9                   0:off  1:off  2:off  3:on   4:off  5:on   6:off

The problem is that sometimes (which is pretty rare, random and non reproducible) one of the tomcats will not start because its AJP port will already be occupied:

May 27, 2012 2:08:16 PM org.apache.jk.common.ChannelSocket init
INFO: Port busy 8015 java.net.BindException: Address already in use
May 27, 2012 2:08:16 PM org.apache.jk.common.ChannelSocket init
SEVERE: Can't find free port 8015 8015

So it'll continue the startup process and start all of its webapps but unfortunatelly they'll never be able to receive any http request.

The relevant configuration is:

<Connector port="8015" protocol="AJP/1.3" ... />

What could be the cause? There isn't anything else listening to 8015.

1 Answer 1

0

I hope that you are using unique port number in the ajp port for each of the 9 tomcat instances. I mean this:

<Connector port="abcd" protocol="AJP/1.3" ... />

I mean the abcd is different for each of the 9 tomcat instances. it might also be because some other program is using the port. Most likely you might be using database in your app which might be holding the port. I mean the client side of the db. You can see which program is holding the port through netstat or ss. Do the following as privileged user to see which program is holding the port:

sudo netstat -antp| grep <port number reported in use>

In the output you would see the pid (process id). Then do the following

ps -ef| grep <pid from above>

The same thing can be done with ss command also, which they say is more efficient. Google or the man pages to see how to get the same thing with ss. It is very simple to use ss.

1
  • Yes of course. Ports 8011 to 8019. This setup has been up and running for years.
    – cherouvim
    May 28, 2012 at 6:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .