文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>Linux下配置JBoss自动启动

Linux下配置JBoss自动启动

时间:2009-03-23  来源:sjhf

安装jboss4.0到/usr/local/jboss4x,编辑/etc/profile
# /etc/profile
jboss_home=/usr/local/jboss4x
path=$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 etc
jboss_home=${jboss_home:-"/usr/local/jboss4x"}
 
#make java is on your path
javapth=${javapth:-"/usr/local/j2sdk1.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
jbosssh=${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" ]; then
  echo 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
 

Ø         添加jboss用户并分配组
# useradd jboss
# usermod -g jboss,root jboss

相关阅读 更多 +
排行榜 更多 +
风雷

风雷

角色扮演 下载
蜘蛛战士模拟

蜘蛛战士模拟

动作格斗 下载
仙栎日语

仙栎日语

学习教育 下载