keepalived+lvs實驗中lvs的rr機制沒有輪詢
使用倆台主機安裝keepalived+lvs,倆台主機做real server,lvs為DR模式,採用rr機制,測試時發現對於vip:192.168.122.100的請求都只能發送到其中一台real server上,不能交替的發給後端倆台real server ,沒有實現輪詢的機制,請指導~
keepalived配置文件
! Configuration File for keepalived
global_defs {
router_id director1
}
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.122.100
}
}
virtual_server 192.168.122.100 80 {
delay_loop 6
lb_algo rr
lb_kind DR
nat_mask 255.255.255.0
persistence_timeout 50
protocol TCP
real_server 192.168.122.4 80 {
weight 1
HTTP_GET {
url {
path /test1.html
digest 2ee55cb8cb23a5db1580d14aa37a5d27
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 192.168.122.5 80 {
weight 1
HTTP_GET {
url {
path /test2.html
digest 8145db84654bc4c9dc5fa077a788c9db
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}
測試
# ab -c 100 -n 100 http://192.168.122.100/
ipvsadm查詢
Every 0.5s: ipvsadm -Lnc Sun Nov 17 06:16:34 2013
IPVS connection entries
pro expire state source virtual destination
TCP 01:26 FIN_WAIT 192.168.122.1:39157 192.168.122.100:80 192.168.122.4:80
TCP 01:26 FIN_WAIT 192.168.122.1:39142 192.168.122.100:80 192.168.122.4:80
TCP 01:26 FIN_WAIT 192.168.122.1:39105 192.168.122.100:80 192.168.122.4:80
TCP 01:26 FIN_WAIT 192.168.122.1:39099 192.168.122.100:80 192.168.122.4:80
TCP 01:27 FIN_WAIT 192.168.122.1:39191 192.168.122.100:80 192.168.122.4:80
TCP 01:26 FIN_WAIT 192.168.122.1:39155 192.168.122.100:80 192.168.122.4:80
TCP 01:26 FIN_WAIT 192.168.122.1:39123 192.168.122.100:80 192.168.122.4:80
TCP 01:27 FIN_WAIT 192.168.122.1:39180 192.168.122.100:80 192.168.122.4:80
TCP 01:27 FIN_WAIT 192.168.122.1:39188 192.168.122.100:80 192.168.122.4:80
TCP 01:26 FIN_WAIT 192.168.122.1:39150 192.168.122.100:80 192.168.122.4:80
TCP 01:26 FIN_WAIT 192.168.122.1:39109 192.168.122.100:80 192.168.122.4:80
TCP 01:27 FIN_WAIT 192.168.122.1:39175 192.168.122.100:80 192.168.122.4:80
TCP 01:27 FIN_WAIT 192.168.122.1:39194 192.168.122.100:80 192.168.122.4:80
TCP 01:27 FIN_WAIT 192.168.122.1:39195 192.168.122.100:80 192.168.122.4:80
TCP 01:26 FIN_WAIT 192.168.122.1:39146 192.168.122.100:80 192.168.122.4:80
..............................
《解決方案》
查到問題了,是persistence_timeout 50保持時間引起的,設置了保持時間,模擬的批量請求在保持時間內都被定向到同一台機器了。