You should be able to just uncomment the <Cluster> tag in the Tomcat
/conf/server.xml file. Then, open the ports, and do 1-3 below, and set
up multicast. You need to enable multicast on your network. You need
to do 1-3 on both machines.
Set the multicast address back to what it was, 228.0.0.4. The multicast
address is needed for the multiple machines to communicate and share
session information.
The multicast address is a broadcast address. It is a single address.
All servers on the network will listen for it. You put the
<distributable/> tag in the web.xml of the applications that want to be
clustered.
Run these commands as root.
1. You will need to open the multicast port 45564 for UDP, and the TCP
listen port 4001 for TCP.
2. The network interfaces should be enabled for multicast.
ifconfig eth0 multicast
3. Create a multicast route for each network interface.
route add -host 239.255.0.1 dev eth0
You can check if multicast is working with,
ping 239.255.0.1
You should get multiple responses back.
-----Original Message-----
From: Niki Diulgerov [mailto:[EMAIL PROTECTED]
Sent: Thursday, November 15, 2007 11:08 AM
To: users@tomcat.apache.org
Subject: clustering mode in apache tomcat 5.5.25
Hello friends,
I read a lot in internet, connected to #tomcat irc channel but still no
help (except one user in irc who told me in this mailing list there are
very nice people).
So my problem is that I'm trying to use 2 tomcats in clustering mode.
I installed standard tomcat 5.5.25 downloaded from the official site.
The operating systems are RHEL4 and Open SuSE10.2
I have setenv.sh
JAVA_OPTS="-server -Xms512m -Xmx1024m -XX:PermSize=512m
-XX:MaxPermSize=1024m -XX:+HeapDumpOnOutOfMemoryError"
CATALINA_OPTS="-Dlogs.root=/extranet/logs -Dwas.install.root=/extranet"
JAVA_HOME=/jdk1.5.0_13
ENCODING=utf-8
Java version jdk1.5.0_13 (I tried with java 1.4 and the compat package
for tomcat 5.5.25 but still the same)
I changed only server.xml file on both machines. Here is how it looks
like:
<Server port="8011"
shutdown="SHUTDOWN" >
<GlobalNamingResources>
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and
saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>
<Service name="Catalina">
<Connector port="9012"
protocol="AJP/1.3" />
<Connector port="9013"
maxThreads="100"
minSpareThreads="4"
maxSpareThreads="4"
/>
<Engine name="Catalina"
defaultHost="localhost"
jvmRoute="node01">
<Realm
className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase" />
<Host name="localhost"
appBase="webapps">
<Cluster
className="org.apache.catalina.cluster.tcp.SimpleTcpCluster"
doClusterLog="true"
clusterLogName="clusterlog"
manager.className="org.apache.catalina.cluster.session.DeltaManager"
manager.expireSessionsOnShutdown="false"
manager.notifyListenersOnReplication="false"
manager.notifySessionListenersOnReplication="false"
manager.sendAllSessions="false"
manager.sendAllSessionsSize="500"
manager.sendAllSessionsWaitTime="20">
<Membership
className="org.apache.catalina.cluster.mcast.McastService"
mcastAddr="228.0.0.4"
mcastBindAddress="127.0.0.1"
mcastClusterDomain="d10"
mcastPort="45564"
mcastFrequency="1000"
mcastDropTime="30000"
recoveryCounter="10"
recoveryEnabled="true"
recoverySleepTime="5000"/>
<Receiver
className="org.apache.catalina.cluster.tcp.ReplicationListener"
tcpListenAddress="auto"
tcpListenPort="9015"
tcpSelectorTimeout="100"
tcpThreadCount="6"/>
<Sender
className="org.apache.catalina.cluster.tcp.ReplicationTransmitter"
replicationMode="fastasyncqueue"
recoverTimeout="5000"
recoverCounter="6"
doTransmitterProcessingStats="true"
doProcessingStats="true"
doWaitAckStats="true"
queueTimeWait="true"
queueDoStats="true"
queueCheckLock="true"
ackTimeout="15000"
waitForAck="true"
keepAliveTimeout="80000"
keepAliveMaxRequestCount="-1"/>
<Valve
className="org.apache.catalina.cluster.tcp.ReplicationValve"
filter=".*\.gif;.*\.js;.*\.css;.*\.png;.*\.jpeg;.*\.jpg;.*\.htm;.*\.html
;.*\.txt;"
primaryIndicator="true" />
<Valve
className="org.apache.catalina.cluster.session.JvmRouteBinderValve"
enabled="true" />
<ClusterListener
className="org.apache.catalina.cluster.session.ClusterSessionListener"
/>
<ClusterListener
className="org.apache.catalina.cluster.session.JvmRouteSessionIDBinderLi
stener"
/>
<Deployer
className="org.apache.catalina.cluster.deploy.FarmWarDeployer"
tempDir="${catalina.base}/war-temp"
deployDir="${catalina.base}/war-deploy/"
watchDir="${catalina.base}/war-listen/"
watchEnabled="true"/>
</Cluster>
</Host>
</Engine>
</Service>
</Server>
I changed only mcastBindAddress="127.0.0.1"
on both machines and replaced 127.0.0.1 with the appropriate IP address
of any of these machines.
everything else was the same. (Here I'm not sure if I should use the
same jvmRoute on both machines)
The problem is that in the catalina.out I have
WARNING: Error receiving mcast package (errorCounter=10). Try Recovery!
java.net.SocketTimeoutException: Receive timed out
at java.net.PlainDatagramSocketImpl.receive0(Native Method)
at
java.net.PlainDatagramSocketImpl.receive(PlainDatagramSocketImpl.java:13
6)
at java.net.DatagramSocket.receive(DatagramSocket.java:712)
at
org.apache.catalina.cluster.mcast.McastServiceImpl.receive(McastServiceI
mpl.java:238)
at
org.apache.catalina.cluster.mcast.McastServiceImpl$ReceiverThread.run(Mc
astServiceImpl.java:330)
Nov 15, 2007 5:22:33 PM
org.apache.catalina.cluster.mcast.McastServiceImpl$RecoveryThread run
INFO: Cluster membership, running recovery thread, multicasting is not
functional.
Nov 15, 2007 5:22:33 PM
org.apache.catalina.cluster.mcast.McastServiceImpl$SenderThread run
WARNING: Sender Thread ends with errorCounter=0.
Nov 15, 2007 5:22:34 PM
org.apache.catalina.cluster.mcast.McastServiceImpl$ReceiverThread run
WARNING: Receiver Thread ends with errorCounter=1.
Nov 15, 2007 5:22:35 PM
org.apache.catalina.cluster.mcast.McastServiceImpl setupSocket
INFO: Setting multihome multicast interface to:/192.9.202.166
Nov 15, 2007 5:22:35 PM
org.apache.catalina.cluster.mcast.McastServiceImpl setupSocket
INFO: Setting cluster mcast soTimeout to 1000
Nov 15, 2007 5:22:35 PM
org.apache.catalina.cluster.mcast.McastServiceImpl$RecoveryThread run
INFO: Membership recovery was successful.
Nov 15, 2007 5:22:43 PM org.apache.catalina.cluster.deploy.WarWatcher
check
INFO: check cluster wars at /extranet/tomcat/war-listen
Nov 15, 2007 5:22:55 PM
org.apache.catalina.cluster.mcast.McastServiceImpl$ReceiverThread run
WARNING: Error receiving mcast package (errorCounter=10). Try Recovery!
java.net.SocketTimeoutException: Receive timed out
at java.net.PlainDatagramSocketImpl.receive0(Native Method)
at
java.net.PlainDatagramSocketImpl.receive(PlainDatagramSocketImpl.java:13
6)
at java.net.DatagramSocket.receive(DatagramSocket.java:712)
at
org.apache.catalina.cluster.mcast.McastServiceImpl.receive(McastServiceI
mpl.java:238)
at
org.apache.catalina.cluster.mcast.McastServiceImpl$ReceiverThread.run(Mc
astServiceImpl.java:330)
Nov 15, 2007 5:22:55 PM
org.apache.catalina.cluster.mcast.McastServiceImpl$RecoveryThread run
INFO: Cluster membership, running recovery thread, multicasting is not
functional.
Nov 15, 2007 5:22:55 PM
org.apache.catalina.cluster.mcast.McastServiceImpl$SenderThread run
WARNING: Sender Thread ends with errorCounter=0.
Nov 15, 2007 5:22:56 PM
org.apache.catalina.cluster.mcast.McastServiceImpl$ReceiverThread run
WARNING: Receiver Thread ends with errorCounter=1.
Nov 15, 2007 5:22:57 PM
org.apache.catalina.cluster.mcast.McastServiceImpl setupSocket
INFO: Setting multihome multicast interface to:/192.9.202.166
Nov 15, 2007 5:22:57 PM
org.apache.catalina.cluster.mcast.McastServiceImpl setupSocket
INFO: Setting cluster mcast soTimeout to 1000
Nov 15, 2007 5:22:57 PM
org.apache.catalina.cluster.mcast.McastServiceImpl$RecoveryThread run
INFO: Membership recovery was successful.
Nov 15, 2007 5:23:03 PM org.apache.catalina.cluster.deploy.WarWatcher
check
INFO: check cluster wars at /extranet/tomcat/war-listen
Nov 15, 2007 5:23:17 PM
org.apache.catalina.cluster.mcast.McastServiceImpl$ReceiverThread run
Please help.