keepalived断网切换测试
1 keepalived切换断网切换
2 环境介绍
2.1 keepalived的master和slave
10.50.85.26(master)
10.50.85.56(slave)
2.1 VIP和端口
10.50.85.200:10051
2.2 后端服务
代理的是tcp的
10.50.85.26:10050
10.50.85.56:10050
2.3 10.50.85.26的keepalived的配置
global_defs {
notification_email {
admin@centos.bz
}
notification_email_from keepalived@domain.com
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id LVS_DEVEL
}
vrrp_script chk_http_port {
script "/etc/keepalived/check.sh"
interval 2
weight 2
}
vrrp_instance VI_2 {
state BACKUP
interface br0
virtual_router_id 200
priority 99
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
track_script {
chk_http_port
}
virtual_ipaddress {
10.50.85.200 dev br0 label br0:0
}
}
2.4 10.50.85.56的keepalived的配置
global_defs {
notification_email {
admin@centos.bz
}
notification_email_from keepalived@domain.com
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id LVS_DEVEL
}
vrrp_script chk_http_port {
script "/etc/keepalived/check.sh"
interval 2
weight 2
}
vrrp_instance VI_2 {
state BACKUP
interface br0
virtual_router_id 200
priority 99
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
track_script {
chk_http_port
}
virtual_ipaddress {
10.50.85.200 dev br0 label br0:0
}
}
3 master 交换机中该网口down掉
3.1 85.26(master)
Nov 24 14:50:58 host85-26 kernel: igb 0000:01:00.0: eth0: igb: eth0 NIC Link is Down
Nov 24 14:50:58 host85-26 kernel: bonding: bond0: link status definitely down for interface eth0, disabling it
Nov 24 14:50:58 host85-26 kernel: bonding: bond0: making interface eth1 the new active one.
Nov 24 14:50:58 host85-26 kernel: device eth0 left promiscuous mode
Nov 24 14:50:58 host85-26 kernel: device eth1 entered promiscuous mode
Nov 24 14:51:06 host85-26 kernel: igb 0000:01:00.1: eth1: igb: eth1 NIC Link is Down
Nov 24 14:51:06 host85-26 kernel: bonding: bond0: link status definitely down for interface eth1, disabling it
Nov 24 14:51:06 host85-26 kernel: device eth1 left promiscuous mode
Nov 24 14:51:06 host85-26 kernel: bonding: bond0: now running without any active interface !
Nov 24 14:51:07 host85-26 kernel: br0: port 1(bond0) entering disabled state
总结:master的br0中绑定的两个实际的网卡都down了,但是vip并没有移除
3.2 85.56(slave)
Nov 24 14:51:09 host85-56 Keepalived_vrrp: VRRP_Instance(VI_2) Transition to MASTER STATE
Nov 24 14:51:10 host85-56 Keepalived_vrrp: VRRP_Instance(VI_2) Entering MASTER STATE
Nov 24 14:51:10 host85-56 Keepalived_vrrp: VRRP_Instance(VI_2) setting protocol VIPs.
Nov 24 14:51:10 host85-56 Keepalived_vrrp: VRRP_Instance(VI_2) Sending gratuitous ARPs on br0 for 10.50.85.200
Nov 24 14:51:10 host85-56 Keepalived_healthcheckers: Netlink reflector reports IP 10.50.85.200 added
总结:master down了之后,slave变成master,设置了vip,对外提供服务
4 master交换机中该网口up
4.1 85.26(master)
Nov 24 14:52:06 host85-26 Keepalived_vrrp: VRRP_Instance(VI_1) Received lower prio advert, forcing new election
Nov 24 14:52:06 host85-26 Keepalived_vrrp: VRRP_Instance(VI_1) Sending gratuitous ARPs on br0 for 10.50.85.200
Nov 24 14:52:11 host85-26 kernel: igb 0000:01:00.0: eth0: igb: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX
Nov 24 14:52:11 host85-26 kernel: bond0: link status definitely up for interface eth0, 1000 Mbps full duplex.
Nov 24 14:52:21 host85-26 kernel: br0: port 1(bond0) entering forwarding state
总结:master网络up之后,自动变为主了,日志中没有体现,因为此优先级高
4.2 85.56(slave)
Nov 24 14:52:06 host85-56 Keepalived_vrrp: VRRP_Instance(VI_2) Received higher prio advert
Nov 24 14:52:06 host85-56 Keepalived_vrrp: VRRP_Instance(VI_2) Entering BACKUP STATE
Nov 24 14:52:06 host85-56 Keepalived_vrrp: VRRP_Instance(VI_2) removing protocol VIPs.
Nov 24 14:52:06 host85-56 Keepalived_healthcheckers: Netlink reflector reports IP 10.50.85.200 removed
总结:slave收到mater消息后,将自己的vip移除
页:
[1]