---
title: "Apache2.2 Tomcat6 Cluster Configuration for Windows"
author: "lyh7609"
date: "2012-02-24T14:59:14Z"
tags: []
categories: ["企业架构"]
slug: "apache2-2-tomcat6-cluster-configuration-for-windows"
draft: false
lastmod: "2012-04-02T12:02:38Z"
id: 1422437
url: "https://lyh7609.iteye.com/blog/1422437"
---

1,add following lines in httpd

 

 

LoadModule jk\_module modules/mod\_jk.so

JkWorkersFile conf/workers.properties

JkMountFile conf/uriworkermap.properties

JkLogFile logs/mod\_jk.log

JkLogLevel warn

JkMount /* controller   

 

 

2,download mod\_jk.so,and copy into folder modules

3,create workers.properties,and content is the followng:

 

worker.list=controller

worker.tomcat1.host=192.168.3.2

worker.tomcat1.port=8009

worker.tomcat1.type=ajp13

worker.tomcat1.connect\_timeout=10000

worker.tomcat1.lbfactor = 6 

 

worker.tomcat2.host=192.168.3.2

worker.tomcat2.port=9009

worker.tomcat2.type=ajp13

worker.tomcat2.connect\_timeout=10000

worker.tomcat2.lbfactor = 2 

 

worker.tomcat3.host=192.168.3.2

worker.tomcat3.port=9010

worker.tomcat3.type=ajp13

worker.tomcat3.connect\_timeout=10000

worker.tomcat3.lbfactor = 2 

 

worker.tomcat4.host=192.168.3.3

worker.tomcat4.port=8009

worker.tomcat4.type=ajp13

worker.tomcat4.connect\_timeout=15000

worker.tomcat4.lbfactor = 2 

 

worker.controller.type=lb

worker.controller.balance\_workers=tomcat1,tomcat2,tomcat3,tomcat4

worker.controller.sticky\_session=True

 

4,create uriworkermap.properties,and content is:

 

/\*=controller

 

 

5,config server.xml in folder tomcat/conf

 

 1)&lt;Engine name="Catalina" defaultHost="localhost" &gt;   ----&gt; &lt;Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1"&gt;

2)add the following code

 

&lt;Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"  channelSendOptions="8"&gt;     

 

       &lt;Manager className="org.apache.catalina.ha.session.DeltaManager"    

                expireSessionsOnShutdown="false"    

                notifyListenersOnReplication="true"/&gt;     

 

       &lt;Channel className="org.apache.catalina.tribes.group.GroupChannel"&gt;     

         &lt;Membership className="org.apache.catalina.tribes.membership.McastService"    

                     address="228.0.0.4"    

                     port="45564"    

                     frequency="500"    

                     dropTime="3000"/&gt;     

         &lt;Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"    

                    address="auto"  

                   port="4001"    

                   autoBind="100"    

                   selectorTimeout="5000"    

                   maxThreads="6"/&gt;     

         &lt;!-- timeout="60000"--&gt;     

         &lt;Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter"&gt;     

           &lt;Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender" /&gt;     

         &lt;/Sender&gt;     

         &lt;Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/&gt;     

         &lt;Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/&gt;     

         &lt;Interceptor className="org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor"/&gt;     

       &lt;/Channel&gt;     

 

       &lt;Valve className="org.apache.catalina.ha.tcp.ReplicationValve"    

              filter=""/&gt;     

       &lt;Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve"/&gt;     

 

       &lt;ClusterListener className="org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener"/&gt;     

       &lt;ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/&gt;     

     &lt;/Cluster&gt;  

 

Note:port="4001" ,the port should be modidfied in diffrent tomcat

 

3)modify the following ports;

 

&lt;Server port="8005" shutdown="SHUTDOWN"&gt;

&lt;Connector port="8401" protocol="HTTP/1.1" 

               connectionTimeout="20000" 

               redirectPort="8443" /&gt;

&lt;Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /&gt;

 

6,note

if you set environment variable CATALINA\_HOME,remember to modify the file: startup.bat/sh and catalina.bat.

 

 

add the line in  above files

set CATALINA\_HOME=C:\\apache-tomcat-cluster2