三主機配置 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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM