geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Geronimo v2.2 > Tomcat Native Clustering
Date Mon, 23 Nov 2009 05:11:00 GMT
<html>
<head>
    <base href="http://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1519/1/1/_/styles/combined.css?spaceKey=GMOxDOC22&amp;forWysiwyg=true" type="text/css">
    </head>
<body style="background-color: white" bgcolor="white">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
     <h2><a href="http://cwiki.apache.org/confluence/display/GMOxDOC22/Tomcat+Native+Clustering">Tomcat Native Clustering</a></h2>
     <h4>Page <b>edited</b> by             <a href="http://cwiki.apache.org/confluence/display/~chirunhua@gmail.com">Runhua Chi</a>
    </h4>
     
          <br/>
     <div class="notificationGreySide">
         <style type='text/css'>/*<![CDATA[*/
table.ScrollbarTable  {border: none;padding: 3px;width: 100%;padding: 3px;margin: 0px;background-color: #f0f0f0}
table.ScrollbarTable td.ScrollbarPrevIcon {text-align: center;width: 16px;border: none;}
table.ScrollbarTable td.ScrollbarPrevName {text-align: left;border: none;}
table.ScrollbarTable td.ScrollbarParent {text-align: center;border: none;}
table.ScrollbarTable td.ScrollbarNextName {text-align: right;border: none;}
table.ScrollbarTable td.ScrollbarNextIcon {text-align: center;width: 16px;border: none;}

/*]]>*/</style><div class="Scrollbar"><table class='ScrollbarTable'><tr><td class='ScrollbarPrevIcon'><a href="/confluence/display/GMOxDOC22/Plugin+based+Farming"><img border='0' align='middle' src='/confluence/images/icons/back_16.gif' width='16' height='16'></a></td><td width='33%' class='ScrollbarPrevName'><a href="/confluence/display/GMOxDOC22/Plugin+based+Farming">Plugin based Farming</a>&nbsp;</td><td width='33%' class='ScrollbarParent'><sup><a href="/confluence/display/GMOxDOC22/Clustering+and+farming"><img border='0' align='middle' src='/confluence/images/icons/up_16.gif' width='8' height='8'></a></sup><a href="/confluence/display/GMOxDOC22/Clustering+and+farming">Clustering and farming</a></td><td width='33%' class='ScrollbarNextName'>&nbsp;<a href="/confluence/display/GMOxDOC22/WADI+Clustering">WADI Clustering</a></td><td class='ScrollbarNextIcon'><a href="/confluence/display/GMOxDOC22/WADI+Clustering"><img border='0' align='middle' src='/confluence/images/icons/forwd_16.gif' width='16' height='16'></a></td></tr></table></div>

<p>The tomcat web container provides a native clustering solution that can be configured through geronimo using gbean definitions within config.xml.  This document will go through the available gbeans and how to configure them for clustering in a geronimo server with a tomcat web container.  Details about each component of the cluster and configuration options can be found in the tomcat documentation here <a href="http://tomcat.apache.org/tomcat-6.0-doc/config/cluster.html" rel="nofollow">http://tomcat.apache.org/tomcat-6.0-doc/config/cluster.html</a></p>

<div>
<ul>
    <li><a href='#TomcatNativeClustering-ClusterConfigurationElements'>Cluster Configuration Elements</a></li>
    <li><a href='#TomcatNativeClustering-SampleClusteringConfigurationwithmulticastconfiguration'>Sample Clustering Configuration with multicast configuration</a></li>
<ul>
    <li><a href='#TomcatNativeClustering-Settingupaclusteringenvironment'>Setting up a clustering environment</a></li>
<ul>
    <li><a href='#TomcatNativeClustering-Planningyourcluster'>Planning your cluster</a></li>
    <li><a href='#TomcatNativeClustering-PreparingyourWebapplication'>Preparing your Web application</a></li>
    <li><a href='#TomcatNativeClustering-Enablingsessionaffinity'>Enabling session affinity</a></li>
    <li><a href='#TomcatNativeClustering-Engagingloadbalancingandfailover'>Engaging load balancing and failover</a></li>
</ul>
    <li><a href='#TomcatNativeClustering-Deployingyourapplicationtoacluster'>Deploying your application to a cluster</a></li>
</ul>
    <li><a href='#TomcatNativeClustering-SampleTomcatClusteringwithUnicastConfiguration'>Sample Tomcat Clustering with Unicast Configuration</a></li>
</ul></div>

<h1><a name="TomcatNativeClustering-ClusterConfigurationElements"></a>Cluster Configuration Elements</h1>

<p>Following are parameters or attributes you will need to configure for a Tomcat native clustering. </p>

<ul>
	<li>Cluster
	<ul>
		<li>ClusterListenerChain</li>
		<li>TomcatValveChain</li>
		<li>Channel
		<ul>
			<li>Membership</li>
			<li>Receiver</li>
			<li>Sender</li>
			<li>ChannelInterceptor
			<ul>
				<li>StaticMember</li>
			</ul>
			</li>
		</ul>
		</li>
		<li>ClusterManager</li>
	</ul>
	</li>
</ul>


<h1><a name="TomcatNativeClustering-SampleClusteringConfigurationwithmulticastconfiguration"></a>Sample Clustering Configuration with multicast configuration</h1>

<p>Although sufficient for many applications, Tomcat clusters have some limitations.</p>
<ul>
	<li>This feature does not replicate stateful session Enterprise JavaBeans (EJBs). You will have to avoid stateful session EJBs in your distributed applications.</li>
	<li>This feature does not replicate dynamic updates to the Java Naming and Directory Interface (JNDI). You will have to configure all the JNDI names used by your distributed applications in every node of the cluster.</li>
	<li>This feature does not replicate distributable Web applications to other nodes in the cluster. You will have to deploy your distributable Web applications to every node.</li>
</ul>


<p>A cluster configuration should be considered when you want to improve the scalability and availability of your Web application. The following sections provide detailed instructions on how to set up your cluster nodes and how to deploy your applications with tomcat clustering enabled.</p>


<h2><a name="TomcatNativeClustering-Settingupaclusteringenvironment"></a>Setting up a clustering environment</h2>
<p>Generally, to set up a small cluster you will need at least 2 nodes and 1 HTTP server.  The HTTP server is used to serve requests from clients and ensure well-balanced traffic load among different nodes. Similarly, each node is configured to use the same logical Tomcat engine and enable session affinity.</p>
<h3><a name="TomcatNativeClustering-Planningyourcluster"></a>Planning your cluster</h3>

<p>The Tomcat cluster replicates HTTP session data via memory to memory multicast communication.</p>

<p>Every node transmits its session data to every node in the cluster. This algorithm is only efficient when the clusters are small. If the clusters grow too large, the overhead in storage utilization and network traffic becomes excessive. To avoid excessive overhead, consider dividing your nodes into several smaller clusters.</p>

<p>HTTP session data is replicated among the nodes in the cluster using a multicast broadcast. All nodes in the cluster must be on the same physical subnet and multicast broadcast must be supported by that subnet.</p>

<h3><a name="TomcatNativeClustering-PreparingyourWebapplication"></a>Preparing your Web application</h3>

<p>To participate in a cluster configuration, your Web application must be implemented correctly.</p>
<ul>
	<li>Ensure that every object placed in the HTTP session implements java.io.Serializable. The clustering feature serializes the objects when it distributes them to the other nodes in the cluster.</li>
	<li>The deployment descriptor for your Web application, that is the <tt>web.xml</tt> file in the Web archive, must indicate that your Web application is distributable. To do this, insert the <b>distributable</b> element in the deployment descriptor.
<div class="code panel" style="border-style: solid;border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;"><b>Excerpt from web.xml</b></div><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;?xml version=<span class="code-quote">"1.0"</span> encoding=<span class="code-quote">"ISO-8859-1"</span>?&gt;</span>
&lt;!DOCTYPE web-app
    PUBLIC <span class="code-quote">"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"</span>
    <span class="code-quote">"http://java.sun.com/dtd/web-app_2_3.dtd"</span>&gt;

<span class="code-tag">&lt;web-app&gt;</span>
    <span class="code-tag">&lt;display-name&gt;</span> ... <span class="code-tag">&lt;/display-name&gt;</span>
    <span class="code-tag">&lt;description&gt;</span> ... <span class="code-tag">&lt;/description&gt;</span>
    <span class="code-tag">&lt;distributable&gt;</span> <span class="code-tag">&lt;distributable/&gt;</span>
    .
    .
    .
<span class="code-tag">&lt;/web-app&gt;</span>
</pre>
</div></div></li>
	<li>Do not use stateful session Enterprise JavaBeans (EJBs). The clustering feature does not replicate stateful EJBs among the nodes in the cluster.</li>
	<li>If your Web application uses a database, make sure the database can be accessed from every node in the cluster. Ensure that the proper JDBC drivers are installed on every node and that the datasource objects are defined correctly on every node.</li>
	<li>Do not depend on dynamic updates to the Java Naming and Directory Interface (JNDI). You will need to configure all the JNDI names used by your application in every node of the cluster. The clustering feature does not replicate JNDI changes among the nodes in the cluster.</li>
</ul>


<h3><a name="TomcatNativeClustering-Enablingsessionaffinity"></a>Enabling session affinity</h3>

<p>Support for <em>session affinity</em>, also known as <em>sticky session</em> support, allows a load balancing service to route an HTTP request back to the same node that created the HTTP session associated with that request until that node fails. You must use session affinity if you configure an asynchronous type of session replication. With asynchronous replication, the reply is returned before the HTTP session is replicated so there is always a chance that the next request using that session arrives before the replication is complete. In this case, the only way to ensure that the request is processed using the correct session data is to route the request to the node that sent the reply to the last request and originated the replication.</p>

<p>In Geronimo v2.2, users can have the same experiences as in Tomcat Web container to configure session affinity. To enable session affinity, you must modify <tt>servel.xml</tt> under <tt>&lt;GERONIMO_HOME&gt;/var/catalina</tt> dirctory and configure the <b>&lt;Engine&gt;</b> with a <b>jvmRoute</b> attribute value that is unique for each node in the cluster. The load balancer will return this value in the session cookie or the encoded URL returned to the browser. When a related request arrives it can use the value to route the request to the correct node. See </p>

<ol>
	<li>For every node in the cluster, update <tt>server.xml</tt> as followed after the server is stopped:
<div class="code panel" style="border-style: solid;border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;"><b>Excerpt from server.xml</b></div><div class="codeContent panelContent">
<pre class="code-xml">
 ...
 <span class="code-tag">&lt;Engine name=<span class="code-quote">"Catalina"</span> defaultHost=<span class="code-quote">"${ServerHostname}"</span> jvmRoute=<span class="code-quote">"nodeId"</span>&gt;</span>
 ...
</pre>
</div></div>
<p>where</p>
	<ul>
		<li><em>nodeId</em> is a node identifier that is unique among all the nodes in the cluster. If you are using mod_jk, make sure that the jvmRoute attribute value matches your worker name in <tt>workers.properties</tt>.</li>
	</ul>
	</li>
	<li>Restart the server to enable the new configuration.</li>
</ol>


<h3><a name="TomcatNativeClustering-Engagingloadbalancingandfailover"></a>Engaging load balancing and failover</h3>

<p>Initially, the server configuration includes an <em>AJP connector</em> suitable for exchanging messages with a load balancing service. See <a href="/confluence/display/GMOxDOC22/Configuring+a+remote+Apache+HTTP+server" title="Configuring a remote Apache HTTP server">Configuring a remote Apache HTTP server</a> for more information about the HTTP server configuration.</p>


<h2><a name="TomcatNativeClustering-Deployingyourapplicationtoacluster"></a>Deploying your application to a cluster</h2>
<p>To deploy your application to a cluster and make sure HTTP sessions are replicated successfully, cluster configuration elements of Tomcat Web containers must be configured using gbean definitions within deployment plans. <br/>
If you want to deploy your Web application to a cluster, install your WAR files to the appropriate cluster member, assuring that you use the correct deployment plan for each member. Here is the template for your Web application deployment plan. See <a href="/confluence/display/GMOxDOC22/Creating+deployment+plans+for+Web+applications" title="Creating deployment plans for Web applications">Creating deployment plans for Web applications</a> for more information about the parameters.</p>
<div class="code panel" style="border-style: solid;border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;"><b>geronimo-web.xml</b></div><div class="codeContent panelContent">
<pre class="code-xml">
&lt;web-app xmlns=<span class="code-quote">"http://geronimo.apache.org/xml/ns/j2ee/web/tomcat-1.2"</span>
         <span class="code-keyword">xmlns:dep</span>=<span class="code-quote">"http://geronimo.apache.org/xml/ns/deployment-1.2"</span>&gt;

    <span class="code-tag">&lt;dep:environment&gt;</span>
      <span class="code-tag">&lt;dep:moduleId&gt;</span>
        <span class="code-tag">&lt;dep:groupId&gt;</span>org.mygroup<span class="code-tag">&lt;/dep:groupId&gt;</span>
        <span class="code-tag">&lt;dep:artifactId&gt;</span>web-cluster-server1<span class="code-tag">&lt;/dep:artifactId&gt;</span>
        <span class="code-tag">&lt;dep:version&gt;</span>2.2<span class="code-tag">&lt;/dep:version&gt;</span>
        <span class="code-tag">&lt;dep:type&gt;</span>war<span class="code-tag">&lt;/dep:type&gt;</span>
      <span class="code-tag">&lt;/dep:moduleId&gt;</span>
      <span class="code-tag">&lt;dep:dependencies&gt;</span>
      	<span class="code-tag">&lt;dep:dependency&gt;</span>
      	<span class="code-tag">&lt;dep:groupId&gt;</span>console.realm<span class="code-tag">&lt;/dep:groupId&gt;</span>
        <span class="code-tag">&lt;dep:artifactId&gt;</span>geronimo-properties-realm<span class="code-tag">&lt;/dep:artifactId&gt;</span>
        <span class="code-tag">&lt;dep:version&gt;</span>1.0<span class="code-tag">&lt;/dep:version&gt;</span>
        <span class="code-tag">&lt;dep:type&gt;</span>car<span class="code-tag">&lt;/dep:type&gt;</span>
        <span class="code-tag">&lt;/dep:dependency&gt;</span>
      <span class="code-tag">&lt;/dep:dependencies&gt;</span>
      <span class="code-tag">&lt;dep:hidden-classes/&gt;</span>
      <span class="code-tag">&lt;dep:non-overridable-classes/&gt;</span>
    <span class="code-tag">&lt;/dep:environment&gt;</span>

    <span class="code-tag">&lt;context-root&gt;</span>/servlet-examples-cluster<span class="code-tag">&lt;/context-root&gt;</span>

    <span class="code-tag">&lt;security-realm-name&gt;</span>geronimo-properties-realm<span class="code-tag">&lt;/security-realm-name&gt;</span>
    <span class="code-tag">&lt;security&gt;</span>
      <span class="code-tag">&lt;default-principal&gt;</span>
        <span class="code-tag">&lt;principal name=<span class="code-quote">"anonymous"</span> class=<span class="code-quote">"org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal"</span>/&gt;</span>
      <span class="code-tag">&lt;/default-principal&gt;</span>
      <span class="code-tag">&lt;role-mappings&gt;</span>
        <span class="code-tag">&lt;role role-name=<span class="code-quote">"tomcat"</span>&gt;</span>
          <span class="code-tag">&lt;principal name=<span class="code-quote">"admin"</span> class=<span class="code-quote">"org.apache.geronimo.security.realm.providers.GeronimoGroupPrincipal"</span>/&gt;</span>
        <span class="code-tag">&lt;/role&gt;</span>
      <span class="code-tag">&lt;/role-mappings&gt;</span>
    <span class="code-tag">&lt;/security&gt;</span>

    <span class="code-tag">&lt;cluster&gt;</span>TomcatCluster<span class="code-tag">&lt;/cluster&gt;</span>
    <span class="code-tag">&lt;gbean class=<span class="code-quote">"org.apache.geronimo.tomcat.cluster.CatalinaClusterGBean"</span> name=<span class="code-quote">"TomcatCluster"</span>&gt;</span>
        <span class="code-tag">&lt;attribute name=<span class="code-quote">"className"</span>&gt;</span>org.apache.catalina.ha.tcp.SimpleTcpCluster<span class="code-tag">&lt;/attribute&gt;</span>
        <span class="code-tag">&lt;attribute name=<span class="code-quote">"initParams"</span>/&gt;</span>
        <span class="code-tag">&lt;reference name=<span class="code-quote">"ClusterManager"</span>&gt;</span>          
            <span class="code-tag">&lt;name&gt;</span>TomcatClusterManager<span class="code-tag">&lt;/name&gt;</span>                
        <span class="code-tag">&lt;/reference&gt;</span>
        <span class="code-tag">&lt;reference name=<span class="code-quote">"TomcatValveChain"</span>&gt;</span>
            <span class="code-tag">&lt;name&gt;</span>ReplicationValve<span class="code-tag">&lt;/name&gt;</span>
        <span class="code-tag">&lt;/reference&gt;</span>
        <span class="code-tag">&lt;reference name=<span class="code-quote">"ClusterListenerChain"</span>&gt;</span>
            <span class="code-tag">&lt;name&gt;</span>ClusterSessionListener<span class="code-tag">&lt;/name&gt;</span>
        <span class="code-tag">&lt;/reference&gt;</span>
        <span class="code-tag">&lt;reference name=<span class="code-quote">"Channel"</span>&gt;</span>
            <span class="code-tag">&lt;name&gt;</span>TomcatGroupChannel<span class="code-tag">&lt;/name&gt;</span>
        <span class="code-tag">&lt;/reference&gt;</span>
    <span class="code-tag">&lt;/gbean&gt;</span>
  <span class="code-tag"><span class="code-comment">&lt;!-- Cluster Manager --&gt;</span></span>
    <span class="code-tag">&lt;gbean name=<span class="code-quote">"TomcatClusterManager"</span> class=<span class="code-quote">"org.apache.geronimo.tomcat.cluster.ClusterManagerGBean"</span>&gt;</span>
        <span class="code-tag">&lt;attribute name=<span class="code-quote">"className"</span>&gt;</span>org.apache.catalina.ha.session.DeltaManager<span class="code-tag">&lt;/attribute&gt;</span>
        <span class="code-tag">&lt;attribute name=<span class="code-quote">"initParams"</span>&gt;</span>name=${clusterName}
           channelSendOptions=6
           expireSessionsOnShutdown=false
           notifyListenersOnReplication=true
           mapSendOptions=6<span class="code-tag">&lt;/attribute&gt;</span>
    <span class="code-tag">&lt;/gbean&gt;</span>
  <span class="code-tag"><span class="code-comment">&lt;!-- Cluster Channel --&gt;</span></span>
    <span class="code-tag">&lt;gbean class=<span class="code-quote">"org.apache.geronimo.tomcat.cluster.ChannelGBean"</span> name=<span class="code-quote">"TomcatGroupChannel"</span>&gt;</span>
        <span class="code-tag">&lt;attribute name=<span class="code-quote">"className"</span>&gt;</span>org.apache.catalina.tribes.group.GroupChannel<span class="code-tag">&lt;/attribute&gt;</span>
        <span class="code-tag">&lt;attribute name=<span class="code-quote">"initParams"</span>/&gt;</span>
        <span class="code-tag">&lt;reference name=<span class="code-quote">"Membership"</span>&gt;</span>
            <span class="code-tag">&lt;name&gt;</span>TomcatMembership<span class="code-tag">&lt;/name&gt;</span>
        <span class="code-tag">&lt;/reference&gt;</span>
        <span class="code-tag">&lt;reference name=<span class="code-quote">"Receiver"</span>&gt;</span>
            <span class="code-tag">&lt;name&gt;</span>TomcatReceiver<span class="code-tag">&lt;/name&gt;</span>
        <span class="code-tag">&lt;/reference&gt;</span>
        <span class="code-tag">&lt;reference name=<span class="code-quote">"Sender"</span>&gt;</span>
            <span class="code-tag">&lt;name&gt;</span>TomcatSender<span class="code-tag">&lt;/name&gt;</span>
        <span class="code-tag">&lt;/reference&gt;</span>
        <span class="code-tag">&lt;reference name=<span class="code-quote">"ChannelInterceptor"</span>&gt;</span>
            <span class="code-tag">&lt;name&gt;</span>TomcatChannelInterceptor<span class="code-tag">&lt;/name&gt;</span>
        <span class="code-tag">&lt;/reference&gt;</span>
    <span class="code-tag">&lt;/gbean&gt;</span>
  <span class="code-tag"><span class="code-comment">&lt;!-- Cluster Membership --&gt;</span></span>
    <span class="code-tag">&lt;gbean class=<span class="code-quote">"org.apache.geronimo.tomcat.cluster.MembershipServiceGBean"</span> name=<span class="code-quote">"TomcatMembership"</span>&gt;</span>
        <span class="code-tag">&lt;attribute name=<span class="code-quote">"className"</span>&gt;</span>org.apache.catalina.tribes.membership.McastService<span class="code-tag">&lt;/attribute&gt;</span>
        <span class="code-tag">&lt;attribute name=<span class="code-quote">"initParams"</span>&gt;</span>
            mcastAddr=228.0.0.4
            mcastPort=45564
            mcastFrequency=500
            mcastDropTime=3000
        <span class="code-tag">&lt;/attribute&gt;</span>
    <span class="code-tag">&lt;/gbean&gt;</span>
  <span class="code-tag"><span class="code-comment">&lt;!-- Cluster Receiver --&gt;</span></span>
    <span class="code-tag">&lt;gbean class=<span class="code-quote">"org.apache.geronimo.tomcat.cluster.ReceiverGBean"</span> name=<span class="code-quote">"TomcatReceiver"</span>&gt;</span>
        <span class="code-tag">&lt;attribute name=<span class="code-quote">"className"</span>&gt;</span>org.apache.catalina.tribes.transport.nio.NioReceiver<span class="code-tag">&lt;/attribute&gt;</span>
        <span class="code-tag">&lt;attribute name=<span class="code-quote">"initParams"</span>&gt;</span>
            tcpListenAddress=auto
            tcpListenPort=4001
            tcpSelectorTimeout=100
            tcpThreadCount=6
        <span class="code-tag">&lt;/attribute&gt;</span>
    <span class="code-tag">&lt;/gbean&gt;</span>
  <span class="code-tag"><span class="code-comment">&lt;!-- Cluster Sender --&gt;</span></span>
    <span class="code-tag">&lt;gbean class=<span class="code-quote">"org.apache.geronimo.tomcat.cluster.SenderGBean"</span> name=<span class="code-quote">"TomcatSender"</span>&gt;</span>
        <span class="code-tag">&lt;attribute name=<span class="code-quote">"className"</span>&gt;</span>org.apache.catalina.tribes.transport.ReplicationTransmitter<span class="code-tag">&lt;/attribute&gt;</span>
        <span class="code-tag">&lt;attribute name=<span class="code-quote">"initParams"</span>&gt;</span>
            replicationMode=pooled
            waitForAck=true
        <span class="code-tag">&lt;/attribute&gt;</span>
    <span class="code-tag">&lt;/gbean&gt;</span>
  <span class="code-tag"><span class="code-comment">&lt;!-- Cluster Valves--&gt;</span></span>
    <span class="code-tag">&lt;gbean class=<span class="code-quote">"org.apache.geronimo.tomcat.ValveGBean"</span> name=<span class="code-quote">"ReplicationValve"</span>&gt;</span>
        <span class="code-tag">&lt;attribute name=<span class="code-quote">"className"</span>&gt;</span>org.apache.catalina.ha.tcp.ReplicationValve<span class="code-tag">&lt;/attribute&gt;</span>
        <span class="code-tag">&lt;attribute name=<span class="code-quote">"initParams"</span>&gt;</span>filter=.*\.gif;.*\.js;.*\.css;.*\.png;.*\.jpeg;.*\.jpg;.*\.htm;.*\.html;.*\.txt;<span class="code-tag">&lt;/attribute&gt;</span>
        <span class="code-tag">&lt;reference name=<span class="code-quote">"NextValve"</span>&gt;</span>
        	<span class="code-tag">&lt;name&gt;</span>JvmRouteBinderValve<span class="code-tag">&lt;/name&gt;</span>
        <span class="code-tag">&lt;/reference&gt;</span>
    <span class="code-tag">&lt;/gbean&gt;</span>
  <span class="code-tag"><span class="code-comment">&lt;!-- Cluster Route Binder --&gt;</span></span>
    <span class="code-tag">&lt;gbean class=<span class="code-quote">"org.apache.geronimo.tomcat.ValveGBean"</span> name=<span class="code-quote">"JvmRouteBinderValve"</span>&gt;</span>
        <span class="code-tag">&lt;attribute name=<span class="code-quote">"className"</span>&gt;</span>org.apache.catalina.ha.session.JvmRouteBinderValve<span class="code-tag">&lt;/attribute&gt;</span>
        <span class="code-tag">&lt;attribute name=<span class="code-quote">"initParams"</span>&gt;</span>enabled=true<span class="code-tag">&lt;/attribute&gt;</span>
    <span class="code-tag">&lt;/gbean&gt;</span>
  <span class="code-tag"><span class="code-comment">&lt;!-- Cluster Listener --&gt;</span></span>
    <span class="code-tag">&lt;gbean class=<span class="code-quote">"org.apache.geronimo.tomcat.cluster.ClusterListenerGBean"</span> name=<span class="code-quote">"ClusterSessionListener"</span>&gt;</span>
        <span class="code-tag">&lt;attribute name=<span class="code-quote">"className"</span>&gt;</span>org.apache.catalina.ha.session.ClusterSessionListener<span class="code-tag">&lt;/attribute&gt;</span>
        <span class="code-tag">&lt;reference name=<span class="code-quote">"NextListener"</span>&gt;</span>
            <span class="code-tag">&lt;name&gt;</span>JvmRouteSessionIDBinderListener<span class="code-tag">&lt;/name&gt;</span>
        <span class="code-tag">&lt;/reference&gt;</span>
    <span class="code-tag">&lt;/gbean&gt;</span>
  <span class="code-tag"><span class="code-comment">&lt;!-- Cluster Binder Listener--&gt;</span></span>
    <span class="code-tag">&lt;gbean class=<span class="code-quote">"org.apache.geronimo.tomcat.cluster.ClusterListenerGBean"</span> name=<span class="code-quote">"JvmRouteSessionIDBinderListener"</span>&gt;</span>
        <span class="code-tag">&lt;attribute name=<span class="code-quote">"className"</span>&gt;</span>org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener<span class="code-tag">&lt;/attribute&gt;</span>
    <span class="code-tag">&lt;/gbean&gt;</span>
  <span class="code-tag"><span class="code-comment">&lt;!-- Cluster Channel Interceptor --&gt;</span></span>
    <span class="code-tag">&lt;gbean class=<span class="code-quote">"org.apache.geronimo.tomcat.cluster.ChannelInterceptorGBean"</span> name=<span class="code-quote">"TomcatChannelInterceptor"</span>&gt;</span>
        <span class="code-tag">&lt;attribute name=<span class="code-quote">"className"</span>&gt;</span>org.apache.catalina.tribes.group.interceptors.TcpFailureDetector<span class="code-tag">&lt;/attribute&gt;</span>
    <span class="code-tag">&lt;/gbean&gt;</span>
<span class="code-tag">&lt;/web-app&gt;</span>
</pre>
</div></div>
<p>where </p>
<ul>
	<li><em>web-cluster-server1</em> should match the WAR file name. It can be different for each node in the cluster.</li>
</ul>


<p>On each node, deploy your Web application, either via admin console or <b>deploy</b> command, following this syntax:</p>
<div class="panel" style="border-style: solid;border-width: 1px;"><div class="panelContent">
<p><tt>deploy --user <em>name</em> --password <em>word</em> deploy <em>archive</em> <em>plan</em></tt></p>
</div></div>
<p>where </p>
<ul>
	<li><em>name</em> is replaced with a user name authorized to manage the server. If you omit this option, you will be prompted to enter a user name.</li>
	<li><em>word</em> is replaced with the password used to authenticate the user. If you omit this option, you will be prompted to enter a password.</li>
	<li><em>archive</em> is replaced with a file specification to your Web application WAR file.</li>
	<li><em>plan</em> is replaced with a file specification to your deployment plan.</li>
</ul>


<p>Note: After installation, the user name is initially <b>system</b>, and the password initially <b>manager</b>.</p>


<h1><a name="TomcatNativeClustering-SampleTomcatClusteringwithUnicastConfiguration"></a>Sample Tomcat Clustering with Unicast Configuration</h1>

<p>The following code snippet is part of a clustering example that uses unicast configuration. Static members are defined using <tt>org.apache.geronimo.tomcat.cluster.StaticMemberGBean</tt>. You have to define each static member within your deployment plan to make sure your application is clustered successfully, and make sure that TCP ports for session replication are defined consistently on each node.</p>

<div class="code panel" style="border-style: solid;border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;"><b>excerpt from geronimo-web.xml</b></div><div class="codeContent panelContent">
<pre class="code-xml">
...
    <span class="code-tag">&lt;cluster&gt;</span>TomcatCluster<span class="code-tag">&lt;/cluster&gt;</span>
        <span class="code-tag">&lt;gbean name=<span class="code-quote">"TomcatCluster"</span> class=<span class="code-quote">"org.apache.geronimo.tomcat.cluster.CatalinaClusterGBean"</span>&gt;</span>
            <span class="code-tag">&lt;attribute name=<span class="code-quote">"className"</span>&gt;</span>org.apache.catalina.ha.tcp.SimpleTcpCluster<span class="code-tag">&lt;/attribute&gt;</span>
            <span class="code-tag">&lt;attribute name=<span class="code-quote">"initParams"</span>/&gt;</span>
            <span class="code-tag">&lt;reference name=<span class="code-quote">"ClusterListenerChain"</span>&gt;</span> 
                    <span class="code-tag">&lt;name&gt;</span>TomcatClusterListenerChain<span class="code-tag">&lt;/name&gt;</span>
            <span class="code-tag">&lt;/reference&gt;</span>
            <span class="code-tag">&lt;reference name=<span class="code-quote">"TomcatValveChain"</span>&gt;</span>
                    <span class="code-tag">&lt;name&gt;</span>ReplicationValve<span class="code-tag">&lt;/name&gt;</span>  
            <span class="code-tag">&lt;/reference&gt;</span>
            <span class="code-tag">&lt;reference name=<span class="code-quote">"Channel"</span>&gt;</span>
                    <span class="code-tag">&lt;name&gt;</span>TomcatChannel<span class="code-tag">&lt;/name&gt;</span>
            <span class="code-tag">&lt;/reference&gt;</span>
            <span class="code-tag">&lt;reference name=<span class="code-quote">"ClusterManager"</span>&gt;</span> 
                    <span class="code-tag">&lt;name&gt;</span>TomcatClusterManager<span class="code-tag">&lt;/name&gt;</span>
            <span class="code-tag">&lt;/reference&gt;</span>
        <span class="code-tag">&lt;/gbean&gt;</span>

        <span class="code-tag">&lt;gbean name=<span class="code-quote">"TomcatClusterListenerChain"</span> class=<span class="code-quote">"org.apache.geronimo.tomcat.cluster.ClusterListenerGBean"</span>&gt;</span>
            <span class="code-tag">&lt;attribute name=<span class="code-quote">"className"</span>&gt;</span>org.apache.catalina.ha.session.ClusterSessionListener<span class="code-tag">&lt;/attribute&gt;</span>
            <span class="code-tag">&lt;attribute name=<span class="code-quote">"initParams"</span>/&gt;</span>
        <span class="code-tag">&lt;/gbean&gt;</span>

        <span class="code-tag">&lt;gbean name=<span class="code-quote">"ReplicationValve"</span> class=<span class="code-quote">"org.apache.geronimo.tomcat.ValveGBean"</span>&gt;</span>
            <span class="code-tag">&lt;attribute name=<span class="code-quote">"className"</span>&gt;</span>org.apache.catalina.ha.tcp.ReplicationValve<span class="code-tag">&lt;/attribute&gt;</span>
            <span class="code-tag">&lt;attribute name=<span class="code-quote">"initParams"</span>&gt;</span>.*\.gif;.*\.js;.*\.jpg;.*\.png;.*\.htm;.*\.html;.*\.css;.*\.txt;<span class="code-tag">&lt;/attribute&gt;</span>
            <span class="code-tag">&lt;reference name=<span class="code-quote">"NextValve"</span>&gt;</span>
        			<span class="code-tag">&lt;type&gt;</span>TomcatValve<span class="code-tag">&lt;/type&gt;</span>
            	                <span class="code-tag">&lt;name&gt;</span>JvmRouteBinderValve<span class="code-tag">&lt;/name&gt;</span>
            <span class="code-tag">&lt;/reference&gt;</span>
        <span class="code-tag">&lt;/gbean&gt;</span>

        <span class="code-tag">&lt;gbean name=<span class="code-quote">"JvmRouteBinderValve"</span> class=<span class="code-quote">"org.apache.geronimo.tomcat.ValveGBean"</span>&gt;</span>
            <span class="code-tag">&lt;attribute name=<span class="code-quote">"className"</span>&gt;</span>org.apache.catalina.ha.session.JvmRouteBinderValve<span class="code-tag">&lt;/attribute&gt;</span>
            <span class="code-tag">&lt;attribute name=<span class="code-quote">"initParams"</span>&gt;</span>enabled=true<span class="code-tag">&lt;/attribute&gt;</span>
        <span class="code-tag">&lt;/gbean&gt;</span>

        <span class="code-tag">&lt;gbean name=<span class="code-quote">"TomcatClusterManager"</span> class=<span class="code-quote">"org.apache.geronimo.tomcat.cluster.ClusterManagerGBean"</span>&gt;</span>
            <span class="code-tag">&lt;attribute name=<span class="code-quote">"className"</span>&gt;</span>org.apache.catalina.ha.session.DeltaManager<span class="code-tag">&lt;/attribute&gt;</span>
            <span class="code-tag">&lt;attribute name=<span class="code-quote">"initParams"</span>&gt;</span>name=${clusterName}
                                         channelSendOptions=6
                                         expireSessionsOnShutdown=false
                                         notifyListenersOnReplication=true
                                         mapSendOptions=6
            <span class="code-tag">&lt;/attribute&gt;</span>
        <span class="code-tag">&lt;/gbean&gt;</span>

        <span class="code-tag">&lt;gbean name=<span class="code-quote">"TomcatChannel"</span> class=<span class="code-quote">"org.apache.geronimo.tomcat.cluster.ChannelGBean"</span>&gt;</span>
            <span class="code-tag">&lt;attribute name=<span class="code-quote">"className"</span>&gt;</span>org.apache.catalina.tribes.group.GroupChannel<span class="code-tag">&lt;/attribute&gt;</span>
            <span class="code-tag">&lt;attribute name=<span class="code-quote">"initParams"</span>/&gt;</span>
            <span class="code-tag">&lt;reference name=<span class="code-quote">"Membership"</span>&gt;</span> 
                    <span class="code-tag">&lt;name&gt;</span>ClusterMembership<span class="code-tag">&lt;/name&gt;</span>
            <span class="code-tag">&lt;/reference&gt;</span>
            <span class="code-tag">&lt;reference name=<span class="code-quote">"Receiver"</span>&gt;</span>
                    <span class="code-tag">&lt;name&gt;</span>ClusterReceiver<span class="code-tag">&lt;/name&gt;</span>                
            <span class="code-tag">&lt;/reference&gt;</span>
            <span class="code-tag">&lt;reference name=<span class="code-quote">"Sender"</span>&gt;</span>                
                    <span class="code-tag">&lt;name&gt;</span>ClusterSender<span class="code-tag">&lt;/name&gt;</span>
            <span class="code-tag">&lt;/reference&gt;</span>
            <span class="code-tag">&lt;reference name=<span class="code-quote">"ChannelInterceptor"</span>&gt;</span>
                    <span class="code-tag">&lt;name&gt;</span>DisableMcastInterceptor<span class="code-tag">&lt;/name&gt;</span>                
            <span class="code-tag">&lt;/reference&gt;</span>
        <span class="code-tag">&lt;/gbean&gt;</span>

        <span class="code-tag">&lt;gbean name=<span class="code-quote">"ClusterMembership"</span> class=<span class="code-quote">"org.apache.geronimo.tomcat.cluster.MembershipServiceGBean"</span>&gt;</span>
            <span class="code-tag">&lt;attribute name=<span class="code-quote">"className"</span>&gt;</span>org.apache.catalina.tribes.membership.McastService<span class="code-tag">&lt;/attribute&gt;</span>
            <span class="code-tag">&lt;attribute name=<span class="code-quote">"initParams"</span>&gt;</span>address=228.0.0.4
                                         port=45564
                                         frequency=500
                                         dropTime=3000
            <span class="code-tag">&lt;/attribute&gt;</span>
        <span class="code-tag">&lt;/gbean&gt;</span>

        <span class="code-tag">&lt;gbean name=<span class="code-quote">"ClusterReceiver"</span> class=<span class="code-quote">"org.apache.geronimo.tomcat.cluster.ReceiverGBean"</span>&gt;</span>
            <span class="code-tag">&lt;attribute name=<span class="code-quote">"className"</span>&gt;</span>org.apache.catalina.tribes.transport.nio.NioReceiver<span class="code-tag">&lt;/attribute&gt;</span>
            <span class="code-tag">&lt;attribute name=<span class="code-quote">"initParams"</span>&gt;</span>address=IPAddress1
                                         port=TCP_port1
                                         selectorTimeout=100
                                         maxThreads=6
            <span class="code-tag">&lt;/attribute&gt;</span>
        <span class="code-tag">&lt;/gbean&gt;</span>

        <span class="code-tag">&lt;gbean name=<span class="code-quote">"ClusterSender"</span> class=<span class="code-quote">"org.apache.geronimo.tomcat.cluster.SenderGBean"</span>&gt;</span>
            <span class="code-tag">&lt;attribute name=<span class="code-quote">"className"</span>&gt;</span>org.apache.catalina.tribes.transport.ReplicationTransmitter<span class="code-tag">&lt;/attribute&gt;</span>
        <span class="code-tag">&lt;/gbean&gt;</span>

        <span class="code-tag">&lt;gbean name=<span class="code-quote">"DisableMcastInterceptor"</span> class=<span class="code-quote">"org.apache.geronimo.tomcat.cluster.ChannelInterceptorGBean"</span>&gt;</span>
            <span class="code-tag">&lt;attribute name=<span class="code-quote">"className"</span>&gt;</span>org.apache.geronimo.tomcat.interceptor.DisableMcastInterceptor<span class="code-tag">&lt;/attribute&gt;</span>
            <span class="code-tag">&lt;attribute name=<span class="code-quote">"initParams"</span>/&gt;</span>
            <span class="code-tag">&lt;reference name=<span class="code-quote">"NextInterceptor"</span>&gt;</span>
                    <span class="code-tag">&lt;name&gt;</span>TcpPingInterceptor<span class="code-tag">&lt;/name&gt;</span>                
            <span class="code-tag">&lt;/reference&gt;</span>
        <span class="code-tag">&lt;/gbean&gt;</span>

        <span class="code-tag">&lt;gbean name=<span class="code-quote">"TcpPingInterceptor"</span> class=<span class="code-quote">"org.apache.geronimo.tomcat.cluster.ChannelInterceptorGBean"</span>&gt;</span>
            <span class="code-tag">&lt;attribute name=<span class="code-quote">"className"</span>&gt;</span>org.apache.catalina.tribes.group.interceptors.TcpPingInterceptor<span class="code-tag">&lt;/attribute&gt;</span>
            <span class="code-tag">&lt;attribute name=<span class="code-quote">"initParams"</span>&gt;</span>Interval=60<span class="code-tag">&lt;/attribute&gt;</span>
            <span class="code-tag">&lt;reference name=<span class="code-quote">"NextInterceptor"</span>&gt;</span>
                    <span class="code-tag">&lt;name&gt;</span>TcpFailureDetector<span class="code-tag">&lt;/name&gt;</span>                
            <span class="code-tag">&lt;/reference&gt;</span>
        <span class="code-tag">&lt;/gbean&gt;</span>

        <span class="code-tag">&lt;gbean name=<span class="code-quote">"TcpFailureDetector"</span> class=<span class="code-quote">"org.apache.geronimo.tomcat.cluster.ChannelInterceptorGBean"</span>&gt;</span>
            <span class="code-tag">&lt;attribute name=<span class="code-quote">"className"</span>&gt;</span>org.apache.catalina.tribes.group.interceptors.TcpFailureDetector<span class="code-tag">&lt;/attribute&gt;</span>
            <span class="code-tag">&lt;attribute name=<span class="code-quote">"initParams"</span>/&gt;</span>
            <span class="code-tag">&lt;reference name=<span class="code-quote">"NextInterceptor"</span>&gt;</span>                
                    <span class="code-tag">&lt;name&gt;</span>StaticMember1Interceptor<span class="code-tag">&lt;/name&gt;</span>                
            <span class="code-tag">&lt;/reference&gt;</span>
        <span class="code-tag">&lt;/gbean&gt;</span>

        <span class="code-tag">&lt;gbean name=<span class="code-quote">"StaticMember1Interceptor"</span> class=<span class="code-quote">"org.apache.geronimo.tomcat.cluster.ChannelInterceptorGBean"</span>&gt;</span>
            <span class="code-tag">&lt;attribute name=<span class="code-quote">"className"</span>&gt;</span>org.apache.catalina.tribes.group.interceptors.StaticMembershipInterceptor<span class="code-tag">&lt;/attribute&gt;</span>
            <span class="code-tag">&lt;attribute name=<span class="code-quote">"initParams"</span>/&gt;</span>
            <span class="code-tag">&lt;reference name=<span class="code-quote">"StaticMember"</span>&gt;</span>
                    <span class="code-tag">&lt;name&gt;</span>StaticMember2<span class="code-tag">&lt;/name&gt;</span>                
            <span class="code-tag">&lt;/reference&gt;</span>
            <span class="code-tag">&lt;reference name=<span class="code-quote">"NextInterceptor"</span>&gt;</span>                
                    <span class="code-tag">&lt;name&gt;</span>MessageDispatch15Interceptor<span class="code-tag">&lt;/name&gt;</span> 
            <span class="code-tag">&lt;/reference&gt;</span>
        <span class="code-tag">&lt;/gbean&gt;</span>

        <span class="code-tag">&lt;gbean name=<span class="code-quote">"MessageDispatch15Interceptor"</span> class=<span class="code-quote">"org.apache.geronimo.tomcat.cluster.ChannelInterceptorGBean"</span>&gt;</span>
            <span class="code-tag">&lt;attribute name=<span class="code-quote">"className"</span>&gt;</span>org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor<span class="code-tag">&lt;/attribute&gt;</span>
            <span class="code-tag">&lt;attribute name=<span class="code-quote">"initParams"</span>/&gt;</span>
            <span class="code-tag">&lt;reference name=<span class="code-quote">"NextInterceptor"</span>&gt;</span>
                    <span class="code-tag">&lt;name&gt;</span>ThroughputInterceptor<span class="code-tag">&lt;/name&gt;</span>                
            <span class="code-tag">&lt;/reference&gt;</span>
        <span class="code-tag">&lt;/gbean&gt;</span>

        <span class="code-tag">&lt;gbean name=<span class="code-quote">"ThroughputInterceptor"</span> class=<span class="code-quote">"org.apache.geronimo.tomcat.cluster.ChannelInterceptorGBean"</span>&gt;</span>
            <span class="code-tag">&lt;attribute name=<span class="code-quote">"className"</span>&gt;</span>org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor<span class="code-tag">&lt;/attribute&gt;</span>
            <span class="code-tag">&lt;attribute name=<span class="code-quote">"initParams"</span>/&gt;</span>
        <span class="code-tag">&lt;/gbean&gt;</span>

        <span class="code-tag">&lt;gbean name=<span class="code-quote">"StaticMember2"</span> class=<span class="code-quote">"org.apache.geronimo.tomcat.cluster.StaticMemberGBean"</span>&gt;</span>
            <span class="code-tag">&lt;attribute name=<span class="code-quote">"className"</span>&gt;</span>org.apache.catalina.tribes.membership.StaticMember<span class="code-tag">&lt;/attribute&gt;</span>
            <span class="code-tag">&lt;attribute name=<span class="code-quote">"initParams"</span>&gt;</span>port=TCP_port2
                                         securePort=-1
                                         host=IPAddress2
                                         domain=test-domain
                                         UniqueId={2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
            <span class="code-tag">&lt;/attribute&gt;</span>
        <span class="code-tag">&lt;/gbean&gt;</span>
...
</pre>
</div></div>

<p>Where</p>
<ul>
	<li><em>IPAddress1</em> is the IP address or host name of current static member.</li>
	<li><em>TCP_port1</em> is the TCP port on the current node to listen for session replication data from other static members.</li>
	<li><em>IPAddress2</em> is the IP address or host name of the second static member.</li>
	<li><em>TCP_port2</em> is the TCP port on the second static member to listen for session replication data from other static members</li>
</ul>


<p>To convert this example to a multicast configuration, the DisableMCastInterceptor, StaticMemberInterceptor, and StaticMember definitions need to be removed.  Also, the value for the "address" attribute for the TomcatReceiver definition should be changed to "auto". </p>
     </div>
     <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href="http://cwiki.apache.org/confluence/users/viewnotifications.action" class="grey">Change Notification Preferences</a>
       </div>

       <a href="http://cwiki.apache.org/confluence/display/GMOxDOC22/Tomcat+Native+Clustering">View Online</a>
       |
       <a href="http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=97071&revisedVersion=15&originalVersion=14">View Change</a>
              |
       <a href="http://cwiki.apache.org/confluence/display/GMOxDOC22/Tomcat+Native+Clustering?showComments=true&amp;showCommentArea=true#addcomment">Add Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message