Clustering JBoss AS 7

User Rating: 4 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Inactive
 
as7In this article we will show how to configure in a nutshell JBoss AS 7 for clustering. Then we will deploy a sample Java EE 6 application on the top of it.

Earlier JBoss users used to start a clustered server configuration by feeding the -c all parameter to the application server starter shell.

The AS 7 is pretty different from other server releases as it does not contain multiple server configuration directories (all, default, minimal ..). It just contains a set of configuration files each one including a different set of server modules.

The built-in cluster configuration file are standalone-ha.xml and standalone-full-ha.xml (the latter one including Corba support). So let’s start a demo cluster configuration composed of two nodes on the same machine.

So unzip two AS 7 distribution on a path of your choice, for example:
 

C:\jboss-as-7.1.1.Final.NodeA
C:\jboss-as-7.1.1.Final.NodeB

In order to start your cluster nodes you need to provide an unique node name and, since you are running multiple servers on the same machine specify a port offset so that you don’t have port conflicts between servers.

So we will start up NodeA with:

standalone -c standalone-ha.xml -Djboss.node.name=nodeA					

and NodeB with:

standalone -c standalone-ha.xml -Djboss.socket.binding.port-offset=100 -Djboss.node.name=nodeB						

Fine. Checkout the welcome page to see that everything works correctly:
http://localhost:8080 (nodeA) and http://localhost:8180 (nodeB)

Configuring Apache Web server to reach JBoss AS 7 cluster

There are more than one available choice to connect a Web server in front of JBoss AS 7 cluster. You can either choose the older mod_jk approach which provides a static view of your AS 7 cluster or, as we suggest, configure mod_cluster which provides additional advantages such as:

  • Dynamic configuration of httpd workers
  • Server-side load balance factor calculation
  • Fine grained web-app lifecycle control

Mod_cluster Java libraries are built-in into JBoss AS 7 distribution so you don't need to hack your server release. On the other hand, you need to add to your Apache server the native libraries required to proxy calls to JBoss AS. Download the latest mod_cluster binaries at:
http://www.jboss.org/mod_cluster/downloads/1-2-0-Final

 The above modules can be found into the mod_cluster distribution under httpd/modules path. You have to place them into the Apache's module folder.

Then we edit httpd.conf. We should add the modules:

LoadModule slotmem_module modules/mod_slotmem.so
LoadModule manager_module modules/mod_manager.so
LoadModule proxy_cluster_module modules/mod_proxy_cluster.so
LoadModule advertise_module modules/mod_advertise.so

  Also, please note we should comment out:

#LoadModule proxy_balancer_module modules/mod_proxy_balancer.so                    

 This one conflicts with cluster module. And then we need to make httpd to listen to public address so we could do the testing. Because we installed httpd on 192.168.1.0 host we will use the following available port:
 

Listen 192.168.1.0:6666

<VirtualHost 192.168.1.0:6666>   
    <Directory />     
      Order deny,allow     
      Deny from all     
      Allow from 192.168.1.  
  </Directory>

  KeepAliveTimeout 60
  MaxKeepAliveRequests 0  
  ManagerBalancerName mycluster
  AdvertiseFrequency 5
</VirtualHost>

Now verify that the Apache JBoss connection works properly by typing: http://192.168.1.0:6666

Related articles available on mastertheboss.com

JBoss Clustering a Web Application

Please Note: This article cover JBoss AS 4/5/6 releases. If you w

Clustering EJB 3 with JBoss AS

To cluster a stateless session bean in EJB 3 all you need to do i

JBoss monitoring HTTP Session replication

In this article we'll show how to monitor HTTPSession replication

How do I change multicast address of JBoss cluster ?

Since JBoss AS 4.0.3, the jboss.partition.udpGroup property can b

JBoss farming service

What is the farming service ? this article explains about it, als

JBoss HTTP Session replication

HTTP session replication is used to replicate the state associate

Follow us on Twitter