但行好事
莫论前程❤

Weblogic另写启动脚本及日志策略配置

Weblogic另写启动脚本及日志策略配置

start_eprkServer1.sh

#!/bin/sh
#***********************USER_ARGS**********************************************
SRV_NAME=eprkServer1

ADMIN_IP=10.200.162.2

ADMIN_PORT=17101

DOMAIN_NAME=epams_domain

DOMAIN_HOME="/weblogic/domains/epams_domain"

HEAP_SIZE="-Xms4096m -Xmx4096m -XX:MaxPermSize=512m -Dweblogic.rjvm.enableprotocolswitch=true"

USER_JAVA_OPTIONS="-Dfile.encoding=GBK"


#***********************INIT ARGS**********************************************

LOG_PATH=/weblogic/wlslogs/epams_domain/${SRV_NAME}

cd /weblogic/domains/epams_domain/start_script

. ./parameter.sh INIT_ARGS


#************************Remove server's user temporary directory************************

rm -rf "${DOMAIN_HOME}/servers/eprkServer1/tmp"


#************************Start Server***********************************************

nohup ${DOMAIN_HOME}/bin/startManagedWebLogic.sh ${SRV_NAME} ${USER_ADMIN_URL} >> ${LOG_FILE} 2>&1 &


paramter.sh日志策略

#*******************************************************
# Explanation: Weblogic Parameter

# Create : 2013-12-25

# Author : yangwenyong

# OS :UNIX

# VER : 1.0

#*******************************************************
#!/bin/sh

if [ ! -d ${LOG_PATH} ]
    then
         mkdir -p ${LOG_PATH}
fi

DATA_FLAG=`date +%Y%m%d%H%M`

USER_ADMIN_URL="http://${ADMIN_IP}:${ADMIN_PORT}"

LOG_FILE=${LOG_PATH}/${SRV_NAME}.out
#LOG_BACKUP
if [ -f ${LOG_FILE} ]
    then
        #删除原备份文件,测试独有
    rm -rf ${LOG_FILE}201*
     mv ${LOG_FILE} ${LOG_FILE}${DATA_FLAG}
fi
#*************************Function START*********************************************** 
#INTI_AGRS
INIT_ARGS () {
JUDGE_IP 
case `uname -s` in
HP-UX)
  export _JAVA_BINARY_HEAPDUMP=1
    MEM_AGRS="-Xverbosegc:file=${LOG_PATH}/${SRV_NAME}_${DATA_FLAG}_GC.log -XX:+HeapDumpOnly -XX:HeapDumpPath=${LOG_PATH}" 
;;
AIX)
  export IBM_HEAPDUMP=1
  export IBM_JAVACOREDIR=${LOG_PATH}
  export IBM_HEAPDUMPDIR=${LOG_PATH} 
  MEM_AGRS="-Xverbosegclog:${LOG_PATH}/${SRV_NAME}_${DATA_FLAG}_GC.log" 

;;
LINUX|Linux)
  MEM_AGRS="-verbose:gc -Xloggc:${LOG_PATH}/${SRV_NAME}_${DATA_FLAG}_GC.log"
  if [ -L ${LOG_PATH}/${SRV_NAME}_GC.log ]
      then
          rm -f ${LOG_PATH}/${SRV_NAME}_GC.log
          ln -s ${LOG_PATH}/${SRV_NAME}_${DATA_FLAG}_GC.log ${LOG_PATH}/${SRV_NAME}_GC.log
      else
          ln -s ${LOG_PATH}/${SRV_NAME}_${DATA_FLAG}_GC.log ${LOG_PATH}/${SRV_NAME}_GC.log
  fi
;;
esac

JAVA_OPTIONS="-Dweblogic.Domain=${DOMAIN_NAME} -Dweblogic.threadpool.MinPoolSize=50 -Dweblogic.threadpool.MaxPoolSize=200 -Djava.security.egd=file:/dev/./urandom ${JAVA_OPTIONS}"

USER_MEM_ARGS="${HEAP_SIZE} ${MEM_AGRS} ${JAVA_OPTIONS} ${USER_JAVA_OPTIONS}"

export USER_MEM_ARGS

}

#INTI_AGRS_Diagnosid
INIT_ARGS_Diagnosid () {
JUDGE_IP ${ADMIN_IP}
case `uname -s` in
HP-UX)

    MEM_AGRS="-Xverbosegc:file=${LOG_PATH}/${SRV_NAME}_${DATA_FLAG}_GC.log" 
;;
AIX)

  MEM_AGRS="-Xverbosegclog:${LOG_PATH}/${SRV_NAME}_${DATA_FLAG}_GC.log" 

;;
LINUX|Linux)

  MEM_AGRS="-verbose:gc -Xloggc:${LOG_PATH}/${SRV_NAME}_${DATA_FLAG}_GC.log" 

;;
esac

JAVA_OPTIONS="-Dweblogic.Domain=${DOMAIN_NAME} -Dweblogic.threadpool.MinPoolSize=50 -Dweblogic.threadpool.MaxPoolSize=200 -Djava.security.egd=file:/dev/./urandom ${JAVA_OPTIONS}"

USER_MEM_ARGS="${HEAP_SIZE} ${MEM_AGRS} ${JAVA_OPTIONS} ${USER_JAVA_OPTIONS}"

export USER_MEM_ARGS
}

