keepalived single primary, non-preemptive, exemplary unicast

keepalived single primary, non-preemptive, exemplary unicast

server hostname ip
keepalived z6 192.168.1.106
keepalived z7 192.168.1.107

A single main provided

A total of two servers: 192.168.1.106 disposed below the master

root@z7:~# apt install  keepalived
root@z7:~# cp  /usr/share/doc/keepalived/samples/keepalived.conf.sample  /etc/keepalived/keepalived.conf
root@z7:~# systemctl restart keepalived
root@z7:~# scp /etc/keepalived/keepalived.conf  192.168.1.106:/etc/keepalived/

conf

vrrp_instance VI_1{
    state MASTER
    interface eth0
    virtual_router_id 50
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111qwer

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

192.168.1.105 to backup, as set

vrrp_instance VI_1 {
    state BACKUP
    interface eth0
    virtual_router_id 50
    priority 80
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111qwer

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

The default is preemptive, multicasting. When the master down, backup will take over the vip address.

Preemptive disadvantage: because of network jitter, vip frequently drift, resulting in unnecessary switching. We recommend the use of non-preemptive

Multicast disadvantages: keepalived all the information is transmitted in multicast mode to the multicast address 224.0.0.18, resulting in a large number of useless information, and generates interference and collisions, so the need to dial a single multicast mode to . This is a safe way to avoid a large number of virtual routing id keepalived create a conflict within the LAN. Unicast mode requires close vrrp_strict, strictly abide by this agreement vrrp option

Second, the non-preemptive mode

nopreempt: a non-preemptive mode defines the operating mode

state as a backup

z6:

vrrp_instance VI_1{
    state BACKUP
    interface eth0
    virtual_router_id 50
    priority 100
    advert_int 1
    nopreempt
    authentication {
        auth_type PASS
        auth_pass 1111qwer

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

z7:

vrrp_instance VI_1 {
    state BACKUP
    interface eth0
    virtual_router_id 50
    priority 80
    advert_int 1
     nopreempt
    authentication {
        auth_type PASS
        auth_pass 1111qwer

    }

When the stop z6 time, ip will drift to z7 machine when z6 restart will not drift back, the machine is still in z7

Third, Unicast mode

format

unicast_src_ip 本机源IP 
	unicast_peer{ 
	目标主机IP 
    }

z6:

vrrp_instance VI_1{
    state BACKUP
    interface eth0
    virtual_router_id 50
    priority 100
    advert_int 1
    nopreempt
    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
    }
}

z7:

vrrp_instance VI_1 {
    state BACKUP
    interface eth0
    virtual_router_id 50
    priority 80
    advert_int 1
     nopreempt
    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
    }

Ethereal verification

mark

Published 62 original articles · won praise 7 · views 1245

Guess you like

Origin blog.csdn.net/qq_36801585/article/details/105083826