Tomcat Cluster Farm Deployer 问题

Tomcat Cluster Farm Deployer 问题

mod_jk我已经在 ubuntu 服务器上设置了 apache-tomcat 集群。我FarmDeployer在将 war 文件部署到集群中的其他 Web 服务器时遇到了一些问题,我希望它能像我发布的那样工作,并使 FarmDeployer 正常工作这里

war 部署器与帖子中的以下配置完美配合,但不能可靠地工作,因为访问页面时有时会出现 404 错误:

 <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">

    <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster">
        <Channel className="org.apache.catalina.tribes.group.GroupChannel">
            <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
                  address="192.168.1.4"
                  port="4000"
                  selectorTimeout="100"
                  maxThreads="6"/>
            <Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>
            <Interceptor className="org.apache.catalina.tribes.group.interceptors.StaticMembershipInterceptor">
                <Member className="org.apache.catalina.tribes.membership.StaticMember"
                      port="4000"
                      securePort="-1"
                      host="192.168.1.2"
                      domain="staging-cluster"
                      uniqueId="{0,1,2,3,4,5,6,7,8,9}"/>
            </Interceptor>
        </Channel>
        <Deployer className="org.apache.catalina.ha.deploy.FarmWarDeployer"
            tempDir="/usr/share/tomcat/temp/"
            deployDir="/usr/share/tomcat/webapps/"
            watchDir="/usr/share/tomcat/watch/"
            watchEnabled="true"/>
    </Cluster>
  </Host>

以下是配置(来自 tomcat 集群文档),它非常适合 HA 和 LB 集群。But it fails in Farm Deployer并且日志中没有任何痕迹表明为什么农场部署程序不工作。

<Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">

<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="228.0.0.4" 

          port="45564" frequency="500" 

          dropTime="3000"/>

    <Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">

     <Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/>

    </Sender>

    <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver" 

           address="auto" port="4000" autoBind="100"

           selectorTimeout="5000" maxThreads="6"/>

    <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"/>

<ClusterListener className="org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener"/>

<ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>

</Cluster>


<Deployer className="org.apache.catalina.ha.deploy.FarmWarDeployer"
            tempDir="/usr/share/tomcat/temp/"
            deployDir="/usr/share/tomcat/webapps/"
            watchDir="/usr/share/tomcat/watch/"
            watchEnabled="true"/>


</Host>

有谁知道或有可行的配置可以使农场部署器与上述 HA 和 LB 配置完美配合吗?

谢谢你!


更新:1

我按照您的配置配置了 3 个节点,但我无法使用域名(指向 LB)访问站点,它提供了 tomcat ROOT 页面,但可以进行ip/myapp渲染。

war 文件 myapp.war 已部署到所有服务器,但除管理器节点(部署者 Web 服务器)之外的其他 2 个节点上没有提取。

登录其他 2 个网络服务器

