h3c vrrp怎么设置成非抢占模式

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了h3c vrrp怎么设置成非抢占模式相关的知识,希望对你有一定的参考价值。

参考技术A undo vrrp vrid preempt-mode
即可
不抢占的意思 是 无论backup优先级比master高 在建立起来后 是不会去成为master的 只有当master down了后 才会成为master
参考技术B 百度里面有很多,其实没必要,一般很少出现问题

keepalived-vrrp-非抢占模式(nopreempt)

1.两台主机都设置为BACKUP模式

[root@localhost keepalived1]# cat keepalived.conf

! Configuration File for keepalived

global_defs

  notification_email

    acassen@firewall.loc

    failover@firewall.loc

    sysadmin@firewall.loc

 

  notification_email_from Alexandre.Cassen@firewall.loc

  smtp_server 192.168.200.1

  smtp_connect_timeout 30

  router_id LVS_DEVEL

  vrrp_skip_check_adv_addr

  vrrp_iptables     

  vrrp_strict

  vrrp_garp_interval 0

  vrrp_gna_interval 0


vrrp_instance VIP1

   state BACKUP   #BACKUP模式

   interface ens192

   virtual_router_id 51

   priority 100

   nopreempt  #非抢占模式

   advert_int 1

   authentication

       auth_type PASS

       auth_pass 1111

   

   virtual_ipaddress

       172.16.116.99 dev ens192 label ens192:0

   

[root@localhost keepalived1]#


[root@localhost keepalived2]# cat keepalived.conf

! Configuration File for keepalived

global_defs

  notification_email

    acassen@firewall.loc

    failover@firewall.loc

    sysadmin@firewall.loc

 

  notification_email_from Alexandre.Cassen@firewall.loc

  smtp_server 192.168.200.1

  smtp_connect_timeout 30

  router_id LVS_DEVEL

  vrrp_skip_check_adv_addr

  vrrp_iptables

  vrrp_strict

  vrrp_garp_interval 0

  vrrp_gna_interval 0

vrrp_instance VIP1

   state BACKUP

   interface ens192

   virtual_router_id 51

   priority 90

   nopreempt          #非抢占模式

   advert_int 1

   authentication

       auth_type PASS

       auth_pass 1111

   

   virtual_ipaddress

       172.16.116.99 dev ens192 label ens192:0

   

[root@localhost keepalived2]# 


验证结果:

[root@localhost keepalived1]#systemctl stop keepalived

[root@localhost keepalived1]#ip  add

1: lo: <LOOPBACK,UP,LOWER_UP> 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: ens192: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000

   link/ether 00:50:56:95:c0:20 brd ff:ff:ff:ff:ff:ff

   inet 172.16.116.91/24 brd 172.16.116.255 scope global noprefixroute ens192

      valid_lft forever preferred_lft forever

   inet6 fe80::8f54:3d46:7596:9ff2/64 scope link noprefixroute  

      valid_lft forever preferred_lft forever

[root@localhost keepalived2]# ip add

1: lo: <LOOPBACK,UP,LOWER_UP> 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: ens192: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000

   link/ether 00:50:56:95:06:4e brd ff:ff:ff:ff:ff:ff

   inet 172.16.116.92/24 brd 172.16.116.255 scope global noprefixroute ens192

      valid_lft forever preferred_lft forever

   inet 172.16.116.99/32 scope global ens192:0

      valid_lft forever preferred_lft forever

   inet6 fe80::d0a1:6048:8a33:73be/64 scope link noprefixroute  

      valid_lft forever preferred_lft forever

[root@localhost keepalived1]#systemctl start keepalived    #重启开启主机1的服务,确认vip会发生漂移不?

[root@localhost keepalived]# tcpdump -i ens192 -nn host 224.0.0.18      #组播模式,默认组播地址为224.0.0.18

tcpdump: verbose output suppressed, use -v or -vv for full protocol decode

listening on ens192, link-type EN10MB (Ethernet), capture size 262144 bytes

16:10:04.450719 IP 172.16.116.92 > 224.0.0.18: VRRPv2, Advertisement, vrid 51, prio 90, authtype simple, intvl 1s, length 20

16:10:05.451816 IP 172.16.116.92 > 224.0.0.18: VRRPv2, Advertisement, vrid 51, prio 90, authtype simple, intvl 1s, length 20

16:10:06.452915 IP 172.16.116.92 > 224.0.0.18: VRRPv2, Advertisement, vrid 51, prio 90, authtype simple, intvl 1s, length 20

16:10:07.454039 IP 172.16.116.92 > 224.0.0.18: VRRPv2, Advertisement, vrid 51, prio 90, authtype simple, intvl 1s, length 20

16:10:08.455124 IP 172.16.116.92 > 224.0.0.18: VRRPv2, Advertisement, vrid 51, prio 90, authtype simple, intvl 1s, length 20

16:10:09.456199 IP 172.16.116.92 > 224.0.0.18: VRRPv2, Advertisement, vrid 51, prio 90, authtype simple, intvl 1s, length 20



以上是关于h3c vrrp怎么设置成非抢占模式的主要内容,如果未能解决你的问题,请参考以下文章

H3C防火墙怎么设置

keepalived绑定单播地址非抢占模式及LVS的TCP模式的高可用

h3c wa2620i-agn怎么无线桥接

h3c交换机怎么设置

Keepalived VRRP-Script抢占延迟VIP单播详解

VRRP单备份