Clustering JBoss AS 5, the easy way
There are a couple of simple steps to get JBoss clustering working in a way that is easy to deploy, and with minimal editing of files.
- Download JBoss AS, and extract it.
- Copy the "all" server (jboss/server/all) to "nodetemplate" (jboss/server/nodetemplate)
- Install Railo or JBoss into the "nodetemplate" server (you may want to use a central location for Railo or ColdFusion libraries, see the railo EAR example)
- Edit the server.xml file (jboss/server/nodetemplate/deploy/jbossweb.sar/server.xml) and add this to the "Engine" tag: jvmRoute="node${jboss.messaging.ServerPeerID}" (Ex: <Engine name="jboss.web" defaultHost="localhost" jvmRoute="node${jboss.messaging.ServerPeerID}"> )
- Change the JMS datasource database
- Edit jboss/server/nodetemplate/messaging/messaging-service.xml and messaging-jboss-beans.xml and change the "MessageSucker" password.
- Create a user named "jboss", if you don't have one already. Be sure it's a system account (not a real user account)
- Copy the "nodetemplate" directory to "node1" (Ex. cp -R nodetemplate node1)
- Give ownership of the jboss folder to the jboss user
- Create a startup script for your nodes in the jboss/bin directory, called "jbossnode".
- Put this in there, and edit the settings (ip addresss, and perhaps your multicast address (jgroups.bind_addr))
jboss.messaging.ServerPeerID will be a unique node number, for use with load balancing later on, and to avoid node conflicts
(this script isn't good for automatic startup without editing, eventually I'll get a new one posted)#!/bin/sh
## jboss home
jboss_home="/path/to/jboss"
## node ips
node_ip_1=10.0.1.8
node_ip_2=10.0.2.1
if [ $# -eq 0 ]; then
echo "please specify node number and an action (start|stop) - Example: jbossnode 2 start"
exit 0
fi
if [ $1 -eq 1 ]; then
instance_number=1
instance_host=$node_ip_1
fi
if [ $1 -eq 2 ]; then
instance_number=2
instance_host=$node_ip_2
fi
if [ $2 = "start" ]; then
sudo -u jboss $jboss_home/bin/run.sh -c node$instance_number -b $instance_host \
-Djboss.messaging.ServerPeerID=$instance_number -Djgroups.bind_addr=127.0.0.1 \
-Djgroups.tcpping.initial_hosts=127.0.0.1[7800] -Djava.net.preferIPv4Stack=true &
fi
if [ $2 = "stop" ]; then
sudo -u jboss $jboss_home/bin/shutdown.sh -s $instance_host -S
fi
echo "$2ing node $instance_number ($instance_host)" - make it executable: ./chmod +x jbossnode
- start node 1 like this: ./jbossnode 1 start
- start node 2 like this: ./jbossnode 2 start
- stop node 1 like this: ./jbossnode 1 stop
- stop node 2 like this: ./jbossnode 2 stop
Create a CFM file containing the following:
mySession = getPageContext().getRequest().getSession(true);
ival = mySession.getAttribute("simplesession.counter");
if (NOT isDefined("ival")){
ival = 1;
} else {
ival = ival + 1;
}
mySession.setAttribute("simplesession.counter", ival);
</cfscript>
<cfoutput>
CFSESSIONID:
<br /><strong>#session.URLToken#</strong>
<br />
JSESSIONID:
<cfdump var="#mySession.getID()#">
Number of refreshes:
<cfdump var="#ival#">
Cookies:
<cfdump var="#cookie#">
<cfif NOT structKeyExists(cookie,"JSESSIONID")>
NO JSESSIONID! Are you proxy/rewriting? Did you remember to change the cookie path (ProxyPassReverseCookiePath)?<br />
</cfif>
Session:
<cfdump var="#session#">
</cfoutput>
This should display something like:
V4VJ3xd4NRn82z6OkPncww__.node1 (emphasis added)
Plus the dumps. Refresh a couple times and verify your sessions are working. Play around with the balance-manager stuff if you want.
Oh, guess you should read the load balancing entry first!
Assuming you already did that, and set up sticky sessions and whatnot, you can bring various nodes up or down and hit that page to see what node you are being served from.
Some helpful links:
http://docs.hp.com/en/5991-5855/ar01s07.html
http://www.yorku.ca/dkha/jboss/docs/ClusterTesting.htm
http://wiki.jboss.org/wiki/UsingMod_proxyWithJBoss
More later

You mention in your post about keeping the railo files in a central location step 3, and refer to a link that isn't there. I would be very interested to know what you mean :). I have had some problems trying to get as 5 and railo to play nice with apache.
I cant seem to get my railo to work external to the deploy folder regardless of how I set my profile.xml file.
Thanks!