首页 > 代码库 > Keepalived 双实例双主模式配置
Keepalived 双实例双主模式配置
一、环境
A 业务在 lb01 上是主模式,在 lb02 上是备模式
B 业务在 lb01 上是备模式,在 lb02 上是主模式
Hostname | IP | 说明 |
lb01 | 192.168.123.101 | VIP :192.168.123.100 ( 用于绑定 A 服务 www.abc.com 域名 ) |
lb02 | 192.168.123.102 | VIP :192.168.123.200 ( 用于绑定 B 服务 bbs.abc.com 域名) |
二、配置
[root@lb01 ~]# cat /etc/keepalived/keepalived.conf ! Configuration File for keepalived global_defs { notification_email { 1054890557@qq.com } notification_email_from Alexandre.Cassen@firewall.loc smtp_server 127.0.0.1 smtp_connect_timeout 30 router_id lb01 }vrrp_instance VI_1 { state MASTER interface eth0 virtual_router_id 55 priority 150 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.123.100/24 dev eth0 label eth0:1 }}vrrp_instance VI_2 { state BACKUP interface eth0 virtual_router_id 56 priority 100 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.123.200/24 dev eth0 label eth0:2 }}
[root@lb02 ~]# cat /etc/keepalived/keepalived.conf! Configuration File for keepalived global_defs { notification_email { 1054890557@qq.com } notification_email_from Alexandre.Cassen@firewall.loc smtp_server 127.0.0.1 smtp_connect_timeout 30 router_id lb02 }vrrp_instance VI_1 { state BACKUP interface eth0 virtual_router_id 55 priority 100 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.123.100/24 dev eth0 label eth0:1 }}vrrp_instance VI_2 { state MASTER interface eth0 virtual_router_id 56 priority 150 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.123.200/24 dev eth0 label eth0:2 }}
[root@lb01 ~]# /etc/init.d/keepalived restart # 查看 lb01 上的主服务器
[root@lb01 ~]# ip addr | egrep "192.168.123.100|192.168.123.200"
inet 192.168.123.100/24 scope global secondary eth0:1
[root@lb02 ~]# /etc/init.d/keepalived restart # 查看 lb02 上的主服务器[root@lb02 ~]# ip addr | egrep "192.168.123.100|192.168.123.200" inet 192.168.123.200/24 scope global secondary eth0:2
[root@lb01 ~]# /etc/init.d/keepalived stop # 停掉 lb01 看会不会切换到 lb02
[root@lb02 ~]# ip addr | egrep "192.168.123.100|192.168.123.200"
inet 192.168.123.200/24 scope global secondary eth0:2
inet 192.168.123.100/24 scope global secondary eth0:1
[root@lb01 ~]# /etc/init.d/keepalived start # 再次启动看会不会切换回来[root@lb01 ~]# ip addr | egrep "192.168.123.100|192.168.123.200" inet 192.168.123.100/24 scope global secondary eth0:1
Keepalived 双实例双主模式配置
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。