JBoss Multi-instance Port Conflict Problem

Keywords: Attribute xml network Tomcat

Background Introduction
The operating system is Linux CentOS 6.5, JDK is 1.7.0_79 and JBoss version is 4.3.0.GA. The R&D and testing environment needs to enable multiple JBoss service instances on one machine at the same time. When the application is deployed for startup, port conflicts are found.

II. Solutions
1. Solution 1: Port modification
There is a very simple way to change the port number directly, which is related to the conflict. In the past, tomcat was used to do this, but Jboss's files to be changed have been searched for the following changes:
1)$JBoss_home/server/default/deploy/ejb3.deployer/META-INF/jboss-service.xml modifies the value of port 3873.
2)$JBoss_home/server/default/deploy/jboss-web.deployer/server.xml to modify port values of 8080, 8009, 8443.
3)$JBoss_home/server/default/conf/jboss-service.xml to modify port values of 8083, 1098, 1099, 4444, 4445, 4446.
4)$JBoss_home/server/default/conf/jboss-minimal.xml modifies the value of port 1099, consistent with that in 3.
5)$JBoss_home/server/default/deploy/jms/uil2-service.xml modifies the value of port 8093.

There are more than a dozen ports that need to be modified. If there are several more service instances, the configuration, maintenance and management of this port is a nightmare.

In fact, Jboss provides Binding-Manager service, which can switch ports and bound IP in a complete set. It is very convenient to find and modify them without using one port at a time.
In the $JBoss_home/ports/bindings.xml file, multiple ports are defined. The default group names are port-default, ports-01, ports-02, etc. The arrangement of ports is incremental by 100, such as ports-default jboss:service=WebService port number 8083, the next group of ports-01 jboss:service=WebService port number 8103, and so on. If the default group is not enough, you can also customize the addition group, port planning is not conflicting, it is recommended to follow the default law of port increment.
Note that the directory of JBoss version 4.3.0.GA's bindings.xml is $JBoss_home/ports. Other versions are not necessarily the same, please note.
The port configuration of a ports-01 is excerpted for reference only.

