Keepalived 不执行脚本

Keepalived 不执行脚本

我执行了一些状态更改脚本,当我查看服务状态时它们似乎被调用,但它们从未运行过。如果我手动执行脚本,它会正常工作。有什么想法吗?使用 Deb9。

答案1

请添加更多详细信息,例如您尝试如何执行。请查看下面的示例,检查文件是否包含。这是通用方法。

vrrp_script <name> {
  script "ping -c1 google.com"
  interval 2                   
  weight 0                     
}
track_script {
      <name>  #Call the name
  }

如需更多参考,请查看此链接https://www.keepalived.org/manpage.html

编辑:因为同一个手册页中的字符太多。请仔细检查您的参数,否则它会失败。

       # for ANY state transition.
       # "notify" script is called AFTER the notify_* script(s) and
       # is executed with 4 additional arguments after the configured
       # arguments provided by Keepalived:
       #   $(n-3) = "GROUP"|"INSTANCE"
       #   $(n-2) = name of the group or instance
       #   $(n-1) = target state of transition (stop only applies to instances)
       #            ("MASTER"|"BACKUP"|"FAULT"|"STOP")
       #   $(n)   = priority value
       #   $(n-3) and $(n-1) are ALWAYS sent in uppercase, and the possible
       #
       # strings sent are the same ones listed above
       #   ("GROUP"/"INSTANCE", "MASTER"/"BACKUP"/"FAULT"/"STOP")
       # (note: STOP is only applicable to instances)
       notify <STRING>|<QUOTED-STRING> [username [groupname]]

相关内容