记一次keepalived.conf配置文件错误排查
如题所述,配置文件中master_backup和slave配置的权重分别为3和1,如配置文件所示:
virtual_server xxx.xx.20.225 5717 {
delay_loop 6
lb_algo wrr
lb_kind DR
nat_mask 255.255.255.255
protocol TCP
real_server xxx.xx.20.123 5717 {
weight 3
TCP_CHECK {
connect_port 5717
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
MISC_CHECK {
misc_path "/home/mysql/keepalived/check_slave.py xxx.xx.20.123 5717"
misc_dynamic
}
}
real_server xxx.xx.20.124 5717 {
weight 1
TCP_CHECK {
connect_port 5717
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
MISC_CHECK {
misc_path "/home/mysql/keepalived/check_slave.py xxx.xx.20.124 5717"
misc_dynamic
}
}
启动keepalived之后,通过/var/log/messeges日志看到:
May 24 17:19:19 localhost Keepalived_healthcheckers[31275]: Changing weight from 1 to 125 for active service [xxx.xx.20.124]:5717 of VS [xxx.xx.20.225]:5717
May 24 17:19:19 localhost Keepalived_healthcheckers[31275]: Changing weight from 3 to 125 for active service [xxx.xx.20.123]:5717 of VS [xxx.xx.20.225]:5717
通过ipvsadm -Ln看到:
虽然LVS调度算法设置为wrr,但是keepalived从启动就自动改变权重。
经过排查,发现MISC_CHECK内调用的检查脚本路径不对,修改之后启动正常