LVS load balancing - the direct routing mode DR

First, the configuration of the network topology of FIG.
Here Insert Picture Description

Second, the configuration server lvs

  • Configure the virtual network adapter address (VIP address)
[the root @ localhost ~] # the ifconfig eno16777728: 0  192.168 . 200.253 Netmask 255.255 . 255.0 
# View Configuration 
[the root @ localhost ~] # the ifconfig eno16777728: 0  
eno16777728: 0 : the flags = 4163 <the UP, BROADCAST, the RUNNING, the MULTICAST> MTU 1500 
        inet 192.168 . 200.253   Netmask 255.255 . 255.0   Broadcast 192.168 . 200.255 
        ether 00 : 0c: 29 : F0: 42 is : 97   txqueuelen 1000  (Ethernet)
  • Ipvsadm install software package lvs poll
[the root @ localhost ~] # yum - Y the install the ipvsadm 
# see the installation results 
[the root @ localhost ~] # RPM - QA the ipvsadm 
the ipvsadm - 1.27 - . 7 .el7.x86_64
  • Configure the polling rules
[root@localhost ~]#  ipvsadm -A -t 192.168.200.253: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.253:80 -r 192.168.200.113:80 -g -w 1

Third, the node configuration Apache server (configured with the same two servers)

  • Virtual NIC configured IP address (VIP address)
[root@localhost ~]# ifconfig lo:0  192.168.200.253 netmask 255.255.255.255 
  • Add routing rule
[the root @ localhost ~] -host the Add route # 192.168 . 200.253 dev LO: 0 
# VIP access data limit to avoid local communication disorder.
  • Adjustment / proc response parameters
[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
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
  • Install Apache open service
[root@localhost ~]# yum -y install httpd
#开启httpd服务
[root@localhost ~]# systemctl start httpd

Fourth, the test

  • All machines off the firewall security rules
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
[root@localhost ~]# iptables -F
  • Prepare the test page
[root@localhost ~]# echo "111111111" > /var/www/html/index.html
  • test
    Here Insert Picture Description

Guess you like

Origin www.cnblogs.com/canflyfish/p/11635039.html