3.2.8. Clustering Changes
3.2.8.1. Make Changes to Your Application for Clustering
Start JBoss EAP 6 with clustering enabled
To enable clustering in JBoss EAP 5.x, you needed to start your server instances using theall
profile or some derivation of it, like this:$ EAP5_HOME/bin/run.sh -c all
In JBoss EAP 6, the method for enabling clustering depends on whether the servers are standalone or running in a managed domain.Enable clustering for servers running in a managed domain
To enable clustering for servers started using the domain controller, update yourdomain.xml
and designate a server group to use theha
profile andha-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>
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
Specify the bind address
In JBoss EAP 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 EAP 6, bind addresses are explicitly defined by the relevant socket bindings within the JBoss EAP 6 configuration files. For servers started using the domain controller, bind addresses are specified within thedomain/configuration/host.xml
file. For standalone servers, bind addresses are specified within thestandalone-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, thepublic
interface is specified as the default interface for all sockets within theha-sockets
socket binding group.Configure
jvmRoute
to support mod_jk and mod_proxyIn JBoss EAP 5, the web serverjvmRoute
was configured using a property in theserver.xml
file. In JBoss EAP 6, thejvmRoute
attribute is configured in the web subsystem of the server configuration file using theinstance-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.Theinstance-id
can also be set using the Management Console.Specify the multicast address and port
In JBoss EAP 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 EAP 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 andjboss.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
Use an alternate protocol stack
In JBoss EAP 5.x, you could manipulate the default protocol stack used for all clustering services using thejboss.default.jgroups.stack
system property.$ EAP_HOME/bin/run.sh -c all -Djboss.default.jgroups.stack=tcp
In JBoss EAP 6, the default protocol stack is defined by the JGroups subsystem withindomain.xml
orstandalone-ha.xml
:<subsystem xmlns="urn:jboss:domain:jgroups:1.0" default-stack="udp"> <stack name="udp"> <!-- ... --> </stack> </subsystem>
Replace Buddy Replication
JBoss EAP 5.x used JBoss Cache Buddy Replication to suppress replication of data to all instances in a cluster. It required that you pass the argument-Djboss.cluster.buddyRepl
on the command line when you started the JBoss server.In JBoss EAP 6, Buddy Replication has been replaced by Infinispan's far superior distributed cache or DIST mode. Distribution is a powerful clustering mode which allows Infinispan to scale linearly as more servers are added to the cluster. The following is an example of how to configure the server to use the DIST caching mode.- Open a command line and start the server with either the HA or Full Profile, for example:
EAP_HOME/bin/standalone.sh -c standalone-ha.xml
- Open another command line and connect to the Management CLI.
- For Linux, enter the following at the command line:
$ EAP_HOME/bin/jboss-cli.sh --connect
- For Windows, enter the following at a command line:
C:\>EAP_HOME\bin\jboss-cli.bat --connect
You should see the following response:Connected to standalone controller at localhost:9999
- Issue the following commands:
/subsystem=infinispan/cache-container=web/:write-attribute(name=default-cache,value=dist) /subsystem=infinispan/cache-container=web/distributed-cache=dist/:write-attribute(name=owners,value=3) :reload
You should see the following response after each command:"outcome" => "success"
These commands create the following configuration in theinfinispan
subsystem of thestandalone-ha.xml
file:<cache-container name="web" aliases="standard-session-cache" default-cache="dist" module="org.jboss.as.clustering.web.infinispan"> <transport lock-timeout="60000"/> <replicated-cache name="repl" mode="ASYNC" batching="true"> <file-store/> </replicated-cache> <replicated-cache name="sso" mode="SYNC" batching="true"/> <distributed-cache name="dist" owners="3" l1-lifespan="0" mode="ASYNC" batching="true"> <file-store/> </distributed-cache> </cache-container>
For more information, refer to the chapter entitled Clustering in Web Applications in the Development Guide for JBoss EAP 6 located on the Customer Portal at https://access.redhat.com/site/documentation/JBoss_Enterprise_Application_Platform/.