Managed Domain
You might want to run an instance of a managed domain. This will allow you to support two server instances using a web application each, as well as the ease of supporting port and interface declarations from a single console view.
The goal will be one managed domain with two servers. Each server will belong to a different server group. Each server group will have its own interface or port declarations that you require.
This gives you a single management console with a set of relative server groups for assigning your current and future servers, with the ability to change, reassign, or shutdown on the fly.
Configuration
The files you need to know about are the host.xml and domain.xml configuration files in the following file path.
~/JBOSS_HOME/domain/configuration
From domain.xml we can see socket binding groups. The following example is a standard group called Standard Sockets, but you can create as many groups as you want, with as many or as few declarations as you need.
<socket-binding-groups> <socket-binding-group name="standard-sockets" default-interface="public"> <socket-binding name="ajp" port="8009"/> <socket-binding name="http" port="8080"/> <socket-binding name="https" port="8443"/> <socket-binding name="osgi-http" interface="management" port="8090"/> <socket-binding name="remoting" port="4447"/> <socket-binding name="txn-recovery-environment" port="4712"/> <socket-binding name="txn-status-manager" port="4713"/> <outbound-socket-binding name="mail-smtp"> <remote-destination host="localhost" port="25"/> </outbound-socket-binding> </socket-binding-group> ...
You can create two socket binding groups for your needs, serving two sets of ports that you may need. Once they exist, you want the server group to know about them. Let's look further in the domain.xml file.
In the following example, we see that the server group refers to the socket binding group. For bonus points, we see that some applications are used for them. This happened through the Management Console, but AS 7 does not support console and CLI configuration.
<server-groups> <server-group name="main-server-group" profile="full"> <jvm name="default"> <heap size="1303m" max-size="1303m"/> <permgen max-size="256m"/> </jvm> <socket-binding-group ref="full-sockets"/> <deployments> <deployment name="your_application.jar" runtime-name="your_application.jar"/> <deployment name="your_application_02.ear" runtime-name="your_application_02.ear"/> <deployment name="test.war" runtime-name="test.war"/> </deployments> </server-group> <server-group name="other-server-group" profile="full-ha"> <jvm name="default"> <heap size="1303m" max-size="1303m"/> <permgen max-size="256m"/> </jvm> <socket-binding-group ref="full-ha-sockets"/> <deployments> <deployment name="your_application_02.ear" runtime-name="your_application_02.ear"/> <deployment name="test.war" runtime-name="test.war"/> </deployments> </server-group> </server-groups>
The domain.xml file is the configuration of the domain controller, which is the "boss" of the managed domain. The actual server information is contained in the main controller, so let's look at the host.xml file.
<servers> <server name="server-one" group="main-server-group"> </server> <server name="server-two" group="main-server-group" auto-start="true"> <socket-bindings port-offset="150"/> </server> <server name="server-three" group="other-server-group" auto-start="false"> <socket-bindings port-offset="250"/> </server> </servers>
We can see three servers in the default domain. The third is a member of the other-server-group , and the first two are members of the main-server-group . Also pay attention to port binding declarations.
You can delete the third server and assign the server server and the second server to the first and second web applications, respectively. Each server can belong to a unique group. Each group can declare a unique port. After that, you are ready to deploy your applications in your respective groups, and you have left.
Using management tools
XML is displayed in the examples, but you must use the Management Console or Management CLI when setting up the installation. The console is quite simple, so some CLI operations will help you here.
To display server groups:
[domain@localhost:9999 /] /server-group=*:read-resource(include-runtime=true)
To show socket binding groups:
[domain@localhost:9999 /] /socket-binding-group=*:read-resource(include-runtime=true)
You want to show specific http attribute values so that we can modify our CLI operation to work with this child node. Enabling the runtime parameter helps us catch something that happened at runtime that was not written or saved on the server model.
[domain@localhost:9999 /] /socket-binding-group=standard-sockets/socket-binding=http:read-resource(include-runtime=true)
And this is how you write.
[domain@localhost:9999 /] /socket-binding-group=standard-sockets/socket-binding=http:write-attribute(name=port,value=8081)
That should get you started. As you can understand, I am a fan of the managed domain ...