一、配置好keepalived.conf文件后,启动keepalived,查看/var/log/message日志报错:
[root@push-5-214 sbin]# tail -f /var/log/messages Jun 12 16:14:52 push-5-214 Keepalived_vrrp[43824]: VRRP_Instance(VI_1) Dropping received VRRP packet... Jun 12 16:14:53 push-5-214 Keepalived_vrrp[43824]: (VI_1): received an invalid passwd! Jun 12 16:14:53 push-5-214 Keepalived_vrrp[43824]: bogus VRRP packet received on em1 !!! Jun 12 16:14:53 push-5-214 Keepalived_vrrp[43824]: VRRP_Instance(VI_1) Dropping received VRRP packet... Jun 12 16:14:54 push-5-214 Keepalived_vrrp[43824]: (VI_1): received an invalid passwd! Jun 12 16:14:54 push-5-214 Keepalived_vrrp[43824]: bogus VRRP packet received on em1 !!! Jun 12 16:14:54 push-5-214 Keepalived_vrrp[43824]: VRRP_Instance(VI_1) Dropping received VRRP packet... Jun 12 16:14:55 push-5-214 Keepalived_vrrp[43824]: (VI_1): received an invalid passwd! Jun 12 16:14:55 push-5-214 Keepalived_vrrp[43824]: bogus VRRP packet received on em1 !!! Jun 12 16:14:55 push-5-214 Keepalived_vrrp[43824]: VRRP_Instance(VI_1) Dropping received VRRP packet... Jun 12 16:14:56 push-5-214 Keepalived_vrrp[43824]: (VI_1): received an invalid passwd! Jun 12 16:14:56 push-5-214 Keepalived_vrrp[43824]: bogus VRRP packet received on em1 !!! Jun 12 16:14:56 push-5-214 Keepalived_vrrp[43824]: VRRP_Instance(VI_1) Dropping received VRRP packet... Jun 12 16:14:57 push-5-214 Keepalived_vrrp[43824]: (VI_1): received an invalid passwd! Jun 12 16:14:57 push-5-214 Keepalived_vrrp[43824]: bogus VRRP packet received on em1 !!! Jun 12 16:14:57 push-5-214 Keepalived_vrrp[43824]: VRRP_Instance(VI_1) Dropping received VRRP packet... Jun 12 16:14:58 push-5-214 Keepalived_vrrp[43824]: (VI_1): received an invalid passwd! Jun 12 16:14:58 push-5-214 Keepalived_vrrp[43824]: bogus VRRP packet received on em1 !!! Jun 12 16:14:58 push-5-214 Keepalived_vrrp[43824]: VRRP_Instance(VI_1) Dropping received VRRP packet... Jun 12 16:14:59 push-5-214 Keepalived_vrrp[43824]: (VI_1): received an invalid passwd! Jun 12 16:14:59 push-5-214 Keepalived_vrrp[43824]: bogus VRRP packet received on em1 !!! Jun 12 16:14:59 push-5-214 Keepalived_vrrp[43824]: VRRP_Instance(VI_1) Dropping received VRRP packet...
解决办法:
修改配置文件中的:virtual_router_id参数,默认为51 ,修改为60,主从都要修改,保存退出,再重启keepalived,启动成功
vrrp_instance VI_1 { state MASTER interface em1 virtual_router_id 60 priority 150 advert_int 1 #设定master与backup之间vrrp通告的时间间隔 authentication { auth_type PASS auth_pass XXXXXX }
Jun 12 16:17:12 push-5-214 systemd: Starting LVS and VRRP High Availability Monitor... Jun 12 16:17:12 push-5-214 Keepalived[44805]: Starting Keepalived v1.3.4 (02/18,2017) Jun 12 16:17:12 push-5-214 Keepalived[44805]: Unable to resolve default script username 'keepalived_script' - ignoring Jun 12 16:17:12 push-5-214 Keepalived[44805]: Opening file '/etc/keepalived/keepalived.conf'. Jun 12 16:17:12 push-5-214 systemd: Failed to read PID from file /run/keepalived.pid: Invalid argument Jun 12 16:17:12 push-5-214 systemd: Started LVS and VRRP High Availability Monitor. Jun 12 16:17:12 push-5-214 Keepalived[44806]: Starting Healthcheck child process, pid=44807 Jun 12 16:17:12 push-5-214 Keepalived[44806]: Starting VRRP child process, pid=44808 Jun 12 16:17:12 push-5-214 Keepalived_healthcheckers[44807]: Netlink reflector reports IP 172.28.5.214 added Jun 12 16:17:12 push-5-214 Keepalived_healthcheckers[44807]: Netlink reflector reports IP fe80::9cc6:b07e:1c95:9925 added Jun 12 16:17:12 push-5-214 Keepalived_healthcheckers[44807]: Registering Kernel netlink reflector Jun 12 16:17:12 push-5-214 Keepalived_healthcheckers[44807]: Registering Kernel netlink command channel Jun 12 16:17:12 push-5-214 Keepalived_healthcheckers[44807]: Opening file '/etc/keepalived/keepalived.conf'. Jun 12 16:17:12 push-5-214 Keepalived_vrrp[44808]: Netlink reflector reports IP 172.28.5.214 added Jun 12 16:17:12 push-5-214 Keepalived_vrrp[44808]: Netlink reflector reports IP fe80::9cc6:b07e:1c95:9925 added Jun 12 16:17:12 push-5-214 Keepalived_vrrp[44808]: Registering Kernel netlink reflector Jun 12 16:17:12 push-5-214 Keepalived_vrrp[44808]: Registering Kernel netlink command channel Jun 12 16:17:12 push-5-214 Keepalived_vrrp[44808]: Registering gratuitous ARP shared channel Jun 12 16:17:12 push-5-214 Keepalived_vrrp[44808]: Opening file '/etc/keepalived/keepalived.conf'. Jun 12 16:17:12 push-5-214 Keepalived_vrrp[44808]: VRRP_Instance(VI_1) removing protocol VIPs. Jun 12 16:17:12 push-5-214 Keepalived_vrrp[44808]: SECURITY VIOLATION - scripts are being executed but script_security not enabled. Jun 12 16:17:12 push-5-214 Keepalived_vrrp[44808]: Using LinkWatch kernel netlink reflector... Jun 12 16:17:12 push-5-214 Keepalived_vrrp[44808]: VRRP sockpool: [ifindex(2), proto(112), unicast(0), fd(10,11)] Jun 12 16:17:12 push-5-214 Keepalived_healthcheckers[44807]: Using LinkWatch kernel netlink reflector... Jun 12 16:17:12 push-5-214 Keepalived_vrrp[44808]: VRRP_Script(chk_nginx) succeeded Jun 12 16:17:13 push-5-214 Keepalived_vrrp[44808]: VRRP_Instance(VI_1) Transition to MASTER STATE Jun 12 16:17:13 push-5-214 Keepalived_vrrp[44808]: VRRP_Instance(VI_1) Changing effective priority from 150 to 152 Jun 12 16:17:14 push-5-214 Keepalived_vrrp[44808]: VRRP_Instance(VI_1) Entering MASTER STATE Jun 12 16:17:14 push-5-214 Keepalived_vrrp[44808]: VRRP_Instance(VI_1) setting protocol VIPs. Jun 12 16:17:14 push-5-214 Keepalived_healthcheckers[44807]: Netlink reflector reports IP 172.28.5.224 added Jun 12 16:17:14 push-5-214 Keepalived_vrrp[44808]: Sending gratuitous ARP on em1 for 172.28.5.224 Jun 12 16:17:14 push-5-214 Keepalived_vrrp[44808]: VRRP_Instance(VI_1) Sending/queueing gratuitous ARPs on em1 for 172.28.5.224 Jun 12 16:17:14 push-5-214 Keepalived_vrrp[44808]: Sending gratuitous ARP on em1 for 172.28.5.224 Jun 12 16:17:14 push-5-214 Keepalived_vrrp[44808]: Sending gratuitous ARP on em1 for 172.28.5.224 Jun 12 16:17:14 push-5-214 Keepalived_vrrp[44808]: Sending gratuitous ARP on em1 for 172.28.5.224 Jun 12 16:17:14 push-5-214 Keepalived_vrrp[44808]: Sending gratuitous ARP on em1 for 172.28.5.224 Jun 12 16:17:19 push-5-214 Keepalived_vrrp[44808]: Sending gratuitous ARP on em1 for 172.28.5.224 Jun 12 16:17:19 push-5-214 Keepalived_vrrp[44808]: VRRP_Instance(VI_1) Sending/queueing gratuitous ARPs on em1 for 172.28.5.224 Jun 12 16:17:19 push-5-214 Keepalived_vrrp[44808]: Sending gratuitous ARP on em1 for 172.28.5.224 Jun 12 16:17:19 push-5-214 Keepalived_vrrp[44808]: Sending gratuitous ARP on em1 for 172.28.5.224 Jun 12 16:17:19 push-5-214 Keepalived_vrrp[44808]: Sending gratuitous ARP on em1 for 172.28.5.224 Jun 12 16:17:19 push-5-214 Keepalived_vrrp[44808]: Sending gratuitous ARP on em1 for 172.28.5.224