是否可以这样配置keepalived?
正常状态下 VIP_1 分配给 SERVER_1,VIP_2 分配给 SERVER_2
当服务器发生故障时,所有 VIP 都会转移到正常工作的服务器上,当发生故障的服务器恢复运行后,我们不会将其 VIP 迁移回给他,由于某些内容复制的原因,我们需要手动进行此操作。
目前的配置:
#SERVER_1
vrrp_sync_group VG1 {
group {
content
}
}
vrrp_instance content {
state BACKUP
interface eth1
virtual_router_id 1
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1212
}
virtual_ipaddress {
192.168.100.111/24
}
}
# SERVER_2
vrrp_sync_group VG1 {
group {
content
}
}
vrrp_instance content {
state BACKUP
interface eth1
virtual_router_id 1
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1212
}
virtual_ipaddress {
192.168.100.111/24 }
}
答案1
在主机 1 上:
vrrp_instance VI_1 {
state MASTER
interface eth0
dont_track_primary
virtual_router_id 1
priority 150
advert_int 5
mcast_src_ip 172.16.40.1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.0.0.1/24 dev eth0
}
}
vrrp_instance VI_2 {
state BACKUP
interface eth0
dont_track_primary
virtual_router_id 5
priority 100
advert_int 5
mcast_src_ip 172.16.40.1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.0.0.2/24 dev eth0
}
}
在主机 2 上:
vrrp_instance VI_1 {
state BACKUP
interface eth0
dont_track_primary
virtual_router_id 1
priority 100
advert_int 5
mcast_src_ip 172.16.40.2
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.0.0.1/24 dev eth0
}
}
vrpp_instance VI_2 {
state MASTER
interface eth0
dont_track_primary
virtual_router_id 5
priority 150
advert_int 5
mcast_src_ip 172.16.40.2
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.0.0.2/24 dev eth0
}
}
对于无自动故障回复,请查看 keepalived.conf 手册页中的 nopreempt,还可参阅: http://article.gmane.org/gmane.linux.keepalived.devel/1537%22