Академический Документы
Профессиональный Документы
Культура Документы
[http://3.bp.blogspot.com/-8Q6t8FkjAuc/T56a-
YSKD4I/AAAAAAAAUMI/x6fxI6OKhoU/s1600/liferay_logo.jpeg]
[http://2.bp.blogspot.com/--6ZD2XXFiLU/T56a8nZZ47I/AAAAAAAAUMA/kLFT9-
QOuy0/s1600/amazon_aws.jpeg]
Recently I got a challenge of setting up a Liferay cluster on Amazon EC2. This proved to be more than a cakewalk
and was a big learning experience for me. Following are the steps I took to setup this cluster. For those who are not
aware, Amazon EC2 doesn't allow for multicasting and hence most of the clustering/caching technologies don't
work out of the box. The setup which I created involves setting up of unicast cluster with cache replication also
happening over unicast.
Two issues are of concern when we are trying to setup a Liferay cluster:
My setup involved use of Liferay 6.0 EE SP2 bundled with tomcat 6.0.32.
Configuration of tomcat:
Tomcat needs to be configured to allow for setup of cluster of two nodes over unicast. Following is section of my
${LIFERAY_HOME}/tomcat-6.0.32/conf/server.xml on server1 (replace node1 with node2 and swap location of
IP_ADDRESSES and change unique_id to anything 16 bit long other than {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2}, on
server.xml in server2) which allowed for this. IP_ADDRESSES here refer to private ip addresses of server1 and
server2 respectively.
http://pastebin.com/R8QnUqaY [http://pastebin.com/R8QnUqaY]
I know this is not safe considering the fact that Amazon doesn't guarantee persistence of this IP address across
reboots, but it was the easiest way out. I also kept both servers under same security group and allowed all
TCP/UDP access to this security group.
http://techynfreesouls.blogspot.in/2012/04/liferay-cluster-on-amazon-ec2.html 1/5
8/21/2015 Liferay cluster on Amazon EC2
Restart tomcat and I could see session replication working as intended. To verify this I loadbalanced both server1
and server2 behind Apache and followed following steps:
Configuration of ehcache:
Once through with session replication, next step was to setup clustering of ehcache. Initially I tried unicast setup for
RMI but it didn't work out (need to understand it more), so I moved over to JGroups. Before trying out I upgraded
ehcache-core, ehcache-jgroupsreplication and jgroups jar files in ${LIFERAY_HOME}/tomcat
6.0.32/webapps/ROOT/WEBINF/lib with their latest versions available from http://ehcache.org
[http://ehcache.org/] and http://www.jgroups.org/ [http://www.jgroups.org/] . Then I extracted tcp.xml from the jgroups
jar file and placed it in a folder called ${LIFERAY_HOME}/tomcat6.0.32/webapps/ROOT/WEB
INF/classes/myehcache. I also extracted hibernate-clustered.xml and liferay-multi-vm-clustered.xml from
ehcache-core jar file and placed them in same folder.
singleton_name="liferay_jgroups_tcp"
[http://www.blogger.com/goog_1948509805]
http://pastebin.com/kUSBfnyv [http://pastebin.com/kUSBfnyv]
JAVA_OPTS="$JAVA_OPTS Dfile.encoding=UTF8
Dorg.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES=false Duser.timezone=GMT Xmx1024m
XX:MaxPermSize=256m Djgroups.bind_addr=IP_ADDRESS_OF_SERVER1
Djgroups.tcpping.initial_hosts=IP_ADDRESS_OF_SERVER1[7800],IP_ADDERSS_OF_SERVER2[7800]"
Next we start tomcat and voilla ! we are up and running :) There are few more tests which I'm planning to execute
and hopefully this system will move to production in next few days !
Posted 30th April 2012 by Mayank Joshi
Labels: Amazon EC2, Ehcache, Jgroups, Liferay, Tomcat
http://techynfreesouls.blogspot.in/2012/04/liferay-cluster-on-amazon-ec2.html 2/5
8/21/2015 Liferay cluster on Amazon EC2
9 View comments
Look into VPC (Virtual Private Cloud). You can guarantee the server's IP address across reboots since you define
http://techynfreesouls.blogspot.in/2012/04/liferay-cluster-on-amazon-ec2.html 3/5
8/21/2015 Liferay cluster on Amazon EC2
but i have this weird issue that i cant change the language after login
kind regards
Reply
http://techynfreesouls.blogspot.in/2012/04/liferay-cluster-on-amazon-ec2.html 4/5
8/21/2015 Liferay cluster on Amazon EC2
Enter your comment...
Publish Preview Notify me
http://techynfreesouls.blogspot.in/2012/04/liferay-cluster-on-amazon-ec2.html 5/5