keepalived-master-slave

Master配置

global_defs {
   notification_email {
     root@localhost   
      }  
   notification_email_from keeplived@localhost
   smtp_server 127.0.0.1
   smtp_connect_timeout 30
   router_id test1
   vrrp_skip_check_adv_addr
   vrrp_garp_interval 0 
   vrrp_gna_interval 0 
   vrrp_mcast_group4 224.0.0.18 
}
vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 100 
    advert_int 1 
    authentication {  
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
            10.211.55.99
    }
}  

 

Backup配置

global_defs {
   notification_email {
     root@localhost   
      }  
   notification_email_from keeplived@localhost
   smtp_server 127.0.0.1
   smtp_connect_timeout 30
   router_id test1
   vrrp_skip_check_adv_addr
   vrrp_garp_interval 0 
   vrrp_gna_interval 0 
   vrrp_mcast_group4 224.0.0.18 
}
vrrp_instance VI_1 {
    state BACKUP
    interface eth0
    virtual_router_id 51
    priority 50
    advert_int 1 
    authentication {  
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
            10.211.55.99
    }
}  

抢占模式

抢占延迟模式,即优先级高的主机恢复后,不会立即抢回IP,而是延迟一段时间,默认300s 再抢回

preempt_delay 30

注意:需要各keepalived服务器state为backup,并且不要启用vrrp_strict

ha1(原来主)
state=BACKUP
preempt_delay 30

 

posted @ 2021-04-26 17:30  huakai201  阅读(119)  评论(0编辑  收藏  举报