<!-- ********************************************************** -->
   <!-- *                          ports-01                      * -->
   <!-- ********************************************************** -->
   <server name="ports-01">

      <!-- EJB3 Remoting Connector ejb3.deployer/META-INF/jboss-service.xml -->

      <service-config name="jboss.remoting:type=Connector,name=DefaultEjb3Connector,handler=ejb3"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
        <delegate-config>
           <attribute name="InvokerLocator">socket://${jboss.bind.address}:3973</attribute>
        </delegate-config>
         <binding port="3973"/>
      </service-config>

      <!-- ********************* jboss-service.xml ****************** -->

      <service-config name="jboss:service=Naming"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="Port" hostName="BindAddress">
            <attribute name="RmiPort">1198</attribute>
         </delegate-config>
         <binding port="1199" host="${jboss.bind.address}"/>
      </service-config>


      <service-config name="jboss:service=WebService"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="Port"/>
         <binding port="8183"/>
      </service-config>


      <service-config name="jboss:service=invoker,type=jrmp"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="RMIObjectPort"/>
         <binding port="4544"/>
      </service-config>


      <service-config name="jboss:service=invoker,type=pooled"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="ServerBindPort"/>
         <binding port="4545"/>
      </service-config>


      <!-- ********************* cluster-service.xml **************** -->

      <service-config name="jboss:service=HAJNDI"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
         <delegate-config portName="Port" hostName="BindAddress">
            <attribute name="RmiPort">1201</attribute>
         </delegate-config>
         <binding port="1200" host="${jboss.bind.address}"/>
      </service-config>

      <service-config name="jboss:service=invoker,type=jrmpha"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
         <delegate-config portName="RMIObjectPort"/>
         <binding port="4544"/>
      </service-config>

      <service-config name="jboss:service=invoker,type=pooledha"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
         <delegate-config portName="ServerBindPort"/>
         <binding port="4548"/>
      </service-config>

      <!-- ********************* iiop-service.xml ****************** -->

      <service-config name="jboss:service=CorbaORB"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="Port"/>
         <binding port="3628"/>
      </service-config>


      <!-- ********************* jmx-rmi-adaptor.sar **************** -->

      <service-config name="jboss.jmx:type=Connector,name=RMI"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="RMIObjectPort"/>
         <binding port="19101"/>
      </service-config>


      <!-- ********************* snmp-adaptor.sar ****************** -->

      <service-config name="jboss.jmx:name=SnmpAgent,service=trapd,type=logger"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="Port"/>
         <binding port="1262"/>
      </service-config>

      <service-config name="jboss.jmx:name=SnmpAgent,service=snmp,type=adaptor"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="Port"/>
         <binding port="1261"/>
      </service-config>


      <!-- ********************* jbossmq-service.xml **************** -->

      <!-- JMS related services -->
      <service-config name="jboss.mq:service=InvocationLayer,type=UIL2"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="ServerBindPort"/>
         <binding port="8193"/>
      </service-config>


      <!-- ********************* jbossmq-httpil.sar **************** -->
      <service-config name="jboss.mq:service=InvocationLayer,type=HTTP"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="URLPort"/>
         <binding port="8180"/>
      </service-config>

      <!-- ********************* hajndi-jms-ds.xml **************** -->

      <!-- The JMS provider loader -->
      <service-config name="jboss.mq:service=JMSProviderLoader,name=HAJNDIJMSProvider"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
         <!--
              MAKE SURE java.naming.provider.url
              PORT IS SAME AS HA-JNDI ABOVE !!!
         -->
         <delegate-config>
            <attribute name="Properties"><![CDATA[
                java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
                java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
                java.naming.provider.url=${jboss.bind.address:localhost}:1200
                jnp.disableDiscovery=false
                jnp.partitionName=${jboss.partition.name:DefaultPartition}
                jnp.discoveryGroup=${jboss.partition.udpGroup:230.0.0.4}
                jnp.discoveryPort=1102
                jnp.discoveryTTL=16
                jnp.discoveryTimeout=5000
                jnp.maxRetries=1
           ]]>
           </attribute>
        </delegate-config>
        <!-- NOTE: YOU MUST ADD THIS ELEMENT, BUT THE VALUE DOESN'T MATTER
             BE SURE THE CORRECT VALUE IS IN java.naming.provider.url ABOVE -->
        <binding port="1200"/>
      </service-config>

      <!-- **************** http-invoker.sar & httpha-invoker.sar*************** -->
      <!-- EJBInvoker -->
      <service-config name="jboss:service=invoker,type=http"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config>
            <attribute name="InvokerURLSuffix">:${port}/invoker/EJBInvokerServlet</attribute>
        </delegate-config>
         <!--
            MUST BE THE SAME AS
            TOMCAT HTTP CONNECTOR BELOW !!!
             -->
         <binding port="8180"/>
      </service-config>

        <!-- JMXInvoker -->
      <service-config name="jboss:service=invoker,type=http,target=Naming"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config>
            <attribute name="InvokerURLSuffix">:${port}/invoker/JMXInvokerServlet</attribute>
        </delegate-config>
         <!--
            MUST BE THE SAME AS
            TOMCAT HTTP CONNECTOR BELOW !!!
             -->
         <binding port="8180"/>
      </service-config>

        <!-- readonly JMXInvoker -->
      <service-config name="jboss:service=invoker,type=http,target=Naming,readonly=true"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config>
            <attribute name="InvokerURLSuffix">:${port}/invoker/readonly/JMXInvokerServlet</attribute>
        </delegate-config>
         <!--
            MUST BE THE SAME AS
            TOMCAT HTTP CONNECTOR BELOW !!!
             -->
         <binding port="8180"/>
      </service-config>

    <!-- **************** httpha-invoker.sar*************** -->
      <!-- EJBInvokerHA -->
      <service-config name="jboss:service=invoker,type=httpHA"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config>
            <attribute name="InvokerURLSuffix">:${port}/invoker/EJBInvokerHAServlet</attribute>
        </delegate-config>
         <binding port="8180"/>
      </service-config>

      <!-- JMXInvokerHA -->
      <service-config name="jboss:service=invoker,type=http,target=HAJNDI"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config>
            <attribute name="InvokerURLSuffix">:${port}/invoker/JMXInvokerHAServlet</attribute>
        </delegate-config>
         <binding port="8180"/>
      </service-config>




      <!-- ********************* jboss-ws4ee.sar **************** -->

      <!-- Web Service related services -->
      <service-config name="jboss.ws4ee:service=AxisService"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
        <delegate-config portName="WebServicePort" hostName="WebServiceHost"/>
        <binding port="8180" host="${jboss.bind.address}"/>
      </service-config>

      <!-- ********************* remoting **************** -->

       <!-- *** remoting connector *** -->
       <service-config name="jboss.remoting:service=Connector,transport=socket"
          delegateClass="org.jboss.services.binding.XSLTConfigDelegate">
          <delegate-config>
             <xslt-config configName="Configuration"><![CDATA[
               <xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>

                  <xsl:output method="xml" />
                  <xsl:param name="port"/>

                  <xsl:template match="/">
                     <xsl:apply-templates/>
                  </xsl:template>

                  <xsl:template match="attribute[@name='serverBindPort']">
                     <attribute type="java.lang.String" name="serverBindPort"><xsl:value-of select='$port'/></attribute>
                  </xsl:template>

                  <xsl:template match="*|@*">
                     <xsl:copy>
                        <xsl:apply-templates select="@*|node()"/>
                     </xsl:copy>
                  </xsl:template>
               </xsl:stylesheet>
          ]]>
          </xslt-config>
          </delegate-config>
          <binding port="5446" />
       </service-config>

      <!-- ********************* hsqldb-ds.xml ********************** -->

      <!-- Hypersonic related services

            Only if using TCP setup (local file setup by default)

      <service-config name="jboss.jca:service=ManagedConnectionFactory,name=DefaultDS"
         delegateClass="org.jboss.services.binding.XSLTConfigDelegate"
      >
         <delegate-config>
         <xslt-config configName="ManagedConnectionFactoryProperties"><![CDATA[
<xsl:stylesheet
      xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>

  <xsl:output method="xml" />
  <xsl:param name="host"/>
  <xsl:param name="port"/>

  <xsl:template match="/">
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="config-property[@name='ConnectionURL']">
    <config-property type="java.lang.String" name="ConnectionURL">jdbc:hsqldb:hsql://<xsl:value-of select='$host'/>:<xsl:value-of select='$port'/></config-property>
  </xsl:template>

  <xsl:template match="*|@*">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>
]]>
         </xslt-config>
         </delegate-config>
         <binding host="localhost" port="1801" />
      </service-config>

      <service-config name="jboss:service=Hypersonic"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
      >
         <delegate-config portName="Port" />
         <binding port="1801" />
      </service-config>

      -->


      <!-- ********************* tomcat ********************** -->

      <service-config name="jboss.web:service=WebServer"
         delegateClass="org.jboss.services.binding.XSLTFileDelegate"
         >
         <delegate-config>
            <xslt-config configName="ConfigFile"><![CDATA[
   <xsl:stylesheet
         xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>

     <xsl:output method="xml" />
     <xsl:param name="port"/>

     <xsl:variable name="portAJP" select="$port - 71"/>
     <xsl:variable name="portHttps" select="$port + 363"/>

     <xsl:template match="/">
       <xsl:apply-templates/>
     </xsl:template>

      <xsl:template match = "Connector">
         <Connector>
            <xsl:for-each select="@*">
            <xsl:choose>
               <xsl:when test="(name() = 'port' and . = '8080')">
                  <xsl:attribute name="port"><xsl:value-of select="$port" /></xsl:attribute>
               </xsl:when>
               <xsl:when test="(name() = 'port' and . = '8009')">
                  <xsl:attribute name="port"><xsl:value-of select="$portAJP" /></xsl:attribute>
               </xsl:when>
               <xsl:when test="(name() = 'redirectPort')">
                  <xsl:attribute name="redirectPort"><xsl:value-of select="$portHttps" /></xsl:attribute>
               </xsl:when>
               <xsl:when test="(name() = 'port' and . = '8443')">
                  <xsl:attribute name="port"><xsl:value-of select="$portHttps" /></xsl:attribute>
               </xsl:when>
               <xsl:otherwise>
                  <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>
               </xsl:otherwise>
            </xsl:choose>
            </xsl:for-each>
            <xsl:apply-templates/>
         </Connector>
      </xsl:template>

     <xsl:template match="*|@*">
       <xsl:copy>
         <xsl:apply-templates select="@*|node()"/>
       </xsl:copy>
     </xsl:template>
   </xsl:stylesheet>
   ]]>
            </xslt-config>
         </delegate-config>
         <binding port="8180"/>
      </service-config>

      <!-- ********************* jboss messaging ********************** -->

      <service-config name="jboss.messaging:service=Connector,transport=bisocket"
                      delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
         <delegate-config>
            <attribute name="Configuration"><![CDATA[
         <config>
            <invoker transport="bisocket">
               <attribute name="marshaller" isParam="true">org.jboss.jms.wireformat.JMSWireFormat</attribute>
               <attribute name="unmarshaller" isParam="true">org.jboss.jms.wireformat.JMSWireFormat</attribute>
               <attribute name="dataType" isParam="true">jms</attribute>
               <attribute name="socket.check_connection" isParam="true">false</attribute>
               <attribute name="timeout" isParam="true">0</attribute>
               <attribute name="serverBindAddress">${jboss.bind.address}</attribute>
               <attribute name="serverBindPort">4557</attribute>
              <attribute name="clientSocketClass" isParam="true">org.jboss.jms.client.remoting.ClientSocketWrapper</attribute>
               <attribute name="serverSocketClass">org.jboss.jms.server.remoting.ServerSocketWrapper</attribute>
               <attribute name="numberOfCallRetries" isParam="true">1</attribute>
               <attribute name="pingFrequency" isParam="true">214748364</attribute>
               <attribute name="pingWindowFactor" isParam="true">10</attribute>
               <attribute name="onewayThreadPool">org.jboss.jms.server.remoting.DirectThreadPool</attribute>
               <attribute name="stopLeaseOnFailure" isParam="true">true</attribute>
               <attribute name="clientLeasePeriod" isParam="true">10000</attribute>
               <attribute name="timeout" isParam="true">0</attribute>
               <attribute name="numberOfRetries" isParam="true">10</attribute>
               <attribute name="JBM_clientMaxPoolSize" isParam="true">200</attribute>
               <attribute name="callbackTimeout">10000</attribute> 
            </invoker>
            <handlers>
               <handler subsystem="JMS">org.jboss.jms.server.remoting.JMSServerInvocationHandler</handler>
            </handlers>
         </config>
         ]]></attribute>
         </delegate-config>
         <binding port="4557"/>
      </service-config>


   </server>

After understanding the bindings.xml file, our next configuration work is very simple. Modify the jboss-service configuration file under the new instance directory, xxx is the deployment application name of the example, $JBoss_HOME/server/xx/conf/jboss-service.xml file, search "ServerName" and find the corresponding mbean, as follows:

<!--
      | Binding service manager for port/host mapping. This is a sample
      | config that demonstrates a JBoss instances with a server name 'ports-01'
      | loading its bindings from an XML file using the ServicesStoreFactory
      | implementation returned by the XMLServicesStoreFactory.
      |
      | ServerName: The unique name assigned to a JBoss server instance for
      | lookup purposes. This allows a single ServicesStore to handle mulitiple
      | JBoss servers.
      |
      | StoreURL: The URL string passed to org.jboss.services.binding.ServicesStore
      | during initialization that specifies how to connect to the bindings store.
      | StoreFactory: The org.jboss.services.binding.ServicesStoreFactory interface
      | implementation to create to obtain the ServicesStore instance.

   <mbean code="org.jboss.services.binding.ServiceBindingManager"
     name="jboss.system:service=ServiceBindingManager">
     <attribute name="ServerName">ports-01</attribute>
     <attribute name="StoreURL">${jboss.home.url}/docs/examples/binding-manager/sample-bindings.xml</attribute>
     <attribute name="StoreFactoryClassName">
       org.jboss.services.binding.XMLServicesStoreFactory
     </attribute>
   </mbean>
   -->

By default, this configuration is closed. Remove the comments and write the group name on the ServerName configuration item to use the set of ports maintained under that group name. Note that the group names filled in here must be defined in bindings.xml.

The benefits of using Binding-Manager are obvious, the workload is reduced a lot, the operation and maintenance are easy to implement, and it is not easy to make mistakes.

Another point to mention is that in the previous bindings.xml configuration file, each group had the configuration of http port and ajp port about jboss-web, that is, the section of service-config named jboss.web:service=Web Server, which required http and ajp ports in the $JBoss_HOME/server/xx/deploy/jboss-web.deployer/server.xml file to be the default 8080 and 809 ports. Can not be modified, or can not be replaced, the specific replacement logic can refer to the ports-01 code given above.

2. Solution 2: Binding different IP
At the bottom of the socket layer, binding a port requires two pieces of information: the port number and the IP address.
When we start the JBoss instance, the IP address is sometimes written as 0.0.0. This special address means: bind to all IP addresses defined in the system. If there is only one network card on the server, all ports will be bound to the IP address. If there are multiple network cards or virtual IP addresses, using 0.0.0 as the IP address bound at startup will cause ports to be bound to all IP addresses.
However, some scenarios do not expect ports to be bound to all IP addresses, such as two IP addresses, one IP to handle external HTTP requests, and the other IP to handle calls between internal systems to achieve a diversion purpose.
According to this idea, different instances of JBoss can be bound to different IP, so that multiple instances of JBoss can share ports, such as 192.168.1.100:8080 and 192.168.1.101:8080. When processing HTTP requests, they can use 8080 ports. In this case, there is no conflict, because each port is bound to a different IP address.

Demonstration examples
1. Scheme 1 Example
Copy all instances of jboss, all-01 and all-02, respectively. According to the steps of scheme one, modify conf/jboss-service.xml, and modify the files of all-01 instances as follows:

<mbean code="org.jboss.services.binding.ServiceBindingManager"
     name="jboss.system:service=ServiceBindingManager">
     <attribute name="ServerName">ports-01</attribute>
     <attribute name="StoreURL">${jboss.home.url}/ports/bindings.xml</attribute>
     <attribute name="StoreFactoryClassName">
       org.jboss.services.binding.XMLServicesStoreFactory
     </attribute>
   </mbean>

The file of all-02 instance is modified as follows:

<mbean code="org.jboss.services.binding.ServiceBindingManager"
     name="jboss.system:service=ServiceBindingManager">
     <attribute name="ServerName">ports-02</attribute>
     <attribute name="StoreURL">${jboss.home.url}/ports/bindings.xml</attribute>
     <attribute name="StoreFactoryClassName">
       org.jboss.services.binding.XMLServicesStoreFactory
     </attribute>
   </mbean>

The expected result is that all-01 binds 8180 port group, all-02 binds 8280 port group, and other port information at instance startup is not discussed.
The startup command is as follows:
run.bat -c all-01 -b 192.168.1.103
run.bat -c all-02 -b 192.168.1.103

Startup log of all-01 instance (part)
2017-07-30 22:08:03,390 DEBUG [org.jboss.web.tomcat.service.JBossWeb] Saw org.jboss.system.server.started notification, starting connectors
2017-07-30 22:08:03,397 INFO [org.apache.coyote.http11.Http11Protocol] Starting Coyote HTTP/1.1 on http-0.0.0.0-8180
2017-07-30 22:08:03,422 INFO [org.apache.coyote.ajp.AjpProtocol] Starting Coyote AJP/1.3 on ajp-0.0.0.0-8109

