Liferay 7: The liferay cluster is back and how to get it
On October 23, 2017, Liferay 7 Community Edition GA5 was released. The great news was the return of the cluster.
Unfortunately cluster support is not distributed along with the Liferay bundle (tomcat, wildfly). The New Clustering Code for Liferay Portal Community article describes how to compile the bundles needed to get cluster support starting from the GA5 source code.
The procedure to obtain the bundle is quite tedious and time consuming. For this reason, I did the operation for you. I made a Docker Compose project that allows you to get within a few minutes a Liferay cluster composed of two working nodes.
This Docker Compose (show in Figure 1) contains this services:
- lb-haproxy: HA Proxy as Load Balancer
- liferay-portal-node-1: Liferay 7 GA5 (with cluster support) node 1
- liferay-portal-node-2: Liferay 7 GA5 (with cluster support) node 2
- postgres: PostgreSQL 10 database
- es-node-1 and es-node-2: Elasticsearch Cluster nodes
As for the shared directory for the Liferay document library, I decided to use a shared dock volume instead of NFS filesystem.
The Docker Compose project for Liferay 7 CE GA5 Cluster is available on the GitHub. Consider that this project is intended for cluster development and testing. For more information about Liferay Cluster you can read this Liferay Portal Clustering on Liferay Developer Network.
The configs directory (of the repository) contains the following items:
- Cluster OSGi Bundle
- com.liferay.portal.cache.ehcache.multiple.jar
- com.liferay.portal.cluster.multiple.jar
- com.liferay.portal.scheduler.multiple.jar
- OSGi configs
- BundleBlacklistConfiguration.config: contains the list of bundles that need not be installed
- ElasticsearchConfiguration.config: contains elastic cluster configuration
- AdvancedFileSystemStoreConfiguration.cfg: contains the configuration of the document library
- Portal properties
- portal-ext.properties: contains common configurations for Liferay, such as database connection, cluster enabling, document library, etc.
- HA Proxy
- haproxy.cfg: It contains the configuration to expose an endpoint http which balances the two Liferay nodes.
1. How to start Liferay 7 Cluster
To start a services from this Docker Compose, please run following docker-compose
command, which will start a Liferay Portal 7 GA5 with cluster support running on Tomcat 8.0.32:
For the first start, proceed as follows:
$ docker-compose up -d liferay-portal-node-1
You can view output from containers following docker-compose logs
or docker-compose logs -f
for follow log output.
After the first Liferay node is on (liferay-portal-node-1), then run:
$ docker-compose up -d liferay-portal-node-2
After the two Liferay nodes are up, then pull the HA Proxy:
$ docker-compose up -d lb-haproxy
For the next start, you can run the only command:
$ docker-compose up -d
If you encounter (ERROR: An HTTP request took too long to complete) this issue regularly because of slow network conditions, consider setting COMPOSE_HTTP_TIMEOUT to a higher value (current value: 60).
$ COMPOSE_HTTP_TIMEOUT=200 docker-compose up -d
After all the services are up, you can reach Liferay this way:
- Via HA Proxy or Load Balancer at URL http://localhost
- Accessing directly to the nodes:
- Liferay Node 1: http://localhost:6080
- Liferay Node 2: http://localhost:7080
You can access the HA Proxy statistics report in this way: http://localhost:8181 (username/password: liferay/liferay)
In my case, I inserted the following entries on my /etc/ hosts file:
## # Liferay 7 CE GA5 Cluster ## 127.0.0.1 liferay-portal-node-1.local 127.0.0.1 liferay-portal-node-2.local 127.0.0.1 liferay-portal.local 127.0.0.1 liferay-lb.local
To access Liferay through HA Proxy goto your browser at http://liferay-lb.local
Would you like to see Liferay 7 CE GA5 Cluster in action? Well, then go Cluster in Action
2. JGroups cluster support
This cluster support is limited to EhCache RMI replication. RMI is known to not scale well when increasing the number of cluster nodes. It creates more threads when adding more nodes to the cluster. They can cause server nodes to decrease its performance and even to crash.
Juan Gonzalez made the needed changes from Liferay 7 CE GA5 sources to change RMI to JGroups.For more detailed information, I suggest you read Liferay Portal 7 CE GA5 with JGroups cluster support