我是靠谱客的博主 健康小蜜蜂,最近开发中收集的这篇文章主要介绍linux下搭建jboss服务,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

搭建jboss服务器


环境:centos 6
jboss版本:jboss-as-web-7.0.2.Final.zip
jdk版本:jdk-6u31-linux-x64.bin


1、默认最小化安装centos


2、安装jdk
创建jdk安装目录:mkdir /opt/java
上传jdk到/opt/下;
赋予jdk可执行权限:chmod u+x jdk-6u31-linux-x64.bin
安装:./jdk-6u31-linux-x64.bin
安装目录为 /opt/java/jdk1.6.0_31


3、设置环境变量


vim /etc/profile.d/java.sh(输入以下内容)
export JAVA_HOME=/opt/java/jdk1.6.0_31
export CLASSPATH=$CLASSPATH:./:$JAVA_HOME/lib
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin


环境变量生效:source /etc/profile


4、安装jboss
上传jboss软件到/data/目录下;
解压jboss软件:unzip jboss-as-web-7.0.2.Final.zip
修改配置文件:/data/jboss/standalone/configuration/standalone.xml
端口配置,使用80端口,linux下1024之下的端口只允许root用户使用;
 <interfaces>
        <interface name="management">
            <inet-address value="${jboss.bind.address.management:127.0.0.1}"/>
        </interface>
        <interface name="public">
            <any-ipv4-address/>
        </interface>
    </interfaces>
    <socket-binding-group name="standard-sockets" default-interface="public" port-offset="100">
        <socket-binding name="http" port="80"/>
        <socket-binding name="https" port="8443"/>
        <socket-binding name="jmx-connector-registry" port="1090" interface="management"/>
        <socket-binding name="jmx-connector-server" port="1091" interface="management"/>
        <socket-binding name="jndi" port="1099"/>
        <socket-binding name="osgi-http" port="8090" interface="management"/>
        <socket-binding name="remoting" port="4447"/>
        <socket-binding name="txn-recovery-environment" port="4712"/>
        <socket-binding name="txn-status-manager" port="4713"/>
    </socket-binding-group>


5、编辑jboss启动脚本
vi /etc/init.d/jboss


#!/bin/sh
#
# JBoss standalone control script
#
# chkconfig: - 80 20
# description: JBoss AS Standalone
# processname: standalone
# pidfile: /var/run/jboss-as/jboss-as-standalone.pid
# config: /etc/jboss-as/jboss-as.conf


# Source function library.
. /etc/init.d/functions


JBOSS_USER=jboss
JBOSS_HOME=/data/jboss
JBOSS_PIDFILE=/var/run/jboss/jboss-standalone.pid
JBOSS_CONSOLE_LOG=/data/logs/jboss/console.log




# Load Java configuration.
[ -r /etc/java/java.conf ] && . /etc/java/java.conf
export JAVA_HOME


# Load JBoss AS init.d configuration.


if [ -z "$JBOSS_CONF" ]; then
  JBOSS_CONF="/etc/jboss-as/jboss-as.conf"
fi


[ -r "$JBOSS_CONF" ] && . "${JBOSS_CONF}"


# Set defaults.


if [ -z "$JBOSS_HOME" ]; then
  JBOSS_HOME=/usr/share/jboss-as
fi
export JBOSS_HOME


if [ -z "$JBOSS_PIDFILE" ]; then
  JBOSS_PIDFILE=/var/run/jboss-as/jboss-as-standalone.pid
fi
export JBOSS_PIDFILE




if [ -z "$JBOSS_CONSOLE_LOG" ]; then
  JBOSS_CONSOLE_LOG=/var/log/jboss-as/console.log
fi


if [ -z "$STARTUP_WAIT" ]; then
  STARTUP_WAIT=30
fi


if [ -z "$SHUTDOWN_WAIT" ]; then
  SHUTDOWN_WAIT=30
fi


if [ -z "$JBOSS_CONFIG" ]; then
  JBOSS_CONFIG=standalone.xml
fi


JBOSS_SCRIPT=$JBOSS_HOME/bin/standalone.sh


prog='jboss-as'


CMD_PREFIX=''


