Linux Advanced Skills: heartbeat + lvs (2) and heartbeatlvs
The previous post introduced the separate use of heartbeat. Today we will first introduce the separate use of lvs, and finally combine the two. Provide a comprehensive service.
1. Three load balancing technologies of LVS:
Fortunately, the LVS module has been built in kernel 2.6x, and The LVS installation package ipvsadm is also available in redhat6.
Next we will compare the three Server Load balancer technologies of LVS:
1. Implement Virtual Server (VS/NAT) through NAT ):
Due to the increasing shortage of IP address space and security in IPv4, many networks use reserved IP addresses. These addresses are not used on the Internet, but are reserved for internal networks. When hosts in the internal Network need to access the Internet or be accessed by the Internet, Network Address Translation (NAT) is required ), convert an internal address to an external address available on Internets. In this way, when the external network accesses the service, it actually accesses the IP address that can communicate with the outside, but the accessed content is load balancing on the Intranet node. Shows the principle:
2. implement virtual servers (VS/TUN) through IP tunneling ):
Its connection scheduling and management are the same as those in VS/NAT, but its packet forwarding methods are different. The scheduler dynamically selects a server based on the load of each server, encapsulates the request packet in another IP packet, and then forwards the encapsulated IP packet to the selected server; after receiving the packet, the server unseals the packet and obtains the packet whose original destination address is VIP. The server finds that the VIP address is configured on the local IP tunneling device, so it processes the request, then, the response packet is directly returned to the customer based on the route table.
Remember that the difference between it and NAT is that you can directly establish a connection with the client. Shows the principle:
3. Implement Virtual Server (VS/DR) through direct routing ):
Both the scheduler and the server group must physically have a network adapter connected through a non-disconnected LAN, such as through a high-speed switch or HUB. The VIP address is shared by the scheduler and the server group. The VIP address configured by the scheduler is externally visible and used to receive request packets from virtual services; all servers configure the VIP address on their Non-ARP network devices. It is invisible to the outside and is only used to process network requests whose target address is VIP.
This model is what we need to do today. Each node has a virtual IP (control node and node (RS) that actually provides services )), the scheduling is completed by the Controller (RR wheel is called an algorithm), and the service does not provide services actively. Like TUN, they can also communicate directly with clients. Principle:
2. installation and configuration of LVS:
First, open the familiar console:
Install ipvsadm:
No scheduling list currently:
Add a virtual ip address as a public access ip Address:
We added the httpd service port of the virtual ip address and adopted the calling algorithm (RR ):
The following code allows the httpd service of server106 and server107 to act as the node of the wheel call:
Install the httpd service on serevr106 and server107 respectively:
Image 8
Then we need to do the following:
1. server106 and server107 should be able to identify the virtual IP address 192.168.2.110, so they should also add this virtual Nic.
2. To reflect the calling effect, we can write different content in the default release directory of the two to show the difference.
Image 9
Image 10
Now, the control node and the node that provides real services can recognize the VIP (192.168.2.110). Next we will add a policy on the node that provides services. This feeling is similar to that of the firewall, however, you need to install an additional software:
Image 11
No policy settings yet:
Figure 13
Add a policy to discard all the packets directly accessing 192.168.2.110, so that the packets from 192.168.2.110 go out from 192.168.2.106 (same as 192.168.2.107 ).
Figure 14
Image 15
Save policy:
Image 16
Now we use a browser to repeatedly access 192.168.2.110 (ensure that the httpd service on the service node is enabled) and refresh it several times:
This is the information recorded by the control node before access:
Image 17
After 32 accesses, we found that the two nodes each call 16 times, but the accessed ip addresses are all virtual ip addresses (192.168.2.110). This is the LVS solution for direct connection.
And the content of the webpage is also changing:
3. Summary:
This post first introduces three Server Load balancer technologies of LVS, and then we have established LVS in direct connection, in the next post, we will combine LVS and heartbeat to form a robust service.
Heartbeat dual-host hot standby service setup on linux I 'd like to ask if heartbeat comes with LINUX
Heartbeat is only carried by suse, rh, and centos. You can see it in the cluster suite, and there is it in the CD. What's more, we recommend you find it online. It's useless to use images.
LVS + heartbeat Problems
What do you mean by this question? What do you want?