Keepalived-双方均设置了Master

Keepalived-双方均设置了Master

描述错误 我正在尝试创建一个主从设置,但主服务器已在两侧设置。我在 keepalived.log 上看到很多这样的消息 Aug 5 21:00:03 CENVLIFEPROXB Keepalived_vrrp[3983]: (VI_1) Received advert from 10.200.6.22 with lower priority 150, ours 200, forcing new election

预期行为 一个服务器为主服务器,另一个服务器为从服务器

Keepalived 版本 2.2.4 keepalived -v Keepalived v2.2.4 (08/21,2021)的输出

版权所有 (C) 2001-2021 Alexandre Cassen,[电子邮件保护]

使用适用于 Linux 4.19.194 的内核头文件构建 在 Linux 4.19.0-17-amd64 上运行 #1 SMP Debian 4.19.194-3 (2021-07-18) 发行版:Debian GNU/Linux 10 (buster)

配置选项:--build=x86_64-linux-gnu --prefix=/usr --includedir=/include --mandir=/share/man --infodir=/share/info --sysconfdir=/etc --localstatedir=/var --disable-silent-rules --libdir=/lib/x86_64-linux-gnu --libexecdir=/lib/x86_64-linux-gnu --runstatedir=/run --disable-maintainer-mode --enable-snmp --enable-sha1 --enable-snmp-rfcv2 --enable-snmp-rfcv3 --enable-dbus --enable-dbus-create-instance --enable-json --enable-bfd --disable-systemd build_alias=x86_64-linux-gnu

配置选项:LVS VRRP VRRP_AUTH VRRP_VMAC JSON BFD OLD_CHKSUM_COMPAT SNMP_V3_FOR_V2 SNMP_VRRP SNMP_CHECKER SNMP_RFCV2 SNMP_RFCV3 DBUS DBUS_CREATE_INSTANCE INIT=SYSV

系统选项:VSYSLOG MEMFD_CREATE IPV4_DEVCONF LIBNL3 RTA_ENCAP RTA_EXPIRES RTA_NEWDST RTA_PREF FRA_SUPPRESS_PREFIXLEN FRA_SUPPRESS_IFGROUP FRA_TUN_ID RTAX_CC_ALGO RTAX_QUICKACK RTEXT_FILTER_SKIP_STATS FRA_L3MDEV FRA_UID_RANGE RTAX_FASTOPEN_NO_COOKIE RTA_VIA FRA_PROTOCOL FRA_IP_PROTO FRA_SPORT_RANGE FRA_DPORT_RANGE RTA_TTL_PROPAGATE IFA_FLAGS LWTUNNEL_ENCAP_MPLS LWTUNNEL_ENCAP_ILA IPTABLES NET_LINUX_IF_H_COLLISION LIBIPVS_NETLINK IPVS_DEST_ATTR_ADDR_FAMILY IPVS_SYNCD_ATTRIBUTES IPVS_64BIT_STATS VRRP_IPVLAN IFLA_LINK_NETNSID GLOB_BRACE GLOB_ALTDIRFUNC INET6_ADDR_GEN_MODE VRF SO_MARK

发行版(请填写以下信息):

  • 名称:Debian
  • 版本:10.10
  • 建筑:64

配置文件: 掌握

global_defs {
   max_auto_priority
}
vrrp_script chk_vi_1 {
   script "/etc/keepalived/keepalived-health-checks-1.sh"
   interval 2
   fall 1
   rise 1
   timeout 3
}

! vrrp_primary_node for cenvlifeproxb.aminerals.cl
vrrp_instance VI_1 {
   state MASTER
   interface eth0
   virtual_router_id 30
   priority 200
   advert_int 1
   virtual_ipaddress {
     10.200.6.26/24 dev eth0 label eth0:1
   }
   track_script {
     chk_vi_1
   }
   notify "/etc/keepalived/keepalived-state.sh"
}

奴隶

global_defs {
   max_auto_priority
}
vrrp_script chk_vi_1 {
   script "/etc/keepalived/keepalived-health-checks-1.sh"
   interval 2
   fall 1
   rise 1
   timeout 3
}

