Nat mode of LVS cluster
Basic concepts:
Cluster :cluster is a group of computers that provide users with a set of network resources as a whole, and these individual computer systems are nodes of the cluster
Types of clusters:
LB Load Balancer cluster HA high availability cluster HPC high Performance computing cluster
How LB is implemented:
1 Software-f5 Load Balancer
2 hardware LVS (4 layers) Nginx (7 layers)
LVS (Linux Virtual Server)
Official website: http://www.linuxvirtualserver.org (English)
http://zh.linuxvirtualserver.org
LVS mode
1 NAT 2 DR 3 TUN
The LVS cluster uses a three-tier structure:
1 Load Scheduler: Responsible for sending the customer's request to the real server execution, the customer will be considered to be the same IP address, we call the VIP address of the public network
2 Server pool: The server that really provides service to the user, the execution service has web,mail,ftp,dns and so on
3 shared storage: In order to ensure that the data provided by the server is consistent, the shared storage area provides the same service, the same content
Features of NAT
Pros: can support any operating system, as well as private networks, and only need a public IP address
Disadvantage: The performance of the entire system is limited, because the execution of NAT every time the need to rewrite the packet, there is a certain delay, another 80% of the data is sent from the server to the client, that is, the user's request is very short, and the server response is very large, the load Balancer to form a great pressure, become a new bottleneck
How the LVS NAT mode works
When the client accesses the scheduler, the scheduler rewrites the destination address of the request message through the network address translation, dispatches the request to the real server in the backend according to the preset scheduling algorithm, and the response message of the real server is rewritten by the scheduling algorithm, the source address of the message is overwritten, and then returned to the customer to complete the whole load dispatch process.
the dispenser is set Reset:
1 ability to turn on packet forwarding
vim/etc/sysctl.conf Net.ipv4.ip_forward = 1 sysctl-p effective immediately (power on automatically)
or modify the kernel parameters echo 1 > Proc/sys/net/ipv4/ip_forward (Temporary effect)
2 Installing the LVS management tool ipvsadmin
rpm-ivh/mnt/packages/ipvsadmin-1.25-9el6x86_64.rpm
3 Add IP address ifconfig-a to see all of the interface information
Setup adds an IP address to the same network segment as the real server
Restart Network Service: Service network restart
View the default gateway Route-n
4 Setting up Rules
Ipvsadm-a-T 192.168.1.63:80-s RR (start polling scheduling algorithm) (VIP)
-a means adding
-T represents the TCP service Vip:port
-s set scheduling algorithm RR indicates polling
5 Add Realserver Address
Ipvsadm-a-T 192.168.1.63:80-r 192.168.2.62-m
Ipvsadm-a-T 192.168.1.63:80-r 192.168.2.64-m
-a means to add an realserver address
-R Make Realserver address
-M means Masquerade is the LVs of NAT
6 Save Configuration
/etc/init.d/ipvsadm Save
7 Viewing Ipvsadmin rules
Ipvsadm-l-N
Ipvsadm-l-n-c (see details of connections)
-NL viewing rules, displaying the kernel Virtual server table
-NLC viewing the client connection dispatcher and Realserver
--state view distribution, number of databases and connections
--rate Viewing connection Rates
Configuration of multiple real server side:
1 Configuring the IP address
Vim/etc/sysconfig/network-scripts/ifcfg-eth0
2 Modifying the NIC mode
Modify the NIC mode to the same network segment as the dispatcher Vmnet4 communication is normal at the same address segment
3 Opening httpd Service
Download Web server software to open the httpd process
Yum Install-y httpd
Service httpd Restart
You can achieve NAT load balancing by writing a static page to the/var/www/html, as for the same storage pool, and I would like to write about it later.
This article is from the "Linux niche" blog, make sure to keep this source http://wangwenxi.blog.51cto.com/10480746/1685100
Load balancing in the NAT mode of LVS