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:$ EAP5_HOME/bin/run.sh -c all -b 192.168.0.2
JBoss EAP 6 binds sockets to the IP addresses and interfaces contained in the<interfaces>
elements instandalone.xml
,domain.xml
andhost.xml
files. The standard configurations that ship with JBoss EAP include two interface configurations:<interfaces> <interface name="management"> <inet-address value="${jboss.bind.address.management:127.0.0.1}"/> </interface> <interface name="public"> <inet-address value="${jboss.bind.address:127.0.0.1}"/> </interface> </interfaces>
These interface configurations use the values of the system propertiesjboss.bind.address.management
andjboss.bind.address
. If these system properties are not set, the default127.0.0.1
is used for each value.You can also specify the bind address as a command line argument when you start the server or you can explicitly define it within the JBoss EAP 6 server configuration file.- Specify the bind argument on the command line when you start the JBoss EAP standalone server.The following is an example of how to specify the bind address on the command line for a standalone server:
EAP_HOME/bin/standalone.sh -Djboss.bind.address=127.0.0.1
Note
You can also use the-b
argument, which is a shortcut for-Djboss.bind.address=127.0.0.1
:EAP_HOME/bin/standalone.sh -b=127.0.0.1
The JBoss EAP 5 syntax format is also still supported:
Note that theEAP_HOME/bin/standalone.sh -b 127.0.0.1
-b
argument only changes thepublic
interface. It does not affect themanagement
interface. - Specify the bind address in the server configuration file.For servers running in a managed domain, specify the bind addresses in the
domain/configuration/host.xml
file. For standalone servers, specify the bind addresses in thestandalone-ha.xml
file.In the following example, thepublic
interface is specified as the default interface for all sockets within theha-sockets
socket binding group.<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>
Note
If you specify the bind address as a hard-coded value rather than a system property in the configuration file, you can not override it with a command line argument.
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:$ EAP5_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.$ EAP5_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.In JBoss EAP 6, Buddy Replication has been replaced by Infinispan's distributed cache, also known asDIST
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 modify thedist
<distributed-cache>
element in theweb
<cache-container>
configuration in theinfinispan
subsystem of thestandalone-ha.xml
file as follows:<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/.