! vrrp_primary_node for cenvlifeproxa.aminerals.cl
vrrp_instance VI_1 {
   state BACKUP
   interface eth0
   virtual_router_id 30
   priority 150
   advert_int 1
   virtual_ipaddress {
     10.200.6.26/24 dev eth0 label eth0:1
   }
   track_script {
     chk_vi_1
   }
   notify "/etc/keepalived/keepalived-state.sh"
}

通知和跟踪脚本 通知脚本

#!/bin/sh
### BEGIN INIT INFO
# Provides:         keepalived-server
# Required-Start:    $local_fs $syslog
# Required-Stop:     $local_fs $syslog
# Should-Start:
# Should-Stop:
# Default-Start:     3 4 5
# Default-Stop:      0 1 6
# Short-Description: keepalived server
# chkconfig: - 80 75
# description: keepalived server
### END INIT INFO
/usr/bin/php /usr/share/artica-postfix/exec.keepalived-state.php --state $1 $2 $3

轨迹脚本

#!/bin/bash
### BEGIN INIT INFO
# Provides:         keepalived-health-checks-1
### END INIT INFO

### BEGIN Proxy INFO
Proxy_id=$(/bin/pidof squid)
if [[ -z $Proxy_id ]]
then
    /usr/bin/php /usr/share/artica-postfix/exec.keepalived-state.php --state primary_node _1 'Proxy is down'
    exit 1
fi
### END Proxy INFO


### BEGIN Proxy INFO
Proxy_id=$(/bin/pidof squid)
if [[ -z $Proxy_id ]]
then
    /usr/bin/php /usr/share/artica-postfix/exec.keepalived-state.php --state primary_node _1 'Proxy is down'
    exit 1
fi
### END Proxy INFO


### BEGIN DISK SPACE INFO
DISK_USAGE_sda1=`/bin/df /dev/sda1 | tail -1 | awk '{print $5}' | sed 's/[^0-9]*//g'`
if (( $DISK_USAGE_sda1 > 96 ))
then
    /usr/bin/php /usr/share/artica-postfix/exec.keepalived-state.php --state primary_node _1 'sda1 low disk space'
    exit 1
fi
### END DISK SPACE INFO

exit 0

系统日志条目

Aug  5 20:58:17 CENVLIFEPROXB Keepalived_vrrp[3983]: Sending gratuitous ARP on eth0 for 10.200.6.26
Aug  5 20:58:17 CENVLIFEPROXB Keepalived_vrrp[3983]: Sending gratuitous ARP on eth0 for 10.200.6.26
Aug  5 20:58:17 CENVLIFEPROXB Keepalived_vrrp[3983]: Sending gratuitous ARP on eth0 for 10.200.6.26
Aug  5 20:58:17 CENVLIFEPROXB Keepalived_vrrp[3983]: Sending gratuitous ARP on eth0 for 10.200.6.26
Aug  5 20:58:17 CENVLIFEPROXB Keepalived_vrrp[3983]: Sending gratuitous ARP on eth0 for 10.200.6.26
Aug  5 21:00:01 CENVLIFEPROXB Keepalived_vrrp[3983]: (VI_1) received an unexpected ip number count 0, expected 1!
Aug  5 21:00:02 CENVLIFEPROXB Keepalived_vrrp[3983]: (VI_1) received an unexpected ip number count 0, expected 1!
Aug  5 21:00:03 CENVLIFEPROXB Keepalived_vrrp[3983]: (VI_1) received an unexpected ip number count 0, expected 1!
Aug  5 21:00:03 CENVLIFEPROXB Keepalived_vrrp[3983]: (VI_1) Received advert from 10.200.6.22 with lower priority 150, ours 200, forcing new election
Aug  5 21:00:03 CENVLIFEPROXB Keepalived_vrrp[3983]: (VI_1) Sending/queueing gratuitous ARPs on eth0 for 10.200.6.26
Aug  5 21:00:03 CENVLIFEPROXB Keepalived_vrrp[3983]: Sending gratuitous ARP on eth0 for 10.200.6.26
Aug  5 21:00:03 CENVLIFEPROXB Keepalived_vrrp[3983]: Sending gratuitous ARP on eth0 for 10.200.6.26
Aug  5 21:00:03 CENVLIFEPROXB Keepalived_vrrp[3983]: Sending gratuitous ARP on eth0 for 10.200.6.26

相关内容