dead.[org.apache.catalina.tribes.membership.MemberImpl[tcp://{-64, -88, 2, 56}:4000,{-64, -88, 2, 56},4000, alive=2908632,id={64 21 -13 -74 -38 -98 70 117 -117 77 40 -79 124 -110 56 59 }, payload={}, command={}, domain={}, ]]
    18 Aug, 2011 3:17:33 AM org.apache.catalina.ha.tcp.SimpleTcpCluster memberAdded
    INFO: Replication member added:org.apache.catalina.tribes.membership.MemberImpl[tcp://{-64, -88, 2, 56}:4000,{-64, -88, 2, 56},4000, alive=1020,id={-65 -93 19 -47 -112 -115 78 -60 -118 99 120 107 -51 115 -88 115 }, payload={}, command={}, domain={}, ]
    18 Aug, 2011 3:19:55 AM org.apache.catalina.core.StandardContext stop
    INFO: Container org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/myapp] has not been started
    18 Aug, 2011 3:19:55 AM org.apache.catalina.startup.HostConfig checkResources
    INFO: Undeploying context [/myapp]
    18 Aug, 2011 3:19:59 AM org.apache.catalina.startup.HostConfig checkResources
    INFO: Undeploying context [/myapp]
    18 Aug, 2011 3:20:01 AM org.apache.catalina.startup.HostConfig deployWAR
    INFO: Deploying web application archive myapp.war
    18 Aug, 2011 3:20:01 AM org.apache.catalina.startup.ContextConfig init
    SEVERE: Exception fixing docBase: {0} 
    java.util.zip.ZipException: invalid CEN header (bad signature)
        at java.util.zip.ZipFile.open(Native Method)
        at java.util.zip.ZipFile.<init>(ZipFile.java:131)
        at java.util.jar.JarFile.<init>(JarFile.java:150)
        at java.util.jar.JarFile.<init>(JarFile.java:87)
        at sun.net.www.protocol.jar.URLJarFile.<init>(URLJarFile.java:90)
        at sun.net.www.protocol.jar.URLJarFile.getJarFile(URLJarFile.java:66)
        at sun.net.www.protocol.jar.JarFileFactory.get(JarFileFactory.java:86)
        at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:122)
        at sun.net.www.protocol.jar.JarURLConnection.getJarFile(JarURLConnection.java:89)
        at org.apache.catalina.startup.ExpandWar.expand(ExpandWar.java:141)
        at org.apache.catalina.startup.ContextConfig.fixDocBase(ContextConfig.java:883)
        at org.apache.catalina.startup.ContextConfig.init(ContextConfig.java:1012)
        at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:279)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
        at org.apache.catalina.core.StandardContext.init(StandardContext.java:5338)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4086)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:830)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:515)
        at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1231)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:616)
        at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297)
        at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:857)
        at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:795)
        at org.apache.catalina.ha.deploy.FarmWarDeployer.check(FarmWarDeployer.java:623)
        at org.apache.catalina.ha.deploy.FarmWarDeployer.messageReceived(FarmWarDeployer.java:246)
        at org.apache.catalina.ha.tcp.SimpleTcpCluster.messageReceived(SimpleTcpCluster.java:899)
        at org.apache.catalina.ha.tcp.SimpleTcpCluster.messageReceived(SimpleTcpCluster.java:880)
        at org.apache.catalina.tribes.group.GroupChannel.messageReceived(GroupChannel.java:269)
        at org.apache.catalina.tribes.group.ChannelInterceptorBase.messageReceived(ChannelInterceptorBase.java:79)
        at org.apache.catalina.tribes.group.ChannelInterceptorBase.messageReceived(ChannelInterceptorBase.java:79)
        at org.apache.catalina.tribes.group.interceptors.TcpFailureDetector.messageReceived(TcpFailureDetector.java:110)
        at org.apache.catalina.tribes.group.ChannelInterceptorBase.messageReceived(ChannelInterceptorBase.java:79)
        at org.apache.catalina.tribes.group.ChannelCoordinator.messageReceived(ChannelCoordinator.java:241)
        at org.apache.catalina.tribes.transport.ReceiverBase.messageDataReceived(ReceiverBase.java:225)
        at org.apache.catalina.tribes.transport.nio.NioReplicationTask.drainChannel(NioReplicationTask.java:188)
        at org.apache.catalina.tribes.transport.nio.NioReplicationTask.run(NioReplicationTask.java:91)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
        at java.lang.Thread.run(Thread.java:636)
    18 Aug, 2011 3:20:01 AM org.apache.catalina.core.StandardContext resourcesStart
    SEVERE: Error starting static Resources
    java.lang.IllegalArgumentException: Invalid or unreadable WAR file : invalid CEN header (bad signature)
        at org.apache.naming.resources.WARDirContext.setDocBase(WARDirContext.java:135)
        at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:3957)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4126)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:830)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:515)
        at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1231)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:616)
        at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297)
        at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:857)
        at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:795)
        at org.apache.catalina.ha.deploy.FarmWarDeployer.check(FarmWarDeployer.java:623)
        at org.apache.catalina.ha.deploy.FarmWarDeployer.messageReceived(FarmWarDeployer.java:246)
        at org.apache.catalina.ha.tcp.SimpleTcpCluster.messageReceived(SimpleTcpCluster.java:899)
        at org.apache.catalina.ha.tcp.SimpleTcpCluster.messageReceived(SimpleTcpCluster.java:880)
        at org.apache.catalina.tribes.group.GroupChannel.messageReceived(GroupChannel.java:269)
        at org.apache.catalina.tribes.group.ChannelInterceptorBase.messageReceived(ChannelInterceptorBase.java:79)
        at org.apache.catalina.tribes.group.ChannelInterceptorBase.messageReceived(ChannelInterceptorBase.java:79)
        at org.apache.catalina.tribes.group.interceptors.TcpFailureDetector.messageReceived(TcpFailureDetector.java:110)
        at org.apache.catalina.tribes.group.ChannelInterceptorBase.messageReceived(ChannelInterceptorBase.java:79)
        at org.apache.catalina.tribes.group.ChannelCoordinator.messageReceived(ChannelCoordinator.java:241)
        at org.apache.catalina.tribes.transport.ReceiverBase.messageDataReceived(ReceiverBase.java:225)
        at org.apache.catalina.tribes.transport.nio.NioReplicationTask.drainChannel(NioReplicationTask.java:188)
        at org.apache.catalina.tribes.transport.nio.NioReplicationTask.run(NioReplicationTask.java:91)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
        at java.lang.Thread.run(Thread.java:636)
    18 Aug, 2011 3:20:01 AM org.apache.catalina.core.StandardContext start
    SEVERE: Error in resourceStart()
    18 Aug, 2011 3:20:01 AM org.apache.catalina.ha.deploy.FileMessageFactory writeMessage
    WARNING: Receive Message again -- Sender ActTimeout to short [ path: /myapp war: /usr/share/tomcat/webapps/myapp.war data: [B@107108e data length: 6535 ]
    18 Aug, 2011 3:20:01 AM org.apache.catalina.core.StandardContext start
    SEVERE: Error getConfigured
    18 Aug, 2011 3:20:01 AM org.apache.catalina.core.StandardContext start
    SEVERE: Context [/myapp] startup failed due to previous errors
    18 Aug, 2011 3:20:01 AM org.apache.catalina.core.StandardContext stop
    INFO: Container org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/myapp] has not been started
    18 Aug, 2011 3:20:09 AM org.apache.catalina.startup.HostConfig deployWAR
    INFO: Deploying web application archive myapp.war
    18 Aug, 2011 3:20:09 AM org.apache.catalina.startup.ContextConfig init
    SEVERE: Exception fixing docBase: {0} 
    java.util.zip.ZipException: invalid CEN header (bad signature)
        at java.util.zip.ZipFile.open(Native Method)
        at java.util.zip.ZipFile.<init>(ZipFile.java:131)
        at java.util.jar.JarFile.<init>(JarFile.java:150)
        at java.util.jar.JarFile.<init>(JarFile.java:87)
        at sun.net.www.protocol.jar.URLJarFile.<init>(URLJarFile.java:90)
        at sun.net.www.protocol.jar.URLJarFile.getJarFile(URLJarFile.java:66)
        at sun.net.www.protocol.jar.JarFileFactory.get(JarFileFactory.java:86)
        at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:122)
        at sun.net.www.protocol.jar.JarURLConnection.getJarFile(JarURLConnection.java:89)
        at org.apache.catalina.startup.ExpandWar.expand(ExpandWar.java:141)
        at org.apache.catalina.startup.ContextConfig.fixDocBase(ContextConfig.java:883)
        at org.apache.catalina.startup.ContextConfig.init(ContextConfig.java:1012)
        at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:279)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
        at org.apache.catalina.core.StandardContext.init(StandardContext.java:5338)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4086)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:830)
        at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:719)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:490)
        at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1217)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:293)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
        at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337)
        at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
        at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
        at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
        at java.lang.Thread.run(Thread.java:636)
    18 Aug, 2011 3:20:09 AM org.apache.catalina.core.StandardContext resourcesStart
    SEVERE: Error starting static Resources
    java.lang.IllegalArgumentException: Invalid or unreadable WAR file : invalid CEN header (bad signature)
        at org.apache.naming.resources.WARDirContext.setDocBase(WARDirContext.java:135)
        at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:3957)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4126)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:830)
        at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:719)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:490)
        at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1217)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:293)
        at 
        at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
        at java.lang.Thread.run(Thread.java:636)
    18 Aug, 2011 3:20:09 AM org.apache.catalina.core.StandardContext start
    SEVERE: Error in resourceStart()
    18 Aug, 2011 3:20:09 AM org.apache.catalina.core.StandardContext start
    SEVERE: Error getConfigured
    18 Aug, 2011 3:20:09 AM org.apache.catalina.core.StandardContext start
    SEVERE: Context [/myapp] startup failed due to previous errors
    18 Aug, 2011 3:20:09 AM org.apache.catalina.core.StandardContext stop
    INFO: Container org.apache.catalina.core.ContainerBase.[Catalina].[www.mydomain.com].[/myapp] has not been started
    18 Aug, 2011 3:28:09 AM org.apache.catalina.ha.session.ClusterSessionListener messageReceived
    WARNING: Context manager doesn't exist:/myapp
    18 Aug, 2011 3:28:09 AM org.apache.catalina.ha.session.ClusterSessionListener messageReceived
    WARNING: Context manager doesn't exist:/myapp

