前言:
一般这种模式不需要相对复杂的配置,相对单网络单主模式,多了一个主可用模式。主要实现单网络双主故障漂移模式。
1.架构示意图:
多播IP是:224.0.0.111。
NAT网络可根据自己的实际情况配置。
+------+ |Client| +------+ /\ +--------+ |Internet| +--------+ /\ +--------+ |NAT 网络| +--------+ /\ +-----------------------+ | 公网VIP1:172.16.8.100 | | 公网VIP2:172.16.8.101 | +-----------------------+ / \ +-----------------------+ +-----------------------+ | KA+Lvs/Nginx/HAProxy | | KA+Lvs/Nginx/HAProxy | | |<---->| | | VIP1:Master (eth1) |多播IP| VIP1:BACKUP (eth1) | | VIP2:BACKUP (eth1) |<---->| VIP2:Master (eth1) | | IP1:172.16.8.10(eth1) | | IP1:172.16.8.11(eth1) | +-----------------------+ +-----------------------+ \ / +-----------------------+ | 公网VIP1:172.16.8.100 | | 公网VIP2:172.16.8.101 | +-----------------------+ \/ +------+ |资源池| +------+
2.ka67配置文件:
global_defs { notification_email { root@localhost } notification_email_from ka@localhost smtp_server 127.0.0.1 smtp_connect_timeout 30 router_id ka67 vrrp_mcast_group4 224.0.0.111 } vrrp_instance VG_1 { state MASTER interface eth0 virtual_router_id 191 priority 100 advert_int 1 authentication { auth_type PASS auth_pass renwole0 } virtual_ipaddress { 172.16.8.100 } notify_master "/usr/local/keepalived/etc/keepalived/notify.sh master" notify_backup "/usr/local/keepalived/etc/keepalived/notify.sh backup" notify_fault "/usr/local/keepalived/etc/keepalived/notify.sh fault" } vrrp_instance VG_2 { state BACKUP interface eth0 virtual_router_id 192 priority 95 advert_int 1 authentication { auth_type PASS auth_pass renwole1 } virtual_ipaddress { 172.16.8.101 } notify_master "/usr/local/keepalived/etc/keepalived/notify.sh master" notify_backup "/usr/local/keepalived/etc/keepalived/notify.sh backup" notify_fault "/usr/local/keepalived/etc/keepalived/notify.sh fault" }
3.ka68配置文件:
global_defs { notification_email { root@localhost } notification_email_from ka@localhost smtp_server 127.0.0.1 smtp_connect_timeout 30 router_id ka68 vrrp_mcast_group4 224.0.0.111 } vrrp_instance VG_1 { state BACKUP interface eth0 virtual_router_id 191 priority 100 advert_int 1 authentication { auth_type PASS auth_pass renwole0 } virtual_ipaddress { 172.16.8.100 } notify_master "/usr/local/keepalived/etc/keepalived/notify.sh master" notify_backup "/usr/local/keepalived/etc/keepalived/notify.sh backup" notify_fault "/usr/local/keepalived/etc/keepalived/notify.sh fault" } vrrp_instance VG_2 { state MASTER interface eth0 virtual_router_id 192 priority 95 advert_int 1 authentication { auth_type PASS auth_pass renwole1 } virtual_ipaddress { 172.16.8.101 } notify_master "/usr/local/keepalived/etc/keepalived/notify.sh master" notify_backup "/usr/local/keepalived/etc/keepalived/notify.sh backup" notify_fault "/usr/local/keepalived/etc/keepalived/notify.sh fault" }