tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From János Löbb <janos.l...@yale.edu>
Subject [Cluster] fail over is failing on application stop
Date Mon, 11 Apr 2011 21:38:32 GMT
Hi,

I started a new thread.  I have two machines bml0065 and bml0066.  Both have OSX 10.6.5, httpd
2.2.17, tomcat 7.0.10, jk 1.2.31.  The bml0065 machine acts as a reverse proxy.

Here is the server.xml from bml0066, without comments:

<nyissz>
<?xml version='1.0' encoding='utf-8'?>
<Server port="8105" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <Listener className="org.apache.catalina.core.JasperListener" />
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

  <GlobalNamingResources>
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>

  <Service name="Catalina">
  
    <Connector port="8180" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8143" />
    
    <Connector port="8143" protocol="org.apache.coyote.http11.Http11Protocol" SSLEnabled="true"
               maxThreads="150" scheme="https" secure="true"
		keystoreFile="/Users/administrator/.keystore" keystorePass="ITAccess"
               clientAuth="false" sslProtocol="TLS" />
    

    <Connector port="8109" protocol="AJP/1.3" redirectPort="8143" />


    <Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1">
      
      <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
              

      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>

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

        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" 

               prefix="localhost_access_log." suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" resolveHosts="false"/>

      </Host>
    </Engine>
  </Service>
</Server>

<nyassz>

Similar server.xml exists for the other machine bml0065 only the jvmRoute and the ports are
different.

Here is a snippet showing the distributable tag in web.xml in the WEB-INF directory of the
examples web app:

<nyissz>
<!--	Temporarily the distributable tag goes here	-->
<!--	It should be in the given webapp's web.xml	-->
	<distributable/>

</web-app>

<nyassz>

I created an examples.xml in the $CATALINA_BASE/conf/Catalina/localhost directory on both
machines and the content of that file is this:

<nyissz>
bml0066:local administrator$ cat tomcat1/conf/Catalina/localhost/examples.xml 
<?xml version="1.0" encoding="UTF-8"?>
<Context className="org.apache.catalina.ha.context.ReplicatedContext"/>

<nyassz>
Unfortunately if I have just <Context org.apache.catalina.ha.context.ReplicatedContext/>
there then I receive these type of messages:
Apr 11, 2011 4:13:39 PM org.apache.tomcat.util.digester.Digester fatalError
SEVERE: Parse Fatal Error at line 18 column 59: Attribute name "org.apache.catalina.ha.context.ReplicatedContext"
associated with an element type "Context" must be followed by the ' = ' character.

I did a little test.  I opened the URL http://bml0065.yalepath.org/tc/examples/servlets/servlet/SessionExample
on my machine /bml0041/.  The reverse proxy sent the request to itself, then jk sent it to
the tomcat3 instance on the same machine.  I can see in the log of bml0065:

<nyissz>
INFO: Server startup in 6161 ms
Apr 11, 2011 4:40:47 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: sessionCreated('CA87BED01E4A1D0FF87AED173F66E35C.tomcat3')
Apr 11, 2011 4:41:04 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: attributeAdded('CA87BED01E4A1D0FF87AED173F66E35C.tomcat3', 's1', 't3')
Apr 11, 2011 4:41:37 PM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: init: Associated with Deployer 'Catalina:type=Deployer,host=localhost'
Apr 11, 2011 4:41:37 PM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: init: Global resources are available
Apr 11, 2011 4:41:37 PM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: list: Listing contexts for virtual host 'localhost'
<nyass>

Looking at the tomcat log on the other machine - bml0066 - I can see that the session is replicated:

<nyissz>
Apr 11, 2011 4:40:47 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: sessionCreated('CA87BED01E4A1D0FF87AED173F66E35C.tomcat3')
Apr 11, 2011 4:41:04 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: attributeAdded('CA87BED01E4A1D0FF87AED173F66E35C.tomcat3', 's1', 't3')
<nyassz>

Then I stop the examples application on the bml0065 machine running the tomcat3 instance.

Then I try to access it via the URL http://bml0065.yalepath.org/tc/examples/servlets/servlet/SessionExample

That is when I receive the 404 page:
<nyissz>
HTTP Status 404 - /examples/servlets/servlet/SessionExample

type Status report

message /examples/servlets/servlet/SessionExample

description The requested resource (/examples/servlets/servlet/SessionExample) is not available.

Apache Tomcat/7.0.10
<nyassz>

This not what I expected.  Because the session was replicated to the bml0066 machine I expected
that jk will re-route the request to the tomcat1 instance running on the bml0066 machine.

What configuration option or tag should I change to achieve tat result ?

What am I doing wrong ?

If I instead of stoping just the examples application stop the whole tomcat3 instance the
fail over is successful.  I guess it does because there is no more heartbeats from the tomcat3
instance.  So what config is needed for mod_jk to sense that the app was stopped and re-route
the request to the replicated session on tomcat1 instance ?

Here is my workers.properties from bml0065:
<nyissz>
worker.list = lb,jkstatus

worker.lb.type=lb
worker.lb.balance_workers=tomcat1,tomcat3
#,tomcat2,tomcat4
worker.lb.sticky_session = True
worker.lb.sticky_session_force = False

worker.jkstatus.type=status

worker.tomcat1.type = ajp13
worker.tomcat1.host = bml0066.yalepath.org
worker.tomcat1.port = 8109
worker.tomcat1.lbfactor = 1
worker.tomcat1.redirect=tomcat3

#worker.tomcat2.type = ajp13
#worker.tomcat2.host = bml0066.yalepath.org
#worker.tomcat2.port = 8209
#worker.tomcat2.lbfactor = 1
#worker.tomcat2.redirect=tomcat4

worker.tomcat3.type = ajp13
worker.tomcat3.host = bml0065.yalepath.org
worker.tomcat3.port = 8309
worker.tomcat3.lbfactor = 1
worker.tomcat3.redirect=tomcat1

#worker.tomcat4.type = ajp13
#worker.tomcat4.host = bml0065.yalepath.org
#worker.tomcat4.port = 8409
#worker.tomcat4.lbfactor = 1
#worker.tomcat4.redirect=tomcat2

<nyassz>



Thanks ahead,

János





---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message