keepalived - Como você define as instâncias de VRRP de vários tipos na mesma interface?

2

Estou em uma situação em que preciso definir duas instâncias de VRRP na mesma interface. Eu preciso conseguir isso porque rsyslogd e elasticsearch precisam usar a interface eth0 para comunicação de rede.

Este post parecia ser um similar não mencionou a configuração, então decidi fazer uma pergunta.

Eu criei uma configuração abaixo, mas dois mestres são criados em hosts diferentes.

Configuração do lado mestre

vrrp_script chk_rsyslog {
  script "netstat -atunp | grep rsyslogd | grep '0.0.0.0:514' &>/dev/null"
  interval 2 # every 2 seconds
  weight 2 # add 2 points if OK
}

vrrp_script chk_es {
  script "netstat -atunp | grep java | grep '192.168.21.14:9300' &>/dev/null"
  interval 2 # every 2 seconds
  weight 2 # add 2 points if OK

vrrp_instance RH_1 {
    state MASTER
    interface eth0
    virtual_router_id 50
    priority 10
    advert_int 1
    virtual_ipaddress {
        192.168.11.250/24
    }

    track_script {
      chk_rsyslog
    }
}

vrrp_instance ES_1 {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 10
    advert_int 1
    virtual_ipaddress {
        192.168.11.251/24
    }

    track_script {
      chk_es
    }
}

Configuração do lado do backup

vrrp_script chk_rsyslog {
  script "netstat -atunp | grep rsyslogd | grep '0.0.0.0:514' &>/dev/null"
  interval 2 # every 2 seconds
  weight 2 # add 2 points if OK
}

vrrp_script chk_es {
  script "netstat -atunp | grep java | grep '192.168.21.15:9300' &>/dev/null"
  interval 2 # every 2 seconds
  weight 2 # add 2 points if OK
}

vrrp_instance RH_1 {
    state BACKUP
    interface eth0
    virtual_router_id 50
    priority 9
    advert_int 1
    virtual_ipaddress {
        192.168.11.250/24
    }

    track_script {
      chk_rsyslog
    }
}

vrrp_instance ES_1 {
    state BACKUP
    interface eth0
    virtual_router_id 51
    priority 9
    advert_int 1
    virtual_ipaddress {
        192.168.11.251/24
    }

    track_script {
      chk_es
    }
}

Efetuar logon no lado do backup mostra que ambas as instâncias são iniciadas, mas ES_1 não é refletido na configuração de ip para os.

Apr 19 08:49:54 rhel2 Keepalived_vrrp[23321]: Netlink reflector reports IP 192.168.11.15 added
Apr 19 08:49:54 rhel2 Keepalived_vrrp[23321]: Netlink reflector reports IP 192.168.21.15 added
Apr 19 08:49:54 rhel2 Keepalived_vrrp[23321]: Netlink reflector reports IP fe80::ab04:d4e4:841e:e3e1 added
Apr 19 08:49:54 rhel2 Keepalived_vrrp[23321]: Netlink reflector reports IP fe80::812:1dd8:9ed1:a6af added
Apr 19 08:49:54 rhel2 Keepalived_vrrp[23321]: Registering Kernel netlink reflector
Apr 19 08:49:54 rhel2 Keepalived_vrrp[23321]: Registering Kernel netlink command channel
Apr 19 08:49:54 rhel2 Keepalived_vrrp[23321]: Registering gratuitous ARP shared channel
Apr 19 08:49:54 rhel2 Keepalived_vrrp[23321]: Opening file '/etc/keepalived/keepalived.conf'.
Apr 19 08:49:54 rhel2 Keepalived_vrrp[23321]: Configuration is using : 69267 Bytes
Apr 19 08:49:54 rhel2 Keepalived_vrrp[23321]: Using LinkWatch kernel netlink reflector...
Apr 19 08:49:54 rhel2 Keepalived_vrrp[23321]: VRRP_Instance(RH_1) Entering BACKUP STATE
Apr 19 08:49:54 rhel2 Keepalived_vrrp[23321]: VRRP_Instance(ES_1) Entering BACKUP STATE
Apr 19 08:49:54 rhel2 Keepalived_vrrp[23321]: VRRP sockpool: [ifindex(2), proto(112), unicast(0), fd(10,11)]
Apr 19 08:49:54 rhel2 Keepalived_healthcheckers[23320]: Configuration is using : 7722 Bytes
Apr 19 08:49:54 rhel2 Keepalived_healthcheckers[23320]: Using LinkWatch kernel netlink reflector...
Apr 19 08:49:54 rhel2 Keepalived_vrrp[23321]: VRRP_Script(chk_rsyslog) succeeded
Apr 19 08:49:58 rhel2 Keepalived_vrrp[23321]: VRRP_Instance(RH_1) Transition to MASTER STATE

Meu resultado do comando ip addr.

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 52:54:00:12:0e:da brd ff:ff:ff:ff:ff:ff
    inet 192.168.11.15/24 brd 192.168.11.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet 192.168.11.250/24 scope global secondary eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::ab04:d4e4:841e:e3e1/64 scope link
       valid_lft forever preferred_lft forever

É possível definir várias instâncias de VRRP na mesma interface?

As informações da minha plataforma estão abaixo.

[root@rhel2 keepalived]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.3 (Maipo)
[root@rhel2 keepalived]# rpm -qa | grep keepalived
keepalived-1.2.13-8.el7.x86_64
    
por Yu Watanabe 19.04.2017 / 02:37

1 resposta

1

Eu não tinha colchete de fechamento '}' para chk_es

    
por 20.04.2017 / 14:22