首页 > 代码库 > Keepalived的全局配置

Keepalived的全局配置

Keepalived的全局配置

默认配置文件如下:

技术分享
  1 ! Configuration File for keepalived
  2 
  3 global_defs {
  4    notification_email {
  5      acassen@firewall.loc
  6      failover@firewall.loc
  7      sysadmin@firewall.loc
  8    }
  9    notification_email_from Alexandre.Cassen@firewall.loc
 10    smtp_server 192.168.200.1
 11    smtp_connect_timeout 30
 12    router_id LVS_DEVEL
 13    vrrp_skip_check_adv_addr
 14    vrrp_strict
 15    vrrp_garp_interval 0
 16    vrrp_gna_interval 0
 17 }
 18 
 19 vrrp_instance VI_1 {
 20     state MASTER
 21     interface eth0
 22     virtual_router_id 51
 23     priority 100
 24     advert_int 1
 25     authentication {
 26         auth_type PASS
 27         auth_pass 1111
 28     }
 29     virtual_ipaddress {
 30         192.168.200.16
 31         192.168.200.17
 32         192.168.200.18
 33     }
 34 }
 35 
 36 virtual_server 192.168.200.100 443 {
 37     delay_loop 6
 38     lb_algo rr
 39     lb_kind NAT
 40     persistence_timeout 50
 41     protocol TCP
 42 
 43     real_server 192.168.201.100 443 {
 44         weight 1
 45         SSL_GET {
 46             url {
 47               path /
 48               digest ff20ad2481f97b1754ef3e12ecd3a9cc
 49             }
 50             url {
 51               path /mrtg/
 52               digest 9b3a0c85a887a256d6939da88aabd8cd
 53             }
 54             connect_timeout 3
 55             nb_get_retry 3
 56             delay_before_retry 3
 57         }
 58     }
 59 }
 60 
 61 virtual_server 10.10.10.2 1358 {
 62     delay_loop 6
 63     lb_algo rr 
 64     lb_kind NAT
 65     persistence_timeout 50
 66     protocol TCP
 67 
 68     sorry_server 192.168.200.200 1358
 69 
 70     real_server 192.168.200.2 1358 {
 71         weight 1
 72         HTTP_GET {
 73             url { 
 74               path /testurl/test.jsp
 75               digest 640205b7b0fc66c1ea91c463fac6334d
 76             }
 77             url { 
 78               path /testurl2/test.jsp
 79               digest 640205b7b0fc66c1ea91c463fac6334d
 80             }
 81             url { 
 82               path /testurl3/test.jsp
 83               digest 640205b7b0fc66c1ea91c463fac6334d
 84             }
 85             connect_timeout 3
 86             nb_get_retry 3
 87             delay_before_retry 3
 88         }
 89     }
 90 
 91     real_server 192.168.200.3 1358 {
 92         weight 1
 93         HTTP_GET {
 94             url { 
 95               path /testurl/test.jsp
 96               digest 640205b7b0fc66c1ea91c463fac6334c
 97             }
 98             url { 
 99               path /testurl2/test.jsp
100               digest 640205b7b0fc66c1ea91c463fac6334c
101             }
102             connect_timeout 3
103             nb_get_retry 3
104             delay_before_retry 3
105         }
106     }
107 }
108 
109 virtual_server 10.10.10.3 1358 {
110     delay_loop 3
111     lb_algo rr 
112     lb_kind NAT
113     persistence_timeout 50
114     protocol TCP
115 
116     real_server 192.168.200.4 1358 {
117         weight 1
118         HTTP_GET {
119             url { 
120               path /testurl/test.jsp
121               digest 640205b7b0fc66c1ea91c463fac6334d
122             }
123             url { 
124               path /testurl2/test.jsp
125               digest 640205b7b0fc66c1ea91c463fac6334d
126             }
127             url { 
128               path /testurl3/test.jsp
129               digest 640205b7b0fc66c1ea91c463fac6334d
130             }
131             connect_timeout 3
132             nb_get_retry 3
133             delay_before_retry 3
134         }
135     }
136 
137     real_server 192.168.200.5 1358 {
138         weight 1
139         HTTP_GET {
140             url { 
141               path /testurl/test.jsp
142               digest 640205b7b0fc66c1ea91c463fac6334d
143             }
144             url { 
145               path /testurl2/test.jsp
146               digest 640205b7b0fc66c1ea91c463fac6334d
147             }
148             url { 
149               path /testurl3/test.jsp
150               digest 640205b7b0fc66c1ea91c463fac6334d
151             }
152             connect_timeout 3
153             nb_get_retry 3
154             delay_before_retry 3
155         }
156     }
157 }
View Code

keepalived的配置文件以块的形式组织,每个块都包含内{}中,# !的都是注释。

Keepalived的所有配置均在/etc/keepalived/keepalived.conf这个配置文件中完成。根据实现的功能,主要可以分3类配置

全局配置:

全局配置对整个keepalived都生效,基本如下

 

Keepalived的全局配置