Configure JBoss automatically start under Linux
(Jboss v4.0)
# R 用户 用户 用户 提 用户
Ø Install J2SDK to / usr / local / j2sdk
1.4.2
, Edit / etc / profile
# / etc / profile java_home = / usr / local / j2sdk path = $ PATH: $ java_home / bin classpath =.: $ java_home / jre / lib / rt.jar
Export Java_Home Path ClassPath
Ø Install JBoss4.0 to / usr / local / jboss4x, edit / etc / profile
# / etc / profile jboss_home = / usr / local / jboss4x path = $ PATH: $ jboss_home / bin
Export jboss _home path
Ø Copy the startup file from the JBoss4 comes to /etc/init.d
# cp $ jboss_home / bin / jboss_init_redhat.sh /etc/init.d/
Ø Set the startup step
# Ln -s /etc/init.d/jboss_init_redhat.sh /etc/rc3.d/k20jboss_init_redhat
# Ln -s /etc/init.d/jboss_init_redhat.sh /etc/rc3.d/s80jboss_init_redhat
# Ln -s /etc/init.d/jboss_init_redhat.sh /etc/rc5.d/k20jboss_init_redhat
# Ln -s /etc/init.d/jboss_init_redhat.sh /etc/rc5.d/s80jboss_init_redhat
At this point, you will create a connection file for S80JBoss_Init_redhat.sh at /etc/rc3.d and /etc/rc5.d, and then assign execution permissions (for simple use of 777 permissions)
# chmod -f 777 /etc/init.d/jboss_init_redhat.sh # chmod -f 777 /etc/rc3.d/s80jboss_init_redhat.sh # chmod -rf 777 $ jboss_home
Ø Edit /etc/init.d/jboss_init_redhat.sh file (Note: Red is the modification section)
# Vi /etc/init.d/jboss_init_redhat.sh
#! / bin / sh
#
# JBoss Control Script
#
# chkconfig: 3 80 20
# Description: JBoss EJB Container
#
# To use this script
# Run it as root - IT Will Switch to The Specified User
# It loses all console output - Use the log.
#
# Here is a little (and extremelyprimitive)
# Startup / Shutdown Script for Redhat Systems. It Assumes
# That JBoss Lives In / usr / local / jboss, it's run by user
# 'jboss' and JDK Binaries Are IN / USR / local / JDK / BIN. All
# this can be changing in the script itself. # bojan
#
# Either amend this script for your requests
# or Just Ensure That The Following Variables Are Set Correctly
# Before calling the script
# [# 420297] JBoss Startup / Shutdown for RedHat
#define where jboss is - this is The Directory Containing Director Log, BIN, Conf ETC
JBoss_Home = $ {jboss_home: - "/ usr / local / jboss4x"}
#make java is on Your Path
JavaPth = $ {JavaPth: - "/ usr / local / j2sdk
1.4.2
/ bin "}
#define the classpath for the shutdown class
JBosscp = $ {jbosscp: - "$ jboss_home / bin / shutdown.jar: $ jboss_home / client / jnet.jar"}
#define the script to use to start jboss
JBOSSH = $ {JBOSSSH: - "$ jboss_home / bin / run.sh -c all"}
IF [-n "$ jboss_console" -a! -d "$ jboss_console"]; then
# Ensure the file exists
Touch $ JBOSS_CONSOLE
Fi
IF [-n "$ jboss_console" -a! -f "$ jboss_console"]; then
Echo "Warning: Location for Saving Console Log Invalid: $ JBOSS_CONSOLE"
Echo "Warning: ignoring it and using / dev / null"
JBoss_Console = "/ dev / null"
Fi
#define What Will Be Done with the console log
JBoss_Console = $ {JBoss_Console: - "/ dev / null"}
#define the user under Which Jboss Will Run, or Use Runasis To Run As The Current User
JBossus = $ {jbossus: - "jboss"}
CMD_Start = "CD $ jboss_home / bin; $ jbosssh"
CMD_Stop = "Java-ClassPath $ jbosscp org.jboss.shutdown --shutdown"
IF [$ JBOSSUS "=" Runasis "]; then
Subit = "" "
Else
Subit = "Su - $ jbossus -c"
Fi
IF [-z "` Echo $ PATH | GREP $ JAVAPTH` "]; then
Export Path = $ PATH: $ JAVAPTH
Fi
IF [! -d "$ jboss_home]; Thenecho Jboss_Home Does Not Exist as a Valid Directory: $ jboss_home
EXIT 1
Fi
Echo cmd_start = $ cmd_start
Case "$ 1" in
START)
CD $ JBOSS_HOME / BIN
IF [-z "$ SUBIT"]; then
Eval $ cmd_start> $ {jboss_console} 2> & 1 &
Else
$ SUBIT "$ cmd_start> $ {jboss_console} 2> & 1 &"
Fi
;
STOP)
IF [-z "$ SUBIT"]; then
$ Cmd_stop
Else
$ SUBIT "$ cmd_stop"
Fi
;
RESTART)
$ 0 STOP
$ 0 Start
;
*)
Echo "Usage: $ 0 (start | stop | restart | help)"
ESAC
Ø Add JBoss users and assign groups
# UserAdd Jboss # usermod -g jboss, root jboss
Ø Configure completion, restart the Linux server