keepalived 双主模式

keepalived 双主模式

​ 主要原理,一个vip 在一个keepalived的机器上是matser 角色,另一个是backup的角色。在一台机器上有多个不同的vrrp_instance 而已。 有多个vip 时 ,减小单台keepalived 的压力

192.168.1.106 上的配置:

上面有一个master 192.168.7.248 backup192.168.7.249

192.168.1.107 上的配置:

上面有一个master 192.168.7.249 backup192.168.7.248


注意: 同一个vip,virtual_route_id 一样。同一个配置文件中vrrp_instance name 不能冲突。而且 “{” 之前有空格,否则会报错


106上的配置

vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 50
    priority 100
    advert_int 1
    unicast_src_ip 192.168.1.106
    unicast_peer {
        192.168.1.107
    }
    authentication {
        auth_type PASS
        auth_pass 1111qwer

    }
    virtual_ipaddress {
        192.168.7.248/24  dev eth0 label eth0:1
    }
}

vrrp_instance VI_2 {
    state BACKUP
    interface eth0
    virtual_router_id 51
    priority 70
    advert_int 1
    unicast_src_ip 192.168.1.106
    unicast_peer {
        192.168.1.107
    }
    authentication {
        auth_type PASS
        auth_pass 1111qwer

    }
    virtual_ipaddress {
        192.168.7.249/24  dev eth0 label eth0:2
    }
}

107 上的配置:

vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 50
    priority 80
    advert_int 1
    unicast_src_ip 192.168.1.107
    unicast_peer {
        192.168.1.106
    }

    authentication {
        auth_type PASS
        auth_pass 1111qwer

    }
    virtual_ipaddress {
        192.168.7.248/24  dev eth0 label eth0:1
    }
}

vrrp_instance VI_2 {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 100
    advert_int 1
    unicast_src_ip 192.168.1.107
    unicast_peer {
        192.168.1.106
    }
    authentication {
        auth_type PASS
        auth_pass 1111qwer

    }
    virtual_ipaddress {
        192.168.7.249/24  dev eth0 label eth0:2
    }
}
发布了62 篇原创文章 · 获赞 7 · 访问量 1244

猜你喜欢

转载自blog.csdn.net/qq_36801585/article/details/105083927