JBoss Clustering in 5 minutes
Building a JBoss Appliaction Server 5.1 Cluster
Having spent a couple of months working on a JBoss App server clustering, I would like to share some thoughts about it.
Clustering of JBoss is relatively straightforward but there are a few gotchas.
Simply executing “run -c all” on two AS instances on the same network is enough for them to form a cluster. But there is lot more to it than executing a command to make a working cluster.
This is the most common production scenario. Assume the machines are named "node1" and "node2", while node1 has an IP address of 192.168.0.101 and node2 has an address of 192.168.0.102.
run -c all -g ProductionCluster -u 239.255.100.100 -b 192.168.0.101 -Djboss.messaging.ServerPeerID=1
run -c all -g ProductionCluster -u 239.255.100.100 -b 192.168.0.102 -Djboss.messaging.ServerPeerID=2
The -c switch says to use the all config, which includes clustering support.
The -g switch sets the cluster name, this should be same for all server nodes in a cluster.
The -u switch sets the multicast address that will be used for intra-cluster communication. This is generally a IPv4 format, remember this IP should not be in use in your Network.
The -b switch sets the address on which sockets will be bound.
The -D switch sets system property jboss.messaging.ServerPeerID, from which JBoss Messaging gets its unique id.
The clustering features in JBoss Application Server are built on top of lower level libraries that provide much of the core functionality -
So after done with your cluster setup you may like to configure your application for clustering.
|
1 2 3 4 5 6 |
<?xml version="1.0"?> <web-app> ... <distributable/> ... </web-app> |
|
1 2 3 4 5 6 7 8 9 |
<?xml version="1.0"?> <jboss> <enterprise-beans> <session> .... <clustered>true</clustered> </session> </enterprise-beans> </jboss> |
Common Problems & Solution
If there is firewall is existing in your network then it will not allow JGroups to communicate
Start a Gossip Server:
java -cp $JBOSS_HOME\server\all\lib\jgroups.jar;$JBOSS_HOME\common\lib\commons-logging.jarorg.jgroups.stack.GossipRouter -port 5555 -bindaddress localhost
Then in the JGroups configuration of the file %JBOSS_HOME\server\all\deploy\ cluster\jgroups-channelfactory.sar\META-INF\jgroups-channelfactory-stacks.xml make the following modifications in all nodes of the cluster:
|
1 2 3 4 |
<UDP ip_mcast="false" mcast_addr="239.255.100.100" mcast_port="45566" ip_ttl="32" mcast_send_buf_size="150000" mcast_recv_buf_size="80000"/> <PING gossip_host="gossip_server_name" gossip_port="5555" gossip_refresh="15000" timeout="2000" num_initial_members="3"/> |
Now, instead of nodes multicasting to find other nodes, they will register and get information about the cluster from the gossip server.
If multicasting is not enabled in the network, this means that JGroups will not work by default, which in turns means that JBoss Clustering will not work either. Then enable the TCP protocol for communication by changing the Entity refrence from shared-up to TCP in file %JBOSS_HOME\server\all\deploy\ cluster\jgroups-channelfactory.sar\META-INF\jgroups-channelfactory-stacks.xml.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE protocol_stacks [ <!ENTITY tcp ' .... '> ]> <protocol_stacks> <stack name="udp" description="Default: IP multicast based stack, with flow control."> <config> ... &tcp; </config> </stack> ... <stack name="jbm-control" description="Stack optimized for the JBoss Messaging Control Channel"> <config> .... &tcp; ... </config> </stack> </protocol_stacks> |
Filed under: JBoss




Very useful.
Thank you