三主机配置 keepalived VIP高可用

 

 

三台主机:
192.168.33.134
192.168.33.136
192.168.33.137
 
实验前:
关闭selinux 和iptables
 
 
1). 192.168.33.134 配置
#yum install keepalived
#systemctl start keepalived
#systemctl enable keepalived
 
#cp vim /etc/keepalived/keepalived.conf{,.bak}
 
#vim /etc/keepalived/keepalived.conf
! Configuration File for keepalived
 
global_defs {
   notification_email {
      root@centos7.magedu.com
   }
   notification_email_from root@centos7.magedu.com
   smtp_server 127.0.0.1
   smtp_connect_timeout 30
   router_id centos7.magedu.com
   vrrp_skip_check_adv_addr
   vrrp_strict
   vrrp_garp_interval 0
   vrrp_gna_interval 0
   vrrp_iptables
}
 
vrrp_instance VIP_1 {
    state MASTER
    interface ens33
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.33.200 dev ens33 label ens33:0
    }
 
 
2). 192.168.33.136 配置
#yum install keepalived
#systemctl start keepalived
#systemctl enable keepalived
 
#cp vim /etc/keepalived/keepalived.conf{,.bak}
 
#vim /etc/keepalived/keepalived.conf
! Configuration File for keepalived
 
global_defs {
   notification_email {
      root@centos7.magedu.com
   }
   notification_email_from root@centos7.magedu.com
   smtp_server 127.0.0.1
   smtp_connect_timeout 30
   router_id centos7.magedu.com
   vrrp_skip_check_adv_addr
   vrrp_strict
   vrrp_garp_interval 0
   vrrp_gna_interval 0
   vrrp_iptables
}
 
vrrp_instance VIP_1 {
    state BACKUP
    interface ens33
    virtual_router_id 51
    priority 50
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.33.200 dev ens33 label ens33:0
    }
 
 
3). 192.168.33.137配置
#yum install keepalived
#systemctl start keepalived
#systemctl enable keepalived
 
#cp vim /etc/keepalived/keepalived.conf{,.bak}
 
#vim /etc/keepalived/keepalived.conf
! Configuration File for keepalived
 
global_defs {
   notification_email {
      root@centos7.magedu.com
   }
   notification_email_from root@centos7.magedu.com
   smtp_server 127.0.0.1
   smtp_connect_timeout 30
   router_id centos7.magedu.com
   vrrp_skip_check_adv_addr
   vrrp_strict
   vrrp_garp_interval 0
   vrrp_gna_interval 0
   vrrp_iptables
}
 
vrrp_instance VIP_1 {
    state BACKUP
    interface ens33
    virtual_router_id 51
    priority 10
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.33.200 dev ens33 label ens33:0
    }

 
 
 
默认组播:抓包,看到流量是发往组播
[root@centos7 ~]#tcpdump -i ens33 -nn host 224.0.0.18
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on ens33, link-type EN10MB (Ethernet), capture size 262144 bytes
10:35:43.325499 IP 192.168.33.134 > 224.0.0.18: VRRPv2, Advertisement, vrid 51, prio 100, authtype simple, intvl 1s, length 20
10:35:44.327673 IP 192.168.33.134 > 224.0.0.18: VRRPv2, Advertisement, vrid 51, prio 100, authtype simple, intvl 1s, length 20
10:35:45.329368 IP 192.168.33.134 > 224.0.0.18: VRRPv2, Advertisement, vrid 51, prio 100, authtype simple, intvl 1s, length 20
10:35:46.331697 IP 192.168.33.134 > 224.0.0.18: VRRPv2, Advertisement, vrid 51, prio 100, authtype simple, intvl 1s, leng

 

posted @ 2019-06-21 15:45  kuroniko  阅读(1960)  评论(0编辑  收藏  举报