Linux下配置JBoss自动启动
(JBoss V4.0)#为root用户的命令提示符 $为jboss用户的命令提示符office:office" />Ø         安装J2SDK到/usr/local/j2sdkoffice:smarttags" />1.4.2,编辑/etc/profile# /etc/profile
 
JAVA_HOME=/usr/local/j2sdkPATH=$PATH:$JAVA_HOME/binCLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar export JAVA_HOME PATH CLASSPATH
 
Ø         安装JBoss4.0到/usr/local/jboss4x,编辑/etc/profile# /etc/profile
 
JBOSS_HOME=/usr/local/jboss4xPATH=$PATH:$JBOSS_HOME/bin export JBOSS _HOME PATH 
 
Ø         复制JBoss4自带的启动文件到/etc/init.d下# cp $JBOSS_HOME/bin/jboss_init_redhat.sh  /etc/init.d/
 
Ø         设置启动脚步# 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
 
此时会在/etc/rc3.d和/etc/rc5.d下创建一个S80jboss_init_redhat.sh的连接文件,然后分配执行权限(为了简单使用了777的权限)# 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
 
Ø         编辑/etc/init.d/jboss_init_redhat.sh文件(注:红色为修改部分)# 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 extremely primitive) # 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 changed in the script itself. # Bojan ## Either amend this script for your requirements# 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 directories log, bin, conf etcJBOSS_HOME=${JBOSS_HOME:-"/usr/local/jboss4x"} #make java is on your pathJAVAPTH=${JAVAPTH:-"/usr/local/j2sdk1.4.2/bin"} #define the classpath for the shutdown classJBOSSCP=${JBOSSCP:-"$JBOSS_HOME/bin/shutdown.jar:$JBOSS_HOME/client/jnet.jar"} #define the script to use to start jbossJBOSSSH=${JBOSSSH:-"$JBOSS_HOME/bin/run.sh -c all"} if [ -n "$JBOSS_CONSOLE" -a ! -d "$JBOSS_CONSOLE" ]; then  # ensure the file exists  touch $JBOSS_CONSOLEfi 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 logJBOSS_CONSOLE=${JBOSS_CONSOLE:-"/dev/null"} #define the user under which jboss will run, or use RUNASIS to run as the current userJBOSSUS=${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:$JAVAPTHfi if [ ! -d "$JBOSS_HOME" ]; then  echo JBOSS_HOME does not exist as a valid directory : $JBOSS_HOME  exit 1fi echo CMD_START = $CMD_START case "$1" instart)    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
 
Ø         添加jboss用户并分配组# useradd jboss# usermod -G jboss,root jboss
 
Ø         配置完成,重新启动Linux服务器
http://www.chinaitpower.com/A/2004-12-30/147969.html

解决方案 »

  1.   

    http://www.kehui.net/index.php?op=article&file=read&aid=40310# 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不过小心这几句,可能有安全隐患,如果自己测试就无所谓
      

  2.   

    设置启动脚步# 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
    ==============================
    K20jboss_init_redhat这些文件等等是哪来的?本来就有?我现在不好看。没有linux环境
    谢谢!为什么要
    添加jboss用户并分配组
      

  3.   

    >>K20jboss_init_redhat这些文件等等是哪来的?
    ln –s  建立的阿,>>添加jboss用户并分配组
    一般这样只是为了安全, 一般很少用 root 直接启动服务,