· Core:
|
windows 上实现Apache 负载均衡 +tomcat群集 (二)
原创
©著作权归作者所有:来自51CTO博客作者ldtrain的原创作品,请联系作者获取转载授权,否则将追究法律责任
Tomcat集群的配置:
1. 下载tomcat的软件包:下载解压版本
下载地址:
解压tomcat 到c盘根目录,重命名为tomcat1,然后复制tomcat1为tomcat2.
修改server.xml配置文件
Tomcat1中修改的部分:
1.<Server port="9005" shutdown="SHUTDOWN">
2. <Connector port="9080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
1. <Connector port="9009" protocol="AJP/1.3" redirectPort="8443" />
4. <Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
-----------------------------------添加的部分-----------------------------------
添加在<Host></Host>之间
<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="224.0.0.1"
port="45564"
frequency="500"
dropTime="3000"/>
<Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
address="auto"
port="5001"
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>
</Host>
Tomcat2中修改的部分:
1.<Server port="10005" shutdown="SHUTDOWN">
2.<Connector port="10080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
3.<Connector port="10009" protocol="AJP/1.3" redirectPort="8443" />
4. 添加在<Host></Host>之间
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<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="45564"
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>
</Host>
集群测试
在2个tomcat里面添加网页
Tomcat1上的\webapps\ROOT\index.html内容如下:
<html>
<head><title>Tomcat 群集1</title></head>
<body>
<center>Tomcat 1号机在tomcatA机上
</center>
</body>
</html>
Tomcat2上的webapps\ROOT\index.html内容如下:
<html>
<head><title>Tomcat 群集2</title></head>
<body>
<center>Tomcat 2号机在TomcatB机上
</center>
</body>
</html>
启动Tomcat1和Tomcat2,再启动Apache
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Apache 负载均衡 + tomcat群集
Apache 负载均衡 + tomcat群集1.环境介绍操作系统环境 :windows xp sp3 (一台机器上跑 2个或多个tomcat服务)Java环境: jdk1.6.0_13软件:apache_2.2.13-win32-x86-no_ssl.msi &nb
Apache tomcat 休闲 群集 Apache 负载均衡 + tomcat -
linux下Apache+Tomcat负载均衡与群集
linux下Apache+Tomcat负载均衡与群集
linux 负载均衡 apache tomcat 休闲 -
Tomcat+apache实现负载均衡
tomcat
tomcat java程序 动态页面 -
Tomcat部署+Nginx负载均衡群集
Tomcat+Nginx代理
tomcat Nginx -
Apache Tomcat AJP 实现负载均衡apache tomcat 服务器 tomcat服务器 web服务器