Load Balancing cluster Introduction LVS introduction LVS scheduling algorithm LVS NAT mode construction

Source: Internet
Author: User
Tags haproxy

Main open source software LVs, keepalived, Haproxy, Nginx, etc.
The LVS belong to 4 layer (network OSI 7 layer model), Nginx belongs to 7 layer, Haproxy can be considered as 4 layer, can also be used as 7 layer
The Keepalived load balancing function is actually the LVS
LVS This 4-tier load balancer can distribute other ports except 80, such as MySQL, while Nginx supports only Http,https,mail,haproxy and MySQL.
In comparison, the 4-layer LVS is more stable, can withstand more requests, and nginx this 7-layer more flexible, to achieve more personalized requirements

Lvs
Three hosts
1 host Add host only native network card
23 host modifies the IP of the gateway to a 1 NIC
Execute on all three machines
Systemctl Stop Firewalld; SYSTEMC Disable FIREWALLD
Systemctl start iptables-services;
No found, systemctl start iptables
Iptables-f; Service Iptables Save

Install Yum Install-y ipvsadm on the Dispatcher
script on Dir, vim/usr/local/sbin/lvs_nat.sh//the following
#!/bin/bash
#director Enable route forwarding on the server
Echo 1 >/proc/sys/net/ipv4/ip_forward
#关闭icmp的重定向
Echo 0 >/proc/sys/net/ipv4/conf/all/ Send_redirects
Echo 0 >/proc/sys/net/ipv4/conf/default/send_redirects
#注意区分网卡名字, the Amin two NICs are ENS33 and ENS37, respectively
Echo 0 >/proc/sys/net/ipv4/conf/eno16777736/send_redirects
Echo 0 >/proc/sys/net/ipv4/conf/ Eno33554984/send_redirects
Director Set NAT firewall
iptables-t nat-f
iptables-t nat-x
#实现同网段ip能够联网
Iptables-t nat-a postrouting-s 192.168.67.0/24-j Masquerade
Director Settings Ipvsadm
ipvsadm= '/usr/sbin/ipvsadm '
$IPVSADM-C
$IPVSADM-A-T 192.168.32.128:80-s wlc-p 3 #新增规则wlc
$IPVSADM-T 192.168.32.128:80-r 192.168.67 .129:80-m-W 1
$IPVSADM-T 192.168.32.128:80-r 192.168.67.130:80-m-W 1

View Firewall rules


Edit Configuration

Two hosts installed Nginx
This is all source package installation, modify Nginx configuration
Host 1:z

Host 2:

Testing: Access to the service IP, experimental success.

Load Balancing cluster Introduction LVS introduction LVS scheduling algorithm LVS NAT mode construction

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.