首页 > 代码库 > 03-keepalived实现nginx负载均衡服务的高可用(主主模式)

03-keepalived实现nginx负载均衡服务的高可用(主主模式)

相比较主备模式,可以设置另一个虚拟路由

此为controller1配置

! Configuration File for keepalived

global_defs {
   notification_email {
        root@localhost
   }
   notification_email_from keepalived@localhost
   smtp_server 127.0.0.1
   smtp_connect_timeout 30
   router_id controller1
   vrrp_mcast_group4 224.0.32.18
}

vrrp_instance keepnginx {
    state MASTER
    interface eno16777736
    virtual_router_id 60
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 123456
    }
    virtual_ipaddress {
        9.110.187.60/24 dev     eno16777736     label   eno16777736:1
    }
track_interface {
        eno16777736
        eno33554960
        }
}

vrrp_instance keepnginx2 {
    state BACKUP
    interface eno16777736
    virtual_router_id 61
    priority 99
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 123456
    }
    virtual_ipaddress {
        9.110.187.61/24 dev     eno16777736     label   eno16777736:1
    }
track_interface {
        eno16777736
        eno33554960
        }
}

技术分享

controller2配置及效果图

技术分享

技术分享

03-keepalived实现nginx负载均衡服务的高可用(主主模式)