Tomcat Cluster"

From Documentation
 
(7 intermediate revisions by 4 users not shown)
Line 2: Line 2:
  
 
= Setup Tomcat Cluster environment =
 
= Setup Tomcat Cluster environment =
*Refer to [http://tomcat.apache.org/tomcat-7.0-doc/cluster-howto.html Tomcat Document] to set up cluster environment.
+
*Please refer to [http://tomcat.apache.org/tomcat-7.0-doc/cluster-howto.html Tomcat Document] to set up cluster environment.
 
*For configuring with Apache http server, refer to
 
*For configuring with Apache http server, refer to
 
**[[Small_Talks/2007/April/How_to_Run_ZK_on_Apache_+_Tomcat_clustering,_Part_I | How to Run ZK on Apache + Tomcat clustering, Part I]]
 
**[[Small_Talks/2007/April/How_to_Run_ZK_on_Apache_+_Tomcat_clustering,_Part_I | How to Run ZK on Apache + Tomcat clustering, Part I]]
Line 8: Line 8:
  
 
== Using more than 3 nodes with ZK ==
 
== Using more than 3 nodes with ZK ==
* Using DeltaManager instead of BackupManager, refer to [http://tomcat.apache.org/tomcat-7.0-doc/config/cluster-manager.html cluster-manager] for more information.
+
* Use DeltaManager instead of BackupManager, please refer to [http://tomcat.apache.org/tomcat-7.0-doc/config/cluster-manager.html cluster-manager] for more information.
  
 
== Sample of server.xml ==
 
== Sample of server.xml ==
<source lang="xml" high="14">
+
<source lang="xml" highlight="14">
 
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster" channelSendOptions="6">
 
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster" channelSendOptions="6">
 
     <Manager className="org.apache.catalina.ha.session.DeltaManager"
 
     <Manager className="org.apache.catalina.ha.session.DeltaManager"
Line 47: Line 47:
 
</Cluster>
 
</Cluster>
 
</source>
 
</source>
'''Note''', if there are multiple tomcat nodes on one machine, the ''Receiver'' port (line 14) should be different.
+
'''Note''', if there are multiple tomcat nodes on one machine, the ''Receiver'' port (line 14) should be different for each of them.
  
 
= Additional setting in ZK project =
 
= Additional setting in ZK project =
You have to configure the following settings to make ZK project work in tomcat cluster environment.
+
You have to configure the following settings to make ZK project work in a tomcat cluster environment.
  
 
== web.xml ==
 
== web.xml ==
*Add the <tt>distributable</tt> element in <tt>WEB-INF/web.xml</tt>.
+
*Add the <code>distributable</code> element in <code>WEB-INF/web.xml</code>.
<source lang="xml" high="7">
+
<source lang="xml" highlight="7">
 
<?xml version="1.0"?>
 
<?xml version="1.0"?>
 
<web-app  xmlns="http://java.sun.com/xml/ns/javaee"
 
<web-app  xmlns="http://java.sun.com/xml/ns/javaee"
Line 67: Line 67:
  
 
== zk.xml ==
 
== zk.xml ==
*Turn on Serializable UI Factory for ZK, please refer to this [[ZK_Developer's_Reference/Clustering/ZK_Configuration | documentation]].
+
 
*If Tomcat cluster nodes is large than 3, also need to add cluster session patch.
+
<source lang="xml" line highlight="3, 7">
For example,
 
<source lang="xml">
 
 
<zk>
 
<zk>
 
     <system-config>
 
     <system-config>
Line 81: Line 79:
 
</zk>
 
</zk>
 
</source>
 
</source>
 +
* Line 3, turn on Serializable UI Factory for ZK, please refer to this [[ZK_Developer's_Reference/Clustering/ZK_Configuration | ZK Configuration]].
 +
* Line 7, if there are more than three Tomcat cluster nodes, or you are using a different cluster-manager such as [https://hazelcast.com/ Hazelcast] and other solutions instead, you also need to add the cluster session patch settings.
  
 
= Version History =
 
= Version History =
 
{{LastUpdated}}
 
{{LastUpdated}}
 
{{ZKInstallationGuidePageFooter}}
 
{{ZKInstallationGuidePageFooter}}

Latest revision as of 04:48, 27 April 2022


Setup Tomcat Cluster environment

Using more than 3 nodes with ZK

  • Use DeltaManager instead of BackupManager, please refer to cluster-manager for more information.

Sample of server.xml

<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster" channelSendOptions="6">
    <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="5001"
            selectorTimeout="100"
            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"/>
        <Interceptor className="org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor"/>
    </Channel>

    <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.JvmRouteSessionIDBinderListener"/>    
    <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>
</Cluster>

Note, if there are multiple tomcat nodes on one machine, the Receiver port (line 14) should be different for each of them.

Additional setting in ZK project

You have to configure the following settings to make ZK project work in a tomcat cluster environment.

web.xml

  • Add the distributable element in WEB-INF/web.xml.
<?xml version="1.0"?>
<web-app  xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    version="2.5">

    <distributable/>

</web-app>

zk.xml

1 <zk>
2     <system-config>
3         <ui-factory-class>org.zkoss.zk.ui.http.SerializableUiFactory</ui-factory-class>
4     </system-config>
5     <!-- clustering environment, since ZK 5.0.8-->
6     <listener>
7         <listener-class>org.zkoss.zkplus.cluster.ClusterSessionPatch</listener-class>
8     </listener>
9 </zk>
  • Line 3, turn on Serializable UI Factory for ZK, please refer to this ZK Configuration.
  • Line 7, if there are more than three Tomcat cluster nodes, or you are using a different cluster-manager such as Hazelcast and other solutions instead, you also need to add the cluster session patch settings.

Version History

Last Update : 2022/04/27



Last Update : 2022/04/27

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.