« Back

Clustering Liferay + Tomcat + Mysql on Windows XP.

Company Blogs March 11, 2008 By Ivan Cheung Staff

Recently I set up a clustered environment using three servers, two with liferay-tomcat-4.4.2 bundle and one with apache 2.2 http server.  Here are my steps:

Download and install the following, each on a different server:
Server A - Apache 2.2
Server B - Tomcat1 (Liferay-tomcat-4.4.x bundle)
Server C - Tomcat2 (Liferay-tomcat-4.4.x bundle)

At this point you should have unzipped the liferay-tomcat-4.4.x bundle to two different servers and Apache 2.2 to a third server.  You shouldn't have changed any of the configurations.

Create a new Liferay schema on Server B on Mysql and connect Tomcat1 and Tomcat2 to the new database. 
Assuming you have Liferay core compiled, or our sql script pack, execute this in windows command window, in the mysql prompt:

mysql> create database portal442 character set utf8;

Modify the ROOT.xml of Tomcat1 and Tomcat2 so that they connect to 'portal442' database. Liferay will automatically populate the database with tables and some minimal data when I start either one of the servers up if I don't run any of the sql scripts availabe in the portal source.

Download and install the mod_jk shared object file into Server A - $Apache_2.2_HOME/modules/

I renamed my mod_jk file so now I have a mod_jk.so in $Apache_2.2_HOME/modules/.  After you've installed mod_jk into the Apache server, you can continue to the next step.

Create httpd-mod_jk.conf in $Apache_2.2_HOME/conf/extras.  Paste these contents into httpd-mod_jk.conf:

LoadModule jk_module modules/mod_jk.so

JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
JkLogLevel info
JkShmFile logs/jk-runtime-status

"LoadModule jk_module modules/mod_jk.so" -  loads mod_jk.so so that you could use mod_jk arguments.
"JkWorkersFile conf/workers.properties"  - specifies location of workers.properties file where the load balancer and any servers involved with the cluster are defined.

Create workers.properties in $Apache_2.2_HOME/conf/.  Paste these contents in there:


worker.portal-01.host=<IP-address of Server B>

worker.portal-02.host=<IP-address of Server C>


I've designated Server B and Server C to be my Liferay servers, an in worker.properties I've given Server B a symbolic name (portal-01) as well as Server C (portal-02).  You can give your servers any symbolic name so long as they are consistent! 
Also make sure that the port and host for each server configuration in workers.properties is consistent with the server itself.


Modify $Apache_2.2_HOME/conf/extras/httpd-vhosts.conf
Make a backup of httpd-vhosts.conf.  The contents of httpd-vhosts.conf should now just consist of:

NameVirtualHost *:80

<VirtualHost *:80>
  JkMount /* loadbalancer

This makes it so that anytime the localhost url of Server A is hit, the load balancing mechanism will control whether the user will actually go to Server B or Server C.

In Apache's httpd.conf we need to include our new httpd-mod_jk.conf and our modified httpd-vhosts.conf. 

Uncomment the following in $Apache_2.2_HOME/conf/httpd.conf:
#Include conf/extra/httpd-vhosts.conf

Append the following in $Apache_2.2_HOME/conf/httpd.conf:
Include conf/extra/httpd-mod_jk.conf

Restart Apache.

Paste this into portal-ext.properties for Tomcat1 and Tomcat2:



retransmit_timeout=300,600,1200,2400,4800; max_xmit_size=8192):UNICAST(timeout=300,600,1200,2400):


Restart both Tomcat1 and Tomcat2.

Threaded Replies Author Date
Great Post! Is this setup applicable to... Jeff Goodwin March 12, 2008 1:38 PM
Jeff, theoretically yes, this setup will work... Ivan Cheung March 12, 2008 5:33 PM
I agree, great post! Thanks Ivan! Edward Shin March 12, 2008 10:57 PM
you rock Ivan! James Min June 12, 2008 9:31 AM
[...] Your url was recorded with keywords... Urlrecorder - URL sharing April 30, 2009 10:01 PM
Hi Friends, Nice Post but I was also willing... Alok Thaker January 12, 2011 2:38 AM
Hi. What about session replication? How is that... Sandeep Nair March 21, 2014 9:05 PM

Great Post! Is this setup applicable to Liferay 4.34?
Posted on 3/12/08 1:38 PM.
Jeff, theoretically yes, this setup will work for 4.34 because most of the configuration is non-Liferay specific. I know we introduced Ehcache in 4.3.x, so any issues would be dependent on the Liferay codebase. Would you mind letting me know the outcomes on 4.34?
Posted on 3/12/08 5:33 PM in reply to Jeff Goodwin.
I agree, great post! Thanks Ivan!
Posted on 3/12/08 10:57 PM.
you rock Ivan!
Posted on 6/12/08 9:31 AM.
Urlrecorder - URL sharing
[...] Your url was recorded with keywords loadbalancer! [...] Read More
Posted on 4/30/09 10:01 PM.
Hi Friends,

Nice Post but I was also willing to implement clustering using heartbeat with DRBD and mysql database clusering and got a great ebook on clustering on http://www.ebooksyours.com/what-is-clustering.html , this ebook guides you everything from scratch from setting up linux cluster with heartbeat,DRBD,OCFS and GFS. It also guides up for setting mysql dual master replication too. I would highly recommend to buy ebook from http://www.ebooksyours.com.

Cheers !
Posted on 1/12/11 2:38 AM.
Hi. What about session replication? How is that managed? In previous cluster configuration there used to be mention about configuring SimpleTCPCluster for tomcat and JBoss. Is that not needed now?
Posted on 3/21/14 9:05 PM.