#INIT_ADMIN
INIT_ADMIN () {
JUDGE_IP
JAVA_OPTIONS="-Djava.security.egd=file:/dev/./urandom -Dweblogic.Domain=${DOMAIN_NAME} ${JAVA_OPTIONS} "
export JAVA_OPTIONS
nohup $DOMAIN_HOME/bin/startWebLogic.sh >> ${LOG_FILE} 2>&1 &

NUM1=`wc -l ${LOG_FILE}|awk '{print $1 }'`
check_num=1
while [ "${check_num}" -le 36 ]
do 
NUM2=`wc -l ${LOG_FILE}|awk '{print $1 }'`
NUM=`expr $NUM2 - $NUM1`
RUNSTAT=`tail -n $NUM ${LOG_FILE} |grep RUNNING |grep -v grep |wc -l `
if [ $RUNSTAT -ge 1 ]
 then
   echo `date`  "AdminServer was started !!!" >> ${LOG_PATH}/${SRV_NAME}_start_stop.log
   exit 0 
  else 
   if [ "${check_num}" -eq 36 ]
     then
      cd /weblogic/domains/${DOMAIN_NAME}/start_script
      echo `date`  "AdminServer  start failed !!!" >> ${LOG_PATH}/${SRV_NAME}_start_stop.log
      ./stop_admin.sh
   fi  
fi
  sleep 5 
check_num=`expr  ${check_num} + 1`
done
}

#STOP
STOP_SCRIPT () {

case `uname -s` in
HP-UX)

    PID=`ps -efx|grep java|grep ${DOMAIN_NAME}|grep -v grep|grep ${SRV_NAME}|awk '{print $2}'` 
;;
AIX)
  export IBM_HEAPDUMP=1
  export IBM_JAVACOREDIR=${LOG_PATH}
  export IBM_HEAPDUMPDIR=${LOG_PATH}
  PID=`ps -ef|grep java|grep ${DOMAIN_NAME}|grep -v grep|grep ${SRV_NAME}|awk '{print $2}'`

;;
LINUX|Linux)

  PID=`ps -ef|grep java|grep ${DOMAIN_NAME}|grep -v grep|grep ${SRV_NAME}|awk '{print $2}'` 

;;
esac
if [ -n "${PID}" ]
   then
      kill -9 ${PID} 

      echo `date`  ${SRV_NAME} "was stoped !!!" >> ${LOG_PATH}/${SRV_NAME}_start_stop.log

else
   echo `date`  "The process of"  ${SRV_NAME} "is not exist !" >> ${LOG_PATH}/${SRV_NAME}_start_stop.log

fi
}
#JUDGE_IP
JUDGE_IP () {
case `uname -s` in
HP-UX)

  judge_ip=`netstat -in |grep ${ADMIN_IP}|wc -l`
;;
AIX)

  judge_ip=`/etc/ifconfig -a |grep ${ADMIN_IP}|wc -l`

;;
LINUX|Linux)

  judge_ip=`/sbin/ifconfig -a |grep ${ADMIN_IP}|wc -l`

;;
esac

if [ $judge_ip -eq 0 ]
  then
     echo `date` "The ip of the start script is not exist on this machine!!!" >> ${LOG_PATH}/${SRV_NAME}_start_stop.log
     exit 0
   else
     echo `date` "${SRV_NAME} begin to start !!!" >> ${LOG_PATH}/${SRV_NAME}_start_stop.log

fi
}
#************************Function END***************************************************
case $1 in 
INIT_ARGS)
   INIT_ARGS
;;
INIT_ARGS_Diagnosid)
   INIT_ARGS_Diagnosid
;;
INIT_ADMIN)
   INIT_ADMIN
;;
STOP_SCRIPT)
   STOP_SCRIPT
;;

esac

stop_eprkServer1.sh

#!/bin/sh
#***********************USER_ARGS**********************************************
SRV_NAME=eprkServer1

DOMAIN_NAME=epams_domain

DOMAIN_HOME="/weblogic/domains/epams_domain"

#***********************INIT ARGS**********************************************

LOG_PATH=/weblogic/wlslogs/epams_domain/${SRV_NAME}
cd /weblogic/domains/epams_domain/start_script
. ./parameter.sh STOP_SCRIPT

start_admin.sh

#!/bin/sh

#***********************USER_ARGS**********************************************

DOMAIN_NAME="epams_domain"

DOMAIN_HOME="/weblogic/domains/epams_domain"

ADMIN_IP=10.200.162.2


#************************START ADMIN***********************************************
SRV_NAME=AdminServer

LOG_PATH=/weblogic/wlslogs/epams_domain/${SRV_NAME}

cd /weblogic/domains/epams_domain/start_script

. ./parameter.sh INIT_ADMIN

stop_admin.sh

#!/bin/sh
#***********************USER_ARGS**********************************************
SRV_NAME=AdminServer

DOMAIN_NAME=epams_domain

DOMAIN_HOME="/weblogic/domains/epams_domain"

#***********************INIT ARGS**********************************************

LOG_PATH=/weblogic/wlslogs/epams_domain/${SRV_NAME}

cd /weblogic/domains/epams_domain/start_script

. ./parameter.sh STOP_SCRIPT
赞(0) 打赏
未经允许不得转载:刘鹏博客 » Weblogic另写启动脚本及日志策略配置
分享到: 更多 (0)

评论 抢沙发

评论前必须登录!

 

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