<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">
<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>
                                <td>
                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>
                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px; -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
Multiple instances of JBoss AS7 on the same machine
</h3>
<span style="margin-bottom: 10px;">
modified by <a href="http://community.jboss.org/people/brian.stansberry">Brian Stansberry</a> in <i>JBoss AS7 Development</i> - <a href="http://community.jboss.org/docs/DOC-16705">View the full document</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><h4>Overview:</h4><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>This wiki explains how multiple instances of JBoss AS7 <em>standalone </em>server, on single physical system, can be started simultaneously.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><h4>Approach#1</h4><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>[Tested against JBoss AS7.0.0 Beta2 and AS7 upstream dated April 8 2011]</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>In this approach we will create multiple copies of JBoss AS7 on a single system.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><ul><li>Download JBoss AS7. And unzip it to some location. Let's call this instance <jboss-as-7-one></li><li>As a sanity test, just start this server once, by running the following script from the <jboss-as-7-one>/bin folder:</li></ul><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><pre class="jive-pre"><code class="jive-code">jpai@jpai-laptop:bin$ ./standalone.sh
</code></pre><ul><li>Make sure the server starts without any errors. Once it has started, shutdown the server by using Ctrl + C</li><li>Let's now copy the entire <jboss-as-7-one> instance to <jboss-as-7-two>. We now have 2 copies of JBoss AS7 on our system.</li><li>Our next step is to configure the second instance to use a different IP address to bind the services to. By default, <jboss-as-7-one> instance uses 127.0.0.1 as the IP address to bind the  services to. This in configured in JBOSS_HOME/standalone/configuration/standalone.xml file (only relevant sections pasted below):</li></ul><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><pre class="jive-pre"><code class="jive-code jive-xml">...
    <span class="jive-xml-tag"><management-interfaces></span>
        <span class="jive-xml-tag"><native-interface interface="default" port="9999"/></span>
        <span class="jive-xml-tag"><http-interface interface="default" port="9990"/></span>
    <span class="jive-xml-tag"></management-interfaces></span>
