Three lvs modes and configurations in linux

Source: Internet
Author: User
Lvs: linuxvirtualserver, a linux Virtual Server. Server load balancer software for linux. Advantages: a. open source, free B. you can find related technical resources on the Internet c. It has the advantages of software load balancing. Technical Introduction: lvs clusters use IP server load balancer technology and

Lvs: linux virtual server, linux virtual server. Server load balancer software for linux.

Advantages: a. open source, free B. you can find related technical resources on the Internet c. It has the advantages of software load balancing.

Technical introduction:

The lvs cluster uses IP server load balancer technology and content-based request distribution technology. The scheduler has a good throughput rate, which transfers requests evenly to different servers for execution. the scheduler automatically shields server faults, thus, a group of servers are formed into a high-performance, high-availability virtual server. The structure of the entire server cluster is transparent to customers, and there is no need to modify the client and server programs.

Three-tier architecture of the cluster:

A. The server load balancer is A front-end server of the entire cluster. it is responsible for sending customer requests to A group of servers for execution. the customer thinks that the service is from an IP address.

B. The server pool is a group of servers that actually execute customer requests. The Services executed include web, mail, ftp, and dhs.

C. shared storage provides a shared storage area for the server. it is easy for the server pool to have the same content and provide the same service.

Scheduler:

The scheduler is the only entry point of the server cluster system. it can use the IP server load balancer technology, content-based request distribution technology, or a combination of the two.

The scheduler uses ip server load balancer technology and content-based request distribution technology or the combination of the two. In the IP server load balancer technology, the server pool must have the same content to provide the same service. When a customer requests arrive, the scheduler selects a server from the server pool based on the server load and the preset scheduling algorithm, forwards the requests to the selected server, and records the scheduling; when other packets of this request arrive, they are also forwarded to the selected server.

In the content-based request distribution technology, the server can provide different services. when a customer requests arrive, the scheduler can select the server to execute the request based on the request content.

Scheduling algorithm:

Call Scheduling: requests are scheduled to different servers in turn in the form of a call. the algorithm is concise and does not need to record the status of all links currently. it is a stateless scheduling.

Weighted round scheduling: the server's processing performance is represented by the corresponding weights. the default weights are 1. requests are allocated to each server based on the weights and call methods.

Minimal connection scheduling: allocates new connection requests to the server with the smallest number of connections currently. it is a dynamic scheduling algorithm that uses the number of active connections on the server to estimate the server load.

Weighted least connection scheduling: the corresponding weights of each server indicate its processing performance. Make sure that the number of established connections on the server is proportional to its weight.

Local-based minimum link: When the server load balancer is deployed, requests with the same IP address are scheduled to the same server to improve the access locality and master cache hit rate of each server.

Local least link with replication: unlike local least link, this requires maintaining the ing from a Target IP address to a group of servers.

Target address hash scheduling: a static ing algorithm that uses a hash function to map a target IP address to a server.
SOURCE address hash scheduling: opposite to target address hash scheduling, the corresponding server is found from the hash list of static allocation based on the requested source IP address as the hash value.

Server load balancer technology vs/nat: using network address translation technology, a group of servers are formed into a high-availability, high-performance virtual server. Vs/tun: virtual server through ip tunnel vs/dr: Virtual Server virtual ip through direct routing: the real ip address of director used to provide services to client computers: use the ip address on the cluster node to provide the ip address of the real service machine director: ip address used by director to connect to the D/rip network client ip address: ip address assigned to the client computer, the source address of the request sent to the cluster.

1. lvs (nat mode configuration)

(1) prepare the network environment
Real Server (application service, IP address, Gateway)
Scheduling server (IP address, data forwarding settings)
Firewall server (IP address, data forwarding settings, NAT configuration)

(2) scheduling server configuration
# Vim/etc/sysctl. conf
Net. ipv4.ip _ forward = 1
# Sysctl-p
# Yum install ipvsadm
# Ipvsadm-A-t 172.16.10.111: 80-s rr
# Ipvsadm-a-t 172.16.10.111: 80-r 10.0.0.11: 80-m
# Ipvsadm-a-t 172.16.10.111: 80-r 10.0.0.12: 80-m
# Ipvsadm-a-t 172.16.10.111: 80-r 10.0.0.13: 80-m
# Service ipvsadm save

(3) firewall configuration
# Vim/etc/sysctl. conf
Net. ipv4.ip _ forward = 1
# Sysctl-p

# Iptables-t nat-a prerouting-I eth1-s 10.10.10.0/24-p tcp -- dport 80-j DNAT -- to-destination = 172.16.10.111: 80

2. lvs (dr mode configuration)
(1) Client configuration
Eth0 (cip): 10.10.10.10
Gw: 10.10.10.110

(2) firewall configuration (Fireware)
Ip configuration
Eth0: 172.16.10.111 (Firewall and scheduling server communication address)
Eth1: 10.10.10.11 (client Gateway)
Eth2: 10.0.0.163 (the communication address between the firewall and the real machine)

# Vim/etc/sysctl. conf
Net. ipv4.ip _ forward = 1
# Sysctl-p

# Iptables-t nat-a prerouting-I eth1-s 10.10.10.0/24-p tcp -- dport 80-j DNAT -- to-destination = 172.16.10.111: 80

(3) configuration of the scheduling server (ldirector)
Ip configuration
Eth0: 10.0.0.164 (communication address with the real server)
Eth1: 172.16.10.100 (Virtual ip (vip ))
Gw: 172.16.10.111

Note: Solve the Error, some other host already uses address 10.0.0.164.
# Vim/etc/sysconfig/network-scripts/ifup-eth \ comment out four lines
# If! /Sbin/arping-q-c 2-w 3-D-I $ {REALDEVICE }$ {ipaddr [$ idx]}; then
# Net_log $ "Error, some other host already uses address $ {ipaddr [$ idx]}."
# Exit 1
# Fi

Configure packet forwarding
# Vim/etc/sysctl. conf
Net. ipv4.ip _ forward = 1
# Sysctl-p

Configure scheduling
# Ipvsadm-A-t 172.16.10.100: 80-s rr
# Ipvsadm-a-t 172.16.10.100: 80-r 10.0.0.11: 80-g
# Ipvsadm-a-t 172.16.10.100: 80-r 10.0.0.12: 80-g
# Ipvsadm-a-t 172.16.10.100: 80-r 10.0.0.13: 80-g
# Ipvsadm-L-n \ view ipvsadm configuration
# Ipvsadm-L-n -- stats \ view ipvsadm status

Add Gateway
# Route add default gw 172.16.10.111

(4) real server configuration
Ip configuration
1) ip address: 10.0.0.11/16
Gw: 10.0.0.139
Vip: 172.16.10.100
# Ifconfig lo: 0 172.16.10.100/32 broadcast 172.16.10.100

Disable receiving broadcast response configuration
# Vim/etc/sysctl. conf
Net. ipv4.conf. lo. arp_ignore = 1
Net. ipv4.conf. lo. arp_announce = 2
Net. ipv4.conf. all. arp_ignore = 1
Net. ipv4.conf. all. arp_announce = 2
# Sysctl-p
Or
# Yum install arptables_jf
# Arptables-a in-d 172.16.10.100-j DROP

Add route
# Route add-host 172.16.10.100 dev lo: 0

Related Article

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.