edfwe 发表于 2015-5-5 08:43:47

keepalived+lvs配置示例

主节点配置:
global_defs {
   notification_email {
   root@one.test.com
   }
   notification_email_from root@one.test.com
   smtp_server 127.0.0.1
   smtp_connect_timeout 30
   router_id one.test.com
}

vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
      auth_type PASS
      auth_pass 1111
    }
    virtual_ipaddress {
      192.168.1.100/24 dev eth0 label eth0:1
    }
}
virtual_server 192.168.1.100 80 {
    delay_loop 6
    lb_algo wrr
    lb_kind DR
    persistence_timeout 0
    protocol TCP

    real_server 192.168.1.2 80 {
      weight 2
      TCP_CHECK {
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
      }
    }
    real_server 192.168.1.3 80 {
      weight 3
      TCP_CHECK {
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
      }
    }
}
从节点配置:
global_defs {
   notification_email {
   root@one.test.com
   }
   notification_email_from root@two.test.com
   smtp_server 127.0.0.1
   smtp_connect_timeout 30
   router_id two.test.com
}

vrrp_instance VI_1 {
    state BACKUP
    interface eth0
    virtual_router_id 51
    priority 98
    advert_int 1
    authentication {
      auth_type PASS
      auth_pass 1111
    }
    virtual_ipaddress {
      192.168.1.100/24 dev eth0 label eth0:1
    }
}
virtual_server 192.168.1.100 80 {
    delay_loop 6
    lb_algo wrr
    lb_kind DR
    persistence_timeout 0
    protocol TCP

    real_server 192.168.1.2 80 {
      weight 2
      TCP_CHECK {
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
      }
    }
    real_server 192.168.1.3 80 {
      weight 3
      TCP_CHECK {
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
      }
    }
}

页: [1]
查看完整版本: keepalived+lvs配置示例