...
<span class="jive-xml-tag"><interfaces></span>
        <span class="jive-xml-tag"><interface name="default"></span>
            <span class="jive-xml-tag"><inet-address value="127.0.0.1"/></span>
        <span class="jive-xml-tag"></interface></span>
        <span class="jive-xml-tag"><interface name="any"></span>
            <span class="jive-xml-tag"><any-address/></span>
        <span class="jive-xml-tag"></interface></span>
        <span class="jive-xml-tag"><interface name="complex"></span>
            <span class="jive-xml-tag"><any></span>
                <span class="jive-xml-tag"><subnet-match value="192.168.0.0/16"/></span>
                <span class="jive-xml-tag"><public-address/></span>
            <span class="jive-xml-tag"></any></span>
            <span class="jive-xml-tag"><not></span>
                <span class="jive-xml-tag"><site-local-address/></span>
            <span class="jive-xml-tag"></not></span>
            <span class="jive-xml-tag"><up/></span>
            <span class="jive-xml-tag"><multicast/></span>
        <span class="jive-xml-tag"></interface></span>
    <span class="jive-xml-tag"></interfaces></span>
    <span class="jive-xml-tag"><socket-binding-group name="standard-sockets" default-interface="default"></span>
        <span class="jive-xml-tag"><socket-binding name="jndi" port="1099"/></span>
        <span class="jive-xml-tag"><socket-binding name="jmx-connector-registry" port="1090"/></span>
        <span class="jive-xml-tag"><socket-binding name="jmx-connector-server" port="1091"/></span>
        <span class="jive-xml-tag"><socket-binding name="http" port="8080"/></span>
        <span class="jive-xml-tag"><socket-binding name="https" port="8447"/></span>
        <span class="jive-xml-tag"><socket-binding name="osgi-http" port="8090"/></span>
        <span class="jive-xml-tag"><socket-binding name="remoting" port="4447"/></span>
        <span class="jive-xml-tag"><socket-binding name="txn-recovery-environment" port="4712"/></span>
        <span class="jive-xml-tag"><socket-binding name="txn-status-manager" port="4713"/></span>
        <span class="jive-xml-tag"><socket-binding name="txn-socket-process-id" port="4714"/></span>
        <span class="jive-xml-tag"><socket-binding name="messaging" port="5445"/></span>
        <span class="jive-xml-tag"><socket-binding name="messaging-throughput" port="5455"/></span>
    <span class="jive-xml-tag"></socket-binding-group></span>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>As can be seen, the management interface and the socket bindings, all use the interface named "default", which binds to 127.0.0.1. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><ul><li>Now for <jboss-as-7-two> let's configure this file to use a different interface. </li><li>Open the <jboss-as-7-two>/standalone/configuration/standalone.xml in a text editor and a custom interface to the <interfaces> section. In this example, we'll name the new interface "specific-ip-interface" and let it bind to a specific IP XXX.YYY.AAA.BBB (should be a valid IP address). So here's the new interface definition:</li></ul><pre class="jive-pre"><code class="jive-code jive-xml"><span class="jive-xml-tag"><interfaces></span>
        <span class="jive-xml-tag"><interface name="default"></span>
            <span class="jive-xml-tag"><inet-address value="127.0.0.1"/></span>
        <span class="jive-xml-tag"></interface></span>
        <span class="jive-xml-comment"><!-- New interface for our second instance --></span>
        <span class="jive-xml-tag"><interface name="specific-ip-interface"></span>
            <span class="jive-xml-tag"><inet-address value="XXX.YYY.AAA.BBB"/></span>
        <span class="jive-xml-tag"></interface></span>
        <span class="jive-xml-tag"><interface name="any"></span>
            <span class="jive-xml-tag"><any-address/></span>
        <span class="jive-xml-tag"></interface></span>
        <span class="jive-xml-tag"><interface name="complex"></span>
            <span class="jive-xml-tag"><any></span>
                <span class="jive-xml-tag"><subnet-match value="192.168.0.0/16"/></span>
                <span class="jive-xml-tag"><public-address/></span>
            <span class="jive-xml-tag"></any></span>
            <span class="jive-xml-tag"><not></span>
                <span class="jive-xml-tag"><site-local-address/></span>
            <span class="jive-xml-tag"></not></span>
            <span class="jive-xml-tag"><up/></span>
            <span class="jive-xml-tag"><multicast/></span>
        <span class="jive-xml-tag"></interface></span>
    <span class="jive-xml-tag"></interfaces></span>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><ul><li>Our next step is to let the socket bindings and the management interface, use this new interface instead of the default one.</li><li>So continue editing the  <jboss-as-7-two>/standalone/configuration/standalone.xml and point the management interface and socket bindings to use this new interface as follows:</li></ul><pre class="jive-pre"><code class="jive-code jive-xml">...
    <span class="jive-xml-tag"><management-interfaces></span>
        <span class="jive-xml-tag"><native-interface interface="specific-ip-interface" port="9999"/></span>
        <span class="jive-xml-tag"><http-interface interface="specific-ip-interface" port="9990"/></span>
    <span class="jive-xml-tag"></management-interfaces></span>
