For the impatient

Simply add

<Cluster className=”org.apache.catalina.ha.tcp.SimpleTcpCluster”/>

to your <Engine> or your <Host> element to enable clustering.

Using the above configuration will enable all-to-all session replication using the DeltaManager to replicate session deltas. By all-to-all we mean that the session gets replicated to all the other nodes in the cluster. This works great for smaller cluster but we don’t recommend it for larger clusters(a lot of Tomcat nodes). Also when using the delta manager it will replicate to all nodes, even nodes that don’t have the application deployed.

To get around this problem, you’ll want to use the BackupManager. This manager only replicates the session data to one backup node, and only to nodes that have the application deployed. Downside of the BackupManager: not quite as battle tested as the delta manager.

Here are some of the important default values:

  • Multicast address is 228.0.0.4
  • Multicast port is 45564 (the port and the address together determine cluster membership.
  • The IP broadcasted is java.net.InetAddress.getLocalHost().getHostAddress() (make sure you don’t broadcast 127.0.0.1, this is a common error)
  • The TCP port listening for replication messages is the first available server socket in range 4000-4100
  • Two listeners are configured ClusterSessionListener
  • Two interceptors are configured TcpFailureDetector and MessageDispatch15Interceptor

 

The following is the default cluster configuration:

<Cluster className=”org.apache.catalina.ha.tcp.SimpleTcpCluster”

channelSendOptions=”8″>

 

<Manager className=”org.apache.catalina.ha.session.DeltaManager”

expireSessionsOnShutdown=”false”

notifyListenersOnReplication=”true”/>

 

<Channel className=”org.apache.catalina.tribes.group.GroupChannel”>

<Membership className=”org.apache.catalina.tribes.membership.McastService”

address=”228.0.0.4″

port=”45564″

frequency=”500″

dropTime=”3000″/>

<Receiver className=”org.apache.catalina.tribes.transport.nio.NioReceiver”

address=”auto”

port=”4000″

autoBind=”100″

selectorTimeout=”5000″

maxThreads=”6″/>

 

<Sender className=”org.apache.catalina.tribes.transport.ReplicationTransmitter”>

<Transport className=”org.apache.catalina.tribes.transport.nio.PooledParallelSender”/>

</Sender>

<Interceptor

 

className=”org.apache.catalina.tribes.group.interceptors.TcpFailureDetector”/>

<Interceptor className=”org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor”/>

</Channel>

 

<Valve className=”org.apache.catalina.ha.tcp.ReplicationValve”

filter=””/>

<Valve className=”org.apache.catalina.ha.session.JvmRouteBinderValve”/>

 

<Deployer className=”org.apache.catalina.ha.deploy.FarmWarDeployer”

tempDir=”/tmp/war-temp/”

deployDir=”/tmp/war-deploy/”

watchDir=”/tmp/war-listen/”

watchEnabled=”false”/>

 

<ClusterListener className=”org.apache.catalina.ha.session.ClusterSessionListener”/>

</Cluster>

 

Will cover this section in more detail later in this document.

Share this post
[social_warfare]
Users and Authentication
Cluster Basics

Get industry recognized certification – Contact us

keyboard_arrow_up