我处于需要在同一接口上设置2个VRRP实例的情况。 我需要做到这一点,因为rsyslogd和elasticsearch需要使用接口eth0进行networking通信。
这篇文章似乎是一个类似的没有提到有关configuration,所以我决定问一个问题。
我在下面创build了一个configuration,但是在不同的主机上创build了两个主设备。
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 } }
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 } }
login备份端显示两个实例首先启动,但ES_1不反映到操作系统的IP设置。
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
我的IP地址命令结果。
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
是否可以在同一个接口上configuration多个VRRP实例?
我的平台信息如下。
[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
我没有右括号'}'chk_es