ConfiguringMultipleJBossInstancesOnOneMachine

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. 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. 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.

  • modify jboss-service.xml 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)

  • You can also override the settings in this file with Java "properties" (either via JAVA_OPTS environment variable or on the Java commandline with -D like "java -Dhttp.port=8080").  See $JBOSS_HOME/docs/examples/binding-manager/sample-bindings.xml "ports-default" entries for all jboss port properties. default-bindings.xml is provided for quick view convienence, but it may not reflect your installation's port settings.

  • NOTE: JBoss AS 4.0.2 has a known bug : one of the ports (4666) 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 4666 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.

 

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 :

  • $JBOSS_HOME

    • server

      • minimal

      • default

      • all

      • node1

      • node2

      • node3

      • nodeX

 

And you then launch each node with the -c option of run.sh/run.bat  (e.g. run.bat/run.sh -c node1)