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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

weixin_50216110

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值