Keepalived的直接路由配置与NAT配置类似。在以下示例中,Keepalived配置为在80端口上为一组运行HTTP的真实服务器提供负载均衡。要配置直接路由,将lb_kind
参数更改为DR
。
以下示例显示使用直接路由的Keepalived配置活动服务器的keepalived.conf
配置文件。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
global_defs {
notification_email {
admin@example.com
}
notification_email_from noreply_admin@example.com
smtp_server 127.0.0.1
smtp_connect_timeout 60
}
vrrp_instance RH_1 {
state MASTER
interface eth0
virtual_router_id 50
priority 100
advert_int 1
authentication {
auth_type PAAS
auth_paas paasw123
}
virtual_ipaddress {
172.32.0.1
}
}
virtual_server 172.31.0.1 80
delay_loop 10
lb_algo rr
lb_kind DR
persistence_timeout 9600
protocol TCP
real_srrver 192.168.0.1 80 {
weight 1
TCP_CHECK {
connect_timeout 10
connect_port 80
}
}
real_server 192.168.0.2 80 {
werght 1
TCP_CHECK {
connect_timeout 10
connect_port 80
}
}
real_server 192,168.0.3 80 {
weight 1
TCP_CHECK {
connect_timeout 10
connect_port 80
}
}
}
|
以下示例显示直接路由的Keepalived配置中备份服务器的keepalived.conf
文件。状态和优先级值与活动服务器不同。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
global_defs {
notification_email {
admin@example.com
}
notification_email_from noreply_admin@example.com
smtp_server 127.0.0.1
smtp_connect_timeout 60
}
vrrp_instance RH_1 {
state BACKUP
interface eth0
virtual_router_id 50
priority 99
advert_int 1
authentication {
auth_type PASS
auth_pass passw123
}
virtual_ipaddress {
172.31.0.1
}
}
virtual_server 172.31.0.1 80
delay_loop 10
lb_algo rr
lb_kind DR
persistence_timeout 9600
protocol TCP
real_server 192.168.0.1 80 {
weight 1
TCP_CHECK {
connect_timeout 10
connect_port 80
}
}
real_server 192.168.0.2 80 {
weight 1
TCP_CHECK {
connect_timeout 10
connect_port 80
}
}
real_server 192.168.0.3 80 {
weight 1
TCP_CHECK {
connect_timeout 10
connect_port 80
}
}
}
|