tomcat cluster

1.vim tomcat/conf/server.xml

    remove comment  <!--<Engine name="Standalone" defaultHost="localhost" jvmRoute="tomcat1">-->

    add comment <!--    <Engine name="Catalina" defaultHost="localhost">-->

 

    add a cluster after <Engine name="Standalone" defaultHost="localhost" jvmRoute="tomcat1">

 

 

<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"
                 channelSendOptions="6">

          <Manager className="org.apache.catalina.ha.session.BackupManager"
                   expireSessionsOnShutdown="false"
                   notifyListenersOnReplication="true"
                   mapSendOptions="6" useDirtyFlag="true"/>
          <!--
          <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="5000"
                      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>

 2.add <distributable/> to the web.xml of the webapp context

 3. notice that all the session object should implment seriabable interace

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是Tomcat集群系统的配置步骤: 1. 在每个Tomcat服务器上安装Tomcat。 2. 在每个Tomcat服务器上配置server.xml文件,以启用集群支持。在server.xml文件中,需要添加一个Cluster元素,例如: ```xml <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/> ``` 3. 在每个Tomcat服务器上配置context.xml文件,以启用会话复制。在context.xml文件中,需要添加一个Manager元素,例如: ```xml <Manager className="org.apache.catalina.ha.session.DeltaManager" expireSessionsOnShutdown="false" notifyListenersOnReplication="true"/> ``` 4. 在每个Tomcat服务器上配置web.xml文件,以启用会话跨上下文复制。在web.xml文件中,需要添加一个distributable元素,例如: ```xml <distributable/> ``` 5. 在Tomcat服务器之间配置JK插件,以实现负载平衡。需要在每个Tomcat服务器上安装JK插件,并在workers.properties文件中配置负载平衡器和Tomcat服务器的信息,例如: ```properties worker.loadbalancer.type=lb worker.loadbalancer.balance_workers=node1,node2 worker.node1.type=ajp13 worker.node1.host=localhost worker.node1.port=8009 worker.node2.type=ajp13 worker.node2.host=localhost worker.node2.port=8010 ``` 其中,loadbalancer是负载平衡器的名称,node1和node2是Tomcat服务器的名称,localhost是Tomcat服务器的主机名,8009和8010是Tomcat服务器的AJP连接端口号。 6. 在HTTP服务器上配置JK插件,以实现与Tomcat服务器之间的通信。需要在HTTP服务器上安装JK插件,并在httpd.conf文件中配置JK插件的信息,例如: ```conf LoadModule jk_module modules/mod_jk.so JkWorkersFile conf/workers.properties JkLogFile logs/mod_jk.log JkLogLevel info JkMount /* loadbalancer ``` 其中,mod_jk.so是JK插件的模块文件,workers.properties是JK插件的配置文件,mod_jk.log是JK插件的日志文件,loadbalancer是负载平衡器的名称。 7. 启动Tomcat服务器和HTTP服务器,测试集群系统的功能。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值