Startup log of all-02 instance (part)
2017-07-30 22:10:47,406 DEBUG [org.jboss.web.tomcat.service.JBossWeb] Saw org.jboss.system.server.started notification, starting connectors
2017-07-30 22:10:47,417 INFO [org.apache.coyote.http11.Http11Protocol] Starting Coyote HTTP/1.1 on http-0.0.0.0-8280
2017-07-30 22:10:47,439 INFO [org.apache.coyote.ajp.AjpProtocol] Starting Coyote AJP/1.3 on ajp-0.0.0.0-8209

The log display is consistent with the expected port, two instances can run simultaneously, and there is no error log of port conflict.

2. Example of Scheme 2
The copy example is the same as the previous one. Server Name in the configuration file is set to ports-01, and two instances are started at the same time. For simplicity, the actual IP is 192.168.1.103. A new virtual IP 192.168.1.137 is added. The startup command is as follows:
run.bat -c all-01 -b 192.168.1.137
run.bat -c all-02 -b 192.168.1.103

2017-07-30 22:40:54,080 DEBUG [org.jboss.web.tomcat.service.JBossWeb] Saw org.jboss.system.server.started notification, starting connectors
2017-07-30 22:40:54,090 INFO [org.apache.coyote.http11.Http11Protocol] Starting Coyote HTTP/1.1 on http-192.168.1.137-8180
2017-07-30 22:40:54,115 INFO [org.apache.coyote.ajp.AjpProtocol] Starting Coyote AJP/1.3 on ajp-192.168.1.137-8109

2017-07-30 22:33:46,836 DEBUG [com.arjuna.ats.jta.logging.loggerI18N] [com.arjuna.ats.internal.jta.recovery.info.firstpass] Local XARecoveryModule - first pass
2017-07-30 22:33:46,843 INFO [org.apache.coyote.http11.Http11Protocol] Starting Coyote HTTP/1.1 on http-192.168.1.103-8180
2017-07-30 22:33:46,858 INFO [org.apache.coyote.ajp.AjpProtocol] Starting Coyote AJP/1.3 on ajp-192.168.1.103-8109

It can be confirmed from the log that both instances start normally and there is no abnormal log with port conflict.
Example conclusion: Both schemes are feasible.

IV. Supplementary Virtual IP Creation Method
1. Windows Platform
Open the Network and Sharing Center, Find the Connected Network

Click on Properties, double-click IPv4, if you get IP automatically, change to manual, and then click Advanced

Click Add IP on IP Address

When the setup is complete, enter ipconfig on the cmd command line and you will see two IP s.

Attention should be paid to the following points:
1. Must change to manual IP acquisition, DHCP mode can not add virtual IP.
2. The new virtual IP must ensure that there is no conflict in the LAN.
3. If DNS is not filled in correctly, it may not be able to connect to the network properly.

2. Linux Platform
Need root permission, add a new file ifcfg-eth0:1 under / etc/sysconfig/network-scripts, as follows:

DEVICE="eth0:1"
IPADDR="192.168.1.107"
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
ONBOOT="yes"
TYPE="Ethernet"

After saving, restart the server and view the network with ifconfig command, you can find that the new virtual IP has been added:

[root@bogon network-scripts]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:79:3A:FD 
          inet addr:192.168.1.106  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe79:3afd/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:43 errors:0 dropped:0 overruns:0 frame:0
          TX packets:43 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:6356 (6.2 KiB)  TX bytes:4447 (4.3 KiB)

eth0:1    Link encap:Ethernet  HWaddr 00:0C:29:79:3A:FD 
          inet addr:192.168.1.107  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:12 errors:0 dropped:0 overruns:0 frame:0
          TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:816 (816.0 b)  TX bytes:816 (816.0 b)

V. Summary
Modifying ports and binding multiple IP address schemes in applications should consider the actual environmental requirements. Generally speaking, modifying ports is the most direct solution. It only needs to modify the ports of jboss itself. Binding multiple IP operations is slightly more complex. It needs to add physical network cards or virtual IP configuration at the operating system level. But it also has its use in solving this problem. It can accomplish the work of reverse proxy server, or it can be regarded as a new solution.

Posted by michaelh613 on Sat, 08 Jun 2019 14:15:57 -0700