January 9, 2013

How to Setup JBoss EAP 6 HA Cluster With mod_cluster Using TCP Multicast Networking

JBoss EAP 6 uses JGroups to handle cluster communication. JGroups is a full fledged communication API and you can read more about it here, http://www.jgroups.org/manual-3.x/html/index.html.

Default is JBoss EAP 6 configured to use UDP, but in this blog I will show you how to configure JBoss EAP 6 HA cluster to use TCP multicast networking instead.

JGroups is flexible API, that can stack several protocol on top of each other, or chain them if you like. The JGroups protocol can be divided into the following:

  • Group Membership: pbcast.GMS, PING, TCPPING, MPING, TCPGOSSIP, FILE_PING, JDBC_PING
  • Failure: MERGE2, FD, FD_ALL, FD_SOCK, VERIFY_SUSPECT
  • Reliable transmission: pbcast.NAKACK, UNICAST, RSVP
  • State transfer: pbcast.STATE_TRANSFER, pbcast.STATE, BARRIER
  • Efficiency: FRAG2, COMPRESS, UFC, MFC, DAISYCHAIN
  • Various: ENCRYPT, AUTH, SEQUENCER, STABLE, RELAY

Now revisit our cluster domain example that I have previously described here http://magnus-k-karlsson.blogspot.se/2013/01/how-to-cluster-domain-jboss-eap-6-and.html. But now lets change the global configuration in ./domain/domain/configuration/domain.xml.

<profile name="ha">
    ...
    <subsystem xmlns="urn:jboss:domain:jgroups:1.1" default-stack="tcpping">
        <stack name="tcpping">
            <transport type="TCP" socket-binding="jgroups-tcp"/>
            <protocol type="TCPPING">
                <property name="initial_hosts">127.0.0.1[7800],127.0.0.1[8000]</property>
                <property name="port_range">0</property>
                <property name="timeout">3000</property>
                <property name="num_initial_members">2</property>
            </protocol>
            <protocol type="MERGE2"/>
            <protocol type="FD_SOCK" socket-binding="jgroups-tcp-fd"/>
            <protocol type="FD"/>
            <protocol type="VERIFY_SUSPECT"/>
            <protocol type="BARRIER"/>
            <protocol type="pbcast.NAKACK"/>
            <protocol type="UNICAST2"/>
            <protocol type="pbcast.STABLE"/>
            <protocol type="pbcast.GMS"/>
            <protocol type="UFC"/>
            <protocol type="MFC"/>
            <protocol type="FRAG2"/>
            <protocol type="RSVP"/>
        </stack>
        ...
    </subsystem>
    ...
</profile>

Now if you have already started the cluster you need to restart the Domain Controller and then log into the domain controller with you CLI tool and restart each cluster node.

# Restart you domain controller
$ ./domain/bin/domain.sh --host-config=host-master.xml

# Start the CLI tool at the domain controller
$ ./domain/bin/jboss-cli.sh

# Restart each cluster node, to pick up the new configuration.
[domain@localhost:9999 /] /host=server1/server-config=server-one:restart
{
    "outcome" => "success",
    "result" => "STARTING"
}
[domain@localhost:9999 /] /host=server2/server-config=server-two:restart
{
    "outcome" => "success",
    "result" => "STARTING"
}

Watch each cluser server node log for error, if any revisit the above and sort out problems. If everything OK, you should see something similar on server1.

[Server:server-one] 06:20:20,934 INFO  [stdout] (ServerService Thread Pool -- 53) 
[Server:server-one] 06:20:20,935 INFO  [stdout] (ServerService Thread Pool -- 53) -------------------------------------------------------------------
[Server:server-one] 06:20:20,935 INFO  [stdout] (ServerService Thread Pool -- 53) GMS: address=server1:server-one/ejb, cluster=ejb, physical address=127.0.0.1:7800
[Server:server-one] 06:20:20,935 INFO  [stdout] (ServerService Thread Pool -- 53) -------------------------------------------------------------------
[Server:server-one] 06:20:20,988 INFO  [stdout] (ServerService Thread Pool -- 52) 
[Server:server-one] 06:20:20,988 INFO  [stdout] (ServerService Thread Pool -- 52) -------------------------------------------------------------------
[Server:server-one] 06:20:20,988 INFO  [stdout] (ServerService Thread Pool -- 52) GMS: address=server1:server-one/web, cluster=web, physical address=127.0.0.1:7800
[Server:server-one] 06:20:20,989 INFO  [stdout] (ServerService Thread Pool -- 52) -------------------------------------------------------------------

...

