Liferay Unicast Clustering On Amazon EC2

Liferay-Unicast-Clustering-On-Amazon-EC2
Blogs

Liferay Unicast Clustering On Amazon EC2

Liferay Clustering can be done with two ways.

  1. Multicast
  2. Unicast

Amazon AWS doesn’t support multicast traffic, hence we need to setup Liferay unicast clustering.

In below example, we have used Jgroups for ehcache replication. Session replication was done by configuring tomcat for unicast communication in cluster.

Prerequisites:

Tomcat Node 1:
IP: 192.168.100.100

Tomcat Node 2:
IP: 192.168.100.200

  • Install liferay on both Amazon nodes.
  • Set JvmRoute in Server.xml file of tomcat. Add “worker1” in tomcat node 1 and “worker2” in tomcat node2.
  • Add in web.xml file in both tomcat nodes.
  • Download below mentioned jar files and add it into /{TOMCAT_HOME}/webapps/ROOT/WEB-INF/lib folder from Cluster Files
    • ehcache.jar
    • ehcache-jgroupsreplication.jar
    • jgroups.jar
  • Add below lines in server.xml of both the tomcat nodes.
    • In tomcat node1, set address=”192.168.100.100” and port=”4444” as receiver properties. And as a member add host=”192.168.100.200”. We will have to keep different uniqueid in both tomcats.
    • In tomcat node2, set address=”192.168.100.200” and port=”4444” as receiver properties. And as a member add host=”192.168.100.100”. We will have to keep different uniqueid in both tomcats.
  • Now add below properties in tomcat/bin/setenv.sh file.

JAVA_OPTS=”$JAVA_OPTS -Djgroups.bind_addr=192.168.100.100 -Djgroups.tcpping.initial_hosts=192.168.100.100[7800],192.168.100.200[7800]”

In Tomcat Node 2, keep below mentioned properties.

JAVA_OPTS=”$JAVA_OPTS -Djgroups.bind_addr=192.168.100.200 -Djgroups.tcpping.initial_hosts=192.168.100.200[7800],192.168.100.200[7800]”

  • Now create tcp.xml file in /{TOMCAT_HOME}/webapps/ROOT/WEB-INF/classes/myehcache location and add below content into it.
  1. Now add below properties in portal-ext.properties.

#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=myehcache/tcp.xml
ehcache.multi.vm.config.location.peerProviderProperties=file=myehcache/tcp.xml

#Setup hibernate
net.sf.ehcache.configurationResourceName=/myehcache/hibernate-clustered.xml

#Setup distributed ehcache
ehcache.multi.vm.config.location=/myehcache/liferay-multi-vm-clustered.xml

Now add liferay-multi-vm-clustered.xml and hibernate-clustered.xml files at /{TOMCAT_HOME}/webapps/ROOT/WEB-INF/classes/myehcache location.
Now restart both liferay portal tomcat and verify clustering.

 Blog Written By Chintan Mehta

Leave your thought here

Your email address will not be published.