啓動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
相關文章
相關標籤/搜索