1.JBoss提供了一种简便的方法:Binding Manager服务,不需要繁琐的端口配置就可以实现多实例运行端口不冲突,详细步骤如下:
以JBoss 4.2.3 GA为例,%JBOSS_HOME%\docs\examples\binding-manager\sample-bindings.xml,该文件默认情况下定义了4组不同的端口配置(ports-default、ports-01、ports-02、ports-03),也就是说默认情况下支持同一台机器部署4个JBoss实例。
2.将server应用下的default复制一份改名为node2.
3.修改node2/conf/jboss-service.xml文件,配置Service Binding(默认注释,取消注视修改ports-01/ports-02/ports-03即可)如下:
<!--
| 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-02</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>
4.修改node2/deploy\jboss-web.deployer\server.xml配置文件
<Connector port="8067" address="0.0.0.0"
maxThreads="250" maxHttpHeaderSize="8192"
emptySessionPath="true" protocol="HTTP/1.1"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" />
5.启动实例,访问端口为8067。