Server Load balancer cluster Open Source Software: LVS configuration details, open source software lvs

Source: Internet
Author: User

Server Load balancer cluster Open Source Software: LVS configuration details, open source software lvs

First, understand common sense. Typical Open-Source Software for Server Load balancer clusters: LVS, haproxy, and nginx.

High Availability cluster software: keepalived, heartbeat.
Configuration preparation:
1. Three servers or virtual machines (My centos7)
Server1: Used as an LVS Load balancer (LB)
IP: 192 .. 168.202.101
Server2: As RS
IP: 192.168.202.103
Server3: As RS
IP: 192.168.202.104
2. Download LVS (the software package name is ipvsadm)
You can download it from the LVS Official Website Based on your kernel version, or directly install YUM (the yum I used)
Kernel version: 3.10.0-327. el7.x86 _ 64
Software Version: ipvsadm-1.27-7.el7.x86_64
LB Configuration:

1. First, start ipvsadm. -------------------------------------------------------- 2. run lsmod | grep ip_vs # ip_vs is a LVS module in the kernel. If the following pattern is displayed, ip_vs_rr 12600 1 ip_vs 140944 3 then 105745 6 ip_vs, nf_nat, nf_nat_ipv4, xt_conntrack, nf_nat_masquerade_ipv4, nf_conntrack_4874libcrc32c 12644 2 xfs, ip_vs -------------------------------------------------------- 3. after confirming that the startup is successful, add VIPifconfig eno16777736: 0 192.168.202.29 up on the NIC. Then, view: 2: eno16777736:
 
  
Mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00: 0c: 29: fe: 6e: 2e brd ff: ff inet 192.168.202.101/24 brd 192.168.202.255 scope global eno16777736 valid_lft forever preferred_lft forever inet 192.168.202.29/24 brd 192.168.202.255 scope global secondary eno167736: 0 ## this IP address is the added virtual IP address valid_lft forever preferred_lft forever inet6 fe80: 20c: 29ff: fefe: 6e2e/64 scope link valid_lft forever Preferred_lft forever ------------------------------------------------------ 4. Execute the command to add the VIP gateway # I have tested it. If you do not add the gateway here, the experiment is successful. Route add-host 192.168.202.29 eno16777736 View: route-nKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use route 0.0.0.0 255.255.255.0 U 0 0 0 255.0.0.0.0 255.255.255.0 U 100 0 255.0.0.0.0 255.255.255.255 UH 0 0 0 region # The added Gateway -------------------------------------------------------- 5. execute ipvsadm-A-t 192.168.202.29: 80-s Rr binds VIP to LVS with ipvsadm-Ln view: IP Virtual Server version 1.2.1 (size = 4096) Prot LocalAddress: Port Scheduler Flags-> RemoteAddress: Port Forward Weight ActiveConn InActConnTCP 192.168.202.29: 80 rr # successfully bound #-A indicates that the bound VIP is added.-t indicates the VIP and-s indicates the algorithm. Listen 6. Execute ipvsadm-a-t 192.168.202.29: 80-r 192.168.202.103: 80-gipvsadm-a-t 192.168.202.29: 80-r 192.168.202.104: 80-g to add RS. #-A indicates adding,-t indicates the VIP address corresponding to the added RS,-r indicates the IP address of the RS,-g indicates the DR mode, and-m indicates the NAT mode, -I indicates the TUN mode. For more information, see -- help. Check if added ipvsadm-Ln: IP Virtual Server version 1.2.1 (size = 4096) Prot LocalAddress: Port sched1_flags-> RemoteAddress: Port Forward Weight ActiveConn InActConnTCP 192.168.202.29: 80 rr-> 192.168.202.103: 80 Route 1 0 0-> 192.168.202.104: 80 Route 1 0 0 # added successfully
 

RS Configuration:

According to the principle, VIP needs to be added to RS and ARP needs to be restrained to prevent data requests sent from the original client to LB from conflicting with rs vip. 1. Add the VIP to the lo Nic. Ifconfig lo: 29 192.168.202.29/32 up later 2. add gateway # if this step is not executed, the route add-host 192.168.202.29 eno16777736 route is also executed successfully. 3. Suppress ARP to prevent VIP conflicts. Echo "1">/proc/sys/net/ipv4/conf/lo/arp_ignoreecho "2">/proc/sys/net/ipv4/conf/lo/arp_announceecho "1" >/proc/sys/net/ipv4/conf/all/arp_ignoreecho "2">/proc/sys/net/ipv4/conf/all/arp_announce

Then, access the VIP address 192.168.202.29 on the webpage.
In DR mode, kernel Forwarding is not required.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.