Binding the same ports for different IPs on the same machine for multiple Carbon Server instances

Archived Content
This article is provided for historical perspective only, and may not reflect current conditions. Please refer to relevant product page for more up-to-date product information and resources.
  • By Kathiravelu Pradeeban
  • 18 Oct, 2011

Applies To

WSO2 Carbon 3.2.0

Introduction

A TCP Socket is a tuple of {IP Address, Port}. Hence we can have multiple WSO2 Carbon Servers on different combinations of IP and Port without conflicting. In this way, we can run multiple instances of WSO2 Carbon based products or services (WSO2 Application Server, WSO2 Enterprise Service Bus, WSO2 Business Activity Monitor, ..) in a single machine.

On Different Ports

Changing the port of the instances is the mostly used and recommended option. By changing the parameter 'offset' in repository/conf/carbon.xml to a positive integer (default is 'zero'), we can make the server ports increased by the given offset. Each port value will be calculated by {given port value} + {offset}. This conveniently changes all the ports, and hence avoids the ports conflicting. The offset property also eliminates the need to change each of the ports over the multiple configuration files. With an offset of '0' and '1', for two Carbon Server instances, we can have management console urls like https://10.200.2.106:9443/ and https://10.200.2.106:9444/ (Note the same IP and different ports).

Using multiple IPs, binding to the same ports

Given a multiple-IP machine, we can configure to have the servers listen to the same ports over the different IPs. We can have management console URLs like https://10.200.2.106:9443/ and https://175.157.179.170:9443/ listening to the same port, on the different IPs. However, we can also have both the IPs as well as the ports to be different for the server instances, using the offset property and the below configurations changed. Hence having two carbon servers management console urls as https://10.200.2.106:9443/ and https://175.157.179.170:9444/.

We will look into how to configure the carbon servers bound to the same ports using different IPs, by changing the configuration files in repository/conf


Changes in axis2.xml

Declare the bind-address property for HTTP and HTTPS transport paramseters,

<parameter name="bind-address" locked="false">175.157.179.170</parameter>


Changes in mgt-transports.xml

Uncomment,

<!--<parameter name="address">127.0.0.1</parameter>-->

and provide with the relevant IP addresses for each of the instances. So, you can have multiple IP addresses with the same ports for Connectors.

Changes in carbon.xml

Find,

    <!--HostName>www.wso2.org</HostName-->
    ... 
    <ServerURL>https://${carbon.local.ip}:${carbon.management.port}/${carbon.context}/services/</ServerURL>


Change this in each Carbon instance, to reflect its respective IP or host name.

For example, change them as below.


    <HostName>10.200.2.106</HostName> 
    ..
    <ServerURL>https://10.200.2.106:${carbon.management.port}/${carbon.context}/services/</ServerURL>


With this change in carbon.xml, the instances will start with a few exceptions complaining ports conflicting for JMXServerManager (11111 for RMIServerPort and 9999 for RMIRegistryPort, by default), QPid (5672 for the BrokerPort and 8672 for BrokerSSLPort, by default) and EmbeddedLDAP (10389 for LDAPServerPort and 8000 for KDCServerPort, by default).


Since these are local ports, we can safely change them without violating our requirement - to utilize the multiple IPs available, while binding to the same ports for the two instance. These local ports are working on the local IP. Hence ensure that these ports aren't conflicting, for the two (or more) ESB instances, by changing the ports respectively in carbon.xml.

To avoid all the conflicts in the other sockets (JMX, LDAP etc), you can use the carbon.xml 'offset' parameter. However, you would need to explicitly set the ports in the mgt-transports.xml file. Alternatively, you can change the respective ports (JMX, LDAP, or QPid) manually in carbon.xml instead, as given below, if you are not interested in using the 'offset' parameter.

For example, change the ports from their default values, as below.

       <!-- The JMX Ports -->
              <JMX>
                     <!--The port RMI registry is exposed-->
                     <RMIRegistryPort>9998</RMIRegistryPort>
                     <!--The port RMI server should be exposed-->
                     <RMIServerPort>11110</RMIServerPort>
              </JMX>


       <!-- Embedded LDAP server specific ports -->
              <EmbeddedLDAP>
                     <!-- Port which embedded LDAP server runs -->
                     <LDAPServerPort>10388</LDAPServerPort>
                     <!-- Port which KDC (Kerberos Key Distribution Center) server runs -->
                     <KDCServerPort>8001</KDCServerPort>
              </EmbeddedLDAP>


       <!-- Embedded Qpid broker ports -->
              <EmbeddedQpid>
                     <!-- Broker TCP Port -->
                     <BrokerPort>5673</BrokerPort>
                     <!-- SSL Port -->
                     <BrokerSSLPort>8673</BrokerSSLPort>
              </EmbeddedQpid> 


With these configuration changes, the Carbon instances will be ready to work over the different IP addresses configured, over the same ports.

Resources

  • WSO2 Enterprise Service Bus (ESB) Endpoint Catalog
  • How to Import LDAP Users to WSO2 Carbon Based Products
  • Clustering Landscape for WSO2 Stack
  • How to setup WSO2 Carbon in production?
  • Author

    Kathiravelu Pradeeban, Software Engineer.