How to run multiple instances of JBoss AS
Author : Bot CDS
From TechnologicalWiki
Contents |
Running multiples instances of JBoss AS in a physical server
In this tutorial, we are using CentOS, JDK6 and JBoss 5.1.x.
Remember that you can only run a process in the same IP/port and this is the reason we need this information if we are going to use multiples JBoss instances.
We go to $JBOSS_HOME/server directory, where default profiles are configured and we create profile1 and profile2 for our two JBoss instances.
[root@neodoo-00 ~]# cd /opt/java/jboss/server/
[root@neodoo-00 server]# cp -Rf default profile1
[root@neodoo-00 server]# cp -Rf default profile2
[edit] Running multiples instances of JBoss AS with a diferent IP address
We only need to use a diferent IP address for each JBoss instante.
In our example, we start 2 servers (we have two IP address configured): one with profile1 at IP 172.24.160.1 and the other with profile2 at IP 172.24.160.2.
/opt/java/jboss/bin/run.sh -c 172.24.160.1 -b profile1
/opt/java/jboss/bin/run.sh -c 172.24.160.2 -b profile2 -Djboss.messaging.ServerPeerID=1
[edit] Running multiples instances of JBoss AS with a single IP address
If you only hace an IP address, we will have to configure all nodes modifying its ports.
[edit] Setting ports manually
You can do it manually modifying a lot of files but there is a easiest to do it we explain next.
[edit] Setting ports using ServiceBindingManager
Instead of to reshape all the ports manually, you can easily configure ports using ServiceBindingManager. This service allows to rotate a fixed amount all the ports of a JBoss instance.
This information is in the file bindings-jboss-beans.xml from the profile you are going to execute.
[root@neodoo-00 ~]# vi /opt/java/jboss/server/default/conf/bindingservice.beans/META-INF/bindings-jboss-beans.xml
The simplest way to use is from command line.
[root@neodoo-00 ~]# cd /opt/java/jboss/bin
[root@neodoo-00 ~]# run.sh -c profile1
[root@neodoo-00 ~]# run.sh -c profile2 -Djboss.service.binding.set=ports-01
With this example, an instance of JBoss AS is running with the profile 'default' using the definition of ports-01 with all ports moved a quantity of 100. Look at the file bindings-jboss-beans.xml the default definition of ports-01.
You can also force JBoss instance to use 'ports-01' modifying bindings-jboss-beans.xml. In our example, We are going to do it with profile2
[root@neodoo-00 ~]# vi /opt/java/jboss/server/profile2/conf/bindingservice.beans/META-INF/bindings-jboss-beans.xml
You can see there is some definitions ready to use and by default, we are going to use the group 'ports-01' (rotate 100 to each port from profile 2).
<parameter>${jboss.service.binding.set:ports-01}</parameter>
Now, you can start this node linked to profileboth nodes which are using differents ports with same IP.
Now, start the first node (it uses default ports).
./run.sh -c profile1
You can access at http://ip_server:8080
In another console, start the second node (it use ports moved 100 from default).
./run.sh -c profile2
You can access at http://ip_server:8180
[edit] Shutdown JBoss instances
AS we have several JBoss instances running, we have to indicate which we want to stop.
Shutdown the first instante profile1.
$JBOSS_HOME/bin/shutdown.sh -s jnp://localhost:11099
Shutdown the instance profile 2.
$JBOSS_HOME/bin/shutdown.sh -s jnp://localhost:11199
Thanks to Apser to leave us the virtual machines !
--79.147.231.248 13:16, 3 October 2009 (UTC)


