BUG1

起始:ping不到keepalived的虚拟IP

解决方法:注释掉keepalived.conf的vrrp_strict

global_defs {
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 cbh100
vrrp_skip_check_adv_addr
#vrrp_strict
vrrp_garp_interval 0
vrrp_gna_interval 0
}

BUG2

起始:给keepalived写了一个根据nginx是否关闭来终止keepalived的监控脚本,但是无法执行 , 脚本代码本身没有问题

#!/bin/bash
echo "start"
num=`ps -C nginx --no-header | wc -l`
if [ $num -eq 0 ];then
killall keepalived
fi

脚本代码执行效果:

[root@chenbaohui keepalived]# ps -ef | grep nginx
root 13218 2611 0 00:19 pts/0 00:00:00 grep --color=auto nginx
[root@chenbaohui keepalived]# ps -ef | grep keepalived
root 12840 1 0 Mar04 ? 00:00:00 /usr/local/sbin/keepalived
root 12841 12840 0 Mar04 ? 00:00:00 /usr/local/sbin/keepalived
root 12842 12840 0 Mar04 ? 00:00:00 /usr/local/sbin/keepalived
root 13220 2611 0 00:19 pts/0 00:00:00 grep --color=auto keepalived
[root@chenbaohui keepalived]# bash ch_nginx.sh
start
[root@chenbaohui keepalived]# ps -ef | grep keepalived
root 13260 2611 0 00:20 pts/0 00:00:00 grep --color=auto keepalived

实际运行效果:

[root@chenbaohui sbin]# ./nginx -s stop
[root@chenbaohui sbin]# ps -ef | grep nginx
root 12884 2611 0 00:00 pts/0 00:00:00 grep --color=auto nginx
[root@chenbaohui sbin]# ps -ef | grep keepalived
root 12840 1 0 Mar04 ? 00:00:00 /usr/local/sbin/keepalived
root 12841 12840 0 Mar04 ? 00:00:00 /usr/local/sbin/keepalived
root 12842 12840 0 Mar04 ? 00:00:00 /usr/local/sbin/keepalived
root 12891 2611 0 00:01 pts/0 00:00:00 grep --color=auto keepalived

解决方法:发现是自己粗心大意把keepalived.conf里面的配置脚本节点,script "/etc/keepalived/ch_nginx.sh"写成了sript "/etc/keepalived/ch_nginx.sh",改回来就好了

[root@chenbaohui sbin]# ps -ef | grep nginx
root 13593 1 0 00:35 ? 00:00:00 nginx: master process ./nginx
nobody 13594 13593 0 00:35 ? 00:00:00 nginx: worker process
nobody 13595 13593 0 00:35 ? 00:00:00 nginx: worker process
root 13688 2611 0 00:36 pts/0 00:00:00 grep --color=auto nginx
[root@chenbaohui sbin]# ls
nginx
[root@chenbaohui sbin]# ./nginx -s stop
[root@chenbaohui sbin]# ps -ef | grep nginx
root 13977 2611 0 00:38 pts/0 00:00:00 grep --color=auto nginx
[root@chenbaohui sbin]# ps -ef | grep keepalived
root 13979 2611 0 00:38 pts/0 00:00:00 grep --color=auto keepalived