日期:2014-05-16 浏览次数:20799 次
1.下载所需的文件
apache
http://labs.renren.com/apache-mirror/httpd/binaries/win32/httpd-2.2.20-win32-x86-no_ssl.msi
tomcat
http://labs.renren.com/apache-mirror/tomcat/tomcat-6/v6.0.33/bin/apache-tomcat-6.0.33.zip
connectors
http://labs.renren.com/apache-mirror/tomcat/tomcat-connectors/jk/binaries/windows/tomcat-connectors-1.2.32-windows-i386-httpd-2.2.x.zip
?
2.例子安装目录
tomcatA
F:\cluster\tomcatA
tomcatB
F:\cluster\tomcatB
apachex
F:\cluster\Apache2.2
connectors放到F:\cluster\Apache2.2\modules
?
3.修改F:\cluster\Apache2.2\conf\httpd.conf,添加
include "F:\cluster\Apache2.2\conf\mod_jk.conf"
?
4.新建F:\cluster\Apache2.2\conf\mod_jk.conf,内容如下
?
#加载mod_jk Module
LoadModule jk_module modules/mod_jk.so
#指定 workers.properties文件路径
JkWorkersFile conf/workers.properties
#指定那些请求交给tomcat处理,"controller"为在workers.propertise里指定的负载分配控制器
JkMount /*.jsp controller
?
?
5.新建workers.properties,内容如下
?
worker.list = controller,tomcat1,tomcat2 ?#server 列表
#========tomcat1========
worker.tomcat1.port=8009 ? ? ? ? #ajp13 端口号,在tomcat下server.xml配置,默认8009
worker.tomcat1.host=localhost ?#tomcat的主机地址,如不为本机,请填写ip地址
worker.tomcat1.type=ajp13
worker.tomcat1.lbfactor = 1 ? #server的加权比重,值越高,分得的请求越多
#========tomcat2========
worker.tomcat2.port=9009 ? ? ? #ajp13 端口号,在tomcat下server.xml配置,默认8009
worker.tomcat2.host=localhost ?#tomcat的主机地址,如不为本机,请填写ip地址
worker.tomcat2.type=ajp13
worker.tomcat2.lbfactor = 1 ? #server的加权比重,值越高,分得的请求越多
?
#========controller,负载均衡控制器========
worker.controller.type=lb
worker.controller.balanced_workers=tomcat1,tomcat2 ? #指定分担请求的tomcat
worker.controller.sticky_session=1
?
?
6.修改两个tomcat的server.xml,端口部分为了简便,保留tomcatA为默认端口,tomcatB的端口加1000,修改F:\cluster\tomcatA\conf\server.xml
engine最后添加jvmRoute="tomcatB",修改后:
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcatB">
engine标签下添加
?
<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="192.168.1.105" 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"/> <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"/> </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="/tm