Keepalived+LVS DR

Keepalived+LVS DR

1 Preparations

The complete architecture requires two servers (the role is dir) to install keepalived software separately, in order to achieve high availability, but keepalived itself also has the function of load balancing, so this experiment can only install one keepalived
keepalived has built-in ipvsadm function, so it is not You need to install the ipvsadm package again, and you don't need to write and execute the lvs_dir script. The
three machines are:
dir (install keepalived) 133.130
rs1 133.132
rs2 133.133
vip 133.200

2 Edit the keepalived configuration file

vim /etc/keepalived/keepalived.conf

vrrp_instance VI_1 {
    #备用服务器上为 BACKUP
    state MASTER
    #绑定vip的网卡为ens33,你的网卡和阿铭的可能不一样,这里需要你改一下
    interface ens33
    virtual_router_id 51
    #备用服务器上为90
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass aminglinux
    }
    virtual_ipaddress {
        192.168.188.110
    }
}
virtual_server 192.168.188.110 80 {
    #(每隔10秒查询realserver状态)
    delay_loop 10
    #(lvs 算法)
    lb_algo wlc
    #(DR模式)
    lb_kind DR
    #(同一IP的连接60秒内被分配到同一台realserver)
    persistence_timeout 60
    #(用TCP协议检查realserver状态)
    protocol TCP
    real_server 192.168.188.129 80 {
        #(权重)
        weight 100
        TCP_CHECK {
        #(10秒无响应超时)
        connect_timeout 10
        nb_get_retry 3
        delay_before_retry 3
        connect_port 80
        }
    }
    real_server 192.168.188.127 80 {
        weight 100
        TCP_CHECK {
        connect_timeout 10
        nb_get_retry 3
        delay_before_retry 3
        connect_port 80
        }
     }
}

//Please go to https://coding.net/u/aminglinux/p/aminglinux-book/git/blob/master/D21Z/lvs_keepalived.conf to get
the ip information that needs to be changed and
execute ipvsadm -C to put the previous ipvsadm rules Clearing
systemctl restart network can clear the previous vip
on two rs, still need to execute the /usr/local/sbin/lvs_rs.sh script
keepalived has a better function, it can no longer be used when one rs is down. forward the request to the
test

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324894863&siteId=291194637