登录部署者 Web 服务器

18 Aug, 2011 4:50:57 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.18
18 Aug, 2011 4:50:57 PM org.apache.catalina.core.StandardContext resourcesStart
SEVERE: Error starting static Resources
java.lang.IllegalArgumentException: Document base /usr/share/tomcat/webapps/myapp does not exist or is not a readable directory
    at org.apache.naming.resources.FileDirContext.setDocBase(FileDirContext.java:141)
    at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:3957)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4126)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    at org.apache.catalina.core.StandardService.start(StandardService.java:516)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
18 Aug, 2011 4:50:57 PM org.apache.catalina.core.StandardContext start
SEVERE: Error in resourceStart()
18 Aug, 2011 4:50:57 PM org.apache.catalina.core.StandardContext start
SEVERE: Error getConfigured
18 Aug, 2011 4:50:57 PM org.apache.catalina.core.StandardContext start
SEVERE: Context [] startup failed due to previous errors
18 Aug, 2011 4:50:57 PM org.apache.catalina.core.StandardContext stop
INFO: Container org.apache.catalina.core.ContainerBase.[Catalina].[www.mydomain.com].[/] 
18 Aug, 2011 4:50:59 PM org.apache.catalina.ha.deploy.FarmWarDeployer start
INFO: Cluster deployment is watching /usr/share/tomcat/watch/ for changes.
18 Aug, 2011 4:50:59 PM org.apache.catalina.ha.deploy.FarmWarDeployer start
INFO: Cluster FarmWarDeployer started.
18 Aug, 2011 4:50:59 PM org.apache.catalina.ha.session.JvmRouteBinderValve start
INFO: JvmRouteBinderValve started
18 Aug, 2011 4:50:59 PM org.apache.catalina.ha.session.DeltaManager start
INFO: Register manager /manager to cluster element Host with name localhost
18 Aug, 2011 4:50:59 PM org.apache.catalina.ha.session.DeltaManager start
INFO: Starting clustering manager at /manager
18 Aug, 2011 4:50:59 PM org.apache.catalina.ha.session.DeltaManager getAllClusterSessions
INFO: Manager [/manager]: skipping state transfer. No members active in cluster group.
18 Aug, 2011 4:50:59 PM org.apache.catalina.ha.session.DeltaManager start
INFO: Register manager /docs to cluster element Host with name localhost

