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 http://www.liferay.com/web/ricardo.funke/blog/-/blogs/liferay-6-1-simple-cluster doesn’t work out of the box.

Environment:
·         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 http://techynfreesouls.blogspot.in/2012/04/liferay-cluster-on-amazon-ec2.html

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 Portal-ext.properties and set below attributes
web.server.display.node=true
#Setup hibernate
net.sf.ehcache.configurationResourceName=/hibernate-clustered.xml
#Setup distributed ehcache
ehcache.multi.vm.config.location=/liferay-multi-vm-clustered.xml
#In order to make use of jgroups
ehcache.bootstrap.cache.loader.factory=com.liferay.portal.cache.ehcache.JGroupsBootstrapCacheLoaderFactory
ehcache.cache.event.listener.factory=net.sf.ehcache.distribution.jgroups.JGroupsCacheReplicatorFactory
ehcache.cache.manager.peer.provider.factory=net.sf.ehcache.distribution.jgroups.JGroupsCacheManagerPeerProviderFactory
net.sf.ehcache.configurationResourceName.peerProviderProperties=file=/tcp.xml
ehcache.multi.vm.config.location.peerProviderProperties=file=/tcp.xml
ehcache.statistics.enabled=true
lucene.replicate.write=true

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] -Djava.net.preferIPv4Stack=true -Xms256m -Xmx1024m -XX:MaxPermSize=512m -Dcom.sun.management.jmxremote   -Dcom.sun.management.jmxremote.port=12345   -Dcom.sun.management.jmxremote.ssl=false   -Dcom.sun.management.jmxremote.authenticate=false"
./startup.sh

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] -Djava.net.preferIPv4Stack=true -Xms256m -Xmx1024m -XX:MaxPermSize=512m -Dcom.sun.management.jmxremote   -Dcom.sun.management.jmxremote.port=12345   -Dcom.sun.management.jmxremote.ssl=false   -Dcom.sun.management.jmxremote.authenticate=false"
./startup.sh


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


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

-------------------------------------------------------------------
GMS: address=node1-22557, cluster=LIFERAY-TRANSPORT-CHANNEL-0, physical address=10.0.123.5:56066
-------------------------------------------------------------------
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 “-Dcom.sun.management.jmxremote   -Dcom.sun.management.jmxremote.port=12345   -Dcom.sun.management.jmxremote.ssl=false   -Dcom.sun.management.jmxremote.authenticate=false” are used for debugging purpose of the cache.




2 comments:

  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.

    ReplyDelete

  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

    ReplyDelete