LVS based on Dr model for load Balancing cluster experiment

Source: Internet
Author: User

Experimental topology:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/70/11/wKiom1Wwk2zjgkqQAADzUzao-dY988.jpg "title=" QQ picture 20150723151000.png "alt=" Wkiom1wwk2zjgkqqaadzuzao-dy988.jpg "/>

Experimental planning:

Director:

Eth0 dip:192.168.1.40

eth0:0 vip:192.168.1.41


RS1:

Eth0 rip1:192.168.1.20

lo:0 vip:192.168.1.41


RS2:

Eth0 rip2:192.168.1.21

lo:0 vip:192.168.1.41


Experimental steps:

    1. Deploying Web Services on each RS

Yum install Httpd-yecho "server is working." >/var/www/html/index.html

To highlight the effect of the experiment, it is recommended to set the main page of Rs to a different content.


2. Setting IP and Kernel parameters

(1) Director configuration

Eth0 configuration is no longer mentioned, the focus here is the VIP configuration

Ifconfig eth0:0 192.168.1.41

Add a special route for the smooth forwarding of messages

When the request message is sent to the Director, the director calls the internal scheduling algorithm to transfer the request to the internal RS, while the source address of the message is the VIP, the outgoing interface is eth0, according to the Linux processing rules of the message, the source address of the message will be changed to dip, rather than VIP

, so you need to add a special route

Route add-host 192.168.1.41 Dev eth0:0

(2) RS Configuration

First configure the network address of the eth0, rs1:192.168.1.20 rs2:192.168.1.21

modifying two kernel parameters

Arp_ignore response level when an ARP request is received

0: Respond as long as the local configuration has a corresponding address

1: Response is only given when the requested destination address is configured on the interface to which the request arrives

Arp_announce defines the level of notification when you advertise your own address outward

0: Advertise any address on any interface on the machine to the outside

1: Attempt to advertise only addresses to the target network that match their network

2: Only network advertisements that match addresses on the local interface

On the RS side, VIP needs to be hidden, only when the corresponding client request as the source address, and Linux, the IP address belongs to the host, so in order not to expose the VIP to the LAN, need to modify the above two kernel parameters

Sysctl-w net.ipv4.conf.eth0.arp_announce=2sysctl-w net.ipv4.conf.all.arp_announce=2sysctl-w Net.ipv4.conf.eth0.arp_ignore=1sysctl-w net.ipv4.conf.all.arp_ignore=1

Configuring VIPs and adding routes

Ifconfig lo:0 192.168.1.41 broadcast 192.168.1.41 netmask 255.255.255.255 uproute add-host 192.168.1.41 Dev lo:0

3. Configure the IPVSADM policy to complete the load balancing function

(1) Add Cluster service, where RR (polling) scheduling algorithm is used

Ipvsadm-a-T 192.168.1.41:80-s RR

(2) Add RS

Ipvsadm-a-T 192.168.1.41:80-r 192.168.1.20-gipvsadm-a-T 192.168.1.41:80-r 192.168.1.21-g

(4) Testing Services

Access to the VIP address 192.168.1.41, after the refresh can be found to change the content of the Web page, the experiment completed.


Report:

Persistent connection of LVS:

Regardless of the algorithm used, the LVS persistent connection can be implemented within a certain period of time, from the same client request sent to the previously selected RS

Persistent connection template (memory buffer)

Each client IP, and the mapping relationship of the RS assigned to it


ipvsadm-a| E ...-p timeout

Timeout: Persistent connection duration, default is 300 seconds, unit is seconds


PPC (Persistent port connection): Requests from the same client for the same cluster service are always directed to the previously selected RS

PCC (Persistent client connection): Requests from the same client for all ports are always directed to the previously selected RS

All ports are defined as cluster services and are forwarded to RS

Ipvsadm-a-T 192.168.1.3:0-S Rr-p ipvsadm-a-T 192.168.1.3:0-R 192.168.1.10-p-W 2 ipvsadm-a-T 192.168.1 .3:0-R 192.168.1.11-p-W 1

PNMPP: Persistent firewall tag connection (when only a portion of the service needs to be persisted)

Iptables-t mangle-a prerouting-d 192.168.10.3-i eth0-p tcp--dport 80-j MARK--set-mark 8iptables-t mangle-a PRERO uting-d 192.168.10.3-i eth0-p tcp--dport 23-j MARK--set-mark 8ipvsadm-a-F 8-s rripvsadm-a-F 8-r 192.168.10.7- G-w 2ipvsadm-a-F 8-r 192.168.10.8-g-W 2


LVS based on Dr model for load Balancing cluster experiment

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.