A Liferay cluster is simply a matter of put some properties in portal-ext.properties. First you'll put these two properties:
The first will enable Liferay to replicate both database caches (ehcache) and search indexes (lucene) through a multicast communication.
The second will tell Liferay what network interface to use for the multicast communication. You must specify an IP address and a port so that Liferay can make a "ping" in that socket (IP + port) to check if that will work.
The third will actually make Lucene replicate the indexes through Cluster Link.
This kind of IP+port verification may seem a bit awkward (I guess it's for both windows and unix system work the same way), but the idea is to set it to a proxy or gateway so that all nodes use the same pair IP+port. But if you, for some reason, can't give an IP+port to Liferay, due to firewall or else, you may use the IP+port of the database. I don't see any reason to block database's IP from Liferay ;)
In some cenarios, you may want to use an specific interface exclusivelly for the multicast communication. This is good, and you can always use the IP+port of that interface for each node individually. The only question is, what port to use? In Linux you can use port 22 for this is a commonly open port in many distributions. Use "netstat" to look what port can be use for that purpose in your system.
Documents and Images
Unlike some folks may think, documents and images aren't stored in the database, is in the filesystem so the performance can be much, much better.
Of course, documents and images must be accessible from all Liferay nodes. The good practice for that is to use a storage area. Then you can set Liferay to use the mounted storage directory. This is done in portal-ext.properties like this:
For Windows Servers. Note that you have to use forward slashes instead of back slashes.
You will end with 3 simple properties in the portal-ext.properties of each node.
Deploy portlets, plugins, themes...
Since the very first version of Liferay, the replication of the portlets and plugins always was a task for the application server you're using for Liferay.
Most of them have a feature called "farm" that do this job. So Liferay is aware of this.
But, to simplify things, you can make a script for that. I wrote one that do it using ssh connection with the rsync tool available in most Linux distributions.
This script can be downloaded from here: https://github.com/ricardofunke/ndeploy/blob/master/ndeploy.sh
To install, make a copy of this script to all your Liferay nodes. I recommend to create a folder inside your LIFERAY_HOME called "ndeploy" and copy the ndeploy.sh script inside it.
Next to the script, inside the same "ndeploy" folder, create another folder called "deploy" where the script will watch for .war files to be replicated to all Liferay nodes.
Grant execute permission to the script with "chmod +x ndeploy.sh"
Edit the script and set the NODES variable with all your Liferay nodes IP except the local one. Don't forget to do this for all the nodes.
Change the variable APPSRV_HOME to the correct path to your application server. This is the path of your LIFERAY_HOME.
You must create ssh public keys and distribute between all nodes using liferay user. This is necessary to eliminate the need for password between the nodes. For example, suppose you're using liferay as the user to run the portal (the java process) in the "node1" server.
# su - liferay
Press enter without set any password
$ ssh-copy-id -i .ssh/id_rsa.pub liferay@node2
Do the same for all Liferay nodes you have.
Now you have to make sure that this script will run with liferay side-by-side as a deamon. Use the option -d to run the script as a deamon. You can put it in your Liferay startup script. Remember to use the same Liferay user to run this script.
Finally, Liferay must be set to deploy the application not to the application server but first to ndeploy.sh "deploy" folder, so that it can copy to all other nodes. The order of deploying will be like this:
- You'll copy your application to the Liferay deploy folder (or you will upload through Control Panel)
- Liferay will copy the application to ndeploy.sh folder
- ndeploy.sh will copy the application to the application server in all nodes locally and remotelly.
To do this, put this property into your portal-ext.properties:
Change the value to correspond to the path to the ndeploy.sh deploy folder. You can make this in the Control Panel instead in Control Panel -> Plugins Installation -> Install More Plugins -> Configuration in the "Destination directory" field.
It's all. Let me know if you have any trouble with this installation.