Searchable Title: Configuring Multiple JBoss Instances On One Machine
Multiple instances of JBoss AS can run on a single machine assuming you have the necessary system resources (RAM, CPU, etc). These instances can be clustered or can run completely independently of one another depending on your needs.
Why would you want to run multiple instances?
32-bit VM limitations : maybe you have a large box with LOTS of RAM that you cannot take advantage of because you are standardized on 32-bit (hardware, OS, VM) heap limitations
isolation : maybe you need complete isolation of your apps because one app is unstable and could negatively impact the other applications
Keep in mind, that JBoss AS is perfectly capable of hosting MULTIPLE applications in a SINGLE instance!
QA : maybe you would like a separate QA environment which is isolated from the development environment on the same box
JBoss AS version dependencies : maybe you have multiple applications and some need version X of JBoss AS and some need version Y of JBoss AS
JVM version dependencies : maybe one app requires JDK 1.4 and another app requires JDK 1.5. Since JBoss AS can use either you can launch one instance using 1.4 and another instance using 1.5 (unclustered of course)
When I try to launch multiple instances I get port conflicts
You cannot have two daemons listening on the same IP address and same port for incoming requests. This is not a limitation of JBoss or even of Java, this is true of any server including databases, webservers, application servers, etc. To address this issue you have two choices:
1. EITHER multi-home your network card so that it has multiple IP addresses (one for each instance)
Launch each instance of JBoss AS with the commandline option to bind this instance to a particular IP address (run.bat/run.sh -b <ip-addressORhost>)
2. OR provide alternate ports for each instance of JBoss AS
This is easier to do and does not require a sysadmin. However, it is not recommended for production systems because it makes firewall rules too difficult to maintain. Usually used in development to try out clustering behavior.
If you installed JBoss from the ZIP file, modify conf/jboss-service.xml and uncomment "Service Binding" section and select "ServerName" value from sample-bindings.xml (e.g. ports-01 or ports-02 or make your own named port configuration)
If you installed JBoss using the installer, firstly, make sure you selected the "binding-service" package from the JMX group and then, open /conf/deploy/binding-service.xml file in the selected configuration and modify the "Service Binding" section as explained in the previous paragraph.
See $JBOSS_HOME/docs/examples/binding-manager/sample-bindings.xml "ports-default" entries for all jboss port properties. default-bindings.xml provides a quick view of jboss-4.0.2 default port settings, but it may not reflect your installation's port settings.
NOTE: JBoss AS 4.0.2 has a known bug : one of the ports (4446) is not included in the sample-bindings.xml file and therefore will continue to conflict even after selecting an alternate port configuration in your jboss-service.xml. To fix this simply select an alternate port (something other than 4446 that is not being used) in cluster-service.xml configuration (obviously not necessary if you are not using the ALL configuration with clustering support). This bug is being fixed in our next release.
If using JBoss-head, port 4446 still lacks alternate bindings. The port is defined in jboss-service.xml in this code base. (see JBAS-1829)
IMPORTANT: You should create a different SERVER CONFIGURATION DIRECTORY for each instance of JBoss AS you want to run. For example, your directory tree should be :
And you then launch each node with the -c option of run.sh/run.bat (e.g. run.bat/run.sh -c node1)
When I simultaneously launch multiple instances configured for clustering I get startup errors.
If you intend to launch multiple JBoss instances on the same machine and have them form a cluster, you might write some kind of script to launch the two instances. It is a good practice to add some kind of pause in your script between the launch of the first instance and the second. 10 to 20 seconds is good.
This is because if both instances are launched simultaneously, they both may decide they are the JGroups coordinator. At this point, you will have two independent clusters of one node each. If this happens, both nodes may begin to start HASingleton services, such as HA-JMS. A few seconds later, the two nodes will discover each other and the two clusters will merge. One of the nodes will no longer be coordinator, and the HASingleton services will be stopped. Stopping a service that's in the middle of starting does not always go cleanly.
By putting a pause in your startup script, it gives the first node a chance to become coordinator before the second node starts. The second node will then cleanly join the cluster, and no HASingleton services will be started on it.