zoukankan      html  css  js  c++  java
  • MSC服务器-主从检测脚本-check_server_state.sh

    说明:

    发现keepalived会在凌晨自动进行主从切换,导致msc相关进程运行不稳定;

    通过运行check_server_state.sh,及时终止/启动相关进程;

    所有脚本使用supervisord进行管理;

    使用smon管理supervisor

    #!/bin/bash

    msc_vip="10.108.144.6"
    check_log="/var/log/sunlight/check_server_state.log"

    check_vip=$(ip addr | grep $msc_vip | wc -l)

    function print_date()
    {
      echo `date "+%Y/%m/%d %H:%M:%S"`
    }

    while true
    do
    echo "-------------------------------------------------------------"
    #master
    if [ $check_vip -eq 1 ];then
      echo "[ info ] $(print_date) Server is in master state......"

      check_gslb=$(ps -ef | grep "gslb_server" | grep -v grep | wc -l)
      echo "[ info ] $(print_date) check_gslb number : $check_gslb"
      if [ $check_gslb -lt 1 ];then
        /usr/local/sunlight/cdn/gslb/bin/startup.sh
      fi

      check_gnm=$(ps -ef | grep "gnm_server" | grep -v grep | wc -l)
      echo "[ info ] $(print_date) check_gnm number : $check_gnm"
      if [ $check_gnm -lt 1 ];then
        /usr/local/sunlight/cdn/gnm/bin/startup.sh
      fi

      check_nm=$(ps -ef | grep -E "nm_server" | grep -v grep | wc -l)
      echo "[ info ] $(print_date) check_nm number : $check_nm"
      if [ $check_nm -lt 1 ];then
        /usr/local/sunlight/cdn/nm/bin/startup.sh
      fi

      check_vms=$(ps -ef | grep vms_server | grep -v grep | wc -l)
      echo "[ info ] $(print_date) check_vms number : $check_vms"
      if [ $check_vms -lt 1 ];then
        /usr/local/sunlight/cdn/vms/bin/startup.sh
      fi

    fi

    #slave
    if [ $check_vip -ne 1 ];then
      echo "[ info ] $(print_date) Server is in slave state......"

      check_gslb=$(ps -ef | grep "gslb_server" | grep -v grep | wc -l)
      echo "[ info ] $(print_date) check_gslb number : $check_gslb"
      if [ $check_gslb -gt 0 ];then
        /usr/local/sunlight/cdn/gslb/bin/shutdown.sh
      fi

      check_gnm=$(ps -ef | grep "gnm_server" | grep -v grep | wc -l)
      echo "[ info ] $(print_date) check_gnm number : $check_gnm"
      if [ $check_gnm -gt 0 ];then
        /usr/local/sunlight/cdn/gnm/bin/shutdown.sh
      fi

      check_nm=$(ps -ef | grep -E "nm_server" | grep -v grep | wc -l)
      echo "[ info ] $(print_date) check_nm number : $check_nm"
      if [ $check_nm -gt 0 ];then
        /usr/local/sunlight/cdn/nm/bin/shutdown.sh
      fi

    fi
    sleep 60
    done

  • 相关阅读:
    MongoDB的索引(六)
    DMZ原理与应用
    MongoDB的增、删、改、查操作(五)
    一分钟了解mongodb(转)
    mongodb-java-driver基本用法
    Mongodb相对于关系型数据库的优缺点(转)
    什么场景应该用 MongoDB(转)
    MongoDB使用场景和局限 (转)
    matlab7与win7不兼容
    sublime的使用
  • 原文地址:https://www.cnblogs.com/ralphdc/p/8179020.html
Copyright © 2011-2022 走看看