1. 程式人生 > >keepalived+lvs叢集配置

keepalived+lvs叢集配置

主用

[[email protected] keepalived]# cat keepalived.conf 
global_defs {
   router_id LVS_DEVEL
}

vrrp_script chk {
   script "/etc/keepalived/check.sh"
   interval 1
   #weight -20
}
vrrp_instance VI_1 {
    state MASTER
    interface ens3
    virtual_router_id 120
    priority 120
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 8888
    }
virtual_ipaddress {
        10.16.16.26 dev ens3
        10.16.16.25 dev ens3
    }
virtual_ipaddress_excluded {

        fe80::5054:ff:febc:d8ee dev ens3
        fe80::5054:ff:febc:d8ec dev ens3    
    }
track_script {
      chk
    }
}
virtual_server 10.16.15.25 80 {
    delay_loop 6
             lb_algo lc
             lb_kind DR
             persistence_timeout 50
             protocol TCP
     real_server 10.16.15.226 80 {
        weight 1
        TCP_CHECK {
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
        }
    }
     real_server 10.16.15.228 80 {
        weight 1
        TCP_CHECK {
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
        }
    }
}
virtual_server fe80::5054:ff:febc:d8ee 80 {
    delay_loop 6
                 lb_algo lc
                 lb_kind DR
                 persistence_timeout 50
                 protocol TCP
}
virtual_server 10.16.16.25 443 {
    delay_loop 6
             lb_algo lc
             lb_kind DR
             persistence_timeout 50
             protocol TCP
     real_server 10.16.15.226 443 {
        weight 1
        TCP_CHECK {
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
        }
    }
     real_server 10.16.15.228 443 {
        weight 1
        TCP_CHECK {
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
        }
    }
}
virtual_server fe80::5054:ff:febc:d8ee 443 {
    delay_loop 6
                 lb_algo lc
                 lb_kind DR
                 persistence_timeout 50
                 protocol TCP
}

備用

[[email protected] ~]# cat /etc/keepalived/keepalived.conf 
global_defs {
   router_id LVS_DEVEL
}

vrrp_script chk {
   script "/etc/keepalived/check.sh"
   interval 1
   #weight -20
}
vrrp_instance VI_1 {
    state BACKUP
    interface ens3
    virtual_router_id 120
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 8888
    }
virtual_ipaddress {
        10.16.16.26 dev ens3
        10.16.16.25 dev ens3
    }
virtual_ipaddress_excluded {

        fe80::5054:ff:febc:d8ee dev ens3
        fe80::5054:ff:febc:d8ec dev ens3    
    }
track_script {
      chk
    }
}
virtual_server 10.16.15.25 80 {
    delay_loop 6
             lb_algo lc
             lb_kind DR
             persistence_timeout 50
             protocol TCP
     real_server 10.16.15.226 80 {
        weight 1
        TCP_CHECK {
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
        }
    }
     real_server 10.16.15.228 80 {
        weight 1
        TCP_CHECK {
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
        }
    }
}
virtual_server fe80::5054:ff:febc:d8ee 80 {
    delay_loop 6
                 lb_algo lc
                 lb_kind DR
                 persistence_timeout 50
                 protocol TCP
}
virtual_server 10.16.15.25 443 {
    delay_loop 6
             lb_algo lc
             lb_kind DR
             persistence_timeout 50
             protocol TCP
     real_server 10.16.15.226 443 {
        weight 1
        TCP_CHECK {
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
        }
    }
     real_server 10.16.15.228 443 {
        weight 1
        TCP_CHECK {
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
        }
    }
}
virtual_server fe80::5054:ff:febc:d8ee 443 {
    delay_loop 6
                 lb_algo lc
                 lb_kind DR
                 persistence_timeout 50
                 protocol TCP
}