首先看 keepalived 的日志, tail -f /var/log/messages
手动将 mysql 服务关闭后,keepalived 日志打印 Keepalived_healthcheckers[3466]: IPVS: Protocol not available 这就是报错
解决方法:
给 ubuntu 安装 ipvsadm
输入 sudo apt-get install ipvsadm
然后启动它,输入 sudo ipvsadm
之后再测试 mysql 服务当机,会看到日志里打印
ubuntu Keepalived_healthcheckers[4864]: Executing [/etc/keepalived/monitor_mysql.sh] for service [192.168.10.190]:3306 in VS [192.168.100.200]:3306
Keepalived 发现 mysql 服务当机后,去调用杀服务的脚本
参考:
http://www.bbtang.info/linux/fuwu/345.html
https://www.linuxidc.com/Linux/2012-09/70147p3.htm