INFO: Starting clustering manager at 
18 Aug, 2011 4:50:59 PM org.apache.catalina.ha.session.DeltaManager getAllClusterSessions
INFO: Manager []: skipping state transfer. No members active in cluster group.
18 Aug, 2011 4:50:59 PM org.apache.catalina.ha.session.DeltaManager start
INFO: Register manager /host-manager to cluster element Host with name localhost
18 Aug, 2011 4:50:59 PM org.apache.catalina.ha.session.DeltaManager start
INFO: Starting clustering manager at /host-manager
18 Aug, 2011 4:50:59 PM org.apache.catalina.ha.session.DeltaManager getAllClusterSessions
INFO: Manager [/host-manager]: skipping state transfer. No members active in cluster group.
18 Aug, 2011 4:51:00 PM org.apache.catalina.ha.session.DeltaManager start
INFO: Register manager /examples to cluster element Host with name localhost
18 Aug, 2011 4:51:00 PM org.apache.catalina.ha.session.DeltaManager start
INFO: Starting clustering manager at /examples
18 Aug, 2011 4:51:00 PM org.apache.catalina.ha.session.DeltaManager getAllClusterSessions
INFO: Manager [/examples]: skipping state transfer. No members active in cluster group.
18 Aug, 2011 4:51:00 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-9080
18 Aug, 2011 4:51:00 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
18 Aug, 2011 4:51:00 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/57  config=null
18 Aug, 2011 4:51:00 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 3206 ms
18 Aug, 2011 4:51:01 PM org.apache.catalina.tribes.io.BufferPool getBufferPool
INFO: Created a buffer pool with max size:104857600 bytes of notified:org.apache.catalina.tribes.membership.MemberImpl[tcp://192.168.1.101:4002,192.168.1.101,4002, alive=0,id={0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }, payload={}, command={}, domain={115 116 97 103 105 110 103 45 99 ...(15)}, ]
18 Aug, 2011 4:51:04 PM org.apache.catalina.ha.tcp.SimpleTcpCluster memberAdded
INFO: Replication member added:org.apache.catalina.tribes.membership.MemberImpl[tcp://192.168.1.101:4002,192.168.1.101,4002, alive=0,id={0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }, payload={}, command={}, domain={115 116 97 103 105 110 103 45 99 ...(15)}, ]
18 Aug, 2011 4:51:06 PM org.apache.catalina.ha.tcp.SimpleTcpCluster memberAdded
INFO: Replication member added:org.apache.catalina.tribes.membership.MemberImpl[tcp://{-64, -88, 2, 53}:4001,{-64, -88, 2, 53},4001, alive=1007,id={80 88 -34 -11 98 72 71 -70 -75 -107 -48 -91 -90 50 -126 116 }, payload={}, command={}, domain={}, ]
18 Aug, 2011 4:51:09 PM org.apache.catalina.tribes.group.interceptors.TcpFailureDetector performBasicCheck
WARNING: Member added, even though we werent notified:org.apache.catalina.tribes.membership.MemberImpl[tcp://192.168.1.102:4001,192.168..102,4001, alive=0,id={0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }, payload={}, command={}, domain={115 116 97 103 105 110 103 45 99 ...(15)}, ]
18 Aug, 2011 4:51:09 PM org.apache.catalina.ha.tcp.SimpleTcpCluster memberAdded
INFO: Replication member added:org.apache.catalina.tribes.membership.MemberImpl[tcp://192.168.1.102:4001,192.168.1.102,4001, alive=0,id={0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }, payload={}, command={}, domain={115 116 97 103 105 110 103 45 99 ...(15)}, ]
18 Aug, 2011 4:51:20 PM org.apache.catalina.ha.deploy.WarWatcher check
INFO: check cluster wars at /usr/share/tomcat/watch
18 Aug, 2011 4:51:20 PM org.apache.catalina.ha.deploy.FarmWarDeployer fileModified
INFO: Installing webapp[/myapp] from /usr/share/tomcat/webapps/myapp.war
18 Aug, 2011 4:51:20 PM org.apache.catalina.ha.deploy.FarmWarDeployer remove
INFO: Cluster wide remove of web app /myapp
18 Aug, 2011 4:51:26 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive myapp.war
18 Aug, 2011 4:51:27 PM org.apache.catalina.ha.session.DeltaManager start
INFO: Register manager /myapp to cluster element Host with name localhost
18 Aug, 2011 4:51:27 PM org.apache.catalina.ha.session.DeltaManager start
INFO: Starting clustering manager at /myapp
18 Aug, 2011 4:51:27 PM org.apache.catalina.ha.session.DeltaManager getAllClusterSessions
WARNING: Manager [/myapp], requesting session state from org.apache.catalina.tribes.membership.MemberImpl[tcp://{-64, -88, 2, 101}:4002,{-64, -88, 2, 101},4002, alive=26275,id={-120 -66 103 32 -56 -122 77 51 -95 20 25 88 83 -69 -59 -115 }, payload={}, command={}, domain={}, ]. This operation will timeout if no session state has been received within 60 seconds.
18 Aug, 2011 4:52:27 PM org.apache.catalina.ha.session.DeltaManager waitForSendAllSessions
SEVERE: Manager [/myapp]: No session state send at 18/8/11 4:51 PM received, timing out after 60,073 ms.
18 Aug, 2011 4:52:44 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive myapp.war
18 Aug, 2011 4:52:45 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
18 Aug, 2011 4:52:48 PM org.apache.catalina.core.ApplicationContext log
INFO: org.tuckey.web.filters.urlrewrite.utils.Log ERROR: logLevelConf: null
18 Aug, 2011 4:52:48 PM org.apache.catalina.core.ApplicationContext log
INFO: org.tuckey.web.filters.urlrewrite.UrlRewriteFilter INFO: loaded (conf ok)
18 Aug, 2011 4:52:48 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'SpringAction'
18 Aug, 2011 4:53:00 PM org.apache.catalina.ha.deploy.WarWatcher check
INFO: check cluster wars at /usr/share/tomcat/watch
18 Aug, 2011 4:53:20 PM org.apache.catalina.ha.deploy.WarWatcher check

更新:2为了编辑

ifconfigeth0在所有 Web 服务器上列出以下条目

UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1

在所有 Web 服务器上执行以下命令

route add -host 228.0.0.4 dev eth0

ping228.0.0.4在任何系统上都不起作用

lsof-i:4000在部署器 Web 服务器(也在其他服务器上)上列出的内容与您列出的内容类似(由于该帖子的字符数超出,因此无法在此处粘贴):

改进:我很高兴地使用了多播配置,当我将 war 文件放在部署器 web 服务器上的监视目录中时,我看到auto了另一台 web 服务器上的 myapp.war。问题是,war 仅在部署器 web 服务器上提取(创建目录),而不是在其他服务器上提取。ipReceiver

答案1

如何更新 3 个 Web 服务器?

与处理 2 个节点时的操作相同。

在部署节点上,再添加一个成员StaticMembershipInterceptor

<Member className="org.apache.catalina.tribes.membership.StaticMember"
                          port="4002"
                          securePort="-1"
                          host="192.168.5.208"
                          domain="staging-cluster"
                          uniqueId="{0,1,2,3,4,5,6,7,8,9}"/>

在节点 3 上,创建如下集群:

        <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster">
            <Channel className="org.apache.catalina.tribes.group.GroupChannel">
                <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
                      address="192.168.5.208"
                      port="4002"
                      selectorTimeout="100"
                      maxThreads="6"/>
            </Channel>
            <Deployer className="org.apache.catalina.ha.deploy.FarmWarDeployer"
                tempDir="/opt/tomcat6/tempdir/"
                deployDir="/opt/tomcat6/webapps/"
                watchDir="/opt/tomcat6/watchdir/"
                watchEnabled="false"/>
        </Cluster>

并将 *.war 文件复制到watchdir部署节点的目录中,将出现以下几行catalina.out

INFO: check cluster wars at /usr/share/tomcat6/watchdir
Aug 17, 2011 2:07:53 PM org.apache.catalina.tribes.group.interceptors.TcpFailureDetector performBasicCheck
WARNING: Member added, even though we werent notified:org.apache.catalina.tribes.membership.MemberImpl[tcp://192.168.5.208:40
02,192.168.5.208,4002, alive=0,id={0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }, payload={}, command={}, domain={115 116 97 103 105 110 
103 45 99 ...(15)}, ]
Aug 17, 2011 2:07:53 PM org.apache.catalina.ha.tcp.SimpleTcpCluster memberAdded
INFO: Replication member added:org.apache.catalina.tribes.membership.MemberImpl[tcp://192.168.5.208:4002,192.168.5.208,4002, 
alive=0,id={0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }, payload={}, command={}, domain={115 116 97 103 105 110 103 45 99 ...(15)}, ]
Aug 17, 2011 2:08:12 PM org.apache.catalina.ha.deploy.WarWatcher check
INFO: check cluster wars at /usr/share/tomcat6/watchdir
Aug 17, 2011 2:08:12 PM org.apache.catalina.ha.deploy.FarmWarDeployer fileModified
INFO: Installing webapp[/cas] from /usr/share/tomcat6/webapps/cas.war
Aug 17, 2011 2:08:12 PM org.apache.catalina.ha.deploy.FarmWarDeployer remove
INFO: Cluster wide remove of web app /cas
Aug 17, 2011 2:08:13 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive cas.war

检查webapps节点3上的文件夹:

drwxr-xr-x  8 root    root        4096 Aug 17 14:08 cas
-rw-r--r--  1 root    root    19962865 Aug 17 14:08 cas.war
...

以及catalina.out

Aug 17, 2011 2:08:13 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive cas.war

编辑

无效或不可读的 WAR 文件:无效的 CEN 标头(错误签名)

部署到其他 2 个节点时,WAR 文件似乎已损坏。这种情况发生的频率是多少?

除了 FarmDeployer 之外,是否可以让 FarmDeployer 与 tomcat 集群文档中的多播协同工作,这对我来说非常完美?

我找到了!原因是您没有为网络接口添加多播路由,因此无法在 Tomcat 节点之间发送/接收集群消息:

lsof -i :4000
COMMAND  PID   USER   FD   TYPE    DEVICE SIZE NODE NAME
java    9968 tomcat   37u  IPv6 121232775       TCP localhost:terabase (LISTEN)

请按照下列步骤进行:

  • 确保您的网络接口已启用多播:

    UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1

  • 添加多播路由:

    route add -host 228.0.0.4 dev bond1

(你应该改成bond1接收集群消息的网络接口)

测试对ping -c 4 228.0.0.4我来说不起作用。所以我下载了多播测试工具,运行它,我看到以下响应:

./bin/multicast-test.sh -local 192.168.5.149 -group 228.0.0.4:45564
PATH=/usr/lib64/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/var/ossec/bin
java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
Java HotSpot(TM) 64-Bit Server VM (build 11.3-b02, mixed mode)

Oracle Coherence Version 3.3.1/389
 Grid Edition: Development mode
Copyright (c) 2000-2007 Oracle. All rights reserved.

Starting test on ip=/192.168.5.149, group=/228.0.0.4:45564, ttl=4
Configuring multicast socket...
Starting listener...
Fri Aug 19 10:19:14 ICT 2011: Sent packet 1.
Fri Aug 19 10:19:14 ICT 2011: Received test packet 1 from self (sent 9ms ago).
Fri Aug 19 10:19:14 ICT 2011: Received 69 bytes from an unknown multicast application at 192.168.5.199: ???
Fri Aug 19 10:19:14 ICT 2011: Received 69 bytes from an unknown multicast application at 192.168.5.149: ???

或者您可以检查lsof,,netstat...

lsof -i :4000
COMMAND   PID   USER   FD   TYPE    DEVICE SIZE NODE NAME
java    11084 tomcat   37u  IPv6 121236631       TCP localhost:terabase (LISTEN)
java    11084 tomcat   59u  IPv6 121236830       TCP localhost:terabase->192.168.5.199:43519 (ESTABLISHED)
java    11084 tomcat   66u  IPv6 121236835       TCP localhost:55538->192.168.5.199:terabase (ESTABLISHED)
java    11084 tomcat   67u  IPv6 121236836       TCP localhost:55539->192.168.5.199:terabase (ESTABLISHED)

您已准备好使用多播配置 Tomcat 集群。

启用与文档中提到的相同的集群配置,但将<Receiver地址从“自动”更改为指定接口:

<Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
                      address="192.168.5.149"
                      port="4000"
                      autoBind="100"
                      selectorTimeout="5000"
                      maxThreads="6"/>

对集群中的所有节点执行相同操作以查看其是否有效。


编辑2

改进:我很高兴地使用多播配置将 Receiver 中的自动更改为 ip,当我将 war 文件放在部署器 Web 服务器上的监视目录中时,我看到了另一台 Web 服务器上的 myapp.war。问题是,war 仅在部署器 Web 服务器上提取(创建目录),而不是在其他服务器上提取。

这意味着部署节点与其他节点之间的连接已建立。你还收到相同的错误吗?“无效或不可读的 WAR 文件:无效的 CEN 标头(错误签名)”? 每次?


java.util.zip.ZipException: invalid END header (bad central directory offset)

根据错误45851,您应该升级 Tomcat 版本(至少 6.0.19)并重试。我使用的是 6.0.29 版本,如您所见,它运行良好。


需要在其他 Web 服务器上重新启动 tomcat,然后复制并提取,并且该站点可通过 other-web-severs-ip/myapp 访问,但不能通过域名访问(404 错误)。您将站点域名指向哪里?我将 DNS 中的站点域名指向 LB,并在所有具有相同域名的 tomcat Web 服务器中创建虚拟主机

。看来你没有清理干净。不需要在所有Tomcat节点上创建虚拟主机。

假设在节点 1 上有 Apache HTTP 服务器和 Tomcat,IP 为 192.168.1.101。另外两个 Tomcat 节点分别位于 1.102、1.103。jvmRoute对应的节点为:tomcat1、tomcat2、tomcat3。

Apache mod_jk.confHTTP 服务器上:

LoadModule          jk_module modules/mod_jk.so

JkWorkersFile       /etc/httpd/conf/workers.properties
JkShmFile           /var/log/httpd/jk.shm

JkLogFile           /var/log/httpd/mod_jk.log
JkLogLevel          info
JkLogStampFormat    "[%a %b %d %H:%M:%S %Y] "

JkMount /myapp/*    cluster

workers.properties这样的:

worker.list = cluster

worker.tomcat1.port=8009        
worker.tomcat1.host=localhost
worker.tomcat1.type=ajp13
worker.tomcat1.lbfactor=1

worker.tomcat2.port=8009        
worker.tomcat2.host=192.168.1.102
worker.tomcat2.type=ajp13
worker.tomcat2.lbfactor=1

worker.tomcat3.port=8009        
worker.tomcat3.host=192.168.1.103
worker.tomcat3.type=ajp13
worker.tomcat3.lbfactor=1

worker.cluster.type=lb
worker.cluster.balance_workers=tomcat1,tomcat2,tomcat3
worker.cluster.sticky_session=1

再试一次。

相关内容