real_server 192.168.2.52 21 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 192.168.2.53 21 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}
reload两台调度器
# /etc/init.d/keepalived reload
!注意:如果使用的是另一个虚拟ip,要在real server主机上用arptables分别添加进去(本实验为了方便不做演示,具体过程如上)。
测试:先用浏览器测试httpd服务是否能正常启动,再用真机终端测ftp服务
# lftp 192.168.2.254
lftp 192.168.2.254:~> ls
drwxr-xr-x 2 0 0 4096 Feb 12 2013 pub
-rw-r--r-- 1 0 0 0 May 31 08:02 server52
lftp 192.168.2.254:/> quit
查看是否添加成功
# ipvsadm -L
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 192.168.2.254:ftp rr persistent 50
-> server52.example.com:ftp Route 1 0 0
-> server53.example.com:ftp Route 1 0 0
TCP 192.168.2.254:http rr
-> server52.example.com:http Route 1 0 0
-> server53.example.com:http Route 1 0 0