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


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

    查看message日志一直报此错误

     [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...

    二、原因分析

    因为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
  • 相关阅读:
    ubuntu下cmake自动化编译的一个例子
    KL变换和PCA的数学推导
    tensorflow c++ API加载.pb模型文件并预测图片
    tensorflow c++接口的编译安装与一些问题记录
    深度增强学习--总结下吧
    深度增强学习--DPPO
    深度增强学习--DDPG
    深度增强学习--A3C
    tomcat远程调试
    springboot问题记录
  • 原文地址:https://www.cnblogs.com/cyleon/p/11253991.html
Copyright © 2020-2023  润新知