LVS_NAT模式负载原理:
通过网络地址转换实现虚拟服务器
缺点:大并发访问时,调度器性能出现瓶颈
基础环境准备:
proxy eth0:192.168.4.5 eth1:192.168.2.2
web1 eth0:192.168.2.100 gateway:192.168.2.2
web2 eth0:192.168.2.200 gateway:192.168.2.2
client eth0:192.168.4.10
web1主机配置:
yum -y install httpd
echo “It’s web1-test” > /var/www/html/index.html
systemctl enable --now httpd
systemctl disable firewalld
sed -i ‘/SELINUX/s/enforcing/disabled/’ /etc/selinux/config
reboot
curl http:localhost
web2主机同web1主机配置一样
proxy主机配置:
systemctl disable firewalld
sed -i ‘/SELINUX/s/enforcing/disabled/’ /etc/selinux/config
reboot
curl http://192.168.2.100
curl http://192.168.2.200
echo “net.ipv4.ip_forward = 1” >> /etc/sysctl.conf
sysctl -p
yum -y install ipvsadm
ipvsadm -A -t 192.168.4.5:80 -s wrr
ipvsadm -a -t 192.168.4.5:80 -r 192.168.2.100 -m -w 1
ipvsadm -a -t 192.168.4.5:80 -r 192.168.2.200 -m -w 1
ipvsadm -Ln
client主机配置:
sed -i ‘/SELINUX/s/enforcing/disabled/’ /etc/selinux/config
systemctl disable firewalld
reboot
curl http://192.168.4.5反复刷新,测试负载效果
LVS_NAT模式配置
最新推荐文章于 2022-11-19 17:08:56 发布