LVS DR模拟实验

Posted lyqlyqlyq

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LVS DR模拟实验相关的知识,希望对你有一定的参考价值。

准备多台服务器,现以三台服务器为例
第一台做调度器 192.168.200.111
[root@localhost ~]# iptables -F
[root@localhost ~]# setenforce 0
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# yum -y install ipvsadm net-tools
[root@localhost ~]# ifconfig ens32:0 192.168.200.254 netmask 255.255.255.0
[root@localhost ~]# ipvsadm -A -t 192.168.200.254:80 -s rr
[root@localhost ~]# ipvsadm -a -t 192.168.200.254:80 -r 192.168.200.112:80 -g -w 1
[root@localhost ~]# ipvsadm -a -t 192.168.200.254:80 -r 192.168.200.113:80 -g -w 1

第二台做节点服务器 192.168.200.112
[root@localhost ~]# iptables -F
[root@localhost ~]# setenforce 0
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# yum -y install httpd net-tools
[root@localhost ~]# ifconfig lo:0 192.168.200.254 netmask 255.255.255.255
[root@localhost ~]# route add -host 192.168.200.254 dev lo:0
[root@localhost ~]# echo 11111 > /var/www/html/index.html
[root@localhost ~]# systemctl start httpd
[root@localhost ~]# 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
[root@localhost ~]# sysctl -p

第二台做节点服务器 192.168.200.113
[root@localhost ~]# iptables -F
[root@localhost ~]# setenforce 0
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# yum -y install httpd net-tools
[root@localhost ~]# ifconfig lo:0 192.168.200.254 netmask 255.255.255.255
[root@localhost ~]# route add -host 192.168.200.254 dev lo:0
[root@localhost ~]# echo 22222 > /var/www/html/index.html
[root@localhost ~]# systemctl start httpd
[root@localhost ~]# 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
[root@localhost ~]# sysctl -p

以上是关于LVS DR模拟实验的主要内容,如果未能解决你的问题,请参考以下文章

构建基于直接路由模式(DR)的负载均衡群集

LVS-NAT LVS-DR

LVS的DR模式配置

LVS DR模式实验

lvs-nat及lvs-dr实验

LB(Load balance)负载均衡集群--{LVS-[NAT+DR]单实例实验+LVS+keeplived实验} 菜鸟入门级