JBoss Howto - Configure Ports

14160 ワード

https://community.jboss.org/docs/DOC-9376
 
ConfigurePorts
バージョン18
作成:2004-6-1午前3:49作成者
tedtollefson  
-最終修正:2010-5-12午後3:46作者
Stelios Koussouris
Setting up multiple instances of JBoss on the same machine
 
The ServiceBindingManager
 
JBoss 5
 
Easy Way
 
Start JBoss with the VM parameter jboss.service.binding.set set to either ports-default, ports-01, ports-02 etc. For example:
 
 
run -Djboss.service.binding.set=ports-01

 
 
The advantage of this way is you don't have to take (and maintain) a separate copy of the all folder if you want to, say, start up multiple instances of JBoss running as a cluster.
 
Harder Way
 
Edit server/default/conf/bindingservice.beans/META-INF/bindings-jboss-beans.xml
 
Change "ports-default":
<!-- The name of the set of bindings to use for this server -->
<parameter>${jboss.service.binding.set:ports-default}</parameter>

 
To any of the defined port sets. JBoss 5 ships with 4 pre defined port sets. You can find them defined further down in the bindings.xml file.
<!-- The ports-01 bindings are obtained by taking the base bindings and adding 100 to each port value -->    <bean name="Ports01Bindings" class="org.jboss.services.binding.impl.ServiceBindingSet">       <constructor>          <!--  The name of the set -->          <parameter>ports-01</parameter>          <!-- Default host name -->          <parameter>${jboss.bind.address}</parameter>          <!-- The port offset -->          <parameter>100</parameter>          <!-- Set of bindings to which the "offset by X" approach can't be applied -->
         <parameter><null/></parameter>
      </constructor>
   </bean>

 
In this case lets change it to use the ports-01 set.
<!-- The name of the set of bindings to use for this server -->
<parameter>${jboss.service.binding.set:ports-01}</parameter>

 
If you familiarize yourself with this configuration file you should find it easy to create you own port sets.
 
Previous versions of JBoss
 
In conf/jboss-service you will find the binding manager.

   <!-- 
      | 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">../docs/examples/binding-manager/sample-bindings.xml</attribute>
     <attribute name="StoreFactoryClassName">
       org.jboss.services.binding.XMLServicesStoreFactory
     </attribute>
   </mbean>

   -->

 
Uncomment this to use the ports-01 settings from the example bindings.
The example contains 4 different ports settings besides the default settings (which is really unecessary).
 
Doing it by hand
 
Thanks to Daniel Kha for this guide
 
It is possible to setup a second instance of JBoss 3.0.6 (or 3.2.0) on the same machine simply by changing the ports of the 2nd installation of JBoss.  I believe this would also work for more than 2 instances.  In brief, to get my second JBoss installation to run, in most of the files I changed the ports by prepending an extra "1"to the default port numbers resulting in ports in the ~10000 range.
 
I've made some changes so you might want to go over this again depending on the last modified date (see bottom).
 
