双备机模式:互为备机,谁先开启,即为主机,重新restart,即成为备机。和网上的主备不一样噢
global_defs {
notification_email {
root@localhost
}
notification_email_from root@localhost
smtp_server localhost
smtp_connect_timeout 30
router_id NodeB
}
vrrp_script chk_magent {
script "</dev/tcp/127.0.0.1/8080"
interval 1
weight -20
}
vrrp_instance VI_1 {
state BACKUP #指定A节点为主节点 备用节点上设置为BACKUP即可
interface ens33 #绑定虚拟IP的网络接口
virtual_router_id 51 #VRRP组名,两个节点的设置必须一样,以指明各个节点属于同一VRRP组
priority 100 #主节点的优先级(1-254之间),备用节点必须比主节点优先级低
advert_int 1 #组播信息发送间隔,两个节点设置必须一样
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.40.220
}
}
192.168.40.122/24配置如上
! Configuration File for keepalived
global_defs {
notification_email {
root@localhost
}
notification_email_from root@localhost
smtp_server localhost
smtp_connect_timeout 30
router_id NodeA
}
vrrp_script chk_magent {
script " "
interval 5
weight -20
}
vrrp_instance VI_1 {
state BACKUP #指定A节点为主节点 备用节点上设置为BACKUP即可
interface ens33 #绑定虚拟IP的网络接口
virtual_router_id 51 #VRRP组名,两个节点的设置必须一样,以指明各个节点属于同一VRRP组
priority 100 #主节点的优先级(1-254之间),备用节点必须比主节点优先级低
advert_int 1 #组播信息发送间隔,两个节点设置必须一样
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.40.220
}
}
192.168.40.60/24如上
192.168.40.60/24