JBoss: Running Multiple Instances on One Host

Occasionally, it’s useful to run multiple JBoss instances on one machine. Like with any network server, this is difficult because only one application can bind to a port at any given time. You have to assign different sets of ports to each instance. JBoss consists of quite a few network services so it’s a lot of tedious work to reconfigure each and every port (I counted 16 different ports on JBoss 6’s default profile).

Fortunately, there’s a little known but documented mechanism to globally remap all JBoss ports. The file server/default/conf/bindingservice.beans/META-INF/bindings-jboss-beans.xml (for the default profile) contains port bindings that you can activate using the jboss.service.binding.set property from the command line.

Suppose there’s already a JBoss instance running (which uses the default ports-default binding). Using the command line property, we can run a second instance like this:

  bin/run.sh -Djboss.service.binding.set=ports-01

The ports-01 binding adds 100 to each port of the ports-default binding, ports-02 adds 200, and ports-03 adds 300. You can easily add more ports bindings yourself if you need them.

I tested this on JBoss 6.0.0.Final and it worked well. An alternative to port mapping approach is to make your machine listen on multiple IP addresses and have each JBoss instance bind to a different IP address using the jboss.bind.address property. Obviously, this requires no port remapping but changes to your network setup, usually including DNS.

Advertisements
This entry was posted in java and tagged , , . Bookmark the permalink.

2 Responses to JBoss: Running Multiple Instances on One Host

  1. gorlok says:

    Good tip. I have used multiple IPs in the past. I found it easier on Linux creating virtual interfaces.

    • mafr says:

      We’re short on IP addresses (yes, even internal ones), so we had to go a different route. But in general, I’d probably use virtual interfaces, too.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s