记一次keepalived配置nopreempt不抢占模式总是失效

那年仲夏 提交于 2020-08-13 09:05:12

配置文件

  • 主配置文件
    
    ! Configuration File for keepalived

global_defs {
router_id gd_ha01
}

vrrp_script check_nginx {
script "pidof nginx"
interval 2
}


vrrp_instance VI_1 {
state BACKUP
interface ens160
virtual_router_id 101
priority 100
advert_int 2
nopreempt
authentication {
auth_type PASS
auth_pass 1111
}









notify_master "/application/keepalived/scripts/master.sh"
notify_backup "/application/keepalived/scripts/backup.sh"
notify_fault "/application/keepalived/scripts/fault.sh"

track_script {
    check_nginx
}

virtual_ipaddress {
    192.168.0.93
}

}

- 备配置文件

! Configuration File for keepalived

global_defs {
router_id gd_ha02
}

vrrp_script check_nginx {
script "pidof nginx"
interval 2
}


vrrp_instance VI_1 {
state BACKUP
interface ens160
virtual_router_id 101
priority 80
advert_int 2
nopreempt
authentication {
auth_type PASS
auth_pass 1111
}









notify_master "/application/keepalived/scripts/master.sh"
notify_backup "/application/keepalived/scripts/backup.sh"
notify_fault "/application/keepalived/scripts/fault.sh"

track_script {
    check_nginx
}

virtual_ipaddress {
    192.168.0.93
}

}



# 原因分析
检查多次配置文件没有错,主的上面nginx杀掉后,vip漂移到备上能正常访问,主的nginx起来后,vip又飘回到主上,各种排查(设置preempt_delay、设置ip转发、了解单播/组播),各种配置文件修改,折腾一番后还是没有解决,正准备打算就这种使用抢占模式使用时,突然想起来前几天自己配置的别的keepalived,发现局域网中有virtual_router_id相同的服务器导致的不抢占模式失效。
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!