Tag: Cluster

How to create cluster in JBoss AS 7.1 in domain mode?

In my last article we had seen How to create cluster in JBoss AS 7.1 in standalone mode now in this article we would be doing the same but in domain mode.

In domain mode we would be using two main xml files called domain.xml and host.xml files which has to be used for creating this cluster.

In this article we would be using JBoss AS 7.1.1 Final which is the latest version of JBoss in community version. Now lets see how can we create cluster in JBoss AS 7.1 in domain mode.

Steps to create a cluster in JBoss AS 7.1 in domain mode

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.

Scenario 1: Cluster on same box

  1. Download and unzipped jboss-as-7.1.1.Final.zip
  2. Now in “/home/user/jboss-as-7.1.1.Final/domain/configuration/domain.xml” file make the below changes, which is just adding a new server-group (i.e. ha-server-group) which would be using ha profile and ha-sockets socket binding group, where ha is for cluster enabled.
  3. <server-groups>
            <server-group name="ha-server-group" profile="ha">
                <jvm name="default">
                    <heap size="64m" max-size="512m"/>
                </jvm>
                <socket-binding-group ref="ha-sockets"/>
            </server-group>
    .
    .
    </server-groups>
    

    Where:

    1. profile: tells which type of profile is been used (i.e. web, messaging, cluster, full)
    2. socket-binding-group: tells which all type of protocols is been used (i.e. web [http,ajp], messaging, jgroups [udp, tcp], full)
    3. server-group : tells what profile is been used and what type of sockets is been used

     

  4. After that you would have to make the below changes in “/home/user/jboss-as-7.1.1.Final/domain/configuration/host.xml” file which is just adding two new JBoss nodes with the name ha-server-1 and ha-server-2 which are using the ha-server-group server group created in the pervious setp and making this servers clusterd enabled
  5.     <servers>
          <server name="ha-server-1" group="ha-server-group" auto-start="true">
                <socket-bindings port-offset="100"/>
            </server>
            <server name="ha-server-2" group="ha-server-group" auto-start="true">
                <socket-bindings port-offset="200"/>
            </server>
    .
    .
    </servers>
    

    Note: You are giving unique name and port offset for these servers, as both the servers are running on the same box.

  6. Create a Management User using the add-user.sh script as shown below. This is done so that we can access admin console.
  7. bin]$ ./add-user.sh 
    
    What type of user do you wish to add? 
     a) Management User (mgmt-users.properties) 
     b) Application User (application-users.properties)
    (a): a
    
    Enter the details of the new user to add.
    Realm (ManagementRealm) : 
    Username : testuser
    Password : testpassword
    Re-enter Password : testpassword
    About to add user 'testuser' for realm 'ManagementRealm'
    Is this correct yes/no? yes
    Added user 'testuser' to file '/home/user/jboss-as-7.1.1.Final/standalone/configuration/mgmt-users.properties'
    Added user 'testuser' to file '/home/user/jboss-as-7.1.1.Final/domain/configuration/mgmt-users.properties'
    
  8. Once everything is done start your server by using the below command, however you would not see that the nodes ha-server-1 and ha-server-2 are in a cluster for that you would have to deploy an application which has the distributable tag in web.xml .
  9. ./domain.sh
    
  10. Now you can download one of our sample clustered application by : clicking here and deploy it from admin console from the URL “http://localhost:9990/console
  11. Adding the application

    Choosing application file

    Verifying the deployed applicaiton name

    Adding the deployed applicaiton to a server group

    Selecting ha-server-group for getting the application deployed

  12. Just after deploying application and adding it to ha-server-group you would see the below cluster view in the prompt in which the domain is running.
  13. [Server:ha-server-2] 15:12:33,971 INFO  [org.jboss.web] (MSC service thread 1-1) JBAS018210: Registering web context: /ClusterWebApp
    [Server:ha-server-2] 15:12:34,239 INFO  [org.jboss.as.clustering.impl.CoreGroupCommunicationService.lifecycle.web] (Incoming-1,null) JBAS010247: New cluster view for partition web (id: 1, delta: 1, merge: false) : [master:ha-server-2/web, master:ha-server-1/web]
    [Server:ha-server-2] 15:12:34,242 INFO  [org.infinispan.remoting.transport.jgroups.JGroupsTransport] (Incoming-1,null) ISPN000094: Received new cluster view: [master:ha-server-2/web|1] [master:ha-server-2/web, master:ha-server-1/web]
    .
    .
    [Server:ha-server-1] 15:12:34,377 INFO  [org.infinispan.remoting.transport.jgroups.JGroupsTransport] (pool-14-thread-3) ISPN000078: Starting JGroups Channel
    [Server:ha-server-1] 15:12:34,378 INFO  [org.infinispan.remoting.transport.jgroups.JGroupsTransport] (pool-14-thread-3) ISPN000094: Received new cluster view: [master:ha-server-2/web|1] [master:ha-server-2/web, master:ha-server-1/web]
    

