RS1网关指向DIP
[root@rs1 ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.153.10 0.0.0.0 UG 100 0 0 ens33
192.168.153.0 0.0.0.0 255.255.255.0 U 100 0 0 ens33
RS2网关指向DIP
[root@rs2 ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.153.10 0.0.0.0 UG 100 0 0 ens33
192.168.153.0 0.0.0.0 255.255.255.0 U 100 0 0 ens33
在director开启核心转发功能
[root@director ~]# vi /etc/sysctl.conf
net.ipv4.ip_forward=1
[root@director ~]# sysctl -p
net.ipv4.ip_forward = 1
在RS1和RS2上分别安装httpd服务
[root@rs1 ~]# yum install httpd -y
[root@rs1 ~]# echo "server RS1" > /var/www/html/index.html
[root@rs1 ~]# systemctl start httpd
[root@rs2 ~]# yum install httpd -y
[root@rs2 ~]# echo "Server RS2" > /var/www/html/index.html
[root@rs2 ~]# systemctl start httpd
在director上安装ipvsadm
[root@director ~]# yum install ipvsadm -y
定义集群
[root@director ~]# ipvsadm -A -t 172.22.27.20:80 -s rr
将后端的RS主机加入集群
[root@director ~]# ipvsadm -a -t 172.22.27.20:80 -r 192.168.153.20 -m
[root@director ~]# ipvsadm -a -t 172.22.27.20:80 -r 192.168.153.30 -m
[root@director ~]# ipvsadm -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 172.22.27.20:80 rr
-> 192.168.153.20:80 Masq 1 0 0
-> 192.168.153.30:80 Masq 1 0 0
原文:https://blog.51cto.com/11886307/2400435