dinggela 发表于 2018-11-11 06:50:32

keepalived+lvs-dr+nginx双主模型

! Configuration File for keepalived  

  
global_defs {
  
   notification_email {
  
   root@localhost
  
   }
  
   notification_email_from Alexandre.Cassen@firewall.loc
  
   smtp_server 127.0.0.1
  
   smtp_connect_timeout 30
  
   router_id LVS_DEVEL
  
   vrrp_mcast_group4 224.0.4.223
  
}
  
vrrp_instance VI_1 {
  
    state MASTER
  
    interface eno16777736
  
    virtual_router_id 108
  
    priority 100
  
    advert_int 1
  
    authentication {
  
      auth_type PASS
  
      auth_pass 1111
  
    }
  
    virtual_ipaddress {
  
      192.168.0.111
  
    }
  
}
  

  
virtual_server 192.168.0.111 80 {
  
    delay_loop 6
  
    lb_algo rr
  
    lb_kind DR
  
    nat_mask 255.255.255.0
  
    protocol TCP
  

  
    real_server 192.168.0.10 80 {
  
      weight 1
  
      HTTP_GET {
  
            url {
  
            path /
  status_code 200
  
            }
  
            connect_timeout 3
  
            nb_get_retry 3
  
            delay_before_retry 3
  
      }
  
    }
  

  
    real_server 192.168.0.20 80 {
  
      weight 1
  
      HTTP_GET {
  
            url {
  
            path /
  status_code 200
  
            }
  
            connect_timeout 3
  
            nb_get_retry 3
  
            delay_before_retry 3
  
      }
  
    }
  
}
  

  
vrrp_instance VI_2 {
  
    state BACKUP
  
    interface eno16777736
  
    virtual_router_id 109
  
    priority 80
  
    advert_int 1
  
    authentication {
  
      auth_type PASS
  
      auth_pass 1111
  
    }
  
    virtual_ipaddress {
  
      192.168.0.222
  
    }
  
}
  

  
virtual_server 192.168.0.222 80 {
  
    delay_loop 6
  
    lb_algo rr
  
    lb_kind DR
  
    nat_mask 255.255.255.0
  
    protocol TCP
  

  
    real_server 192.168.0.10 80 {
  
      weight 1
  
      HTTP_GET {
  
            url {
  
            path /
  status_code 200
  
            }
  
            connect_timeout 3
  
            nb_get_retry 3
  
            delay_before_retry 3
  
      }
  
    }
  

  
    real_server 192.168.0.20 80 {
  
      weight 1
  
      HTTP_GET {
  
            url {
  
            path /
  status_code 200
  
            }
  
            connect_timeout 3
  
            nb_get_retry 3
  
            delay_before_retry 3
  
      }
  
    }
  
}


页: [1]
查看完整版本: keepalived+lvs-dr+nginx双主模型