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
- Copy “/home/user/jboss-as-7.1.1.Final/bin/init.d/jboss-as-standalone.sh” to “/etc/init.d”
- Rename the script something like “jboss-as-standalone-node1.sh“
- 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.
- Now edit the following variables as per your environment in the “/etc/init.d/jboss-as-standalone-node1.sh”
- JBOSS_CONF = Loads JBoss AS init.d configuration
- JBOSS_HOME = Tells where your JBoss AS is been installed
- JBOSS_PIDFILE = Tells where should JBoss creates the PID file
- JBOSS_CONSOLE_LOG = Tells whree console logs should be created
- JBOSS_CONFIG = Loads the standalone configuration
- JBOSS_SCRIPT = Runs the standalone script and any startup commands
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"
- 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
- That’s it !!! Your first “standalone-node1” has been created and ready to run as a service.
# 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.
Now we would be seeing what all things we need to make sure to create/start another JBoss node on the same Linux box
- 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.
- Only in “JBOSS_SCRIPT” value you would have to add the following command
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.
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.
December 11th, 2012 on 10:17 am
Hi, I did the above changes, but it’s failing to run. I am trying to create script for only one server. When I compiled the bash script, it’s failing with the message, runuser: cannot set groups: Operation not permitted. Not clear what it is related to as user has all the permissions. I complied the bash script and below is output, all the paths are valid, so as the user. I can run the $JBOSS_HOME/bin/standalone.sh directly. I’d really appreciate your inputs, thanks 🙂
+ runuser -s /bin/bash – oracle -c ‘ulimit -S -c 0 >/dev/null 2>&1 ; LAUNCH_JBOSS_IN_BACKGROUND=1 JBOSS_PIDFILE=/apps/jboss-as-7.1.1-test/standalone/jboss-as-standalone.pid /apps/jboss-as-7.1.1-test/bin/standalone.sh -c /apps/jboss-as-7.1.1-test/standalone/configuration/standalone.xml’
+ ‘[‘ 1 -eq 0 ‘]’
+ sleep 1
runuser: cannot set groups: Operation not permitted
+ ‘[‘ 1 -eq 0 ‘]’
+ failure ‘LAUNCH_JBOSS_IN_BACKGROUND=1 startup’
Best,
vpn
December 11th, 2012 on 1:12 pm
Hi vpn,
Try checking the user name given in the “JBOSS_USER” value which is given in the “jboss-as.conf” file. More information about it can be found int he 3 rd step.
Let me know if that helps you.
Regards,
Ravish Mody
December 11th, 2012 on 9:54 pm
Ravish, thanks for the quick reply, yes, the value looks coorect.
JBOSS_USER=oracle
Anything else you can suggest? thanks again!
Best,
Vipin
December 12th, 2012 on 1:30 am
I got it working. I was not root and looks like runuser must be run under root.
Thanks for your time Ravish!
Best,
Vipin
April 3rd, 2015 on 2:04 am
Hi All,
I am using Jboss-6.1.0-Final version and planning to have two instances of Jboss on single linux machine.
two instance are in two separate directories (node1 and node2),using separate scripts for start/stop and enabled the service.binding.set=ports-02 for second instance.
while trying to stop node2, node1 is shutting down.
Can you guide me how can we stop the second instance of jboss ?
tried to give /shutdown.sh –server=localhost:1299 but didnt work.