实验环境:一台调度器和两台web主机
所有机器关闭防火墙及linux安全机制
iptables -F
systemctl stop firewalld
setenforce 0
配置调度器:
1.安装ipvsadm服务
yum -y install ipvsadm
2.配置负载调度器
ifconfig ens32:0 192.168.200.254 netmask 255.255.255.0
3.查看端口
ifconfig ens32:0
4.配置负载分配策略
ipvsadm -A -t 192.168.200.254:80 -s rr
ipvsadm -a -t 192.168.200.254:80 -r 192.168.200.113:80 -g -w 1
ipvsadm -a -t 192.168.200.254:80 -r 192.168.200.114:80 -g -w 1
5.完善调度器
ipvsadm -Ln
6.查看子接口的IP地址
ip a
配置节点服务器:
1.安装apache服务
yum -y install httpd
2.配置节点IP
ifconfig lo:0 192.168.200.254 netmask 255.255.255.255
route add -host 192.168.200.254 dev lo:0
3.创建测试网页
echo "server111" > /var/www/html/index.html
4.起服务
systemctl start httpd
5.调整响应参数
vim /etc/sysctl.conf
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
net.ipv4.conf.default.arp_ignore = 1
net.ipv4.conf.default.arp_announce = 2
net.ipv4.conf.lo.arp_ignore = 1
net.ipv4.conf.lo.arp_announce = 2
6.加载配置项
sysctl -p
原文地址:https://www.cnblogs.com/990114-jhc/p/11631231.html