手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

基于mod_proxy+Apache 2.2.16+Tomcat 7的负载均衡与集群配置

[日期:2012-08-30] 来源:Linux社区  作者:peterwei [字体:大 中 小]

四、 详细配置:
1. 修改tomcat7_a/conf/server.xml, 我们采用的是默认的配置,在<Engine>节点下添加:

  1. <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"  
  2.                  channelSendOptions="8">   
  3.   
  4.           <Manager className="org.apache.catalina.ha.session.DeltaManager"  
  5.                    expireSessionsOnShutdown="false"  
  6.                    notifyListenersOnReplication="true"/>   
  7.   
  8.           <Channel className="org.apache.catalina.tribes.group.GroupChannel">   
  9.             <Membership className="org.apache.catalina.tribes.membership.McastService"  
  10.                         address="228.0.0.4"  
  11.                         port="45564"  
  12.                         frequency="500"  
  13.                         dropTime="3000"/>   
  14.             <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"  
  15.                       address="auto"  
  16. <!—tcpListenPort如果是同一机器部署两个tomcat7应用,则修改tomcat7_b为4001,以免冲突. 不同机器下,不用更改此项。—>   
  17.                       [color=red]port="4000"[/color]   
  18.                       autoBind="100"  
  19.                       selectorTimeout="5000"  
  20.                       maxThreads="6"/>   
  21.   
  22.             <Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">   
  23.               <Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/>   
  24.             </Sender>   
  25.             <Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>   
  26.             <Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/>   
  27.           </Channel>   
  28.   
  29.           <Valve className="org.apache.catalina.ha.tcp.ReplicationValve"  
  30.                  filter=""/>   
  31.           <Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve"/>   
  32.   
  33.           <Deployer className="org.apache.catalina.ha.deploy.FarmWarDeployer"  
  34.                     tempDir="/tmp/war-temp/"  
  35.                     deployDir="/tmp/war-deploy/"  
  36.                     watchDir="/tmp/war-listen/"  
  37.                     watchEnabled="false"/>   
  38.   
  39.           <ClusterListener className="org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener"/>   
  40.           <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>   
  41.         </Cluster>  

2. <Connector port="8081" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> 修改,仅为了调试方便。

3. tomcat7_a\webapps\cluster\WEB-INF\web.xml中加入<distributable/>

4. <Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat7_a">,添加jvmRoute属性,此项为后面apache负载均衡用到。

五、 复制一份tomcat7_a应用,改名为tomcat7_b.只是为了图方便,实际应该复制的是前面的cluster工程。注意以下几点配置就ok.

1. 修改tomcat7_a/conf/server.xml 中的Server port属性<Server port="8006" shutdown="SHUTDOWN">,因为是同一台机器两个tomcat应用,所以改一下。

2. 修改<connector port="8082" protocol="HTTP/1.1" onnectionTimeout="20000" edirectPort="8443" />,同理,为了避免同一台机器端口号冲突。部置在不同的机器是不用管的。

3. 修改<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat7_b">,此项为后面apache负载均衡用到。

4. 修改<Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver" address="auto" port="4001" autoBind="100" selectorTimeout="5000" maxThreads="6"/>

5. tomcat7_b\ebapps\cluster\WEB-INF\web.xml中加入<distributable/>

到此集群配置完成.

linux
相关资讯       负载均衡 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款