Wednesday, 6 November 2013

Unicast liferay cluster on amazon EC2

Setting up liferay cluster on Aamzon EC2:

Amazon EC2 environment doesn’t allow multicasting that’s the reason. The steps mentioned at wiki doesn’t work out of the box.

·         Liferay 6.0.6 CE
·         Java version 1.7.0_45
·         Red Hat Enterprise Linux Server release 6.4
There are two entities that needs to be taken care while clustering
1.       Tomcat  HTTP Session replication
2.       Liferay cache replication
The scope of document is to cover “Liferay Cache Replication”. If you need information related to tomcat session replication please follow wiki

Extract :
·         tcp.xml from “/liferay/tomcat/webapps/ROOT/WEB-INF/lib/jgroups.jar” and copy to /liferay/tomcat/webapps/ROOT/WEB-INF/classes
·         hibernate-clustered.xml from “/liferay/tomcat/webapps/ROOT/WEB-INF/lib/portal-impl.jar ” and copy to /liferay/tomcat/webapps/ROOT/WEB-INF/classes
·         liferay-multi-vm-clustered.xml from “/liferay/tomcat/webapps/ROOT/WEB-INF/lib/portal-impl.jar ” and copy to /liferay/tomcat/webapps/ROOT/WEB-INF/classes

Edit tcp.xml  and set <TCP  singleton_name="liferay_jgroups_tcp" bind_port="7800"

Edit and set below attributes
#Setup hibernate
#Setup distributed ehcache
#In order to make use of jgroups

In my env I have two node cluster. The above changes needs to be performed on both the nodes.

Start tomcat on node1:
export JAVA_HOME=/jdk1.7.0_45
export PATH=$JAVA_HOME/bin:$PATH
export JAVA_OPTS="-Djgroups.bind_addr=node1 -Djgroups.tcpping.initial_hosts=node2[7800],node1[7800] -Xms256m -Xmx1024m -XX:MaxPermSize=512m"

Start tomcat on node2:

export JAVA_HOME=/jdk1.7.0_45
export PATH=$JAVA_HOME/bin:$PATH
export JAVA_OPTS="-Djgroups.bind_addr=node2 -Djgroups.tcpping.initial_hosts=node2[7800],node1[7800] -Xms256m -Xmx1024m -XX:MaxPermSize=512m"

If everything goes well. You should see following channels gets created .  Verify liferay log.

GMS: address=node1-17685, cluster=EH_CACHE, physical address=
GMS: address=node1-36406, cluster=EH_CACHE, physical address=
GMS: address=node1-10244, cluster=LIFERAY-CONTROL-CHANNEL, physical address=

GMS: address=node1-22557, cluster=LIFERAY-TRANSPORT-CHANNEL-0, physical address=
Test cases:
1.       Create a user in node1 and  search for the same user in node2. You should see user in node2
2.       Add a asset publisher portlet on page1  and access the same page on the other sever. The asset publisher portlet should be seen.

BTW..  ehcache.statistics.enabled=true and “” are used for debugging purpose of the cache.


  1. I'm extremely impressed together with your writing talents as neatly as with the structure in your weblog. Is this a paid topic or did you modify it yourself? Either way stay up the excellent quality writing, it's rare to peer a nice blog like this one today.
    How to submit website to Dmoz? Here is the Process.


  2. I recently came across your blog and have been following it. I'm very impressed. You're truly well informed and very intelligent. You've been able to write in a way people can understand easily. I'm saving this for future use.
    liferay training in hyderabad