if [ ! -z "$JBOSS_USER" ]; then
  if [ -x /etc/rc.d/init.d/functions ]; then
    CMD_PREFIX="daemon --user $JBOSS_USER"
  else
    CMD_PREFIX="su - $JBOSS_USER -c"
  fi
fi


start() {
  echo -n "Starting $prog: "
  if [ -f $JBOSS_PIDFILE ]; then
    read ppid < $JBOSS_PIDFILE
    if [ `ps --pid $ppid 2> /dev/null | grep -c $ppid 2> /dev/null` -eq '1' ]; then
      echo -n "$prog is already running"
      failure
      echo
      return 1 
    else
      rm -f $JBOSS_PIDFILE
    fi
  fi
  mkdir -p $(dirname $JBOSS_CONSOLE_LOG)
  cat /dev/null > $JBOSS_CONSOLE_LOG


  mkdir -p $(dirname $JBOSS_PIDFILE)
  chown $JBOSS_USER $(dirname $JBOSS_PIDFILE) || true
  #$CMD_PREFIX JBOSS_PIDFILE=$JBOSS_PIDFILE $JBOSS_SCRIPT 2>&1 > $JBOSS_CONSOLE_LOG &
  #$CMD_PREFIX JBOSS_PIDFILE=$JBOSS_PIDFILE $JBOSS_SCRIPT &


  if [ ! -z "$JBOSS_USER" ]; then
    if [ -x /etc/rc.d/init.d/functions ]; then
      daemon --user $JBOSS_USER LAUNCH_JBOSS_IN_BACKGROUND=1 JBOSS_PIDFILE=$JBOSS_PIDFILE $JBOSS_SCRIPT  2>&1 > $JBOSS_CONSOLE_LOG &
    else
      su - $JBOSS_USER -c "LAUNCH_JBOSS_IN_BACKGROUND=1 JBOSS_PIDFILE=$JBOSS_PIDFILE $JBOSS_SCRIPT " 2>&1 > $JBOSS_CONSOLE_LOG &
    fi
  fi


  count=0
  launched=false


  until [ $count -gt $STARTUP_WAIT ]
  do
    grep 'JBoss AS.*started in' $JBOSS_CONSOLE_LOG > /dev/null 
    if [ $? -eq 0 ] ; then
      launched=true
      break
    fi 
    sleep 1
    let count=$count+1;
  done
  
  success
  echo
  return 0
}


stop() {
  echo -n $"Stopping $prog: "
  count=0;


  if [ -f $JBOSS_PIDFILE ]; then
    read kpid < $JBOSS_PIDFILE
    let kwait=$SHUTDOWN_WAIT


    # Try issuing SIGTERM


    kill -15 $kpid
    until [ `ps --pid $kpid 2> /dev/null | grep -c $kpid 2> /dev/null` -eq '0' ] || [ $count -gt $kwait ]
    do
      sleep 1
      let count=$count+1;
    done


    if [ $count -gt $kwait ]; then
      kill -9 $kpid
    fi
  fi
  rm -f $JBOSS_PIDFILE
  success
  echo
}


status() {
  if [ -f $JBOSS_PIDFILE ]; then
    read ppid < $JBOSS_PIDFILE
    if [ `ps --pid $ppid 2> /dev/null | grep -c $ppid 2> /dev/null` -eq '1' ]; then
      echo "$prog is running (pid $ppid)"
      return 0
    else
      echo "$prog dead but pid file exists"
      return 1
    fi
  fi
  echo "$prog is not running"
  return 3
}


case "$1" in
  start)
      start
      ;;
  stop)
      stop
      ;;
  restart)
      $0 stop
      $0 start
      ;;
  status)
      status
      ;;
  *)
      ## If no parameters are given, print which are avaiable.
      echo "Usage: $0 {start|stop|status|restart|reload}"
      exit 1
      ;;
Esac


赋予jboss启动脚本权限:chmod 700 /etc/init.d/jboss


6、日常维护
jboss启动:/etc/init.d/jboss start
jboss关闭:/etc/init.d/jboss stop
jboss重启:/etc/init.d/jboss restart

最后

以上就是健康小蜜蜂为你收集整理的linux下搭建jboss服务的全部内容,希望文章能够帮你解决linux下搭建jboss服务所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(32)

评论列表共有 0 条评论

立即
投稿
返回
顶部