Many users of JBoss like to run there JBoss nodes as a service in there Linux boxes, so that when ever they restart there box JBoss node starts with it. However when you are planing to start more then one JBoss AS 7 node on the same box, during that time many people get stuck here. Hence we came up with the steps which solve this issue for you.

By following these steps you would be able to start more then one JBoss AS standalone node as a service on the same box without any issues or complication.

For this article we would be using JBoss AS 7.1.1.Final as till now it is the latest JBoss AS version available. Now let see how can we create multiple JBoss AS 7.1 nodes running as a service on single box in Linux.

Steps to run multiple JBoss AS 7.1 as a service on single box in Linux

  1. Copy “/home/user/jboss-as-7.1.1.Final/bin/init.d/jboss-as-standalone.sh” to “/etc/init.d”
  2. Rename the script something like “jboss-as-standalone-node1.sh
  3. Uncomment JBOSS_USER and give the user who can run this script in the “/home/user/jboss-eap-6.0/bin/init.d/jboss-as.conf” file.
  4. Now edit the following variables as per your environment in the “/etc/init.d/jboss-as-standalone-node1.sh”
    1. JBOSS_CONF = Loads JBoss AS init.d configuration
    2. JBOSS_HOME = Tells where your JBoss AS is been installed
    3. JBOSS_PIDFILE = Tells where should JBoss creates the PID file
    4. JBOSS_CONSOLE_LOG = Tells whree console logs should be created
    5. JBOSS_CONFIG = Loads the standalone configuration
    6. JBOSS_SCRIPT = Runs the standalone script and any startup commands
    7. Example:

      JBOSS_CONF="/home/user/jboss-as-7.1.1.Final/bin/init.d/jboss-as.conf"
      JBOSS_HOME=/home/user/jboss-as-7.1.1.Final
      JBOSS_PIDFILE=/var/run/jboss-as-7.1.1.Final/standalone-node1/jboss-as-standalone.pid
      JBOSS_CONSOLE_LOG=/var/log/jboss-as-7.1.1.Final/standalone-node1/console.log
      JBOSS_CONFIG=standalone.xml
      JBOSS_SCRIPT="$JBOSS_HOME/bin/standalone.sh -Djboss.node.name=standalone-node1"
      
  5. To complete you “jboss-as-standalone-node1.sh” service file you just need to add the below chkconfig so that your Linux box can understand that it need to start this script on start-up/reboot
  6. # chkconfig: 2345 85 15
    # description: JBoss AS 7.1.1.Final
    # processname: standalone-node1.sh
    

    Where: 2345 would be running in 2 (Multiuser, without NFS), 3 (Full multiuser mode, with NFS) , 4 (unused) and 5 (X11) which are the runlevels. 85 is the start priority and 15 is the stop priority.

  7. That’s it !!!  Your first “standalone-node1” has been created and ready to run as a service.

Now we would be seeing what all things we need to make sure to create/start another JBoss node on the same Linux box

  1. You just have to create a copy the above created “jboss-as-standalone-node1.sh” and rename it to “jboss-as-standalone-node2.sh” and all replace “standalone-node1” vaules/folder names to “standalone-node2” in the variables inside the script.
  2. Only in “JBOSS_SCRIPT” value  you would have to add the following command
  3. JBOSS_SCRIPT="$JBOSS_HOME/bin/standalone.sh -Djboss.node.name=standalone-node2 -Djboss.socket.binding.port-offset=100 -Djboss.server.base.dir=/home/user/jboss-as-7.1.1.Final/standalone-1"
    

    where:
    “standalone-1” in Djboss.server.base.dir is a copy of “standalone” folder which is inside JBOSS_HOME

If everything is been configured properly you would be able to start two JBoss AS nodes as a service on the same Linux box.

Uncomment JBOSS_USER and give the user who can run this script in the /home/user/jboss-eap-6.0/bin/init.d/jboss-as.conf file.
If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.