You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Babu Satasiya <ba...@gmail.com> on 2007/02/13 21:10:49 UTC

Re: [OT] A Howto for Tomcat 6.0.9, mod_jk, apache 2.2 load balancing + session replication

Hi,

Please update about cluster option in server.xml, without that how does it
work. If you can post all the steps will help others, otherwise it may even
confuse to others.

Thanks for posting on session replication, please let me know if we anyone
have live application and if they go for session replication which you
explain is method using session in memory. Will they need to do anything in
application or not?

With regards,

Babulal Satasiya


Sriram Narayanan wrote:
> 
> Hi all:
> 
> I just got this working, so I thought of posting a small howto for the
> list :)
> 
> ================================================
> 
> An apache instance (httpd) that serves http://localhost/examples/
> where /examples is served by two Tomcat instances (if one is
> down/unavailable, then httpd decides to redirect requests to the
> second tomcat instances.
> 
> What I've got working so far:
> - Session replication between the various Tomcat instances in the cluster.
> - In case one instance is not available, then apache sends new
> requests to the next instance.
> - When and instance comes back, it joins the cluster, receives session
> replication, and is ready to take over when required.
> 
> What else is possible:
> - Load balance based on the number of requests already sent to a Tomcat
> instance
> - Configure timeouts, etc
> - More information at
> http://tomcat.apache.org/connectors-doc/reference/workers.html
> 
> What's not possible:
> - If the first instance dies, then the second instance carries on
> processing from that point.
> 
> To try this yourself:
> 1. Download and install Apache Tomcat 6.0.9
> 
> 2. In server.xml, uncomment the tag for clustering
> 
> 3. Edit the webapps/example/WEB-INF/web.xml to include the distributable
> tag
> 	<distributable/>
> 
> 4. Create a copy of this Tomcat folder (say, Tomcat2)
> 
> 5. Edit the server.xml in Tomcat2. Change all the port numbers. e.g.
> change the AJP port number to 8010
> 
> 6. Download the file
> http://mirrors.24-7-solutions.net/pub/apache/tomcat/tomcat-connectors/jk/binaries/win32/jk-1.2.20/mod_jk-apache-2.2.3.so
> and save it as mod_jk.so at apache/modules folder.
> 
> 7. Place the following contents in the file apache/conf/worker.properties
> 	# The advanced router LB worker
> 	  worker.list=router,worker2,worker1
> 	
> 	  # Define a worker using ajp13
> 	  worker.worker1.port=8009
> 	  worker.worker1.host=localhost
> 	  worker.worker1.type=ajp13
> 	  worker.worker1.lbfactor=1
> 	  # Define prefered failover node for worker1
> 	  worker.worker1.redirect=worker2
> 	
> 	  # Define another worker using ajp13
> 	  worker.worker2.port=8010
> 	  worker.worker2.host=localhost
> 	  worker.worker2.type=ajp13
> 	  worker.worker2.lbfactor=1
> 	  worker.worker2.mount=/examples/*
> 	  # Disable worker2 for all requests except failover
> 	  worker.worker2.activation=disabled
> 	
> 	  # Define the LB worker
> 	  worker.router.type=lb
> 	  worker.router.balance_workers=worker1,worker2
> 	
> 	  worker.list=jkstatus
> 	  # Define a 'jkstatus' worker using status
>   worker.jkstatus.type=status
> 
> 8. Edit apache/conf/httpd.conf to include the following:
> LoadModule    jk_module  modules/mod_jk.so
> 
> #AddModule     mod_jk.c
> 
> JkWorkersFile conf/worker.properties
> 
> JkShmFile     mod_jk.shm
> JkLogFile     mod_jk.log
> 
> JkLogLevel    info
> JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
> 
> JkMount /jkmanager/* jkstatus
> 
> JkMount  /examples/* router
> 
> 9. Start the two Tomcat instances
> 	You should see some replication related messages in the console
> 
> 	Feb 13, 2007 8:01:34 PM org.apache.catalina.ha.tcp.SimpleTcpCluster
> memberAdded
> 	INFO: Replication member
> added:org.apache.catalina.tribes.membership.MemberImpl[
> 
> tcp://Ramn.corporate.thoughtworks.com:4001,Ramn.corporate.thoughtworks.com,4001,
> 	 alive=1016,id={99 34 -19 82 10 -107 64 51 -119 77 9 -117 -91 9 24 -9
> }, payload
> ={}, command={}, domain={}, ]
> 
> INFO: Manager [localhost#/examples]; session state send at 2/13/07 8:01 PM
> recei
> ved in 125 ms.
> 
> 
> 10. Restart the httpd web server
> 
> Testing the session replication
> 1. Browse to http://localhost/examples/
> 
> 2. Try the Session examples for the servlet.
> 
> 3. Set a variable into the session with a value
> 
> 4. Stop the first Tomcat instance
> 
> 5. Set another variable into the session.
> 	This time, the second Tomcat instance will serve the content
> 	You'll see that the first variable is still in the session. This is a
> sign that replication has been successful.
> 
> 6. Restart the first instance, wait for it to enter the cluster and
> for the replication to happen
> INFO: Manager [localhost#/examples]; session state send at 2/13/07 8:01 PM
> recei
> ved in 125 ms.
> 
> 7. Stop the second Tomcat instance.
> 
> 8. Set another variable into the session.
> 
> 9. You'll see that all the variables are still available.
> 
> -- Sriram
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/A-Howto-for-Tomcat-6.0.9%2C-mod_jk%2C-apache-2.2-load-balancing-%2B-session-replication-tf3221269.html#a8952084
Sent from the Tomcat - User mailing list archive at Nabble.com.


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


Re: [OT] A Howto for Tomcat 6.0.9, mod_jk, apache 2.2 load balancing + session replication

Posted by Sriram Narayanan <sr...@gmail.com>.
On 2/16/07, Babu Satasiya <ba...@gmail.com> wrote:
>
> Hi,
>
> Thanks,
>
> Do you think application needs to take care of new session replication or
> not, if not then try cart in example and you will find error message, You
> need to do some serialization of objects unless its not possible.
>

Even if you didn't want clustering support, all objects that are added
into the session _have_ to be Serializable. This is a requirement.

What is the error that you get when you try the cart example ?

> Regarding multicast address setup on that cluster option, do we need to
> setup that on all the cluter tomcat system, otherwise how it will work?
>

There is a default multicast address and port. When you enable the
SimpleTCP option, that default value is used.

If you read the document at
http://tomcat.apache.org/tomcat-5.5-doc/cluster-howto.html, scroll
down to the section called "Simple Cluster Configuration". That has a
server.xml which contains the tag "<Cluster
className="org.apache.catalina.cluster.tcp.SimpleTcpCluster"/>".

By, default, this tag is commented out. We need to uncomment it.

In that same document, beneath the sample server.xml, you'll find text
on the default multicast address (228.0.0.4) and the multicast udp
port (8012). So, all Tomcats that use this default configuration will
also become part of the same cluster.

If you want multiple Tomcat instances to be part of various clusters
selectively, you'll have to specify different groups of  multicast
addresses. So, TomcatA and TomcatB would have one multicast address
and port, while TomcatC and TomcatD would have some other multicast
address and port.

This too is documented at that same section.


> Please update on all the steps which you might have done not documented to
> how to which will help others to get going with session replication. If it
> is possible you can add your server.xml of both tomcat.
>
> With regards,
>
> Babulal Satasiya
> Cisco System Inc.
>
>
> Sriram Narayanan wrote:
> >
> > On 2/14/07, Babu Satasiya <ba...@gmail.com> wrote:
> >>
> >> Hi,
> >>
> >> Please update about cluster option in server.xml, without that how does
> >> it
> >> work. If you can post all the steps will help others, otherwise it may
> >> even
> >> confuse to others.
> >>
> >
> > I just looked over my previous post, and I see the following statement:
> >
> > 2. In server.xml, uncomment the tag for clustering
> >
> > That's all that I needed to do for enabling clustering on Tomcat.
> >
> >
> >> Thanks for posting on session replication, please let me know if we
> >> anyone
> >> have live application and if they go for session replication which you
> >> explain is method using session in memory. Will they need to do anything
> >> in
> >> application or not?
> >>
> > http://tomcat.apache.org/tomcat-5.5-doc/cluster-howto.html That link
> > describes clustering better than I would.
> >
> > -- Sriram
> >
> > ---------------------------------------------------------------------
> > To start a new topic, e-mail: users@tomcat.apache.org
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
> >
> >
>
> --
> View this message in context: http://www.nabble.com/A-Howto-for-Tomcat-6.0.9%2C-mod_jk%2C-apache-2.2-load-balancing-%2B-session-replication-tf3221269.html#a8998726
> Sent from the Tomcat - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

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


Re: [OT] A Howto for Tomcat 6.0.9, mod_jk, apache 2.2 load balancing + session replication

Posted by Babu Satasiya <ba...@gmail.com>.
Hi,

Thanks,

Do you think application needs to take care of new session replication or
not, if not then try cart in example and you will find error message, You
need to do some serialization of objects unless its not possible.

Regarding multicast address setup on that cluster option, do we need to
setup that on all the cluter tomcat system, otherwise how it will work?

Please update on all the steps which you might have done not documented to
how to which will help others to get going with session replication. If it
is possible you can add your server.xml of both tomcat.

With regards,

Babulal Satasiya
Cisco System Inc.


Sriram Narayanan wrote:
> 
> On 2/14/07, Babu Satasiya <ba...@gmail.com> wrote:
>>
>> Hi,
>>
>> Please update about cluster option in server.xml, without that how does
>> it
>> work. If you can post all the steps will help others, otherwise it may
>> even
>> confuse to others.
>>
> 
> I just looked over my previous post, and I see the following statement:
> 
> 2. In server.xml, uncomment the tag for clustering
> 
> That's all that I needed to do for enabling clustering on Tomcat.
> 
> 
>> Thanks for posting on session replication, please let me know if we
>> anyone
>> have live application and if they go for session replication which you
>> explain is method using session in memory. Will they need to do anything
>> in
>> application or not?
>>
> http://tomcat.apache.org/tomcat-5.5-doc/cluster-howto.html That link
> describes clustering better than I would.
> 
> -- Sriram
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/A-Howto-for-Tomcat-6.0.9%2C-mod_jk%2C-apache-2.2-load-balancing-%2B-session-replication-tf3221269.html#a8998726
Sent from the Tomcat - User mailing list archive at Nabble.com.


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


Re: [OT] A Howto for Tomcat 6.0.9, mod_jk, apache 2.2 load balancing + session replication

Posted by Sriram Narayanan <sr...@gmail.com>.
On 2/14/07, Babu Satasiya <ba...@gmail.com> wrote:
>
> Hi,
>
> Please update about cluster option in server.xml, without that how does it
> work. If you can post all the steps will help others, otherwise it may even
> confuse to others.
>

I just looked over my previous post, and I see the following statement:

2. In server.xml, uncomment the tag for clustering

That's all that I needed to do for enabling clustering on Tomcat.


> Thanks for posting on session replication, please let me know if we anyone
> have live application and if they go for session replication which you
> explain is method using session in memory. Will they need to do anything in
> application or not?
>
http://tomcat.apache.org/tomcat-5.5-doc/cluster-howto.html That link
describes clustering better than I would.

-- Sriram

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