In this blog I will show you how to cluster two JBoss standalone servers.
- JBoss EAP 6 or AS 7. I will use JBoss EAP 6.0.1
- Apache Web Server. See http://magnus-k-karlsson.blogspot.se/2013/01/install-apache-web-server-on-red-hat.html
- mod_cluster for load balancing. See http://magnus-k-karlsson.blogspot.se/2013/01/how-to-install-jboss-eap-601-native.html
When you have the prerequisites up and running we are ready to start the JBoss servers. Here I will start with the most simple configuration, i.e. standalone-ha mode.
To simulate a more real situation I have unziped jboss-eap-6.0.1.zip to two different folders, jb1 and jb2. Now lets start each JBoss server.
Since we will be running two servers on the same machine we need to differentiate the servers ports. This can easy be made with the JBoss property port-offset.
Now you should see in each JBoss log file that it picked up mod_cluster.
Also verify that mod_cluster in Apache Web Server has detected the two JBoss servers.
If mod_cluster have not detected two server or they have not Status: OK, then stop here and check the Apache Web Server error log file (/etc/httpd/logs/error_log) and JBoss server log file (./jb1/standalone/log/server.log).
In my case had SELinux problem that stopped the second JBoss instance to be properly detected by mod_cluster in Apache Web Server. I received the following error message in /etc/httpd/logs/error_log.
To temporarily disable that, run the below on RHEL 6.3. For a lengthier description see http://sysadminsjourney.com/content/2010/02/01/apache-modproxy-error-13permission-denied-error-rhel/.
Since the new JBoss load modules lazily, you will not see much in the log file, without a cluster application. You can write you own clustered application, but that is out of scope for this blog, so I copied a simple application from https://github.com/akquinet/jbosscc-as7-examples/tree/master/cluster-example.
Now deploy the clusterd application to each JBoss deploy folder $JBOSS_HOME/standalone/deployments/. And you see in each JBoss log file, that they have started Infinispan, and clustering have detected each other.
After successful deployment, now lets try the web app, http://127.0.0.1/cluster/index.jsf.
Now to test the failover capability kill the server you was served for. And then hit http://127.0.0.1/cluster/index.jsf again.