Scenario 2: Cluster on different boxes

  1. After unzipping JBoss AS 7 in both the boxes [i.e. box-1=10.10.10.10 and box-2=20.20.20.20 ] choose which one of the boxes would be working as a domain controller and other as host controller
  2. Suppose you choose box-1 [10.10.10.10] as domain controller then you would have to follow Step-2 and Step-3 of Scenario 1, creating only one JBoss server which is ha-server-1
  3. For the box-2 [20.20.20.20] which would be working as a host controller having the name host1, now only follow Step-3 of Scenario 1, this is because we would be using domain.xml of the domain controller and creating the other JBoss server which is ha-server-2 .
  4. Once you have done with the above changes you would have to follow the steps given in the article How to start JBoss AS 7.1 in domain mode ? and the below image would give you a better understanding of the architecture
  5. Now the last thing which you would have to do is to deploy the application using the console which would be running in the domain controller hence you would be using the URL http://10.10.10.10:9990/console and repeat the Step 6 of Scenario 1
  6. Once everything is done properly you would see similar below lines in respective prompts of domain and host controller
  7. [Server:ha-server-1] 19:39:29,458 INFO  [org.jboss.as.clustering.impl.CoreGroupCommunicationService.lifecycle.web] (Incoming-20,null) JBAS010247: New cluster view for partition web (id: 7, delta: 0, merge: true) : [master:ha-server-1/web, host1:ha-server-2/web]
    

How to create cluster in JBoss AS 7.1 in standalone mode?

We have seen that JBoss AS 7 is totally different then the earlier versions of JBoss, hence if you want to create a cluster in JBoss AS 7 there are few things which has been change and has to be known or else you would face issues.

In JBoss AS 7 we have by default two modes which are domain mode and standalone mode , in this article we would be using standalone mode. However in standalone mode also we have different xml files under the configuration folder from which cluster is enabled in standalone-ha.xml and standalone-full-ha.xml, thus make sure you would be using them and not other xml files.

In this article we would be using JBoss AS 7.1.1 Final which is the latest version of JBoss in community version. Now lets see how can we create cluster in JBoss AS 7.1

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.

Scenario 1: 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
  2. /home/user/jboss-as-7.1.1.Final/standalone-node1
    /home/user/jboss-as-7.1.1.Final/standalone-node2
    

    Note: Make sure you keep the original copy for standalone folder as it is for future usage.

  3. Now you would have to run the below command to start both the JBoss node in a cluster
  4. 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
    

    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 

    1. Both the nodes should have same multicast address
    2. Both the nodes should have different node names
    3. Both the nodes should have different socket binding port-offsets
  5. 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 . You can download one of our sample clustered application by : clicking here
  6. After downloading the ClusterWebApp.war you just have to keep it in (/home/user/jboss-as-7.1.1.Final/standalone-nodeX/deployments) both nodes deployments folder, just after that you would see similar below messages in both the nodes prompt, having both node names in there cluster view.
  7. 18:32:46,863 INFO  [stdout] (pool-13-thread-1) -------------------------------------------------------------------
    18:32:46,863 INFO  [stdout] (pool-13-thread-1) GMS: address=node1/web, cluster=web, physical address=10.10.10.10:55300
    18:32:46,863 INFO  [stdout] (pool-13-thread-1) -------------------------------------------------------------------
    18:32:47,572 INFO  [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (MSC service thread 1-8) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be pasivated.
    18:32:47,581 INFO  [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (MSC service thread 1-1) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be pasivated.
    18:32:47,771 INFO  [org.infinispan.remoting.transport.jgroups.JGroupsTransport] (pool-15-thread-1) ISPN000078: Starting JGroups Channel
    18:32:47,791 INFO  [org.infinispan.remoting.transport.jgroups.JGroupsTransport] (pool-15-thread-1) ISPN000094: Received new cluster view: [node1/web|1] [node1/web, node2/web]
    

Scenario 2: Cluster on different boxes

  1. After unzipping JBoss AS 7 in both the boxes [i.e. box-1=10.10.10.10 and box-2=20.20.20.20 ] then you can create just a single copies of standalone folder in respective boxes
  2. Box-1 : 10.10.10.10

    /home/user/jboss-as-7.1.1.Final/standalone-node1
    

    Box-2 : 20.20.20.20

    /home/user/jboss-as-7.1.1.Final/standalone-node2
    
  3. 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
  4. Node1 on Box-1 [10.10.10.10]

    ./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
    

    Node2 on Box-2 [20.20.20.20]

    ./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
    

    Here we would not have to worry about the port conflicts as we are running both the nodes on different boxes having different binding address.

  5. Repeat the same step-3 and step-4 of Scenario-1 and you would then see the same cluster view in each running nodes prompts.

If you are looking for running multiple clusters, then you would have to make sure you give a different set of multicast address (i.e  -u option) for each cluster.


Copyright © 2010-2012 Middleware Magic. All rights reserved. |