3.2.6. Clustering Changes

3.2.6.1. Make Changes to Your Application for Clustering

Procedure 3.22. 

  1. Start JBoss Enterprise Application Platform 6 with clustering enabled

    To enable clustering in JBoss Enterprise Application Platform 5.x, you needed to start your server instances using the all profile or some derivation of it, like this:
    $ EAP5_HOME/bin/run.sh -c all
    In JBoss Enterprise Application Platform 6, the method for enabling clustering depends on whether the servers are standalone or running in a managed domain.
    1. Enable clustering for servers running in a managed domain

      To enable clustering for servers started using the domain controller, update your domain.xml and designate a server group to use the ha profile and ha-sockets socket binding group. For example:
      <server-groups>
        <server-group name="main-server-group" profile="ha">
          <jvm name="default">
            <heap size="64m" max-size="512m"/>
          </jvm>
          <socket-binding-group ref="ha-sockets"/>
        </server-group>
      </server-group>
    2. Enable clustering for standalone servers

      To enable clustering for standalone servers, start the server using the appropriate configuration file as follows: $ EAP_HOME/bin/standalone.sh --server-config=standalone-ha.xml -Djboss.node.name=UNIQUE_NODE_NAME
  2. Specify the bind address

    In JBoss Enterprise Application Platform 5.x, you would typically indicate the bind address used for clustering using the -b command line argument like this: $ EAP_HOME/bin/run.sh -c all -b 192.168.0.2
    In JBoss Enterprise Application Platform 6, bind addresses are explicitly defined by the relevant socket bindings within the JBoss Enterprise Application Platform 6 configuration files. For servers started using the domain controller, bind addresses are specified within the domain/configuration/host.xml file. For standalone servers, bind addresses are specified within the standalone-ha.xml file:
    <interfaces>
          <interface name="management">
        <inet-address value="192.168.0.2"/>
          </interface>
          <interface name="public">
        <inet-address value="192.168.0.2"/>
      </interface>
      </interfaces>
    <socket-binding-groups>
          <socket-binding-group name="ha-sockets" default-interface="public">
        <!-- ... -->
          </socket-binding-group>
      </socket-binding-groups>
    In the example above, the public interface is specified as the default interface for all sockets within the ha-sockets socket binding group.
  3. Configure jvmRoute to support mod_jk and mod_proxy

    In JBoss Enterprise Application Platform 5, the web server jvmRoute was configured using a property in the server.xml file. In JBoss Enterprise Application Platform 6, the jvmRoute attribute is configured in the web subsystem of the server configuration file using the instance-id attribute as follows:
    <subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" native="false" instance-id="{JVM_ROUTE_SERVER}">
    
    The {JVM_ROUTE_SERVER} above should be replaced by the jvmRoute server ID.
    The instance-id can also be set using the Management Console.
  4. Specify the multicast address and port

    In JBoss Enterprise Application Platform 5.x, you could specify the multicast address and port used for intra-cluster communication using the command line arguments -u and -m, respectively, like this: $ EAP_HOME/bin/run.sh -c all -u 228.11.11.11 -m 45688
    In JBoss Enterprise Application Platform 6, the multicast address and port used for intra-cluster communication are defined by the socket-binding referenced by the relevant JGroups protocol stack as follows:
    <subsystem xmlns="urn:jboss:domain:jgroups:1.0" default-stack="udp">
        <stack name="udp">
            <transport type="UDP" socket-binding="jgroups-udp"/>
            <!-- ... -->
        </stack>
    </subsystem>
    <socket-binding-groups>
        <socket-binding-group name="ha-sockets" default-interface="public">
            <!-- ... -->
            <socket-binding name="jgroups-udp" port="55200" multicast-address="228.11.11.11" multicast-port="45688"/>
            <!-- ... -->
        </socket-binding-group>
    </socket-binding-groups>
    
    If you prefer to specify the multicast address and port in the command line, you can define the multicast address and ports as system properties and then use those properties on the command line when you start the server. In the following example, jboss.mcast.addr is the variable name for the multicast address and jboss.mcast.port is the variable name for the port.
    <socket-binding name="jgroups-udp" port="55200"
     multicast-address="${jboss.mcast.addr:230.0.0.4}" multicast-port="${jboss.mcast.port:45688}"/>
    
    You can then start your server using the following command line arguments: $ EAP_HOME/bin/domain.sh -Djboss.mcast.addr=228.11.11.11 -Djboss.mcast.port=45688
  5. Use an alternate protocol stack

    In JBoss Enterprise Application Platform 5.x, you could manipulate the default protocol stack used for all clustering services using the jboss.default.jgroups.stack system property. $ EAP_HOME/bin/run.sh -c all -Djboss.default.jgroups.stack=tcp
    In JBoss Enterprise Application Platform 6, the default protocol stack is defined by the JGroups subsystem within domain.xml or standalone-ha.xml:
    <subsystem xmlns="urn:jboss:domain:jgroups:1.0" default-stack="udp">
        <stack name="udp">
            <!-- ... -->
        </stack>
    </subsystem>