keepalived知识补充

2023-12-29 12:35:36

一、前言?

? ? ?补充一下keepalived关于通过自身状态来执行一些特定脚本的参数解释,在Keepalived配置文件中,notify_masternotify_backup等参数是用于在状态切换时触发通知脚本的配置项。这些配置项允许在切换到Master或Backup状态时执行自定义的脚本,以便进行一些额外的操作或通知

二、配置和解析

配置

vi /etc/keepalived/keepalived.conf

! Configuration File for keepalived

global_defs {
   script_user root
   enable_script_security
   notification_email {
     acassen@firewall.loc
     failover@firewall.loc
     sysadmin@firewall.loc
   }
   notification_email_from Alexandre.Cassen@firewall.loc
   smtp_server 192.168.200.1
   smtp_connect_timeout 30
   router_id nfs02
  # vrrp_skip_check_adv_addr
  # vrrp_strict
  # vrrp_garp_interval 0
  # vrrp_gna_interval 0
}

vrrp_script check_nfs {
   script "/etc/keepalived/check_nfs.sh"
   interval 3
}

vrrp_instance VI_4 {
    state BACKUP
    interface ens192
    virtual_router_id 53
    priority 80
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        10.1.60.6
    }
    track_script {
       check_nfs
    }
    notify "/opt/nfs-rsync/vip-monitor.sh"      #当keepalived发生角色切换或者故障时会执行以下脚本
    notify_stop "/opt/nfs-rsync/vip-monitor.sh"   #当keepalived服务停止时会执行以下脚本
}

notify_master:在Keepalived状态切换到Master时执行指定的脚本

notify_backup:在Keepalived状态切换到backup时执行指定的脚本

notify_fault:在Keepalived检测到故障时执行指定的脚本

notify:在任何状态变化(Master、Backup或Fault)时执行指定的脚本

notify_stop:在Keepalived服务挂掉时执行指定的脚本,kill或者stop等停止keepalived的命令有效

文章来源:https://blog.csdn.net/ApexPredator/article/details/135287407
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。