Mod cluster on JBoss AS 5.x



Contents



Download Files

Download all files, to build mod_cluster and mod_proxy_ajp

1.Download packages for Mod_cluster module version 1.1.1 :
  http://downloads.jboss.org/mod_cluster//1.1.1.Final/mod_cluster-1.1.1.Final-bin.tar.gz
2.Download library for Mod_cluster :
  http://downloads.jboss.org/mod_cluster//1.1.1.Final/mod_cluster-1.1.1.Final-linux2-x64-so.tar.gz
3.Reference Documentation for mod_cluster and how it works
  wget -c http://www.jugs.ch/html/events/slides/090313_BrianStansberry_mod-cluster-jug.pdf
http://community.jboss.org/thread/162859


Install

Install mod_cluster
extract file mod_cluster-1.1.1.Final-bin.tar.gz
copy folder mod_cluster.sar to JBoss AS/server/node01/deploy or where the server node stored
configure file mod_cluster-jboss-beans.xml at mod_cluster.sar/META-INF add this following lines :
<bean name="HAModClusterConfig" class="org.jboss.modcluster.config.ha.HAModClusterConfig" mode="On Demand">
<property name="proxyList">${jboss.modcluster.proxyList:localhost:80}</property>
<property name="domain">${jboss.Domain:DefaultDomain}</property>
<property name="stickySession">true</property>
       <property name="stickySessionForce">true</property>
           <property name="stickySessionRemove">false</property>
               <property name="maxAttempts">1</property>
                   <property name="workerTimeout">-1</property>
                       <property name="balancer">${jboss.modcluster.balancer}</property>
 </bean>


Web Server

Install the Web Server for this you can use the native jboss web server you can download it at
http://downloads.jboss.org/mod_cluster//1.1.1.Final/mod_cluster-1.1.1.Final-linux2-x64-ssl.tar.gz
extract and put it at /opt
Configure Web server Edit the http.conf and add the Virtual hosts for JBoss AS node if you want use a web server from download.jboss.org:
edit the configuration at /opt/jboss/httpd/httpd/conf
Unmark this line
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
then leave this native configuration we only need to remark the Advertise module, so we still can access the mod_cluster-manager from localhost
# MOD_CLUSTER_ADDS
# Adjust to you hostname and subnet.
<IfModule manager_module>
  Listen 127.0.0.1:6666
  ManagerBalancerName mycluster
   <VirtualHost 127.0.0.1:6666>
      <Location />
       Order deny,allow
       Deny from all
       Allow from 127.0.0
      </Location>
KeepAliveTimeout 300
  MaxKeepAliveRequests 0
  #ServerAdvertise on http://@IP@:6666
  #AdvertiseFrequency 5 ==> remark this line, so the Advertise modules will not conflict with the virtual host 
  #AdvertiseSecurityKey secret
  #AdvertiseGroup @ADVIP@:23364
 
      <Location /mcm>
        SetHandler mod_cluster-manager
        Order deny,allow
        #Deny from all
        Allow from 127.0.0
      </Location>
  </VirtualHost>
</IfModule>
In this configuration modules is already loaded, and the *.so files is already at modules directory. next we need to configure the VirtualHost at
/opt/jboss/httpd/httpd/conf/extra/httpd-vhost.conf
add this line:
<VirtualHost node01.asik.local:80> # change the node
 <Directory />
    Order deny,allow
    Allow from all
 </Directory>
 <Location /mcm>
     SetHandler mod_cluster-manager
     Order deny,allow
     Allow from all
     Allow from 192.168
 </Location>
 KeepAliveTimeout 60
 MaxKeepAliveRequests 0
 ManagerBalancerName testcluster
 AdvertiseFrequency 5
</VirtualHost>
<VirtualHost *:80>
 ServerAdmin admin@asik.local
 DocumentRoot /opt/jboss/httpd/htdocs/htdocs/node01.asik.local/data
 ServerName node01.asik.local:80                                        # change the node
 ErrorLog logs/node01.asik.local-error_log                              # change the node
 CustomLog logs/node01.asik.local-access_log combined                   # change the node
 LogLevel debug
 ProxyPass / balancer://cluster1/application1 stickysession=JSESSIONID|jsessionid nofailover=On
 ProxyPassReverse / balancer://cluster1/application1 #the application1 is a test aplication for cluster we will use it
</VirtualHost>


Restart Web Server

Run the web server
#/opt/jboss/httpd/sbin/httpd -k start
or
#/opt/jboss/httpd/sbin/apachectl start


Build application tester

download the file at
http://community.jboss.org/servlet/JiveServlet/download/588259-27006/clusterjsp.war
extract and repack again with different name
jar xvf clusterjsp.war
jar cvf application1.war *
Put the application1.war at JBoss AS/server/deploy/ Run the JBoss AS
./bin/run.sh -c node01 -g cluster1 -Djboss.messaging.ServerPeerID=1 -Djboss.service.binding.set=ports-default 
-Djboss.jvmRoute="node01" -Djboss.Domain=domain1 -Djboss.mod_cluster.proxyList="192.168.1.176:80" 
-Djboss.modcluster.balancer="cluster1"  -Djboss.bind.address="0.0.0.0"


Run application tester

open the mod_cluster-manager
< JBoss server fqdn / ip address >/mcm
open application tester
< JBoss server fqdn / ip address >/application1

Comments