January 4, 2013

How to Cluster Standalone JBoss EAP 6 and AS 7

In this blog I will show you how to cluster two JBoss standalone servers.

Prerequisites:

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.

4 comments:

Zippisan said...

This was a great post. Thanks

Custom Precision Manufacturer said...

I found your post is very informative. The article is professionally written and I feel like the author knows the subject very well.Keep it that way.

madhu said...

Hi,

When we migrated from JBoss EAP 5.1.2 to version 6.0.1, the session id that is being created by my java code looks different.

With v5.1.2 session id looks like this : "1D5C800599BA12AD8A10FC54100E7F60"

With v6.0.1 session id looks like this: "u5tvf1Zd5A5F0-4 uwH6VdE7"

Please suggest how can i make 6.0.1 version to generate session id as JBoss 5.1.2 does.

Arun Kumar said...

I really appreciate information shared above. It’s of great help. If someone want to learn Online (Virtual) instructor lead live training in Alfresco , kindly contact us http://www.maxmunus.com/contact
MaxMunus Offer World Class Virtual Instructor led training on Alfresco. We have industry expert trainer. We provide Training Material and Software Support. MaxMunus has successfully conducted 100000+ trainings in India, USA, UK, Australlia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.
For Demo Contact us:
Name : Arunkumar U
Email : arun@maxmunus.com
Skype id: training_maxmunus
Contact No.-+91-9738507310
Company Website –http://www.maxmunus.com