[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 deployment problem.  XML
Forum Index -> Terracotta for Web Sessions
Author Message
masterpc

neo

Joined: 06/07/2007 16:51:48
Messages: 2
Offline

Hi,
I'm a newbie to terracotta.
I'm trying to deploy terracotta for session clustering for two tomcats.

Each tomcat is installed on a different server.

My web app is based on Spring and Acegi(http://www.acegisecurity.org/) framework.

All that I want is sharing user information between two tomcats.
However,
when I tried to test like..
http://192.168.1.150:8080/login.jsp
http://192.168.1.160:8080/login.jsp

Each tomcat created an individual session for each connection.
Therefore, even if I logged in on 192.168.1.150, there was no information about logged user on 192.168.1.160.

What shoud I do for solving this problem?

The procedures I have done
--
1. installed terracotta on /opt/terracotta on each server

2. /etc/bashrc

export JAVA_HOME=/usr/local/jdk1.6.0_01
export PATH=$JAVA_HOME/bin:$PATH

export TC_INSTALL_DIR=/opt/terracotta
export TC_HOME=/opt/terracotta
 


3. created dso-boot jar on each server

4. tc-config-tomcat.xml

<?xml version="1.0" encoding="UTF-8"?>
<tc:tc-config xmlns:tc="http://www.terracotta.org/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.terracotta.org/schema/terracotta-3.xsd">
<servers>
<server host="192.168.1.150">
<data>/opt/terracotta/server-data</data>
<logs>/opt/terracotta/server-logs</logs>
</server>
</servers>
<clients>
<logs>/opt/terracotta/client-logs</logs>
</clients>
<application>
<dso>
<instrumented-classes>
<include>
<class-expression>*..*</class-expression>
</include>
<exclude>org.apache.coyote..*</exclude>
<exclude>org.apache.catalina..*</exclude>
<exclude>org.apache.jasper..*</exclude>
<exclude>org.apache.tomcat..*</exclude>
</instrumented-classes>

<web-applications>
<web-application>ROOT</web-application>
</web-applications>
</dso>
</application>
</tc:tc-config>
 


5. $TOMCAT_HOME/bin/tcstartup.sh on 192.168.1.150

TC_SERVER=localhost
TC_CONFIG_PATH="${TC_SERVER}:9510"
. $TC_HOME/bin/dso-env.sh -q
export JAVA_OPTS="${TC_JAVA_OPTS}"
./startup.sh
 


6. $TOMCAT_HOME/bin/tcstartup.sh on 192.168.1.160

TC_SERVER=192.168.1.150
TC_CONFIG_PATH="${TC_SERVER}:9510"
. $TC_HOME/bin/dso-env.sh -q
export JAVA_OPTS="${TC_JAVA_OPTS}"
./startup.sh
 


7. run terracotta on 192.168.1.150
$TC_INSTALL_DIR/bin/start-tc-server.sh -f tc-config-tomcat.xml

8. run each tomcat
$TOMCAT_HOME/bin/tcstartup.sh on 192.168.1.150
$TOMCAT_HOME/bin/tcstartup.sh on 192.168.1.160

Any idea?

Thanks in advance.
tgautier

seraphim

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

However,
when I tried to test like..
http://192.168.1.150:8080/login.jsp
http://192.168.1.160:8080/login.jsp  


Are you using these URLs to test? Or do you have a load balancer?
[WWW]
masterpc

neo

Joined: 06/07/2007 16:51:48
Messages: 2
Offline

I used these URLs for test.

I'm planning to use a load balancer for production level.

It can be a problem?


Thanks.

tgautier

seraphim

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

Yes you need some form of a load balancer to make the requests appear as though they are going to the same machine from your browsers perspective, otherwise it will think that the cookies generated for host A are not valid to be sent to host B.

We're writing installation doc right now that cover this topic. For now I will just paste a copy of the draft docs on setting up a very simple load balancer that is included with Terracotta.

Configure and Start the Load Balancer

In a production environment, you should use a production quality hardware or software load balancer. For testing purposes, Terracotta comes with a simple TCP proxy that may be used like a load balancer. You should not use this TCP proxy in a production environment.

Here's a sample script to start the TCP proxy:

TC_INSTALL_DIR=<path to terracotta installation>

exec "${JAVA_HOME}/bin/java" \
-Dtc.install-root="${TC_INSTALL_DIR}" -Ddaemon=true \
${JAVA_OPTS} \\
-cp "${TC_INSTALL_DIR}/lib/tc.jar" \
com.tc.net.proxy.TCPProxy <port to listen to> <web host 1>:<port>,<web host 2>:<port>,<web host 3>:<port>

Here's a version of the script with the terracotta installation directory and the web hosts filled in:

[orion@loadbalancer ~]$ cat bin/start-loadbalancer.sh
TC_INSTALL_DIR=/home/orion/terracotta

exec "${JAVA_HOME}/bin/java" \
-Dtc.install-root="${TC_INSTALL_DIR}" -Ddaemon=true \
${JAVA_OPTS} \
-cp "${TC_INSTALL_DIR}/lib/tc.jar" \
com.tc.net.proxy.TCPProxy 8080 web01:8080,web02:8080,web03:8080

To run the TCP proxy, execute the script on the load balancer machine:

[orion@loadbalancer ~]$ bin/start-loadbalancer.sh
Thu Jun 07 18:56:02 EDT 2007: Starting listener on port 8080, proxying to [web01/10.255.54.145:8080],
[web02/10.255.54.97:8080], [web03/10.255.54.146:8080] with 0ms delay
 

[WWW]
kbhasin

consul

Joined: 12/04/2006 13:08:21
Messages: 340
Offline

Hello masterpc,

Taylor is right, you will need a load balancer.

Just to test, you can try running tomcat on the same box but on different ports (change ports in server.xml under conf in Tomcat installation). Also, you can attach the admin-console (admin.sh under bin in Terracotta installation) to your Terracotta Server and see if you see anything under roots and clients.

Please keep in mind that if you run multiple Tomcat instances or even a Tomcat instance with the Terracotta server on the same box, your are bound to use more CPU and Memory compared to running just a single unclustered Tomcat and hence it will not be a good performance comparison.

Lastly, you can also consider balance (http://www.linux.com/article.pl?sid=05/07/27/1729229) which is a very lightweight and extremely easy to use software load balancer. This suggestion is for testing purposes only as I am not aware of the performance and reliability characteristics of balance.

Regards,

Kunal Bhasin,
Terracotta, Inc.

Be a part of the Terracotta community: Join now!
 
Forum Index -> Terracotta for Web Sessions
Go to:   
Powered by JForum 2.1.7 © JForum Team