客户要求每周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).
# ****************************************************************************

weblogic重启脚本的更多相关文章

  1. Tomcat重启脚本restart.sh停止脚本stop.sh

    Tomcat重启脚本restart.sh停止脚本stop.sh Tomcat本身提供了 startup.sh(启动)shutdown.sh(关闭)脚本,我们在部署中经常会出现死进程形象,无法杀掉进程需 ...

  2. Nginx和PHP-FPM的启动/重启脚本 [转发]

    Nginx和PHP-FPM的启动/重启脚本 [转发] (2012-07-27 16:07:52) 标签: it 分类: 学习 转载自:http://blog.sina.com.cn/s/blog_53 ...

  3. Nginx 启动脚本/重启脚本

    第一步先运行命令关闭nginx sudo kill `cat /usr/local/nginx/logs/nginx.pid` 第二步 vi /etc/init.d/nginx 输入以下内容 #!/b ...

  4. Hadoop2.0重启脚本

    Hadoop2.0重启脚本 方便重启带ha的集群,写了这个脚本 #/bin/bash sh /opt/zookeeper-3.4.5-cdh4.4.0/bin/zkServer.sh restart ...

  5. linux服务器挂掉自动重启脚本(转)

    实现原理主要是使用linux提供的crontab机制,定时查询服务器进程是否存在,如果宕机则执行我们预设的重启脚本. 首先我们要向crontab加入一个新任务 sudo crontab -e #进入编 ...

  6. springboot以jar包方式启动、关闭、重启脚本

    springboot以jar包方式启动.关闭.重启脚本 启动 编写启动脚本startup.sh #!/bin/bash echo Starting application nohup java -ja ...

  7. linux shell 写swoole重启脚本

    linux shell 写swoole重启脚本 代码如下<pre>#!/bin/shkill `lsof -t -i:9501`sleep 2php /data/web/mircoweb/ ...

  8. 常见的linux上的服务重启脚本

    手写linux上的重启脚本,先把提纲列下 1.检查进程是否存在 存在杀死 2.备份原来的包到指定目录 3. 拉取新包,我这边为了简便,没有从jenkins slave上拿 4.启动命令 5.检查是否进 ...

  9. windows程序意外关闭子订重启脚本

    window程序意外关闭自动重启脚本实现   @echo off :1 tasklist|find /i "xxxx"||start yyyy ping/n 11 127.1> ...

随机推荐

  1. ctrl+shift+i eclipse快捷键,debug时显示全黑屏

    ctrl+shift+i eclipse快捷键,debug时显示全黑屏,这样方便进行查看内容.

  2. Nginx 504 Gateway Time-out问题解决

    今天站群VPS上面的所有站出现的 504 网关错误,现在小色还是菜菜的,斗胆解决下.在网上面搜解决方案,尝试设置ngxin的fast-cgi_buffers 和重启ngxin来解决,但是错误依旧.怀疑 ...

  3. C++ 虚函数表浅析

    一.背景知识(一些基本概念) 虚函数(Virtual Function):在基类中声明为 virtual 并在一个或多个派生类中被重新定义的成员函数. 纯虚函数(Pure Virtual Functi ...

  4. java数组随机排序实现代码

    例一 代码如下 复制代码 import java.lang.Math;import java.util.Scanner;class AarrayReverse{ public static void ...

  5. Redis介绍及安装

    官网:https://redis.io/ Redis中文社区:http://www.redis.net.cn/ Redis教程:http://www.redis.net.cn/tutorial/350 ...

  6. 使用 sqlyog 导入导出数据显示 lost connection to mysql server during query

    mysql中经常需要备份数据,在使用 sqlyog 进行备份数据库为转储文件,然后在其他数据库中导入发生 lost connection 经过查询大量资料是数据库配置的 max_allowed_pac ...

  7. Vue的计算属性和侦听器

    1 计算属性:他是根据对象已有的属性计算出新的属性值.具有缓存的功能,如果原始属性不变,则用缓存.否则,重新计算. 前端 <form> <label>姓</label&g ...

  8. 让Redis在你的系统中发挥更大作用

    Redis在很多方面与其他数据库解决方案不同:它使用内存提供主存储支持,而仅使用硬盘做持久性的存储:它的数据模型非常独特,用的是单线程.另一个大区别在于,你可以在开发环境中使用Redis的功能,但却不 ...

  9. unity, Collider2D.bounds的一个坑

    Note that this will be an empty bounding box if the collider is disabled or the game object is inact ...

  10. CentOS 7 重装mysql编译过程报错解决方法

    错误记录: [ 82%] Building C object libmysql/CMakeFiles/clientlib.dir/__/sql-common/client.c.o/usr/local/ ...