Apache 负载均衡+Tomcat集群(测试)
一、本机环境
1.Windows 7 64位操作系统
2.java版本 "1.6.0_20"
3.Apache安装包httpd-2.2.21-win32-x86-no_ssl.msi,默认安装
4.tomcat压缩包(apache-tomcat-6.0.24.zip)
5.在一台机器上进行的
二、配置
1.前提是Apache安装正确,启动正常
2.解压缩多个tomcat,例如d:\tomcat_01,d:\tomcat_02
3.配置httpd.conf文件
找到如下信息,并进行修改
找到 <Engine name="Catalina" defaultHost="localhost" > 改成 <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm2"> 并在<Engine name="."..></Engine>标签中加上如下代码 <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster" channelSendOptions="6"> <Manager className="org.apache.catalina.ha.session.BackupManager" expireSessionsOnShutdown="false" notifyListenersOnReplication="true" mapSendOptions="6"/> <Channel className="org.apache.catalina.tribes.group.GroupChannel"> <Membership className="org.apache.catalina.tribes.membership.McastService" address="228.0.0.4" port="45565" frequency="500" dropTime="3000"/> <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver" address="auto" port="5002" selectorTimeout="100" 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"/> <Interceptor className="org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor"/> </Channel> <Valve className="org.apache.catalina.ha.tcp.ReplicationValve" filter=".*\.gif;.*\.js;.*\.jpg;.*\.png;.*\.htm;.*\.html;.*\.css;.*\.txt;"/> <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.ClusterSessionListener"/> </Cluster>
第一个tomcat配置为<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
改动Membership port 的值与另一个设置为不同
改动Receiver port的值与另一个设置为不同
为了防止冲突
6.所有配置已经完毕,我们现在可以进行测试
7.为了让效果更加明显,我们改动\tomcat_01\webapps\ROOT\index.html,在<body></dody>中加上<h1>tomcat1</h1>
改动\tomcat_02\webapps\ROOT\index.html,在<body></dody>中加上<h1>tomcat2</h1>
8.在浏览器中输入http://localhost,看看效果吧!刷新一下会有意外惊喜
相关推荐
Kafka 2020-09-18
Wepe0 2020-10-30
杜倩 2020-10-29
windle 2020-10-29
minerd 2020-10-28
mengzuchao 2020-10-22
Junzizhiai 2020-10-10
bxqybxqy 2020-09-30
风之沙城 2020-09-24
kingszelda 2020-09-22
大唐帝国前营 2020-08-18
yixu0 2020-08-17
TangCuYu 2020-08-15
xiaoboliu00 2020-08-15
songshijiazuaa 2020-08-15
xclxcl 2020-08-03
zmzmmf 2020-08-03
newfarhui 2020-08-03
likesyour 2020-08-01