共计 4271 个字符,预计需要花费 11 分钟才能阅读完成。
导读 | 在生产环境中,公网与内网都是独立分开的,所以称之为双网络。下面配置将要实现内网和公网故障时不必同步漂移,例如:Keepalived+LVS-DR、Keepalived+Nginx、Keepalived+HAProxy 这些都无需同步漂移的。另外 Keepalived+LVS-NAT 则需要同步漂移。 |
示意图
多播 IP 是:224.0.0.111。一台机器的 VIP 内外网互为主备。+------+ | |
|Client| | |
+------+ | |
/\ | |
+--------+ | |
|Internet| | |
+--------+ | |
/\ | |
+--------+ | |
|NAT 网络 | | |
+--------+ | |
/\ | |
+----------------------+ | |
| 内网 VIP1:10.16.8.100 | | |
| 内网 VIP2:10.16.8.101 | | |
+----------------------+ | |
/ \ | |
+-----------------------+ +-----------------------+ | |
|KA+Lvs-DR/Nginx/HAProxy| |KA+Lvs-DR/Nginx/HAProxy| | |
| 内网 VIP1:Master (eth1) | | 内网 VIP1:BACKUP (eth1) | | |
| 内网 VIP2:BACKUP (eth1) | | 内网 VIP2:Master (eth1) | | |
| 内网:10.16.8.10 (eth1) || 内网:10.16.8.11 (eth1) | | |
|-----------------------| 多播 IP|-----------------------| | |
| 公网 VIP1:Master (eth2) || 公网 VIP1:BACKUP (eth2) | | |
| 公网 VIP2:BACKUP (eth2) | | 公网 VIP2:Master (eth2) | | |
| 公网:172.16.8.10(eth2) | | 公网:172.16.8.11(eth2) | | |
+-----------------------+ +-----------------------+ | |
\ / | |
+-----------------------+ | |
| 公网 VIP1:172.16.8.100 | | |
| 公网 VIP2:172.16.8.101 | | |
+-----------------------+ | |
\/ | |
+------+ | |
| 资源池 | | |
+------+ |
ka67 配置文件
global_defs { | |
notification_email {root | }|
notification_email_from ka | |
smtp_server 127.0.0.1 | |
smtp_connect_timeout 30 | |
router_id ka67 | |
vrrp_mcast_group4 224.0.0.111 | |
} | |
vrrp_instance External_1 { | |
state MASTER | |
interface eth1 | |
virtual_router_id 171 | |
priority 100 | |
advert_int 1 | |
authentication { | |
auth_type PASS | |
auth_pass renwole0 | |
} | |
virtual_ipaddress {10.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 External_2 { | |
state BACKUP | |
interface eth1 | |
virtual_router_id 172 | |
priority 95 | |
advert_int 1 | |
authentication { | |
auth_type PASS | |
auth_pass renwole1 | |
} | |
virtual_ipaddress {10.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" | |
} | |
vrrp_instance Internal_1 { | |
state MASTER | |
interface eth2 | |
virtual_router_id 191 | |
priority 100 | |
advert_int 1 | |
authentication { | |
auth_type PASS | |
auth_pass renwole2 | |
} | |
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 Internal_2 { | |
state BACKUP | |
interface eth2 | |
virtual_router_id 192 | |
priority 95 | |
advert_int 1 | |
authentication { | |
auth_type PASS | |
auth_pass renwole3 | |
} | |
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" | |
} |
ka68 配置文件
global_defs { | |
notification_email {root | }|
notification_email_from ka | |
smtp_server 127.0.0.1 | |
smtp_connect_timeout 30 | |
router_id ka68 | |
vrrp_mcast_group4 224.0.0.111 | |
} | |
vrrp_instance External_1 { | |
state BACKUP | |
interface eth1 | |
virtual_router_id 171 | |
priority 100 | |
advert_int 1 | |
authentication { | |
auth_type PASS | |
auth_pass renwole0 | |
} | |
virtual_ipaddress {10.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 External_2 { | |
state MASTER | |
interface eth1 | |
virtual_router_id 172 | |
priority 95 | |
advert_int 1 | |
authentication { | |
auth_type PASS | |
auth_pass renwole1 | |
} | |
virtual_ipaddress {10.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" | |
} | |
vrrp_instance Internal_1 { | |
state BACKUP | |
interface eth2 | |
virtual_router_id 191 | |
priority 100 | |
advert_int 1 | |
authentication { | |
auth_type PASS | |
auth_pass renwole2 | |
} | |
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 Internal_2 { | |
state MASTER | |
interface eth2 | |
virtual_router_id 192 | |
priority 95 | |
advert_int 1 | |
authentication { | |
auth_type PASS | |
auth_pass renwole3 | |
} | |
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" | |
} |
正文完
星哥玩云-微信公众号
