所以我在两台服务器上运行keepalived,但无法将其故障转移到另一台服务器。
下面我有我的其中一台服务器的配置。两者之间唯一的区别是优先级数字主为 110,后为 109。
但是当我用 /etc/init.d/process stop keepalived 停止我的进程时,它不会进行故障转移。我只是得到 VRRP_Script(chk_script) 失败,没有别的。没有故障转移或什么都没有。
vrrp_script chk_script {
script "/usr/local/bin/failover.sh"
interval 2
weight 2
}
vrrp_instance HAInstance {
state BACKUP
interface eth0
virtual_router_id 8
priority 109
advert_int 1
nopreempt
vrrp_unicast_bind 10.10.10.8
vrrp_unicast_peer 10.10.10.9
virtual_ipaddress {
10.10.10.10/16 dev eth0
}
notify /usr/local/bin/keepalivednotify.sh
track_script {
chk_script weight 20
}
}
Run Code Online (Sandbox Code Playgroud)
这是我下面的 chk_script。当我将 killall -0 进程作为我的脚本时,也会发生同样的问题。
!/bin/bash
SERVICE='process'
STATUS=$(ps ax | grep -v grep | grep $SERVICE)
if [ "$STATUS" != "" ]
then
exit 0
else …Run Code Online (Sandbox Code Playgroud)