[Logo] Terracotta Discussion Forums (LEGACY READ-ONLY ARCHIVE)
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
[Expert]
Tomcat clustering example  XML
Forum Index -> Terracotta for Web Sessions
Author Message
Q

neo

Joined: 05/24/2007 08:41:19
Messages: 2
Offline

Hello there,

I just run over the features of Terracotta and I wonder if there is a step by step document that will show how to cluster a tomcat application on the same box.

On top of that few questions about that. I use Hibernate and since I had one instance of tomcat I have ehcache as my cache manager. I cache quite a bit of data to avoid trips to the database. When I'd cluster my every single JVM will double the space so I'd have to move to a different kind of caching (OSCache) how ever I still have trouble to figure it out how that will work - where that instance of cache manager will reside ? Anyone is facing this issue ?

Then I use apache to front my tomcat. Do I have to create workers and load balance them in Apache ?


Gimme some hits from your perspective how will that work !?

Thanks,
Q
tgautier

seraphim

Joined: 06/05/2006 12:19:26
Messages: 1781
Offline

If you download Terracotta, there is native support for Tomcat and it is actually included in the product.

After you download and install Terracotta, run the Welcome application. There are three tabs, select the "Session" tab. After that, you will see a link for "Configurator".

The Configurator is an application written by Terracotta that will let you see Terracotta in action running on top of the bundled Tomcat. If you run Configurator you will see several applications already imported into Configurator.

From the Configurator, you have the option to start a Terracotta Server instance as well as two Tomcat instances, which will be clustered by Terracotta.

After you see the demo applications working in the Configurator, stop the servers and you can go ahead and import your application WAR file into the Configurator. This is just a handy way to setup and configure Terracotta to run your application. Select "File | Import" to get started.

Finally, if you are interested in getting Terracotta installed into your own instances of Terracotta, then you can look at the scripts that come with Terracotta and that are used by the Configurator. They are located in the Terracotta directory under "tools/sessions/configurator-sandbox/tomcat-5.5" In here you will see startup scripts that start the two Tomcat instances. Basically installing Teracotta is as easy as modifying a few JAVA_OPTS variables before calling the catalina start script.

Thanks for the suggestion to write a specific step-by-step - we definitely need to add that to the docs, as well as one for Weblogic, JBoss, Geronimo, Jetty and all the other Containters we support.

Terracotta supports ehcache as of the latest trunk version, so you can easily add support to cluster your ehcache instance. If you want to try this out you need to download the "trunk" nightly version, not the 2.3 version (I recommend if you are just getting started with Terracotta to use the 2.3 version first and get familiar with it and then try the more advanced stuff later).

If you have more than one Tomcat instance alive, you will definitely need to have some mechanism for load-balancing. The load balancing features found in Apache should be fine.

Hope that helps!
[WWW]
Q

neo

Joined: 05/24/2007 08:41:19
Messages: 2
Offline

Well I thought I know everything and then I encountered Terracotta so there is something new to know :). That's what we,Q, do

On a serious note, thanks for info. I will try to look it up on my dev box. However I don't remember seeing an answer about the memory. If I understand correctly running two instances will take double the amount of memory - the part that concerns me is the ehcache cached data will I have the cache replicated as well. Is that assumption correct ?

On production deployment, do you support anything like hot deploy ? In my prod. box I only have control to a shell console so I won;t be able to view the UI's for Configurator. Are there any other options ?

Also the prod box is a Linux box (as you could guess it) and currently I run my java using jvsc. Do you have a recommended way to run Terracotta on a prod. box ?

Thanks a lot for writing me back!
Q

tgautier

seraphim

Joined: 06/05/2006 12:19:26
Messages: 1781
Offline

You don't need the Configurator to run Terracotta - it's just a development time tool to help you get started.

I am not certain I understand why you would want two instances on the same machine?

In any case, there isn't a simple answer to your question, as Terracotta has a virtual memory function that only brings in the objects it needs. Therefore if you have a 100 MB cache, you may have only some portion of it resident on either instance at any one time.
[WWW]
dmangot

journeyman

Joined: 05/24/2006 13:00:33
Messages: 28
Location: San Francisco, USA
Offline

Q wrote:

Also the prod box is a Linux box (as you could guess it) and currently I run my java using jvsc. Do you have a recommended way to run Terracotta on a prod. box ?
 


Q,

You should have no problem running your Tomcat instances using jsvc. There used to be a problem in the past, but the fix is in our latest release.
(see http://jira.terracotta.org/jira/browse/CDV-284)

There is no need to run the Terracotta server itself with jsvc because it can be run clustered (on the same box if necessary) anyway. Just make sure you define the DATA directory to be the same for both instances (or checkout the new network-only setup). This can be done with NFS, SAN, or on the same box.

Here is an init script suitable for use on most Linux distributions for starting the Terracotta server.

Code:
 #!/bin/sh
 #
 #
 # chkconfig: 2345 55 25
 # description: Terracotta L2 server daemon                                                                                                                 
 # shamelessy taken from the jsvc example script for Tomcat 
 # 
 JAVA_HOME=/usr/java/jdk1.5.0_11
 JAVA_OPTS="-server -Xms256m -Xmx256m -Dcom.sun.management.jmxremote"
 TC_HOME=/usr/local/terracotta
 DATA_DIR=/export1/shares
 CONFIG_FILE=tc-config.xml
 TC_OPTS="-Dtc.config=${DATA_DIR}/configs/${CONFIG_FILE}"
 LOG_DIR=logs-primary
 #LOG_DIR=logs-secondary
 CLASSPATH=\
 ${TC_HOME}/common/lib/tc.jar
 TC_USER=_tc
 TC_SERVER=l2a
 
 
 case "$1" in
   start)
     #
     # Start Terracotta
     #
     su - $TC_USER -c "${JAVA_HOME}/bin/java \
     $TC_OPTS \
     $JAVA_OPTS \
     -Dtc.server.name=$TC_SERVER \
     -Dtc.install-root=$TC_HOME \
     -classpath $CLASSPATH \
     com.tc.server.TCServerMain  > ${DATA_DIR}/${LOG_DIR}/terracotta.out  2>&1 &"
     ;;
 
   stop)
     #
     # Stop Terracotta
     #
     su - $TC_USER -c "${JAVA_HOME}/bin/java \
     $TC_OPTS \
     $JAVA_OPTS \
     -Dtc.install-root=$TC_HOME \
     -classpath $CLASSPATH \
     com.tc.admin.TCStop -n $TC_SERVER"
     ;;
 
   *)
     echo "Usage $0 start/stop"
     exit 1;;
 esac
 


In this example, you should only need to change the $TC_SERVER and $LOG_DIR variables between the clustered Terracotta instances.

Cheers,

-Dave
[WWW] [Yahoo!]
 
Forum Index -> Terracotta for Web Sessions
Go to:   
Powered by JForum 2.1.7 © JForum Team