keepalived VIP单播设置

一 VIP单播配置格式

注意:启用单播,不能启用 vrrp_strict

分别在各个keepalived 节点设置对方主机的IP,建议设置为专用于对应心跳线网络的地址,而非使用业务网络

unicast_src_ip <IPADDR> #指定单播的源IP

unicast_peer {

         <IPADDR> # #指定单播的对方目标主机IP

         ......

}

二 master节点设置

点击查看代码
root@node-01:~# cat /etc/keepalived/keepalived.conf
! Configuration File for keepalived

global_defs {
   notification_email {
     1304005320@qq.com
   }
   notification_email_from 1304005320@qq.com
   smtp_server 127.0.0.1
   smtp_connect_timeout 30
   router_id node-01
   vrrp_skip_check_adv_addr
#   vrrp_strict
   vrrp_garp_interval 0
   vrrp_gna_interval 0
}

include /etc/keepalived/conf.d/*.conf


root@node-01:~# cat /etc/keepalived/conf.d/master.conf 
vrrp_instance VI_1 {
    state MASTER
    interface ens33
    virtual_router_id 101
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    unicast_src_ip 192.168.174.120
    unicast_peer{
        192.168.174.121
    }
    virtual_ipaddress {
        192.168.174.20
    }
    notify_master "/etc/keepalived/notify.sh master"
    notify_backup "/etc/keepalived/notify.sh backup"
    notify_fault "/etc/keepalived/notify.sh fault"
}

三 slave节点设置

点击查看代码
! Configuration File for keepalived

global_defs {
   notification_email {
     1304995320@qq.com
   }
   notification_email_from 1304995320@qq.com 
   smtp_server 192.168.200.1
   smtp_connect_timeout 30
   router_id node-02
   vrrp_skip_check_adv_addr
   #vrrp_strict
   vrrp_garp_interval 0
   vrrp_gna_interval 0
}
include /etc/keepalived/conf.d/*.conf


root@node-02:~# cat /etc/keepalived/conf.d/slave.conf 
vrrp_instance VI_1 {
    state BACKUP
    interface ens33
    virtual_router_id 101
    priority 80
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    unicast_src_ip 192.168.174.121
    unicast_peer{
        192.168.174.120
    }

    virtual_ipaddress {
        192.168.174.20
    }
    notify_master "/etc/keepalived/notify.sh master"
    notify_backup "/etc/keepalived/notify.sh backup"
    notify_fault "/etc/keepalived/notify.sh fault"
}
posted @ 2021-11-10 14:10  小吉猫  阅读(411)  评论(0编辑  收藏  举报