Recently I worked on making sure that GlassFish 3.1 can use a multihomed server effectively.  This article talks about what it takes to configure a GlassFish domain to use multihoming. Unfortunately, this takes some detailed configuration at this point; there is an RFE filed to make this easier.

Briefly, a multihomed server has multiple IP addresses.  There are two primary use cases for multihomed servers:

1. Multiple distinct installations and/or domains of GlassFish are being operated on a server, with the intent to have one domain use one network and another use another network. For a particular DAS or instance, all of the ports for that instance are bound to the same host name.

2. A server with multiple networks, e.g., a front-end network for web requests, a back-end administrative network, and a back-end database network. The HTTP/S listeners are bound to the front-end network, while the admin-listener, GMS traffic, etc. is bound to the administrative network. Presumably in this case, the nodes would be defined to use the administrative network.

To configure either of these cases, the “address” attributes for all of the listeners must be configured to use a specific address rather than “0.0.0.0”. The address can either be an IP address or a DNS name. In each case the attribute is called “address”, but for some listeners, the default of “0.0.0.0” doesn’t show up in the domain.xml, so it has to be added.  The easiest way to find all of the addresses that need to be set is to search for “port” attributes.

For example, in the default domain.xml file, the “server-config” (which is used for the DAS) as the following entry:

<network-listener port="8080" protocol="http-listener-1" 
    transport="tcp" name="http-listener-1"
    thread-pool="http-thread-pool"/>

To configure this to bind to a specific address, such as 192.168.0.1, set this as follows:

<network-listener address="192.168.0.5" port="8080"
    protocol="http-listener-1" transport="tcp" 
    name="http-listener-1" thread-pool="http-thread-pool"/>

Now, when this domain starts, the http-listener-1 will listen only on the address 192.168.0.5 rather than all addresses. By doing this for all of the ports on which the server listens, either of the use cases above can be supported.

To make this configuration change from the command line, the asadmin command is:

asadmin set configs.config.server-config.network-config.
  network-listeners.network-listener.http-listener-1.address=192.168.0.5

After making this change, restart the server and you can see that it is only listening on the specified address using the netstat command.

Here is the list of addresses that need to be set in the default configuration:

  • JMX System Connector
  • JMS Provider
  • HTTP Listener
  • HTTP/SSL Listener
  • Administration Listener
  • IIOP Listener
  • IIOP/SSL Listener
  • IIOP/SSL Mutual Authorization

The Java debugger port and the OSGi Shell port are bound to localhost by default, so typically they do not need to be changed.

The multihomed server support is working in GlassFish 3.1 as of the MS4 build. If you have any interesting experiences to share with using this, please let us know.