Jboss 4.x 端口及其修改

[color=red]注:本文中所述内容适合于Jboss 4.x系列应用服务器。[/color]

为了在同一台服务器上能够运行多个Jboss服务器,或者同时运行Jboss和Tomcat服务器,我们需要修改Jboss的各种端口。

[b]Why configure JBoss's Ports? [/b]
Configuring port numbers in JBoss can seem a little complicated, but it's actually pretty easy to understand once you get how JBoss is configured. However, why bother spending the time learning all this if it isn't going to be useful? Here are a few reasons why you might want to configure JBoss ports:
[list=1]
[*]You are running an instance of Tomcat on your machine already, and you can't start JBoss because port 8080 is already in use.
[*]You have a team of developers sharing a deployment machine. Each developer needs their own instance of JBoss (Note: if so, you will want to look at Shared JBoss Installation Directory also)
[*]A testing team wants to test different versions of the application using the same machine.
[*]You are planning on deploying more than one JBoss JVM per machine in a cluster to get higher availability and better performance (lots of smaller JVMs).
[/list]

[b]JBoss 4.x Ports[/b]
Here are the ports used by JBoss 4.x:
[color=violet]Default port numbers and where they are configured.[/color]
[table]
|Default Port|Location|Description|
|1099|./conf/jboss-service.xml or ./naming.sar/META-INF/jboss-service.xml|Bootstrap JNP port.|
|1098 (anon)|./conf/jboss-service.xml or ./naming.sar/META-INF/jboss-service.xml| RMI naming service port.Use '0' for an anonymous port.|
|4444|./conf/jboss-service.xml or ./deploy/invokers-service.xml|RMI/JRMP invoker port |
|4445| ./conf/jboss-service.xml or ./deploy/invokers-service.xml|Pooled invoker |
|8083|./conf/jboss-service.xml or ./deploy/dynclassloader-service.xml|RMI dynamic class loader port |
|8080| ./deploy/jbossweb-tomcat55.sar/server.xml|HTTP port for the web container |
|8009|./deploy/jbossweb-tomcat55.sar/server.xml|AJP port for the web container |
|8093| ./deploy/jms/uil2-service.xml|UIL for JMS. |
|8443 (optional)|./deploy/jbossweb-tomcat55.sar/server.xml|HTTPS port for the web container |
[/table]
[color=violet]Additional port numbers for clustered configurations[/color]
[table]
|Default Port|Location|Description|
|1100| ./deploy/cluster-service.xml|HA-JNDI|
|1101 (anon) |./deploy/cluster-service.xml|RMI for HA-JNDI Use '0' for an anonymous port.|
|4446|./deploy/cluster-service.xml|HA Pooled Invoker |
|4447|./deploy/cluster-service.xml|HA JRMP |
|45566 (mcast)|./deploy/cluster-service.xml|JGroups clustering|
[/table]

[color=violet]Other ports for optional services [/color]
[table]
|Default Port|Location|Description|
|3528|./deploy/iiop-service.xml|CORBA port |
|3873|./deploy/ejb3.deployer/META-INF/jboss-service.xml|EJB3 remote invoker |
|1162|./deploy/snmp-adaptor.sar/META-INF/jboss-service.xml|SNMP Log |
|1161|./deploy/snmp-adaptor.sar/META-INF/jboss-service.xml|SNMP Adaptor |
|19001|jmx-rmi-adaptor.sar|JMX over RMI |
[/table]

[b]How to configure ports for different instances of JBoss [/b]
[color=olive]Solution #1 : Use the Service Binding facility [/color]
The "Service Binding" feature uses a JMX bean to configure the other JMX beans (as far as I can tell). This requires you to make a file that has all of the possible bindings for each 'jboss server name'. The basics are:
这段话是说,Jboss在启动时会用一个MBean去配置其他MBean使用到的端口,我们就可以将不同Jboss实例使用的端口号预先定义在这个文件中,然后在jboss-service.xml中使用那个MBean,指定需要的参数,然后Jboss就会用你指定的端口去配置其他MBean。这个MBean的名字是org.jboss.services.binding.ServiceBindingManager。在jboss-service.xml中可以找到其定义,如下:

<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>

其中<attribute name="ServerName">ports-01</attribute>这个属性指定你要使用的某组端口号,<attribute name="StoreURL">${jboss.home.url}/docs/examples/binding-manager/sample-bindings.xml</attribute>这个属性定义了你使用的配置端口号的文件,这个链接是一个例子,我们可以根据这个例子配置自己的端口号。
[list=1]
[*]Create a globally shared "Service Binding" file that will contain the port numbers for each possible instance of JBoss on the machine by 'configuration name'.
例如,我$JBOSS_HOME$\server\default\conf目录下面建立了一个名为bindings.xml的文件,在这个文件中,定义了多组端口号,每组端口号对应一个Jboss实例。
[*]Uncomment or add a "Service Binding" section in conf/jboss-service.xml. This where the configuration will select which set of bindings it will use from the shared bindings file.
在jboss-service.xml里面启动org.jboss.services.binding.ServiceBindingManager这个MBean,指定参数之后,Jboss启动时就会用你指定的那组端口来配置其他的MBean。
[/list]
See: [url]http://wiki.jboss.org/wiki/Wiki.jsp?page=ConfiguringMultipleJBossInstancesOnOneMachine [/url]
这个功能在JBoss 5.x系列中是默认提供的。
[color=olive]Solution #2: Use M4 or ANT to pre-process the XML configuration files.[/color]
If JBoss isn't the only thing that needs port numbers, host names and directories configured into each instance than you need more than just the Service Binding feature. In this case, we experience one drawback of JBoss's modular configuration: there are lots of files to change! Although this isn't really that difficult it requires a bit of work and it might break if JBoss changes their configuration files around if you're not careful.

[color=olive]
Solution #3 (the best of both) : Use a combination of Service Binding and ANT or M4[/color]
The answer to the drawbacks of solutions #1 and #2: Use both! If you use substitution on the service binding configuration file itself then it is as if all JBoss ports are configured in one file. This means you don't have to process each individual configuration file. The basic idea here is to create a service binding XML file that has the substitutable tokens in it, and use ANT or M4 to process this one file.

[b]Mapping the EJB3 Remote Invoker Port [/b]
The example port bindings file doesn't map the EJB3 remoting port. This is easy:

<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}:3873</attribute>
</delegate-config>
<binding port="3873"/>
</service-config>

Just replace '3873' with the port number you want to use.

[b]What ports is JBoss Listening on? [/b]
On Linux, you can use:
$ lsof -p {jboss pid} | grep TCP

[color=red]附:
Jboss 5.x以上版本的应用服务器跟4.x本版的应用服务器在端口修改上有很大不同。从本文可以看到对4.x端口修改要涉及到很多个文件,这样修改起来还是很不方便的。所以在5.x以上版本中,jboss提供了一个binding.xml文件,在/default/conf/bootstrap目录下面。所以在5.x版本里面端口的修改要方便一点。
[/color]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值