I have setup apache-tomcat clustering(Ubuntu Server) and I used tomcat supported clustering technique with mod_jk following the link. I've setup with One Load Balancer and Two web servers.
The major problem is deploying the WAR file and to which web server?. I got to know about Farmed Deployment which deploys war file to other tomcat servers in the cluster but I haven't got it working yet. I used the farm deployer in the below fashion in the element on two of the web servers.
Web Server 1(192.168.1.101)
<Deployer className="org.apache.catalina.ha.deploy.FarmWarDeployer"
tempDir="/usr/share/tomcat/temp/"
deployDir="/usr/share/tomcat/webapps/"
watchDir="/usr/share/tomcat/watch/"
watchEnabled="true"/>
Web Server 2(192.168.1.102)
<Deployer className="org.apache.catalina.ha.deploy.FarmWarDeployer"
tempDir="/usr/share/tomcat/temp/"
deployDir="/usr/share/tomcat/webapps/"
watchDir="/usr/share/tomcat/webapps/"
watchEnabled="false"/>
I placed the WAR in watch directory on web server 1 but it's not deploying to other server. Anybody got this working, Any thing I'm doing wrong?, please let me know!.
Thank you!
Update:1
I could see the following info in either of the machines in catalina.out logs,
14 Aug, 2011 9:12:11 PM org.apache.catalina.ha.deploy.FarmWarDeployer start
SEVERE: FarmWarDeployer can only work as host cluster subelement!
It don't even deploy to webserver1 and also not to webserver2. Getting 404 error when accessed the site. Any more help…?. One more thing, I didn't install tomcat from apt repository but I built it from source which is working perfectly for the our java apps.
Best Answer
The first location you should take a look at is
catalina.out
, it will tell you what might be wrong.If you can't make it works with multicast, just try static membership (I think it will simpler).
Below is my config:
Put the
<Cluster
node inside the<Host
element:address
attribute in<Receiver
element is the node1's IP address. (in your case is .101)port
is listening for replication messages on node 1 (4000-4100)Member's port
in<Interceptor
is listening for cluster messages on node 2Member's host
is the IP address of node 2 (.102)server.xml
on the node 2:Make sure that Tomcat can write to
tempDir
andwatchDir
folder:If you don't do this, you will get the below error:
Remember to add
<distributable/>
intowebapps/ROOT/WEB-INF/web.xml
:Whenever you copy a
.war
file intowatchdir
folder on node 1, you will see something like the following incatalina.out
:and on the node 2:
Good luck!