analytic

Saturday, 24 November 2012

Configuring Jboss Cluster using Apache JK Module:


Configuring Jboss Cluster using Apache JK Module:

Jboss clustering is used to enable application failover and load balancing.  To configure jboss cluster, you need to Jboss Application Servers with similar configuration and one apache server.  Apache can also be configured on any one of the jboss application server.

Please follow the below steps to configure a jboss cluster using Apache JK Module.

1. Install apache 2.0.x server.
2. Download and install JK module from apache.org.  If the JK module is installed, you would find a file with name mod_jk.so in /etc/httpd/modules folder provided the apache (http) server’s configuration files reside in /etc/httpd folder.
3. Load the JK module by adding below line /etc/httpd/conf/httpd.conf file (Apache Configuration File)

LoadModule jk_module modules/mod_jk.so

4. Once the module is loaded, add the following entries at the end of the /etc/httpd/conf/httpd.conf (Apache configuration file)

<IfModule mod_jk.c>
include conf/modjk.conf
</IfModule>

5. Now create modjk.conf file in /etc/httpd/conf folder with the following contents

JkLogFile logs/modjk.log
JkLogLevel info
JkWorkersFile conf/jkworkers.properties
JkMountFile conf/jkmount.properties
<Location /status/>
JkMount jkstatus
Order deny,allow
Allow from all
</Location>
  6. Once modjk configuration file is created, create the jkworkers.properties file in 
      /etc/httpd/conf/ with the following contents.

worker.list=jboss,jkstatus
# Entries for 1st node
worker.node1.type=ajp13
worker.node1.host=10.154.2.202 ## IP address of 1st node
worker.node1.port=8009
worker.node1.lbfactor=1
worker.node1.disabled=false
worker.node1.socket_timeout=10
worker.node1.connect_timeout=20000
# Entries for 2nd node
worker.node2.type=ajp13
worker.node2.host=10.154.2.186 ## IP address of 2nd node
worker.node2.port=8009
worker.node2.lbfactor=1
worker.node2.disabled=false
worker.node2.socket_timeout=10
worker.node2.connect_timeout=20000
#Load Balancer
worker.jboss.type=lb
worker.jboss.balance_workers=node1,node2
worker.jboss.sticky_session=true
worker.jboss.sticky_session_force=false
worker.jboss.method=R
worker.jboss.lock=P
worker.jkstatus.type=status

7. Now, create the jkmount.properties file in /etc/httpd/conf/ folder with the following contents

/jmx-console*=jboss
/application/* = jboss

Replace your application url in place of “/application/*” above i.e. if your application is url is  http://jbossserver:8080/myapp replace “/myapp/*” with “/aplication/*”

8. Restart httpd (apache) server.
Now, we have completed the apache configuration however the jboss configuration is still pending.   

9. Copy server/all to server/nodex.

10.Add jvm route to differentiate jboss instances by updating.  To add jvm route, locate a line which contains “<Engine name=jboss.web defaultHost=localhost>” in $JBOSS_HOME/deploy/jboss-web.deployer/server.xml file and replace it with “<Engine name=jboss.web defaulHost=localhost jvmRoute=nodex)”

11. Now, as a last step, enable JK Module in Jboss.  To enable JK Module, locate a line which contains “<attribute name=UseJK> false </attribute>” and replace it with “<attribute name=UseJKtrue </attribute>” in $JBOSS_HOME/server/nodex/deploy/jboss-web.deployer/META-INF/jboss-service.xml file

12. Repeat steps 9,10 & 11 for all the Jboss Nodes.  You need to replace nodex with the appropriate node number i.e. node1, node2 etc.

13. Restart jboss application server with new profile i.e. node1, node2 etc.

Deploying Web Applications:

You need to deploy the applications on any node in server/profile/farm folder. Replace profile with the appropriate profile i.e. node1, node2 etc based upon the node on which you are deploying your applications.  Once application is deployed on any one node in the cluster, the cluster service will copy those applications on other nodes automatically and the application would be available on all the nodes.

Accessing the Web Applications:

The application can now be accessed directly by accessing the apache http server url i.e.http://httpserver/application. Replace httpserver with domainname or ip address of http server and application with the application you configured in jkmount.properties file. The additional port number is not required to access the Web application. The JK module will automatically forward the request to specific port on JBOSS Application Server.