Monday 13 May 2013

Jboss as 7.1 : Clustering



Steps to create a cluster in JBoss AS 7.1
We would be seeing two scenarios here one would be creating a cluster on the same box and second when creating a cluster between different boxes.

Cluster on same box

1.       Once you have unzipped jboss-as-7.1.1.Final.zip , you would have to create two copies of standalone folder and rename them as standalone-node1 and standalone-node2 as shown below
/home/user/jboss-as-7.1.1.Final/standalone-node1
/home/user/jboss-as-7.1.1.Final/standalone-node2

2.      Now you would have to run the below command to start both the JBoss node in a cluster
Node1
./standalone.sh -c standalone-ha.xml -b 10.10.10.10 -u 230.0.0.4 
-Djboss.server.base.dir=../standalone-node1 -Djboss.node.name=node1 
-Djboss.socket.binding.port-offset=100
 
Where 10.10.10.10 is the IP of machine.
 
Node2
./standalone.sh -c standalone-ha.xml -b 10.10.10.10 -u 230.0.0.4 
-Djboss.server.base.dir=../standalone-node2 -Djboss.node.name=node2 
-Djboss.socket.binding.port-offset=200
Where:
-c = is for server configuration file to be used
-b = is for binding address
-u = is for multicast address
-Djboss.server.base.dir = is for the path from where node is present
-Djboss.node.name = is for the name of the node
-Djboss.socket.binding.port-offset = is for the port offset on which node would be running

Note: However we need to keep in mind the following things 
·         Both the nodes should have same multicast address
·         Both the nodes should have different node names
·         Both the nodes should have different socket binding port-offsets

3.      Once both the node comes up properly you would not see them in cluster, hence to make sure if both of the nodes are in a cluster then you would need to deploy the an application which has the distributable tag in web.xml .
Eg. < distributable />
4.       Now keep the War in both the standalone / deployment  folder and start the server.

Cluster on different boxes

1.       After unzipping JBoss AS 7 in both the boxes then you can create just a single copies of standalone folder in respective boxes
Box-1 : /home/user/jboss-as-7.1.1.Final/standalone-node1

Box-2 : /home/user/jboss-as-7.1.1.Final/standalone-node2
 
2.      Now you would have to run the below command to start both the JBoss node in a cluster

Note: However we need to keep in mind the following things 
  1. Both the nodes should have same multicast address
  2. Both the nodes should have different node names
  3. Both the nodes should be running on the IP_ADDRESS or HOST_NAME of the box
Node1 on Box-1
./standalone.sh -c standalone-ha.xml -b 10.10.10.10 -u 230.0.0.4 
-Djboss.server.base.dir=../standalone-node1 -Djboss.node.name=node1

Where 10.10.10.10 is the IP of machine
Node2 on Box-2
./standalone.sh -c standalone-ha.xml -b 20.20.20.20 -u 230.0.0.4 
-Djboss.server.base.dir=../standalone-node2 -Djboss.node.name=node2

Where 20.20.20.20 is the IP of machine
Now make the changes in the Application as mention above and start the server.

5 comments:

  1. Hi Abhishek,

    Is there any example as to how to set up the load balancing in domain mode of jboss?

    Thanks,
    Sampath

    ReplyDelete
  2. Hi Abhisek,

    I am using jboss 7.1. I am trying to implement session replication in two cluster node which is running on same system.
    What i did is :
    ==========
    In Web.xml
    I make my application distributable by using tag .

    In Jboss-web.xml
    =============

    ACCESS
    ATTRIBUTE
    SYNCHRONOUS



    But session in not replicating. Can u tel me is there any thing wrong in my configuration.

    Thanks,
    Kiran

    ReplyDelete
  3. I can not see any web.xml file in jboss as & , can you post the location of the web.xml file in JBoss AS 7

    ReplyDelete
  4. @krian Where did you find web.xml file in JBoss AS7?

    ReplyDelete
  5. web.xml resides inside the ear/war file.

    ReplyDelete