[Server:server-one] 06:20:21,376 INFO  [org.infinispan.remoting.transport.jgroups.JGroupsTransport] (ServerService Thread Pool -- 54) ISPN000078: Starting JGroups Channel
[Server:server-one] 06:20:21,376 INFO  [org.infinispan.remoting.transport.jgroups.JGroupsTransport] (ServerService Thread Pool -- 53) ISPN000078: Starting JGroups Channel
[Server:server-one] 06:20:21,393 INFO  [org.infinispan.remoting.transport.jgroups.JGroupsTransport] (ServerService Thread Pool -- 53) ISPN000094: Received new cluster view: [server2:server-two/ejb|13] [server2:server-two/ejb, server1:server-one/ejb]
[Server:server-one] 06:20:21,393 INFO  [org.infinispan.remoting.transport.jgroups.JGroupsTransport] (ServerService Thread Pool -- 54) ISPN000094: Received new cluster view: [server2:server-two/web|13] [server2:server-two/web, server1:server-one/web]

...

[Server:server-one] 06:20:21,758 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 54) JBAS010281: Started repl cache from web container
[Server:server-one] 06:20:21,759 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 53) JBAS010281: Started repl cache from ejb container

And host server2.

[Server:server-two] 06:19:02,782 INFO  [stdout] (ServerService Thread Pool -- 52) 
[Server:server-two] 06:19:02,782 INFO  [stdout] (ServerService Thread Pool -- 52) -------------------------------------------------------------------
[Server:server-two] 06:19:02,783 INFO  [stdout] (ServerService Thread Pool -- 52) GMS: address=server2:server-two/ejb, cluster=ejb, physical address=127.0.0.1:8000
[Server:server-two] 06:19:02,783 INFO  [stdout] (ServerService Thread Pool -- 52) -------------------------------------------------------------------
[Server:server-two] 06:19:02,835 INFO  [stdout] (ServerService Thread Pool -- 53) 
[Server:server-two] 06:19:02,836 INFO  [stdout] (ServerService Thread Pool -- 53) -------------------------------------------------------------------
[Server:server-two] 06:19:02,836 INFO  [stdout] (ServerService Thread Pool -- 53) GMS: address=server2:server-two/web, cluster=web, physical address=127.0.0.1:8000
[Server:server-two] 06:19:02,837 INFO  [stdout] (ServerService Thread Pool -- 53) -------------------------------------------------------------------

...

[Server:server-two] 06:19:03,238 INFO  [org.infinispan.remoting.transport.jgroups.JGroupsTransport] (ServerService Thread Pool -- 53) ISPN000078: Starting JGroups Channel
[Server:server-two] 06:19:03,238 INFO  [org.infinispan.remoting.transport.jgroups.JGroupsTransport] (ServerService Thread Pool -- 54) ISPN000078: Starting JGroups Channel
[Server:server-two] 06:19:03,254 INFO  [org.infinispan.remoting.transport.jgroups.JGroupsTransport] (ServerService Thread Pool -- 54) ISPN000094: Received new cluster view: [server1:server-one/web|11] [server1:server-one/web, server2:server-two/web]
[Server:server-two] 06:19:03,255 INFO  [org.infinispan.remoting.transport.jgroups.JGroupsTransport] (ServerService Thread Pool -- 54) ISPN000079: Cache local address is server2:server-two/web, physical addresses are [127.0.0.1:8000]
[Server:server-two] 06:19:03,254 INFO  [org.infinispan.remoting.transport.jgroups.JGroupsTransport] (ServerService Thread Pool -- 53) ISPN000094: Received new cluster view: [server1:server-one/ejb|11] [server1:server-one/ejb, server2:server-two/ejb]
[Server:server-two] 06:19:03,258 INFO  [org.infinispan.remoting.transport.jgroups.JGroupsTransport] (ServerService Thread Pool -- 53) ISPN000079: Cache local address is server2:server-two/ejb, physical addresses are [127.0.0.1:8000]

...

[Server:server-two] 06:19:03,569 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 52) JBAS010281: Started repl cache from ejb container
[Server:server-two] 06:19:03,571 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 54) JBAS010281: Started repl cache from web container

Now in the JBoss EAP 6 Administration and Configuration Guide there is suggested to turn off the ServerAdvertise in the Apache Web Server mod_cluster, we do that and restart everything. After restart make sure that mod_cluster is up and running, by checking every cluster node is registered in the http://127.0.0.1:6666/mod_cluster_manager.

Now you can test the clustered application by open http://127.0.0.1/cluster/index.jsf.

No comments: