LVS之NAT + keepalived 模式配置文档

拓扑图介绍:

                                                                                                                   RS01 (real-server)

Client <- [DR01 + DR02-BACKUP] keepalived (Director-s) <-- |

                                                                                                                    RS02 (real-server)

DR01:

        192.168.131.90  (内网)

        192.168.43.90   (外网)

DR02-BACKUP:

        192.168.131.91 (内网)

        192.168.43.91   (外网)

RS01: 

        192.168.131.92  (内网)

RS02: 

        192.168.131.93  (内网)

Client: 

        192.168.43.110

vip(内网): 192.168.131.190

vip(外网): 192.168.43.199

内网网关: 192.168.131.190

外网网关: 192.168.43.1

附:IP地址严格此规划,selinux设置、关闭防火墙、基本软件的安装(略)

如果使用vmware进行试验,RS01、RS02、DR02-BACKUP、DR01的131网段均使用host-only模式,DR01、DR02-BACKUP的43网段使用桥接模式。


报文请求过程分析

1.当用户请求到达DS时,请求报文会先经过内核空间中的PREROUTING链,此时源IP为CIP,目的IP为VIP;

2.在PREROUTING规则链上进行检查目的IP是否为本机,如果是的话将数据包送至INPUT 链;

3.数据包到达INPUT链后,IPVS会比对数据包请求的服务是否为集群服务,若是,修改数据包的目标IP地址为后端服务器IP(这里需要根据各种算法计算,哪台RS更合适),

再将数据包发至POSTROUTING链,此时报文的源IP为CIP,目标IP为 RIP;

4.POSTROUTING链的作用就是选路,根据INPUT链中目标IP,将数据包发送给RS;

5.RS发现数据包中的目标IP是自己的IP,此时它会开始构建响应报文发并回给DS, 此时报文的源IP为RIP,目标IP为CIP;

6.DS收到RS响应后,但在响应客户端,会将源IP地址修改为自己的VIP地址,然后发送给客户端,此时报文的源IP为 VIP,目标IP为CIP;

参阅(图):

https://www.cnblogs.com/blxt/p/13099437.html


(一)ipvsadm与keepalived安装配置

1.开启ip_forward转发功能

执行机器:DR01与DR02-BACKUP

[root@DR01 ~]# echo 1 > /proc/sys/net/ipv4/ip_forward

[root@DR01 ~]# cat /proc/sys/net/ipv4/ip_forward

1

[root@DR02-BACKUP ~]# echo 1 > /proc/sys/net/ipv4/ip_forward

[root@DR02-BACKUP ~]# cat /proc/sys/net/ipv4/ip_forward

1

2.ipvsadmin与keepalived安装

执行机器:DR01与DR02-BACKUP

[root@DR01 ~]# yum install ipvsadm keepalived -y

[root@DR01 ~]# rpm -qa | grep ipvs

ipvsadm-1.27-8.el7.x86_64

[root@DR01 ~]# rpm -qa | grep keepalived

keepalived-1.3.5-16.el7.x86_64

[root@DR01 ~]#

[root@DR02-BACKUP ~]# yum install ipvsadm keepalived -y

[root@DR02-BACKUP ~]# rpm -qa | grep ipvs

ipvsadm-1.27-8.el7.x86_64

[root@DR02-BACKUP ~]# rpm -qa | grep keepalived

keepalived-1.3.5-16.el7.x86_64

[root@DR02-BACKUP ~]#

3.keepalived的配置

*DR01配置:

[root@DR01 /]# cat /etc/keepalived/keepalived.conf

! Configuration File for keepalived

global_defs {

  router_id LVS_01

  #vrrp_skip_check_adv_addr

  #vrrp_garp_interval 0

  #vrrp_gna_interval 0

}

vrrp_instance VI_1 {

    state MASTER

    interface ens37

    virtual_router_id 51

    priority 100

    advert_int 1

    authentication {

        auth_type PASS

        auth_pass 1111

    }

    virtual_ipaddress {

        192.168.43.199

    }

}

vrrp_instance LAN_GATEWAY {

    state MASTER

    interface ens33

    virtual_router_id 52

    priority 100

    advert_int 1

    authentication {

        auth_type PASS

        auth_pass 1111

    }

    virtual_ipaddress {

        192.168.131.190

    }

}

virtual_server 192.168.43.199 80 {

    delay_loop 6

    lb_algo rr

    lb_kind NAT

    #persistence_timeout 50

    protocol TCP

    real_server 192.168.131.92 80 {

        weight 10

        TCP_CHECK {

          connect_timeout 3

          retry 3

          delay_before_retry 3

          connect_port 80

        }

    }

    real_server 192.168.131.93 80 {

      weight 10

      TCP_CHECK {

      connect_timeout 3

      retry 3

      delay_before_retry 3

      connect_port 80

      }

    }

}

[root@DR01 /]#

*DR02-BACKUP配置:

[root@DR02-BACKUP keepalived]# cat /etc/keepalived/keepalived.conf

! Configuration File for keepalived

global_defs {

  router_id LVS_01

  #vrrp_skip_check_adv_addr

  #vrrp_garp_interval 0

  #vrrp_gna_interval 0

}

vrrp_instance VI_1 {

    state BACKUP

    interface ens37

    virtual_router_id 51

    priority 90

    advert_int 1

    authentication {

        auth_type PASS

        auth_pass 1111

    }

    virtual_ipaddress {

        192.168.43.199

    }

}

vrrp_instance LAN_GATEWAY {

    state BACKUP

    interface ens33

    virtual_router_id 52

    priority 90

    advert_int 1

    authentication {

        auth_type PASS

        auth_pass 1111

    }

    virtual_ipaddress {

        192.168.131.190

    }

}

virtual_server 192.168.43.199 80 {

    delay_loop 6

    lb_algo rr

    lb_kind NAT

    #persistence_timeout 50

    protocol TCP

    real_server 192.168.131.92 80 {

        weight 10

        TCP_CHECK {

          connect_timeout 3

          retry 3

          delay_before_retry 3

          connect_port 80

        }

    }

    real_server 192.168.131.93 80 {

      weight 10

      TCP_CHECK {

      connect_timeout 3

      retry 3

      delay_before_retry 3

      connect_port 80

      }

    }

}

[root@DR02-BACKUP keepalived]#

4.keepalived服务脚本调整与更改日志路径

执行机器:DR01与DR02-BACKUP

[1]服务脚本修正:

[root@DR01 ~]# cat /usr/lib/systemd/system/keepalived.service

[Unit]

Description=LVS and VRRP High Availability Monitor

After=syslog.target network-online.target

[Service]

Type=forking

PIDFile=/var/run/keepalived.pid

#KillMode=process  调整的这里,注释掉

EnvironmentFile=-/etc/sysconfig/keepalived

ExecStart=/usr/sbin/keepalived $KEEPALIVED_OPTIONS

ExecReload=/bin/kill -HUP $MAINPID

[Install]

WantedBy=multi-user.target

[root@DR01 ~]#

[root@DR01 ~]# systemctl daemon-reload

[root@DR02-BACKUP ~]#  cat /usr/lib/systemd/system/keepalived.service

[Unit]

Description=LVS and VRRP High Availability Monitor

After=syslog.target network-online.target

[Service]

Type=forking

PIDFile=/var/run/keepalived.pid

#KillMode=process  调整的这里,注释掉

EnvironmentFile=-/etc/sysconfig/keepalived

ExecStart=/usr/sbin/keepalived $KEEPALIVED_OPTIONS

ExecReload=/bin/kill -HUP $MAINPID

[Install]

WantedBy=multi-user.target

[root@DR02-BACKUP ~]#

[root@DR02-BACKUP ~]# systemctl daemon-reload

[2]日志路径更改

[root@DR01 ~]#  grep 'local0.*' /etc/rsyslog.conf

local0.*                                                /var/log/keepalived.log

[root@DR01 ~]# grep 'KEEPALIVED_OPTIONS' /etc/sysconfig/keepalived

KEEPALIVED_OPTIONS="-D -d -S 0"

[root@DR01 ~]# systemctl start rsyslog

[root@DR01 ~]#  systemctl status rsyslog

● rsyslog.service - System Logging Service

  Loaded: loaded (/usr/lib/systemd/system/rsyslog.service; enabled; vendor preset: enabled)

  Active: active (running) since Mon 2020-08-03 13:49:07 CST; 1h 9min ago

    Docs: man:rsyslogd(8)

          http://www.rsyslog.com/doc/

Main PID: 999 (rsyslogd)

  CGroup: /system.slice/rsyslog.service

          └─999 /usr/sbin/rsyslogd -n

Aug 03 13:49:07 DR01 systemd[1]: Starting System Logging Service...

Aug 03 13:49:07 DR01 rsyslogd[999]:  [origin software="rsyslogd" swVersion="8.24.0-38.el7" x-pid="999" x-info="http://www.rsyslog.com"] start

Aug 03 13:49:07 DR01 systemd[1]: Started System Logging Service.

[root@DR01 ~]# systemctl enable rsyslog

[root@DR01 ~]#

[root@DR02-BACKUP ~]# grep 'local0.*' /etc/rsyslog.conf

local0.*                                                /var/log/keepalived.log

[root@DR02-BACKUP ~]# grep 'KEEPALIVED_OPTIONS' /etc/sysconfig/keepalived

KEEPALIVED_OPTIONS="-D -d -S 0"

[root@DR02-BACKUP ~]# systemctl start rsyslog

[root@DR02-BACKUP ~]# systemctl status rsyslog

● rsyslog.service - System Logging Service

  Loaded: loaded (/usr/lib/systemd/system/rsyslog.service; enabled; vendor preset: enabled)

  Active: active (running) since Mon 2020-08-03 12:17:59 CST; 2h 37min ago

    Docs: man:rsyslogd(8)

          http://www.rsyslog.com/doc/

Main PID: 999 (rsyslogd)

  CGroup: /system.slice/rsyslog.service

          └─999 /usr/sbin/rsyslogd -n

Aug 03 12:17:59 DR02-BACKUP systemd[1]: Starting System Logging Service...

Aug 03 12:17:59 DR02-BACKUP rsyslogd[999]:  [origin software="rsyslogd" swVersion="8.24.0-38.el7" x-pid="999" x-info="http://www.rsyslog.com"] start

Aug 03 12:17:59 DR02-BACKUP systemd[1]: Started System Logging Service.

[root@DR02-BACKUP ~]# systemctl enable rsyslog

[root@DR02-BACKUP ~]#

5.nginx的安装以便于测试

执行机器:RS01与RS02

[root@RS01 wordpress]# yum install -y nginx

[root@RS01 opt]# curl http://192.168.43.92/wordpress/index.html

This is RS01!!

[root@RS02 wordpress]# yum install -y nginx

[root@RS02 opt]# curl http://192.168.43.93/wordpress/index.html

This is RS02!!


(二)服务的启动与自启

1.keepalived添加开机自启

[root@DR01 ~]# systemctl start keepalived

[root@DR01 ~]# systemctl enable keepalived

[root@DR02 ~]# systemctl start keepalived

[root@DR02 ~]# systemctl enable keepalived

2.nginx添加开机自启

[root@RS01 opt]# systemctl start nginx

[root@RS01 opt]# systemctl enable nginx

[root@RS02 opt]# systemctl start nginx

[root@RS02 opt]# systemctl enable nginx


(三)配置完成后的分析与观察

DR01与DR02-BACKUP的情况:

观察vip的产生及负载均衡情况:

[root@DR01 /]# ip a

1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000

    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

    inet 127.0.0.1/8 scope host lo

      valid_lft forever preferred_lft forever

    inet6 ::1/128 scope host

      valid_lft forever preferred_lft forever

2: ens33: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000

    link/ether 00:0c:29:09:5e:dd brd ff:ff:ff:ff:ff:ff

    inet 192.168.131.90/24 brd 192.168.131.255 scope global ens33

      valid_lft forever preferred_lft forever

    inet 192.168.131.190/32 scope global ens33  # 观察:产生VIP

      valid_lft forever preferred_lft forever

    inet6 fe80::20c:29ff:fe09:5edd/64 scope link

      valid_lft forever preferred_lft forever

3: ens37: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000

    link/ether 00:0c:29:09:5e:e7 brd ff:ff:ff:ff:ff:ff

    inet 192.168.43.90/24 brd 192.168.43.255 scope global ens37

      valid_lft forever preferred_lft forever

    inet 192.168.43.199/32 scope global ens37  # 观察:产生VIP

      valid_lft forever preferred_lft forever

    inet6 fe80::20c:29ff:fe09:5ee7/64 scope link

      valid_lft forever preferred_lft forever

[root@DR01 /]# ipvsadm -Ln

IP Virtual Server version 1.2.1 (size=4096)

Prot LocalAddress:Port Scheduler Flags

  -> RemoteAddress:Port          Forward Weight ActiveConn InActConn

TCP  192.168.43.199:80 rr

  -> 192.168.131.92:80            Masq    10    0          0

  -> 192.168.131.93:80            Masq    10    0          0

[root@DR01 /]#

[root@DR02-BACKUP keepalived]# ip a

1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000

    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

    inet 127.0.0.1/8 scope host lo

      valid_lft forever preferred_lft forever

    inet6 ::1/128 scope host

      valid_lft forever preferred_lft forever

2: ens33: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000

    link/ether 00:0c:29:e4:23:8e brd ff:ff:ff:ff:ff:ff

    inet 192.168.131.91/24 brd 192.168.131.255 scope global ens33

      valid_lft forever preferred_lft forever

    inet6 fe80::20c:29ff:fee4:238e/64 scope link

      valid_lft forever preferred_lft forever

3: ens37: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000

    link/ether 00:0c:29:e4:23:98 brd ff:ff:ff:ff:ff:ff

    inet 192.168.43.91/24 brd 192.168.43.255 scope global ens37

      valid_lft forever preferred_lft forever

    inet6 fe80::20c:29ff:fee4:2398/64 scope link

      valid_lft forever preferred_lft forever

[root@DR02-BACKUP keepalived]# ipvsadm -Ln

IP Virtual Server version 1.2.1 (size=4096)

Prot LocalAddress:Port Scheduler Flags

  -> RemoteAddress:Port          Forward Weight ActiveConn InActConn

TCP  192.168.43.199:80 rr

  -> 192.168.131.92:80            Masq    10    0          0

  -> 192.168.131.93:80            Masq    10    0          0

[root@DR02-BACKUP keepalived]#


(四)测试

我们在IP为192.168.43.110的客户端进行测试调度情况:

[root@harbor ~]# while true ; do  curl http://192.168.43.199/wordpress/index.html ; sleep 2; done

This is RS01!!

This is RS02!!

This is RS01!!

This is RS02!!

This is RS01!!

This is RS02!!

This is RS01!!

This is RS02!!

This is RS01!!

This is RS02!!

^C


(五)故障模拟及日志分析

1.模拟DR01关闭keepalived服务

DR01分析:

[root@DR01 /]# systemctl stop keepalived

[root@DR01 /]# ipvsadm -Ln

IP Virtual Server version 1.2.1 (size=4096)

Prot LocalAddress:Port Scheduler Flags

  -> RemoteAddress:Port          Forward Weight ActiveConn InActConn

[root@DR01 /]# tail -f /var/log/keepalived.log

Aug  3 21:25:27 DR01 Keepalived[2801]: Stopping

Aug  3 21:25:27 DR01 Keepalived_healthcheckers[2802]: Removing service [192.168.131.92]:80 from VS [192.168.43.199]:80

Aug  3 21:25:27 DR01 Keepalived_healthcheckers[2802]: Removing service [192.168.131.93]:80 from VS [192.168.43.199]:80

Aug  3 21:25:27 DR01 Keepalived_healthcheckers[2802]: Stopped    # 已经关闭

Aug  3 21:25:27 DR01 Keepalived_vrrp[2803]: VRRP_Instance(VI_1) sent 0 priority

Aug  3 21:25:27 DR01 Keepalived_vrrp[2803]: VRRP_Instance(VI_1) removing protocol VIPs.

Aug  3 21:25:27 DR01 Keepalived_vrrp[2803]: VRRP_Instance(LAN_GATEWAY) sent 0 priority

Aug  3 21:25:27 DR01 Keepalived_vrrp[2803]: VRRP_Instance(LAN_GATEWAY) removing protocol VIPs.

Aug  3 21:25:28 DR01 Keepalived_vrrp[2803]: Stopped

Aug  3 21:25:28 DR01 Keepalived[2801]: Stopped Keepalived v1.3.5 (03/19,2017), git commit v1.3.5-6-g6fa32f2

[root@DR01 /]# ip a  # vip发生漂移

1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000

    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

    inet 127.0.0.1/8 scope host lo

      valid_lft forever preferred_lft forever

    inet6 ::1/128 scope host

      valid_lft forever preferred_lft forever

2: ens33: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000

    link/ether 00:0c:29:09:5e:dd brd ff:ff:ff:ff:ff:ff

    inet 192.168.131.90/24 brd 192.168.131.255 scope global ens33

      valid_lft forever preferred_lft forever

    inet6 fe80::20c:29ff:fe09:5edd/64 scope link

      valid_lft forever preferred_lft forever

3: ens37: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000

    link/ether 00:0c:29:09:5e:e7 brd ff:ff:ff:ff:ff:ff

    inet 192.168.43.90/24 brd 192.168.43.255 scope global ens37

      valid_lft forever preferred_lft forever

    inet6 fe80::20c:29ff:fe09:5ee7/64 scope link

      valid_lft forever preferred_lft forever

[root@DR01 /]#

DR02-BACKUP分析:

[root@DR02-BACKUP keepalived]# ipvsadm -Ln

IP Virtual Server version 1.2.1 (size=4096)

Prot LocalAddress:Port Scheduler Flags

  -> RemoteAddress:Port          Forward Weight ActiveConn InActConn

TCP  192.168.43.199:80 rr

  -> 192.168.131.92:80            Masq    10    0          0

  -> 192.168.131.93:80            Masq    10    0          0

[root@DR02-BACKUP keepalived]# ip a

1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000

    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

    inet 127.0.0.1/8 scope host lo

      valid_lft forever preferred_lft forever

    inet6 ::1/128 scope host

      valid_lft forever preferred_lft forever

2: ens33: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000

    link/ether 00:0c:29:e4:23:8e brd ff:ff:ff:ff:ff:ff

    inet 192.168.131.91/24 brd 192.168.131.255 scope global ens33

      valid_lft forever preferred_lft forever

    inet 192.168.131.190/32 scope global ens33    # VIP漂移过来

      valid_lft forever preferred_lft forever

    inet6 fe80::20c:29ff:fee4:238e/64 scope link

      valid_lft forever preferred_lft forever

3: ens37: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000

    link/ether 00:0c:29:e4:23:98 brd ff:ff:ff:ff:ff:ff

    inet 192.168.43.91/24 brd 192.168.43.255 scope global ens37

      valid_lft forever preferred_lft forever

    inet 192.168.43.199/32 scope global ens37      # VIP漂移过来

      valid_lft forever preferred_lft forever

    inet6 fe80::20c:29ff:fee4:2398/64 scope link

      valid_lft forever preferred_lft forever

[root@DR02-BACKUP keepalived]#

[root@DR02-BACKUP ~]# tail -f /var/log/keepalived.log

Aug  3 21:25:28 DR02-BACKUP Keepalived_vrrp[2741]: VRRP_Instance(VI_1) Transition to MASTER STATE

Aug  3 21:25:28 DR02-BACKUP Keepalived_vrrp[2741]: VRRP_Instance(LAN_GATEWAY) Transition to MASTER STATE

Aug  3 21:25:29 DR02-BACKUP Keepalived_vrrp[2741]: VRRP_Instance(VI_1) Entering MASTER STATE

Aug  3 21:25:29 DR02-BACKUP Keepalived_vrrp[2741]: VRRP_Instance(VI_1) setting protocol VIPs.

Aug  3 21:25:29 DR02-BACKUP Keepalived_vrrp[2741]: Sending gratuitous ARP on ens37 for 192.168.43.199

Aug  3 21:25:29 DR02-BACKUP Keepalived_vrrp[2741]: VRRP_Instance(VI_1) Sending/queueing gratuitous ARPs on ens37 for 192.168.43.199

Aug  3 21:25:29 DR02-BACKUP Keepalived_vrrp[2741]: Sending gratuitous ARP on ens37 for 192.168.43.199

Aug  3 21:25:29 DR02-BACKUP Keepalived_vrrp[2741]: Sending gratuitous ARP on ens37 for 192.168.43.199

Aug  3 21:25:29 DR02-BACKUP Keepalived_vrrp[2741]: Sending gratuitous ARP on ens37 for 192.168.43.199

Aug  3 21:25:29 DR02-BACKUP Keepalived_vrrp[2741]: Sending gratuitous ARP on ens37 for 192.168.43.199

Aug  3 21:25:29 DR02-BACKUP Keepalived_vrrp[2741]: VRRP_Instance(LAN_GATEWAY) Entering MASTER STATE

Aug  3 21:25:29 DR02-BACKUP Keepalived_vrrp[2741]: VRRP_Instance(LAN_GATEWAY) setting protocol VIPs.

Aug  3 21:25:29 DR02-BACKUP Keepalived_vrrp[2741]: Sending gratuitous ARP on ens33 for 192.168.131.190

Aug  3 21:25:29 DR02-BACKUP Keepalived_vrrp[2741]: VRRP_Instance(LAN_GATEWAY) Sending/queueing gratuitous ARPs on ens33 for 192.168.131.190

Aug  3 21:25:29 DR02-BACKUP Keepalived_vrrp[2741]: Sending gratuitous ARP on ens33 for 192.168.131.190

Aug  3 21:25:29 DR02-BACKUP Keepalived_vrrp[2741]: Sending gratuitous ARP on ens33 for 192.168.131.190

Aug  3 21:25:29 DR02-BACKUP Keepalived_vrrp[2741]: Sending gratuitous ARP on ens33 for 192.168.131.190

Aug  3 21:25:29 DR02-BACKUP Keepalived_vrrp[2741]: Sending gratuitous ARP on ens33 for 192.168.131.190

Aug  3 21:25:34 DR02-BACKUP Keepalived_vrrp[2741]: Sending gratuitous ARP on ens37 for 192.168.43.199

Aug  3 21:25:34 DR02-BACKUP Keepalived_vrrp[2741]: VRRP_Instance(VI_1) Sending/queueing gratuitous ARPs on ens37 for 192.168.43.199

Aug  3 21:25:34 DR02-BACKUP Keepalived_vrrp[2741]: Sending gratuitous ARP on ens37 for 192.168.43.199

2.模拟DR01关闭恢复开启keepalived服务

[1]DR01分析:

[root@DR01 /]# systemctl start keepalived

[root@DR01 /]# ipvsadm -Ln

IP Virtual Server version 1.2.1 (size=4096)

Prot LocalAddress:Port Scheduler Flags

  -> RemoteAddress:Port          Forward Weight ActiveConn InActConn

TCP  192.168.43.199:80 rr

  -> 192.168.131.92:80            Masq    10    0          0

  -> 192.168.131.93:80            Masq    10    0          0

[root@DR01 /]# ip a

1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000

    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

    inet 127.0.0.1/8 scope host lo

      valid_lft forever preferred_lft forever

    inet6 ::1/128 scope host

      valid_lft forever preferred_lft forever

2: ens33: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000

    link/ether 00:0c:29:09:5e:dd brd ff:ff:ff:ff:ff:ff

    inet 192.168.131.90/24 brd 192.168.131.255 scope global ens33

      valid_lft forever preferred_lft forever

    inet 192.168.131.190/32 scope global ens33    # 注意:vip漂移还原

      valid_lft forever preferred_lft forever

    inet6 fe80::20c:29ff:fe09:5edd/64 scope link

      valid_lft forever preferred_lft forever

3: ens37: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000

    link/ether 00:0c:29:09:5e:e7 brd ff:ff:ff:ff:ff:ff

    inet 192.168.43.90/24 brd 192.168.43.255 scope global ens37

      valid_lft forever preferred_lft forever

    inet 192.168.43.199/32 scope global ens37      # 注意:vip漂移还原

      valid_lft forever preferred_lft forever

    inet6 fe80::20c:29ff:fe09:5ee7/64 scope link

      valid_lft forever preferred_lft forever

[root@DR01 /]#

[root@DR01 /]# tail -f /var/log/keepalived.log

Aug  3 21:30:25 DR01 Keepalived[2854]: Starting Keepalived v1.3.5 (03/19,2017), git commit v1.3.5-6-g6fa32f2

Aug  3 21:30:25 DR01 Keepalived[2854]: Opening file '/etc/keepalived/keepalived.conf'.

Aug  3 21:30:25 DR01 Keepalived[2855]: Starting Healthcheck child process, pid=2856

Aug  3 21:30:25 DR01 Keepalived[2855]: Starting VRRP child process, pid=2857

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: Initializing ipvs

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: Opening file '/etc/keepalived/keepalived.conf'.

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: ------< Global definitions >------

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: Router ID = LVS_01

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: Default interface = eth0

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: LVS flush = false

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: VRRP IPv4 mcast group = 224.0.0.18

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: VRRP IPv6 mcast group = ff02::12

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: Gratuitous ARP delay = 5

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: Gratuitous ARP repeat = 5

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: Gratuitous ARP refresh timer = 0

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: Gratuitous ARP refresh repeat = 1

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: Gratuitous ARP lower priority delay = 4294

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: Gratuitous ARP lower priority repeat = -1

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: Send advert after receive lower priority advert = true

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: Send advert after receive higher priority advert = false

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: Gratuitous ARP interval = 0

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: Gratuitous NA interval = 0

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: VRRP default protocol version = 2

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: Iptables input chain = INPUT

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: Using ipsets = true

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: ipset IPv4 address set = keepalived

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: ipset IPv6 address set = keepalived6

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: ipset IPv6 address,iface set = keepalived_if6

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: VRRP check unicast_src = false

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: VRRP skip check advert addresses = false

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: VRRP strict mode = false

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: VRRP process priority = 0

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: VRRP don't swap = false

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: Checker process priority = 0

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: Checker don't swap = false

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: SNMP keepalived disabled

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: SNMP checker disabled

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: SNMP RFCv2 disabled

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: SNMP RFCv3 disabled

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: SNMP traps disabled

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: SNMP socket = default (unix:/var/agentx/master)

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: Network namespace = (default)

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: Script security disabled

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: Default script uid:gid 0:0

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: ------< SSL definitions >------

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: Using autogen SSL context

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: ------< LVS Topology >------

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: System is compiled with LVS v1.2.1

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: VIP = 192.168.43.199, VPORT = 80

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]:  Address family = inet

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]:  delay_loop = 6, lb_algo = rr

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]:  Hashed = disabled

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]:  flag-1 = disabled

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]:  flag-2 = disabled

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]:  flag-3 = disabled

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]:  One packet scheduling = disabled

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]:  protocol = TCP

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]:  alpha is OFF, omega is OFF

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]:  quorum = 1, hysteresis = 0

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]:  lb_kind = NAT

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]:  RIP = 192.168.131.92, RPORT = 80, WEIGHT = 10

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]:  RIP = 192.168.131.93, RPORT = 80, WEIGHT = 10

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: ------< Health checkers >------

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: [192.168.131.92]:80

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]:  Keepalive method = TCP_CHECK

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]:  Connection dest = [192.168.131.92]:80

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]:  Connection timeout = 3

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]:    Retry count = 3

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]:    Retry delay = 3

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: [192.168.131.93]:80

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]:  Keepalive method = TCP_CHECK

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]:  Connection dest = [192.168.131.93]:80

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]:  Connection timeout = 3

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]:    Retry count = 3

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]:    Retry delay = 3

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: Activating healthchecker for service [192.168.43.199]:80

Aug  3 21:30:25 DR01 Keepalived_healthcheckers[2856]: Activating healthchecker for service [192.168.43.199]:80

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: Registering Kernel netlink reflector

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: Registering Kernel netlink command channel

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: Registering gratuitous ARP shared channel

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: Opening file '/etc/keepalived/keepalived.conf'.

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: VRRP_Instance(VI_1) removing protocol VIPs.

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: VRRP_Instance(LAN_GATEWAY) removing protocol VIPs.

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: ------< Global definitions >------

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: Router ID = LVS_01

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: Default interface = eth0

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: LVS flush = false

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: VRRP IPv4 mcast group = 224.0.0.18

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: VRRP IPv6 mcast group = ff02::12

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: Gratuitous ARP delay = 5

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: Gratuitous ARP repeat = 5

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: Gratuitous ARP refresh timer = 0

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: Gratuitous ARP refresh repeat = 1

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: Gratuitous ARP lower priority delay = 5

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: Gratuitous ARP lower priority repeat = 5

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: Send advert after receive lower priority advert = true

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: Send advert after receive higher priority advert = false

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: Gratuitous ARP interval = 0

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: Gratuitous NA interval = 0

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: VRRP default protocol version = 2

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: Iptables input chain = INPUT

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: Using ipsets = false

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: ipset IPv4 address set = keepalived

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: ipset IPv6 address set = keepalived6

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: ipset IPv6 address,iface set = keepalived_if6

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: VRRP check unicast_src = false

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: VRRP skip check advert addresses = false

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: VRRP strict mode = false

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: VRRP process priority = 0

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: VRRP don't swap = false

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: Checker process priority = 0

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: Checker don't swap = false

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: SNMP keepalived disabled

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: SNMP checker disabled

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: SNMP RFCv2 disabled

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: SNMP RFCv3 disabled

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: SNMP traps disabled

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: SNMP socket = default (unix:/var/agentx/master)

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: Network namespace = (default)

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: Script security disabled

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: Default script uid:gid 0:0

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: ------< VRRP Topology >------

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: VRRP Instance = VI_1

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Using VRRPv2

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Want State = MASTER

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Running on device = ens37

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Skip checking advert IP addresses = no

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Enforcing strict VRRP compliance = no

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Using src_ip = 192.168.43.90

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Gratuitous ARP delay = 5

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Gratuitous ARP repeat = 5

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Gratuitous ARP refresh timer = 0

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Gratuitous ARP refresh repeat = 1

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Gratuitous ARP lower priority delay = 5

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Gratuitous ARP lower priority repeat = 5

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Send advert after receive lower priority advert = true

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Send advert after receive higher priority advert = false

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Virtual Router ID = 51

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Priority = 100

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Advert interval = 1 sec

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Accept enabled

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Promote_secondaries disabled

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Authentication type = SIMPLE_PASSWORD

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Password = 1111

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Virtual IP = 1

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:    192.168.43.199/32 dev ens37 scope global

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: VRRP Instance = LAN_GATEWAY

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Using VRRPv2

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Want State = MASTER

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Running on device = ens33

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Skip checking advert IP addresses = no

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Enforcing strict VRRP compliance = no

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Using src_ip = 192.168.131.90

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Gratuitous ARP delay = 5

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Gratuitous ARP repeat = 5

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Gratuitous ARP refresh timer = 0

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Gratuitous ARP refresh repeat = 1

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Gratuitous ARP lower priority delay = 5

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Gratuitous ARP lower priority repeat = 5

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Send advert after receive lower priority advert = true

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Send advert after receive higher priority advert = false

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Virtual Router ID = 52

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Priority = 100

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Advert interval = 1 sec

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Accept enabled

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Promote_secondaries disabled

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Authentication type = SIMPLE_PASSWORD

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Password = 1111

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:  Virtual IP = 1

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]:    192.168.131.190/32 dev ens33 scope global

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: ------< NIC >------

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: Name = ens33

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: index = 2

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: IPv4 address = 192.168.131.90

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: IPv6 address = fe80::20c:29ff:fe09:5edd

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: MAC = 00:0c:29:09:5e:dd

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: is UP

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: is RUNNING

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: MTU = 1500

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: HW Type = ETHERNET

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: ------< NIC >------

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: Name = ens37

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: index = 3

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: IPv4 address = 192.168.43.90

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: IPv6 address = fe80::20c:29ff:fe09:5ee7

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: MAC = 00:0c:29:09:5e:e7

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: is UP

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: is RUNNING

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: MTU = 1500

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: HW Type = ETHERNET

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: Using LinkWatch kernel netlink reflector...

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: VRRP sockpool: [ifindex(3), proto(112), unicast(0), fd(10,11)]

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: VRRP sockpool: [ifindex(2), proto(112), unicast(0), fd(12,13)]

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: VRRP_Instance(VI_1) Transition to MASTER STATE

Aug  3 21:30:25 DR01 Keepalived_vrrp[2857]: VRRP_Instance(LAN_GATEWAY) Transition to MASTER STATE

Aug  3 21:30:26 DR01 Keepalived_vrrp[2857]: VRRP_Instance(VI_1) Entering MASTER STATE

Aug  3 21:30:26 DR01 Keepalived_vrrp[2857]: VRRP_Instance(VI_1) setting protocol VIPs.

Aug  3 21:30:26 DR01 Keepalived_vrrp[2857]: Sending gratuitous ARP on ens37 for 192.168.43.199

Aug  3 21:30:26 DR01 Keepalived_vrrp[2857]: VRRP_Instance(VI_1) Sending/queueing gratuitous ARPs on ens37 for 192.168.43.199

Aug  3 21:30:26 DR01 Keepalived_vrrp[2857]: Sending gratuitous ARP on ens37 for 192.168.43.199

Aug  3 21:30:26 DR01 Keepalived_vrrp[2857]: Sending gratuitous ARP on ens37 for 192.168.43.199

Aug  3 21:30:26 DR01 Keepalived_vrrp[2857]: Sending gratuitous ARP on ens37 for 192.168.43.199

Aug  3 21:30:26 DR01 Keepalived_vrrp[2857]: Sending gratuitous ARP on ens37 for 192.168.43.199

Aug  3 21:30:26 DR01 Keepalived_vrrp[2857]: VRRP_Instance(LAN_GATEWAY) Entering MASTER STATE

Aug  3 21:30:26 DR01 Keepalived_vrrp[2857]: VRRP_Instance(LAN_GATEWAY) setting protocol VIPs.

Aug  3 21:30:26 DR01 Keepalived_vrrp[2857]: Sending gratuitous ARP on ens33 for 192.168.131.190

Aug  3 21:30:26 DR01 Keepalived_vrrp[2857]: VRRP_Instance(LAN_GATEWAY) Sending/queueing gratuitous ARPs on ens33 for 192.168.131.190

Aug  3 21:30:26 DR01 Keepalived_vrrp[2857]: Sending gratuitous ARP on ens33 for 192.168.131.190

Aug  3 21:30:26 DR01 Keepalived_vrrp[2857]: Sending gratuitous ARP on ens33 for 192.168.131.190

Aug  3 21:30:26 DR01 Keepalived_vrrp[2857]: Sending gratuitous ARP on ens33 for 192.168.131.190

Aug  3 21:30:26 DR01 Keepalived_vrrp[2857]: Sending gratuitous ARP on ens33 for 192.168.131.190

Aug  3 21:30:31 DR01 Keepalived_vrrp[2857]: Sending gratuitous ARP on ens37 for 192.168.43.199

Aug  3 21:30:31 DR01 Keepalived_vrrp[2857]: VRRP_Instance(VI_1) Sending/queueing gratuitous ARPs on ens37 for 192.168.43.199

Aug  3 21:30:31 DR01 Keepalived_vrrp[2857]: Sending gratuitous ARP on ens37 for 192.168.43.199

Aug  3 21:30:31 DR01 Keepalived_vrrp[2857]: Sending gratuitous ARP on ens37 for 192.168.43.199

Aug  3 21:30:31 DR01 Keepalived_vrrp[2857]: Sending gratuitous ARP on ens37 for 192.168.43.199

Aug  3 21:30:31 DR01 Keepalived_vrrp[2857]: Sending gratuitous ARP on ens37 for 192.168.43.199

Aug  3 21:30:31 DR01 Keepalived_vrrp[2857]: Sending gratuitous ARP on ens33 for 192.168.131.190

Aug  3 21:30:31 DR01 Keepalived_vrrp[2857]: VRRP_Instance(LAN_GATEWAY) Sending/queueing gratuitous ARPs on ens33 for 192.168.131.190

Aug  3 21:30:31 DR01 Keepalived_vrrp[2857]: Sending gratuitous ARP on ens33 for 192.168.131.190

Aug  3 21:30:31 DR01 Keepalived_vrrp[2857]: Sending gratuitous ARP on ens33 for 192.168.131.190

[root@DR02-BACKUP ~]# tail -f /var/log/keepalived.log

Aug  3 21:30:25 DR02-BACKUP Keepalived_vrrp[2741]: VRRP_Instance(VI_1) Received advert with higher priority 100, ours 90

Aug  3 21:30:25 DR02-BACKUP Keepalived_vrrp[2741]: VRRP_Instance(VI_1) Entering BACKUP STATE

Aug  3 21:30:25 DR02-BACKUP Keepalived_vrrp[2741]: VRRP_Instance(VI_1) removing protocol VIPs.

Aug  3 21:30:25 DR02-BACKUP Keepalived_vrrp[2741]: VRRP_Instance(LAN_GATEWAY) Received advert with higher priority 100, ours 90

Aug  3 21:30:25 DR02-BACKUP Keepalived_vrrp[2741]: VRRP_Instance(LAN_GATEWAY) Entering BACKUP STATE

Aug  3 21:30:25 DR02-BACKUP Keepalived_vrrp[2741]: VRRP_Instance(LAN_GATEWAY) removing protocol VIPs

3.模拟RS01上nginx关闭时的情况

[root@RS02 opt]# systemctl stop nginx

[root@RS02 opt]#

[root@DR01 /]# ipvsadm -Ln

IP Virtual Server version 1.2.1 (size=4096)

Prot LocalAddress:Port Scheduler Flags

  -> RemoteAddress:Port          Forward Weight ActiveConn InActConn

TCP  192.168.43.199:80 rr

  -> 192.168.131.92:80            Masq    10    0          0

  # 同样被移除

[root@DR01 ~]# tail -f /var/log/keepalived.log

Aug  3 21:33:58 DR01 Keepalived_healthcheckers[2856]: TCP connection to [192.168.131.93]:80 failed.

Aug  3 21:34:01 DR01 Keepalived_healthcheckers[2856]: TCP connection to [192.168.131.93]:80 failed.

Aug  3 21:34:04 DR01 Keepalived_healthcheckers[2856]: TCP connection to [192.168.131.93]:80 failed.

Aug  3 21:34:07 DR01 Keepalived_healthcheckers[2856]: TCP connection to [192.168.131.93]:80 failed.

Aug  3 21:34:07 DR01 Keepalived_healthcheckers[2856]: Check on service [192.168.131.93]:80 failed after 3 retry.

Aug  3 21:34:07 DR01 Keepalived_healthcheckers[2856]: Removing service [192.168.131.93]:80 from VS [192.168.43.199]:80

[root@DR02-BACKUP ~]# tail -f /var/log/keepalived.log

Aug  3 21:33:58 DR02-BACKUP Keepalived_healthcheckers[2856]: TCP connection to [192.168.131.93]:80 failed.

Aug  3 21:34:01 DR02-BACKUP Keepalived_healthcheckers[2856]: TCP connection to [192.168.131.93]:80 failed.

Aug  3 21:34:04 DR02-BACKUP Keepalived_healthcheckers[2856]: TCP connection to [192.168.131.93]:80 failed.

Aug  3 21:34:07 DR02-BACKUP Keepalived_healthcheckers[2856]: TCP connection to [192.168.131.93]:80 failed.

Aug  3 21:34:07 DR02-BACKUP Keepalived_healthcheckers[2856]: Check on service [192.168.131.93]:80 failed after 3 retry.

Aug  3 21:34:07 DR02-BACKUP Keepalived_healthcheckers[2856]: Removing service [192.168.131.93]:80 from VS [192.168.43.199]:80

[root@DR02-BACKUP keepalived]# ipvsadm -Ln

IP Virtual Server version 1.2.1 (size=4096)

Prot LocalAddress:Port Scheduler Flags

  -> RemoteAddress:Port          Forward Weight ActiveConn InActConn

TCP  192.168.43.199:80 rr

  -> 192.168.131.92:80            Masq    10    0          0

[root@DR02-BACKUP keepalived]#

[root@harbor ~]# while true ; do  curl http://192.168.43.199/wordpress/index.html ; sleep 2; done

This is RS01!!

This is RS01!!

This is RS01!!

This is RS01!!

This is RS01!!

^C

[root@harbor ~]#

你可能感兴趣的:(LVS之NAT + keepalived 模式配置文档)