一、环境信息:win7 64位
1,Apache: httpd-2.4.16-win32-VC14
2,Tomcat6.0
3,JK: mod_jk-1.2.40-win32-VC14.zip
二、Apache官网配置指南
For the impatient | ||||||||||||||||||
|
Cluster Basics |
|
Overview | |||||||||
|
Cluster Information |
|
Bind session after crash to failover node |
|
Configuration Example | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Cluster Architecture | |||||||||
|
How it Works |
|
三、配置文件
1,Apache\conf\httpd.conf
##文件末尾添加以下配置
##############################################################
# (httpd.conf)
# 加载 mod_jk 模块
LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workers.properties
JkMountFile conf/uriworkermap.properties
JkLogFile logs/mod_jk.log
JkLogLevel info
##############################################################
2,Apache\conf\workers.properties
#server 列表
worker.list=DLOG4J,status
#========tomcat1========
#ajp13 端口号,在tomcat下server.xml配 置,默认8009
worker.tomcat1.port=8010
#tomcat的主机地址,如不为本机,请填写ip地址
worker.tomcat1.host=sso.test
worker.tomcat1.type=ajp13
#server的加权比重,值越高,分得的请求越多
worker.tomcat1.lbfactor = 1
#========tomcat3========
#ajp13 端口号,在tomcat下server.xml配置,
worker.tomcat3.port=8012
#tomcat的主机地址,如不为本机,请填写ip地址
worker.tomcat3.host=sso.test
worker.tomcat3.type=ajp13
#server的加权比重,值越高,分得的请求越多
worker.tomcat3.lbfactor=1
#========tomcat4========
#ajp13 端口号,在tomcat下server.xml配置,
worker.tomcat4.port=8013
#tomcat的主机地址,如不为本机,请填写ip地址
worker.tomcat4.host=sso.test
worker.tomcat4.type=ajp13
#server的加权比重,值越高,分得的请求越多
worker.tomcat4.lbfactor=1
#========tomcat7========TOMCAT7无法与TOMCAT6同时部署集群
#ajp13 端口号,在tomcat下server.xml配置,
#worker.tomcat7.port=8016
#tomcat的主机地址,如不为本机,请填写ip地址
#worker.tomcat7.host=sso.test
#worker.tomcat7.type=ajp13
#server的加权比重,值越高,分得的请求越多
#worker.tomcat7.lbfactor=1
#========controller,负载均衡控制器========
worker.DLOG4J.type=lb
worker.retries=3
worker.DLOG4J.balanced_workers=tomcat1,tomcat3,tomcat4
worker.DLOG4J.sticky_session=true
worker.status.type=status
3,Apache\conf\uriworkermap.properties
/*=DLOG4J
/jkstatus=status
!/*.gif=DLOG4J
!/*.jpg=DLOG4J
!/*.png=DLOG4J
!/*.css=DLOG4J
!/*.js=DLOG4J
!/*.htm=DLOG4J
!/*.html=DLOG4J
4,Tomcat\conf\server.xml
<!-- 在Engine标签替换成以下 -->
<Engine name="Catalina" defaultHost="sso.test" jvmRoute="tomcat1">
<!--For clustering, please take a look at documentation at:
/docs/cluster-howto.html (simple how to)
/docs/config/cluster.html (reference documentation) -->
<!--
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
-->
<!--集群配置开始 -->
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"
channelSendOptions="8">
<!--
<Manager className="org.apache.catalina.ha.session.BackupManager"
expireSessionsOnShutdown="false"
notifyListenersOnReplication="true"
mapSendOptions="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"/>
<!-- 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"/>
<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>
<!--集群配置结束 -->
参考文件:
1,http://tomcat.apache.org/tomcat-6.0-doc/config/cluster.html
2,http://tomcat.apache.org/tomcat-6.0-doc/cluster-howto.html#Cluster%20Basics