今天搭建了一个主主的环境,使用keepalived做故障切换,但是在测试的过程中发现一个问题,无论是那台机器的keepalived重启,VIP就跳到了那台重启的机器上面去了,不知道是什么原因,还望高手能指点一下,谢谢。配置如下
! Configuration File forkeepalived
global_defs {
notification_email {
test
@163.com
}
notification_email_from ha@163.com
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id MYSQL
#组标识,双主相同
}
vrrp_instance VI_1 {
state BACKUP
#两台都设置BACKUP
interface eth0
virtual_router_id 51
#主备相同
priority 150
#优先级,backup设置90 master设置100
advert_int 1
nopreempt
#MASTER配置不主动抢占资源,Backup不配置
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.80.133
#虚拟IP
}
}
virtual_server 192.168.80.133 3306 {
delay_loop 2
persistence_timeout 50
#同一IP的连接60秒内被分配到同一台真实服务器
protocol TCP
real_server 192.168.80.129 3306 {
#检测本地mysql,backup也要写检测本地mysql
weight 3
notify_down
/usr/local/keepalived/mysql
.sh
#当mysq服down时,执行此脚本,杀死keepalived实现切换
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}