LVS_DR模式配置

LVS_DR模式工作原理:
直接使用路由技术实现虚拟服务器
基础环境准备:
proxy eth0:192.168.4.5
web1 eth0:192.168.4.100
web2 eth0:192.168.4.200
client eth0:192.168.4.10
VIP 192.168.4.15
所有主机配置时间同步、禁用防火墙、禁用selinux
yum -y install ntpdate
ntpdate cn.pool.ntp.org
hwclock --systohc
systemctl disable firewalld
sed -i ‘/SELINUX/s/enforcing/disabled/’ /etc/selinux/config
reboot
proxy主机配置:
ifconfig eth0:0 192.168.4.15 netmask 255.255.255.255
route add -host 192.168.4.15 dev eth0:0
ip a s
yum -y install ipvsadm
ipvsadm -A -t 192.168.4.15:80 -s rr
ipvsadm -a -t 192.168.4.15:80 -r 192.168.4.100 -g
ipvsadm -a -t 192.168.4.15:80 -r 192.168.4.200 -g
ipvsadm -Ln
web1主机配置:
ifconfig lo:0 192.168.4.15 netmask 255.255.255.255
route add -host 192.168.4.15 dev lo:0
ip a s
cat >> /etc/sysctl.conf << EOF
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.lo.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
net.ipv4.conf.lo.arp_announce = 2
EOF
sysctl -p
yum -y install httpd
echo “web1” > /var/www/html/index.html
systemctl enable --now httpd
curl http://localhost
web2主机配置:
ifconfig lo:0 192.168.4.15 netmask 255.255.255.255
route add -host 192.168.4.15 dev lo:0
ip a s
cat >> /etc/sysctl.conf << EOF
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.lo.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
net.ipv4.conf.lo.arp_announce = 2
EOF
sysctl -p
yum -y install httpd
echo “web2” > /var/www/html/index.html
systemctl enable --now httpd
curl http://localhost
client主机配置:
yum -y install elinks
elinks -dump http://192.168.4.100
web1
elinks -dump http://192.168.4.200
web2
while true; do elinks -dump http://192.168.4.15; sleep 3; done
web1
web2
web1
web2

已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 深蓝海洋 设计师:CSDN官方博客 返回首页