• weblogic重启脚本


    客户要求每周weblogic重启,每台机器上有多个weblogic实例,开始准备单个服务器实例做成sysv风格的脚本,但是实例较多,于是在满足需求和自动化重启的情况下,多个服务器实例的重启放在了一起,bash脚本实现:

    #!/bin/bash
    #Auther:jjw
    #Version:0.7
    #date:2017-05-05
    #weblogic重启脚本
    
    DIR="$(cd $(dirname $0) && pwd)"
    #log name
    log="${DIR}/$0_log"
    #日志记录函数
    function log(){
    
      echo "`date` $1" | tee -a ${log}
    
    }
    
    if [ `whoami`x != "weblogic"x ]; then
      log "请切换到weblogic用户执行脚本"
      exit 1
    fi
    
    if [ ! -s ${DIR}/admin.conf ]; then
      log "请检查admin.conf文件是否配置"
      exit 1
    fi
    
    source ${DIR}/admin.conf
    
    while read server
      do
        let FLAG=0
        #停止服务
        log "开始停止服务${server}..." && ${DOMAIN_BIN}/stopManagedWebLogic.sh ${server} ${ADMIN_URL} ${W_USER} ${W_PWD} && log "${server}服务已停止." || let FLAG=1
    
        if [ ${FLAG} -eq 1 ]; then
          log "停止${server}服务失败,请控制台强制停止..."
          while true
            do
              if [ `ps -ef | grep "${server}" | grep -v "grep" | wc -l` -eq 0 ]; then
                log "${server}服务已停止."
                let FLAG=0
                break
              fi
          done
        fi
        
        log "开始启动服务${server}..." && cd ${DOAMIN_HOME} && nohup ./startManagedWebLogic${server}.sh > ${server}.out &
        let SLEEP_TIME=0
        while true
          do
            sleep 10s
            if [ `cat ${DOAMIN_HOME}/${server}.out | grep "Server started in RUNNING mode" | grep -v grep | wc -l` -eq 1 ]; then
              log "${server}重启成功."
              break
            fi
            let SLEEP_TIME+=10
            if [ ${SLEEP_TIME} -gt ${TIMEOUT} ]; then
              log "${server}服务重启超时,请检查后手动处理."
              break
            fi
        done
    
    done < ${DIR}/server.conf
    
    exit $?
    

     admin.conf需根据实际的情况改写

    #administator账户信息
    W_USER="weblogic"
    W_PWD="weblogic"
    #受管服务器所在域目录
    DOAMIN_HOME="/u01/Middleware/domains/base_domain"
    #administator监听地址
    ADMIN_URL="t3://localhost:7001"
    #服务器相关脚本所在目录
    DOMAIN_BIN="${DOAMIN_HOME}/bin"
    #单台服务器启动脚本目录(自己编写,启动时加各种参数)
    START_SCRIPT="${DOAMIN_HOME}"
    #服务器启动超时时间
    TIMEOUT=180
    

     server.conf

    server01
    server02
    server03
    

     startManagedWebLogic${server}.sh

    #!/bin/sh
    # ****************************************************************************
    # This script is used to start a managed WebLogic Server for the domain in the 
    # current working directory.  This script reads in the SERVER_NAME and 
    # ADMIN_URL as positional parameters, sets the SERVER_NAME variable, then 
    # starts the server.
    #
    # Other variables that startWLS takes are:
    #
    # WLS_USER       - cleartext user for server startup
    # WLS_PW         - cleartext password for server startup
    # PRODUCTION_MODE      - Set to true for production mode servers, false for 
    #                  development mode
    # JAVA_OPTIONS   - Java command-line options for running the server. (These
    #                  will be tagged on to the end of the JAVA_VM and MEM_ARGS)
    # JAVA_VM        - The java arg specifying the VM to run.  (i.e. -server, 
    #                  -hotspot, etc.)
    # MEM_ARGS       - The variable to override the standard memory arguments
    #                  passed to java
    #
    # For additional information, refer to the WebLogic Server Administration Guide
    # (/ConsoleHelp/startstop.html).
    # ****************************************************************************
    
  • 相关阅读:
    discuz论坛X3升级时 文件下载出现问题,请查看您的服务器网络以及data目录是否有写权限
    discuz管理中心无法登陆
    在Windows 7下面IIS7的安装和 配置ASP的正确方法
    window.open
    linux下的vmware虚拟机如何回收虚拟磁盘空间
    CentOS7 安装lamp 3分钟脚本
    pyhon 编译C++安装需要 c99 模式
    条件判断
    python字符串杂项
    RIPv1&v2
  • 原文地址:https://www.cnblogs.com/jjzd/p/6825931.html
Copyright © 2020-2023  润新知