The following was written primarily for JBoss 3.0.6.  Updates were done for JBoss 3.2.0 (noted in steps where it's different between the versions).
Update 2006-02-14: Locations of the files in JBoss-4.0.4RC1 (and probably other versions of jboss4) were added.
 
JBoss Configuration Files to Change:
 
1.  In /server/all/conf/jboss-service.xml (4.0.4rc1: deploy/dynclassloader-service.xml for WebService, deploy/naming-service.xml for NamingService, deploy/invokers-service.xml for JRMPInvoker), edit the following:
 
- For the mbean org.jboss.web.WebService, change the port setting line to (8083 is the default):
18083
 
- For the mbean org.jboss.naming.NamingService, change the port setting line to (1099 is the default):
11099
 
- For the mbean org.jboss.invocation.jrmp.server.JRMPInvoker, change the port setting line to (4444 is the default):
14444
 
 
2.  In /server/all/deploy/cluster-service.xml (4.0.4rc1: could not find this one), edit the following:
 
- For the mbean org.jboss.ha.jndi.HANamingService, add this port setting (1100 is the default so I just prefixed an extra "1"):
11100
 
- Also for the mbean org.jboss.ha.jndi.HANamingService, add this port setting (0 is the default, I just made it 19000 to keep things sort of consistent with the above):
19000
 
 
3.  In /server/all/deploy/jbossmq-service.xml (4.0.4rc1: could not find the first one, deploy/jms/uil2-service.xml for UILServerILService), edit the following:
 
- For the mbean org.jboss.mq.il.oil.OILServerILService, change the port setting line to (8090 is the default):
18090
 
- For the mbean org.jboss.mq.il.uil.UILServerILService, change the port setting line to (8091 is the default):
18091
 
For JBoss 3.2.0, also do these steps (contributed by Anantha Krishnan V):
 
3.a In /server/all/deploy/jbossmq-service.xml, edit the following:
 
- For the mbean org.jboss.mq.il.oil2.OIL2ServerILService, change the port setting line to (8092 is the default):
18092
 
- For the mbean org.jboss.mq.il.uil2.UILServerILService, change the port setting line to (8093 is the default):
18093
 
 
4.  In /server/all/deploy/hsqldb-service.xml, edit the following:
 
- For the mbean org.jboss.jdbc.HypersonicDatabase, change the port setting line to (1476 is the default):
11476
 
- For the mbean org.jboss.resource.connectionmanager.RARDeployment, change the ConnectionURL property to reflect the new port setting line (1476 is the default):
jdbc:hsqldb:hsql://localhost:11476
 
For JBoss 3.2.0, do these steps (contributed by Anantha Krishnan V):
 
4.a In /server/all/deploy/hsqldb-ds.xml, edit the following:
 
- For the mbean org.jboss.jdbc.HypersonicDatabase, change the port setting line to (1701 is the default):
11701
 
- Change the local-tx-datasource to reflect the new port setting line (1701 is the default):
jdbc:hsqldb:hsql://localhost:11701
 
 
5.  In /server/all/deploy/jbossweb.sar/META-INF/jboss-service.xml, edit the following:
 
- Under the "Configure the Request Listeners"section, look for the add listener call of "org.mortbay.http.SocketListener"and change the port setting line to (8080 is the default):

 
- Under the "Configure the Request Listeners"section, look for the add listener call of "org.mortbay.http.ajp.AJP13Listener"and change the port setting line to (8009 is the default):
18009
 
- Also the call "org.mortbay.http.ajp.AJP13Listener", change the port setting line to (443 is the default):
1443
 
For JBoss 3.2.0, do these steps (contributed by Anantha Krishnan V):
 
5.a In /server/all/deploy/jbossweb-jetty.sar/META-INF/jboss-service.xml, edit the following:
 
- Do the same as above, since the .sar was renamed.
 
For JBoss 3.2.1 with Tomcat, do these steps:
 
5.b In /server/all/deploy/jbossweb-tomcat.sar/META-INF/jboss-service.xml, edit the following:
 
- Under the "Configure the Request Listeners"section, look for the add listener call of "org.apache.coyote.tomcat4.CoyoteConnector"and change the port setting line to (8080 is the default):

 
- Also the AJP 1.3 Connector, change the port setting line to (8009 and 8443 are the defaults):
           
 
6.  In /server/all/deploy/jmx-rmi-adaptor.sar/META-INF/jboss-service.xml, edit the following:
 
- For the mbean org.jboss.jmx.adaptor.rmi.RMIAdaptorService, change the port setting line to (0 is the default, but I made it 19001 since we already used 19000):
19001
 
 
7.  In /server/all/conf/jacorb.properties, edit the following (if you are using JBoss 3.0.6):
 
- For the line OAPort=n, change the port setting line to (3528 is the default):
OAPort=13528
 
 
8.  Now execute the run.bat or run.sh script from the
/bin directory in each of the JBoss instances (in sequence, one after the other) and things should work!
 
 
To shutdown the different instances:
 
1.  Execute the shutdown.bat or shutdown.sh script from the
/bin directory with 2 extra arguments.  The first argument is the hostname and the second is the port number.
 
In our example you would shutdown the JBoss instance that is configured with default ports using this command:
\bin\shutdown.bat -s jnp://localhost:11099 -u -p
 
And for the second instance with the modified ports, use this command:
\bin\shutdown.bat -s jnp://localhost:11199 -u -p
 
Note: The port will be each binding port that was specified for jboss:service=Naming
 
Note: UNIX users use shutdown.sh.
添付ファイル:
patched-sample-bindings-jboss-4.0.2-node2.xml  (34.2 K)