keepalived管理LVS文件详解

#全局设置,只设置一个 全局路由就可以,全局路由不能重复唯一标识.

global_defs {

  router_id LVS_01 #全局路由ID,唯一不能重复

}

#实例

vrrp_instance VI_I {

  state MASTER #状态可以随便写,相当于标记,但是最好要明确主

  interface eth0

  virtual_router_id 51 #虚拟路由ID,同一个家族相同

  priority 150 # 优先级高低决定谁是主的服务

       advert_int 1 #advert_int心跳时间间隔

  authentication {  #心跳之间通信的密码,一般简单密码

    auth_type PASS

    auth_pass 1111

  }

  virtual_ipaddress {

    10.0.0.13/24  #绑定的虚拟IP

  }

}

#LVS专属特性

virtual_server 10.0.0.13 80 {

  delay_loop 6 #健康检查时间间隔

  lb_algo rr  #负载均衡调度算法

       lb_kind DR #负载均衡转发规则

  net_mask 255.255.255.0

  persisitence_timeout

  protocol TCP  #协议TCP

  #真实服务IP配置

  real_server 10.0.0.17 80 {

    weight 1 #权重

    TCP_CHECK{ #健康

      connect_timeout 8

      nb_get_retry 3

      delay_before_retry 3

      connect_port 80

    }

  }

}

原文地址:https://www.cnblogs.com/gaoyuechen/p/7920222.html