实验环境:
servera作为lvs服务器
serverc,serverd作为web服务器
一.配置serverc,serverd
对两台服务器做相同配置:
1.安装nginx服务:yum install nginx -y2.切换到nginx根目录cd /usr/share/nginx/html/3.将原来的index.html备份mv index.html index.html.bak4.输出测试echo "web test page, ip is `hostname -I`." > index.html5.重启nginx服务systemctl restart nginx6.访问网页curl localhost7.添加VIPifconfig lo:20 192.168.233.50 netmask 255.255.255.2558.arp抑制cat >> /etc/sysctl.conf << EOFnet.ipv4.conf.all.arp_ignore = 1net.ipv4.conf.all.arp_announce = 2EOF9.使配置生效sysctl -p
二.LVS端配置:
1.安装管理工具ipvsadm
yum install ipvsadm -y
2.添加VIP
ifconfig ens160:01 192.168.233.50 netmask 255.255.255.255
3.添加虚拟IP及指定的算法
ipvsadm -A -t 192.168.233.50:80 -s rr
4.添加web服务器端的IP
ipvsadm -a -t 192.168.233.50:80 -r 192.168.233.140
ipvsadm -a -t 192.168.233.50:80 -r 192.168.233.141
5.查看添加的IP信息
ipvsadm -Ln