You are on page 1of 3

1/6/2010 http://svn.terracotta.

org/svn/forge/pro…
This is a stab at getting Liferay portal clustered with Terracotta. As of this
writing, this is a proof-of-concept, not intended for production use.

The layout of this project is as follows:

- src/liferay
This contains files that are useful for setting up Liferay to test
clustering. This stuff isn't really part of the configuration module.

- src/liferay/tc-config.xml
This is a sample Terracotta config file that uses the Liferay configuration
module.

- src/liferay/conf/context.xml
This should be put in $TOMCAT_HOME/conf/context.xml. It's here to disable
the built-in Tomcat session persistence.

- src/liferay/java
This contains mods to liferay that should be overlayed on the liferay source
before building and deploying. Again, this is just proof-of-concept code.

- src/main
This is the stuff that is used in the actual configuration module. As of
this writing, it's just a Terracotta configuration snippet.

- src/main/resources/terracotta.xml
This is the Terracotta configuration snippet that contains Liferay-specific
configuration.

INSTRUCTIONS

- Download and install Terracotta. Wherever you install it, I'll call $terracotta

- build the clustered-lucene configuration module:

mvn install

copy target/liferay-4.3.1-1.0.0.jar to the modules directory in the


terracotta installation:

cp target/liferay-4.3.1-1.0.0.jar $terracotta/modules/

- Make a bootjar for your platform that also includes some of the stuff
required by the liferay module:

$terracotta/bin/make-boot-jar.sh -f src/liferay/tc-config.xml

- Set up multiple Tomcat instances


- set up two installations of Tomcat. I'll call them $tomcat-1 and $tomcat-2
- modify the ports in server.xml of one of them so they don't conflict
- disable Tomcat session persistence in context.xml (see
src/liferay/conf/context.xml for details)
- modify catalina.sh in each instance so that the terracotta JVM options are
set according to you terracotta installation. You can use
$terracotta/bin/dso-env.sh to determine the appropriate values:

$terracotta/bin/dso-env.sh localhost:9510

Then add those values to JAVA_OPTS in catalina.sh (or set the JAVA_OPTS
environment variable)

svn.terracotta.org/svn/…/README.txt 1/3
1/6/2010 http://svn.terracotta.org/svn/forge/pro…
- remove webapps/ROOT from the tomcat installations. Liferay will deploy
itself there.
- make sure the JDBC driver for your database is installed in common/lib/ext

- you may want to increase the max heap size for tomcat, since liferay seems
to sometimes lose its mind and run out of memory with the default heap size
(even without Terracotta). I use -Xmx500M

- Set up a database instance. Since there is more than one instance of


Liferay, you should use a database server. Using the embedded hypersonic
database won't work.

- Grab the Liferay source code to liferay 4.3.0 (It might work on the 4.3.x
branch, but I haven't tried it yet)

Wherever you unpack or check this out, I'll call $liferay

- get ym.jar and put it in $liferay/lib/portal


it's available here:

http://jymsg9.sourceforge.net/

get ymsg_network.jar, copy it to $liferay/lib/portal and rename it ym.jar

- Overlay src/liferay/java/com/liferay/portal/lucene/LuceneUtil.java on
$liferay/portal-impl/src/com/liferay/portal/lucene/LuceneUtil.java:

cp src/liferay/java/com/liferay/portal/lucene/LuceneUtil.java $liferay/portal-
impl/src/com/liferay/portal/lucene/LuceneUtil.java

- Modify $liferay/tools/ext_tmpl/servers/tomcat/conf/Catalina/localhost/ROOT.xml:
- configure it for your database. I haven't quite figured out when this is
and is not copied during deployment. If the values from here don't
actually make it over to the tomcat deployments, then hand edit this file
in both tomcat installations after you've deployed liferay:

$tomcat-n/conf/catalina/localhost/ROOT.xml

- Modify $liferay/app.server.properties:
- change app.server.parent.dir to point to the parent directory of your
tomcat instance.
- change app.server.tomcat.dir to point to the first of your Tomcat
instances.

- run ant in $liferay. For whatever reason, the deploy task doesn't seem to
work unless you run the all task first.

- run ant deploy in $liferay. This will deploy liferay in the first Tomcat
instance.

- Modify $liferay/app.server.properties:
- change app.server.tomcat.dir to point to the second of your Tomcat
instances.

- run ant deploy in $liferay again. This will deploy liferay in the second
Tomcat instance.

- start the terracotta server using the tc-config.xml that comes with this
distribution:

$terracotta/bin/start-tc-server.sh -f src/liferay/tc-config.xml
svn.terracotta.org/svn/…/README.txt 2/3
1/6/2010 http://svn.terracotta.org/svn/forge/pro…

- start the first tomcat instance

- start the second tomcat instance

- Test lucene clustering:

- log in as test@liferay.com/test on one of the tomcat instances

- add the message board portlet

- log in as test@liferay.com/test on the other tomcat instance

- add a category and a thread to the message board on the first instance

- perform a search in that message board on the second instance. You should
see valid search results on the second instance.

- To see what happens without Terracotta lucene clustering, shut down both
tomcat instances, modify catalina.sh in each installation so that
Terracotta is not enabled (I comment out the line that I add that sets the
Terracotta enabled JAVA_OPTS). Then, perform the same test. You should
see inconsistent search results between tomcat instances because the lucene
indexes are out of sync.

svn.terracotta.org/svn/…/README.txt 3/3

You might also like