Like mod_jk, mod_cluster is also a httpd based load balancer which uses a communication channel to forward requests from the httpd to one of a set of application server nodes. So the question comes Why mod_cluster ? To answer this question we will let you know few advantages of mod_cluster over mod_jk and other httpd-based load balancers.

Hence in this article we would share you why should one use mod_cluster ? and how to configure mod_cluster with JBoss ? Hopping all our subscribers would take the advantage of this article and would help them to choose which is the best option for httpd based load balancer for there requirement.

Why should one use mod_cluster ?

  • Dynamic configuration:
  • Server side load balance:
  • AJP is optional:
  • Web application lifecycle control:

To know all the Advantages and Great features of mod_cluster refer to :

Steps to configure mod_cluster with JBoss

I have divided this configuration into two parts to, so that it would be much more easier to understand follow the steps. Here the following are the two parts

  1. Apache side configuration
  2. JBoss side configuration

Apache side configuration

  1. Download the required binaries for your OS from below link, example for RHEL x64 bit its [dynamic libraries linux2-x64]
  2. http://www.jboss.org/mod_cluster/downloads/1-1-0.html

  3. Copy following .so files to your “<Apache_Home>/modules” folder.
  4. mod_proxy.so
    mod_proxy_ajp.so
    mod_slotmem.so
    mod_manager.so
    mod_proxy_cluster.so
    mod_advertise.so

  5. Edit your httpd.conf (i.e. /conf/http.conf) and add following lines at the bottom of the file. However this virtualhost setting is a sample, you might have to make some changes as per your own environment.
  6. ############### mod_cluster Setting - STARTED ###############
    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
    <VirtualHost *:80>
    	<Directory />
    		Order deny,allow
    		Allow from all
    	</Directory>
    	<Location /mod_cluster_manager>
    		SetHandler mod_cluster-manager
    		Order deny,allow
    		Allow from all
    	</Location>
    	KeepAliveTimeout 60
    	MaxKeepAliveRequests 0
    	ManagerBalancerName testcluster
    	AdvertiseFrequency 5
    </VirtualHost>
    ############### mod_cluster Setting - ENDED ###############
    

    NOTE:

    You have to COMMENT the follwoing module (i.e. mod_proxy_balancer.so) in “httpd.conf” file, or else you would get error while starting your Apache, this is been done because we are now using mod_proxy_cluster.so instead of mod_proxy_balancer.so

    #LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
    
  7. Restart Apache.
  8. NOTE:

    You have to do the following things before starting the APACHE

    Command:

    setenforce 0
    

    The above command will disable SE Linux for your current running session. However if you want to disable it permanently then follow the below steps

    vi /etc/selinux/config
    
    #SELINUX=enforcing (comment this line and add the below line)
    SELINUX=disabled
    
    

    May be this would need to restart your system, this way you will be sure that the changes have taken place.

JBoss side configuration

  1. Copy “mod-cluster.sar” from “/home/testusr/AS6/mod_cluster” to “/server/cluster_node1/deploy”
  2. Edit “mod-cluster-jboss-beans.xml” from “<JBOSS_HOME>/server/cluster_node1/deploy/mod-cluster.sar/META-INF/mod-cluster-jboss-beans.xml” so that it has following.
  3. BELOW

    <bean name="HAModClusterConfig" class="org.jboss.modcluster.config.ha.HAModClusterConfig" mode="On Demand">
    
    <!-- START Comma separated list of address:port listing the httpd servers where mod_cluster is running. -->
        <property name="proxyList">${jboss.modcluster.proxyList:localhost:80}</property>
        <property name="domain">${jboss.Domain:DefaultDomain}</property>
    <!-- END Comma separated list of address:port listing the httpd servers where mod_cluster is running. -->
    
  4. Edit “server.xml” from “/server/all/deploy/jbossweb.sar/server.xml” so that it has following lines.
  5. <!-- START mod_cluster setting -->
         <Listener  className="org.jboss.web.tomcat.service.deployers.MicrocontainerIntegrationLifecycleListener" delegateBeanName="HAModClusterService"/>
    <!-- END mod_cluster setting -->
    

    NOTE:
    Make sure you add above line BEFORE/ABOVE

       <Service name="jboss.web">
    

    and

    <!-- START mod_cluster setting -->
         <Engine name="jboss.web" defaultHost="localhost" jvmRoute="${jboss.jvmRoute}">
    <!-- END mod_cluster setting -->
    

    NOTE:
    Make sure you replace above line instead of this line

          <Engine name="jboss.web" defaultHost="localhost">
    
  6. Edit “jboss-beans.xml” (/server/all/deploy/jbossweb.sar/META-INF/jboss-beans.xml) and add the below line in “bean” element
  7. <depends>HAModClusterService</depends>
    

Command to start the servers

Below is the command to start the serves in a cluster which are on the same Box/Physical Machine

NODE-1:

./run.sh -c cluster_node1 -g ClusterA -u 239.255.100.101 -b localhost -Djboss.Domain=test -Djboss.messaging.ServerPeerID=1 -Djboss.service.binding.set=ports-01 -Djboss.jvmRoute="node1"

NODE-2:

./run.sh -c cluster_node2 -g ClusterA -u 239.255.100.101 -b localhost -Djboss.Domain=test -Djboss.messaging.ServerPeerID=2 -Djboss.service.binding.set=ports-02 -Djboss.jvmRoute="node2"

URL to hit

http://localhost/mod_cluster_manager

Regards,

Middleware Magic

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.