启动keepalived报错(VI_1): received an invalid passwd!

1、署keepalived后测试主down掉后没法自动切换到备

查看message日志一直报此错误nginx

[root@lb-nginx-master ~]# tailf /var/log/messages Jul 27 09:58:09 lb-nginx-master Keepalived_vrrp[28598]: (VI_1): received an invalid passwd! Jul 27 09:58:09 lb-nginx-master Keepalived_vrrp[28598]: bogus VRRP packet received on eth0 !!! Jul 27 09:58:09 lb-nginx-master Keepalived_vrrp[28598]: VRRP_Instance(VI_1) Dropping received VRRP packet... Jul 27 09:58:10 lb-nginx-master Keepalived_vrrp[28598]: (VI_1): received an invalid passwd! Jul 27 09:58:10 lb-nginx-master Keepalived_vrrp[28598]: bogus VRRP packet received on eth0 !!! Jul 27 09:58:10 lb-nginx-master Keepalived_vrrp[28598]: VRRP_Instance(VI_1) Dropping received VRRP packet...

2、缘由分析

由于virtual_router_id,路由ID实例,必须是惟一的,其它环境中有存在相同的实例ID,因此要修改一个其它的实例ID服务器

# 主节点 [root@lb-nginx-master ~]# cat /etc/keepalived/keepalived.conf bal_defs { # 接收邮件地址 notification_email { acassen@firewall.loc failover@firewall.loc sysadmin@firewall.loc } # 邮件发送地址 notification_email_from Alexandre.Cassen@firewall.loc smtp_server 127.0.0.1 smtp_connect_timeout 30 router_id NGINX_MASTER } vrrp_script check_nginx { script "/etc/keepalived/check_nginx.sh" } vrrp_instance VI_1 { state MASTER interface eth0 virtual_router_id 70 # VRRP 路由 ID实例,每一个实例是惟一的 priority 100    # 优先级,备服务器设置 90 advert_int 1 # 指定VRRP 心跳包通告间隔时间,默认1秒 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.5.60/24 } track_script { check_nginx } } # 备节点 [root@lb-nginx-backup ~]# cat /etc/keepalived/keepalived.conf bal_defs { # 接收邮件地址 notification_email { acassen@firewall.loc failover@firewall.loc sysadmin@firewall.loc } # 邮件发送地址 notification_email_from Alexandre.Cassen@firewall.loc smtp_server 127.0.0.1 smtp_connect_timeout 30 router_id NGINX_MASTER } vrrp_script check_nginx { script "/etc/keepalived/check_nginx.sh" } vrrp_instance VI_1 { state BACKUP interface eth0 virtual_router_id 70 # VRRP 路由 ID实例,每一个实例是惟一的 priority 50    # 优先级,备服务器设置 90 advert_int 1 # 指定VRRP 心跳包通告间隔时间,默认1秒 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.5.60/24 } track_script { check_nginx } } # 检查脚本 [root@lb-nginx-master ~]# cat /etc/keepalived/check_nginx.sh count=$(ps -ef |grep nginx |egrep -cv "grep|$$") if [ "$count" -eq 0 ];then systemctl stop keepalived fi

主备都重启keepalived,重启后再测试已正常。测试

[root@lb-nginx-master ~]# systemctl start keepalived.service  [root@lb-nginx-backup ~]# systemctl restart keepalived
相关文章
相关标签/搜索