...
    <span class="jive-xml-tag"><interfaces></span>
        <span class="jive-xml-tag"><interface name="default"></span>
            <span class="jive-xml-tag"><inet-address value="127.0.0.1"/></span>
        <span class="jive-xml-tag"></interface></span>
        <span class="jive-xml-comment"><!-- New interface for our second instance --></span>
        <span class="jive-xml-tag"><interface name="specific-ip-interface"></span>
            <span class="jive-xml-tag"><inet-address value="XXX.YYY.AAA.BBB"/></span>
        <span class="jive-xml-tag"></interface></span>
        <span class="jive-xml-tag"><interface name="any"></span>
            <span class="jive-xml-tag"><any-address/></span>
        <span class="jive-xml-tag"></interface></span>
        <span class="jive-xml-tag"><interface name="complex"></span>
            <span class="jive-xml-tag"><any></span>
                <span class="jive-xml-tag"><subnet-match value="192.168.0.0/16"/></span>
                <span class="jive-xml-tag"><public-address/></span>
            <span class="jive-xml-tag"></any></span>
            <span class="jive-xml-tag"><not></span>
                <span class="jive-xml-tag"><site-local-address/></span>
            <span class="jive-xml-tag"></not></span>
            <span class="jive-xml-tag"><up/></span>
            <span class="jive-xml-tag"><multicast/></span>
        <span class="jive-xml-tag"></interface></span>
    <span class="jive-xml-tag"></interfaces></span>
    <span class="jive-xml-tag"><socket-binding-group name="standard-sockets" default-interface="specific-ip-interface"></span>
        <span class="jive-xml-tag"><socket-binding name="jndi" port="1099"/></span>
        <span class="jive-xml-tag"><socket-binding name="jmx-connector-registry" port="1090"/></span>
        <span class="jive-xml-tag"><socket-binding name="jmx-connector-server" port="1091"/></span>
        <span class="jive-xml-tag"><socket-binding name="http" port="8080"/></span>
        <span class="jive-xml-tag"><socket-binding name="https" port="8447"/></span>
        <span class="jive-xml-tag"><socket-binding name="osgi-http" port="8090"/></span>
        <span class="jive-xml-tag"><socket-binding name="remoting" port="4447"/></span>
        <span class="jive-xml-tag"><socket-binding name="txn-recovery-environment" port="4712"/></span>
        <span class="jive-xml-tag"><socket-binding name="txn-status-manager" port="4713"/></span>
        <span class="jive-xml-tag"><socket-binding name="txn-socket-process-id" port="4714"/></span>
        <span class="jive-xml-tag"><socket-binding name="messaging" port="5445"/></span>
        <span class="jive-xml-tag"><socket-binding name="messaging-throughput" port="5455"/></span>
    <span class="jive-xml-tag"></socket-binding-group></span>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><ul><li>Save the changes. That's it for configurations. Now let's start these individual instances.</li><li>From the command prompt, go to <jboss-as-7-one>/bin and run the following command:</li></ul><pre class="jive-pre"><code class="jive-code">jpai@jpai-laptop:jboss-as-7-one/bin$ ./standalone.sh</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><ul><li>Run the same command from <jboss-as-7-two>/bin:</li></ul><pre class="jive-pre"><code class="jive-code">jpai@jpai-laptop:jboss-as-7-two/bin$ ./standalone.sh</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>You'll now have 2 different instances of JBoss AS7 running on the same physical system.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><h4>Approach#2(?)</h4><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Use the same interface but bind to different ports:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><pre class="jive-pre"><code class="jive-code jive-xml">...
    <span class="jive-xml-tag"><management-interfaces></span>
        <span class="jive-xml-tag"><native-interface interface="default" port="19999"/></span>
        <span class="jive-xml-tag"><http-interface interface="default" port="19990"/></span>
    <span class="jive-xml-tag"></management-interfaces></span>
...
    <span class="jive-xml-tag"><socket-binding-group name="standard-sockets" default-interface="default" port-offset="100"></span>
        <span class="jive-xml-tag"><socket-binding name="jndi" port="1099"/></span>
        <span class="jive-xml-tag"><socket-binding name="jmx-connector-registry" port="1090"/></span>
        <span class="jive-xml-tag"><socket-binding name="jmx-connector-server" port="1091"/></span>
        <span class="jive-xml-tag"><socket-binding name="http" port="8080"/></span>
        <span class="jive-xml-tag"><socket-binding name="https" port="8447"/></span>
        <span class="jive-xml-tag"><socket-binding name="osgi-http" port="8090"/></span>
        <span class="jive-xml-tag"><socket-binding name="remoting" port="4447"/></span>
        <span class="jive-xml-tag"><socket-binding name="txn-recovery-environment" port="4712"/></span>
        <span class="jive-xml-tag"><socket-binding name="txn-status-manager" port="4713"/></span>
        <span class="jive-xml-tag"><socket-binding name="txn-socket-process-id" port="4714"/></span>
        <span class="jive-xml-tag"><socket-binding name="messaging" port="5445"/></span>
        <span class="jive-xml-tag"><socket-binding name="messaging-throughput" port="5455"/></span>
    <span class="jive-xml-tag"></socket-binding-group></span>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>The key is the "port-offset" param on the socket-binding-group param. With that set, all sockets (except those whose socket-binding element has a 'fixed-port="true"' attribute) will have their port number offset by 100 from the declared value.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>All sockets, that is, except the 2 management interfaces, which (currently at least) aren't getting their socket configuration from the socket-binding-group, hence the new port values in the example above.</p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Comment by <a href="http://community.jboss.org/docs/DOC-16705">going to Community</a></p>
        <p style="margin: 0;">Create a new document in JBoss AS7 Development at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=102&containerType=14&container=2225">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>