• keepalived检测脚本及注意事项


    keepalived检测脚本的作用及注意事项:

    1. 默认每隔3秒钟执行一次检测脚本,检查nginx服务是否启动,如果没启动就把nginx服务启动起来,如果启动不成功,就把keepalived服务down掉,让漂浮到备keepalived上
    2. 检测脚本
      #!/bin/bash
      run=`ps -C nginx --no-header | wc -l`
      if [ $run -eq 0 ]
      then
      /usr/local/nginx/sbin/nginx -s stop
      /usr/local/nginx/sbin/nginx
      sleep 3
      if [ `ps -C nginx --no-header | wc -l` ]
      then
      killall keepalived
      fi
      fi

    3. 检测脚本一定要写在vrrp_instance的前面也就是上面,而且花括号一定要有空格,追踪trace_script要定在vip的后面,多少人栽在了这上面好多小时

    4. vrrp_script check_ng {
      script " /etc/keepalived/check_nginx.sh "
      interval 2
      }
      vrrp_instance VI_1 {
      state MASTER
      interface eth0
      virtual_router_id 51
      priority 100
      advert_int 1
      authentication {
      auth_type PASS
      auth_pass 1111
      }
      virtual_ipaddress {
      192.168.76.25/24
      }
      track_script {
      check_ng
      }
      }

  • 相关阅读:
    Python time
    Python List/Tutle/Set/Str/Dict
    python os
    Python 学习之九九乘法表
    Pycharm配置
    python 打包exe:
    Linux 安装PHP扩展过程
    tkinter在循环中创建按钮以传递命令参数,闭包的坑
    tkinter
    设置greenplum用户和密码访问:
  • 原文地址:https://www.cnblogs.com/mmdln/p/8988977.html
Copyright © 2020-2023  润新知