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)<Engine name="Catalina" defaultHost="localhost" > ----> <Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1">
2)add the following code
<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="4001"
autoBind="100"
selectorTimeout="5000"
maxThreads="6"/>
<!-- timeout="60000"-->
<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>
<Valve className="org.apache.catalina.ha.tcp.ReplicationValve"
filter=""/>
<Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve"/>
<ClusterListener className="org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener"/>
<ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>
</Cluster>
Note:port="4001" ,the port should be modidfied in diffrent tomcat
3)modify the following ports;
<Server port="8005" shutdown="SHUTDOWN">
<Connector port="8401" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
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