eepalived 多节点设置
目的: 进一步提高keepalived 可用性
设计:有3台keepalived 服务器 192.168.1.106 192.168.1.107 192.168.1.108。vip 是192.168.1.249
效果:只要有一台keepalive 运行正常。vip 就可以访问
server hostname ip
keepalived z6 192.168.1.106
keepalived z7 192.168.1.107
keepalived z8 192.168.1.108
z6:
vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 50
nopreempt
priority 60
advert_int 1
unicast_src_ip 192.168.1.106
unicast_peer {
192.168.1.107
192.168.1.108
}
authentication {
auth_type PASS
auth_pass 1111qwer
}
virtual_ipaddress {
192.168.7.249/24 dev eth0 label eth0:1
}
}
z7:
vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 50
priority 70
advert_int 1
nopreempt
unicast_src_ip 192.168.1.107
unicast_peer {
192.168.1.106
192.168.1.108
}
authentication {
auth_type PASS
auth_pass 1111qwer
}
virtual_ipaddress {
192.168.7.249/24 dev eth0 label eth0:1
}
}
z8:
vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 50
priority 80
advert_int 1
nopreempt
unicast_src_ip 192.168.1.108
unicast_peer {
192.168.1.106
192.168.1.107
}
authentication {
auth_type PASS
auth_pass 1111qwer
}
virtual_ipaddress {
192.168.7.249/24 dev eth0 label eth0:1
}
}
非抢占模式 默认 是谁先开启vip 运行在哪台机器上的。如果发生故障转移,再比较priority
我这里先开启的先开启是z8
验证:
当停止z8 时 vip 会跑在z7 上
Mar 24 16:52:48 z7 Keepalived_vrrp[1200]: VRRP_Instance(VI_1) Entering BACKUP STATE
Mar 24 16:56:02 z7 Keepalived_vrrp[1200]: VRRP_Instance(VI_1) Transition to MASTER STATE
Mar 24 16:56:03 z7 Keepalived_vrrp[1200]: VRRP_Instance(VI_1) Entering MASTER STATE
当停止z7 上 vip 会运行在 z6 上
Mar 24 16:55:44 z6 systemd[1]: Started Keepalive Daemon (LVS and VRRP).
Mar 24 16:55:44 z6 Keepalived_healthcheckers[1138]: Opening file '/etc/keepalived/keepalived.conf'.
Mar 24 16:55:44 z6 Keepalived_vrrp[1139]: Registering Kernel netlink reflector
Mar 24 16:55:44 z6 Keepalived_vrrp[1139]: Registering Kernel netlink command channel
Mar 24 16:55:44 z6 Keepalived_vrrp[1139]: Registering gratuitous ARP shared channel
Mar 24 16:55:44 z6 Keepalived_vrrp[1139]: Opening file '/etc/keepalived/keepalived.conf'.
Mar 24 16:55:44 z6 Keepalived_vrrp[1139]: Using LinkWatch kernel netlink reflector…
Mar 24 16:55:44 z6 Keepalived_vrrp[1139]: VRRP_Instance(VI_1) Entering BACKUP STATE
Mar 24 16:56:43 z6 Keepalived_vrrp[1139]: VRRP_Instance(VI_1) Transition to MASTER STATE
Mar 24 16:56:44 z6 Keepalived_vrrp[1139]: VRRP_Instance(VI_1) Entering MASTER STATE
然后把z7、z8重启 ,当停止z6 ,vip 会运行在z8 上
Mar 24 17:10:09 z8 systemd[1]: Started Keepalive Daemon (LVS and VRRP).
Mar 24 17:10:09 z8 Keepalived[1736]: Starting VRRP child process, pid=1738
Mar 24 17:10:09 z8 Keepalived_healthcheckers[1737]: Opening file '/etc/keepalived/keepalived.conf'.
Mar 24 17:10:09 z8 Keepalived_vrrp[1738]: Registering Kernel netlink reflector
Mar 24 17:10:09 z8 Keepalived_vrrp[1738]: Registering Kernel netlink command channel
Mar 24 17:10:09 z8 Keepalived_vrrp[1738]: Registering gratuitous ARP shared channel
Mar 24 17:10:09 z8 Keepalived_vrrp[1738]: Opening file '/etc/keepalived/keepalived.conf'.
Mar 24 17:10:09 z8 Keepalived_vrrp[1738]: Using LinkWatch kernel netlink reflector…
Mar 24 17:10:09 z8 Keepalived_vrrp[1738]: VRRP_Instance(VI_1) Entering BACKUP STATE
Mar 24 17:11:08 z8 Keepalived_vrrp[1738]: VRRP_Instance(VI_1) Transition to MASTER STATE
Mar 24 17:11:09 z8 Keepalived_vrrp[1738]: VRRP_Instance(VI_1) Entering MASTER STATE
原文链接:https://blog.csdn.net/yujia_666/article/details/114402123
原创文章,作者:优速盾-小U,如若转载,请注明出处:https://www.cdnb.net/bbs/archives/7408