WO2013097484A1 - 虚拟机集群的负载均衡方法、服务器及*** - Google Patents

虚拟机集群的负载均衡方法、服务器及*** Download PDF

Info

Publication number
WO2013097484A1
WO2013097484A1 PCT/CN2012/081175 CN2012081175W WO2013097484A1 WO 2013097484 A1 WO2013097484 A1 WO 2013097484A1 CN 2012081175 W CN2012081175 W CN 2012081175W WO 2013097484 A1 WO2013097484 A1 WO 2013097484A1
Authority
WO
WIPO (PCT)
Prior art keywords
virtual machine
server
address
response message
load balancer
Prior art date
Application number
PCT/CN2012/081175
Other languages
English (en)
French (fr)
Inventor
刘利锋
杨强
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2013097484A1 publication Critical patent/WO2013097484A1/zh

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1001Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
    • H04L67/1038Load balancing arrangements to avoid a single path through a load balancer

Definitions

  • the present invention relates to the field of virtual machine clusters, and in particular, to a load balancing method, server and system for a virtual machine cluster. Background technique
  • Computer clusters are computer systems that work together in a highly tightly coordinated manner through a loosely integrated set of computer software or hardware.
  • the computer cluster is operated by one or more virtual machines simulated on the server, the computer cluster is a virtual machine cluster.
  • Load balancing refers to balancing workloads (work tasks) and distributing them to multiple operating units, such as Web servers, FTP servers, enterprise critical application servers, and other key task servers to accomplish work tasks together.
  • the LVS (Linux Virtual Server) project provides the most commonly used load balancing software on the Linux operating system.
  • the LVS system includes a front end for receiving a request message sent by the client, a load balancer for task distribution, and a server at the back end.
  • An IP address is configured on the load balancer to communicate with the load balancer, and each virtual machine is configured with a unique IP address. Because the IP addresses of the two ends are different, in order to enable the request message to be accurately received and processed,
  • the existing LVS system uses Network Address Translation (NAT) to implement load balancing.
  • NAT Network Address Translation
  • the client sends a request packet whose destination address is the load balancer address to the load balancer.
  • the load balancer provides true A virtual machine is selected in the service virtual machine and the address of the request message is modified to the address of the selected virtual machine and sent to the server where the virtual machine is located; the virtual machine processes the request message to obtain a response message.
  • the response message is sent to the load balancer through the server where it is located; the load balancer sends the response message to the client.
  • the response packet needs to be sent from the server to the load balancer, and then forwarded to the client by the load balancer. Therefore, the communication path is long and the communication efficiency is not high.
  • the present invention provides the following solutions:
  • a load balancing method for a virtual machine cluster is applied to a server, where the method includes: receiving a second request packet sent by a load balancer; and the second request packet is that the load balancer receives the client After the first request message is sent, the destination address of the first request message is generated by converting the address of the load balancer to an address of a virtual machine on the server.
  • the invention also provides a server, the server comprising:
  • a source address translation unit a sending unit, and at least one virtual machine.
  • the virtual machine is configured to generate a first response message according to the second request packet sent by the received load balancer, where the second request message is that the load balancer receives the first request sent by the client After the message is received, the destination address of the first request message is generated by converting the address of the load balancer to the address of the virtual machine.
  • the source address translation unit is configured to convert a source address of the first response message from an address of the virtual machine to an address of the load balancer to generate a second response message.
  • the sending unit is configured to send the second response message to the client.
  • the virtual network card of the virtual machine is bridged to the virtual bridge, and the source address translation unit is connected to the virtual network bridge and the physical network card of the server.
  • the virtual machine sends the first response message to the source address translation unit through the virtual bridge.
  • the sending unit sends the second response message to the client by using a physical network card of the server.
  • the virtual machine receives the second request packet by using a virtual network card, a virtual bridge, and a physical network card that are sequentially connected.
  • the source address translation unit includes a firewall.
  • the present invention also provides a virtual machine cluster system, the system comprising:
  • the load balancer is configured to receive a first request packet sent by the client, and convert the destination address of the first request packet from an address of the load balancer to an address of a virtual machine on the server.
  • the second request message is generated.
  • the server includes: a virtual machine, a source address translation unit, and a sending unit.
  • the virtual machine is configured to generate a first response packet according to the received second request packet.
  • the source address translation unit is configured to convert a source address of the first response message from an address of the virtual machine to an address of the load balancer to generate a second response message.
  • the sending unit is configured to send the second response message to the client.
  • the virtual network card of the virtual machine is bridged to the virtual bridge, and the source address translation unit is connected to the virtual network bridge and the physical network card of the server;
  • the virtual machine sends the first response message to the source address translation unit through the virtual bridge; the sending unit sends the second response message to the client by using the physical network card of the server.
  • the source address translation unit includes a firewall.
  • the system includes a Linux virtual server system.
  • the present invention discloses the following technical effects:
  • the source address translation of the response message is performed in the server, and the converted message is directly sent to the client, which solves the problem that the server needs to send the generated response message to the load balancer in the prior art.
  • Source address translation which leads to the problem of low communication efficiency of the virtual machine cluster system.
  • Embodiment 1 is a flow chart of Embodiment 1 of the present invention.
  • FIG. 2 is a structural diagram of a server according to Embodiment 2 of the present invention.
  • Figure 3 is a connection diagram of virtual machines and proxy units on the server in Embodiment 2 of the present invention.
  • Figure 4 is a system configuration diagram of Embodiment 3 of the present invention. detailed description
  • the virtual machine, the load balancer and the client are in the same subnet range, and the client refers to the last one in the subnet range to receive the request report from the external network. Network equipment.
  • Embodiment 1 of the present invention provides a load balancing method for a virtual machine cluster, which is applied to a server.
  • the method includes the following steps:
  • the loader equalizes the destination address of the first request message from the address of the load balancer to the address of a virtual machine on the server.
  • the front end is one or more load balancers
  • the back end is one or a group of servers that provide real services. More specifically, the back end is a set of virtual machines that are simulated by software on a server that provides real services. Specifically, multiple virtual machines can be simulated on the same server, or multiple virtual machines can be simulated on multiple servers. Configured on the load balancer
  • IP address in order for the load balancer to communicate with the virtual machine, a unique IP address is configured on each virtual machine.
  • the IP address of all the virtual machines on the backend is saved in the load balancer. Therefore, after receiving the first request packet whose destination address is its own IP address, the load balancer selects a virtual machine from the back end, and The destination address of the first request packet is modified to be the address of the virtual machine, and the second request packet is generated and sent to the virtual machine. The virtual machine sees that the received second request message has the same address as its own IP address and will process it.
  • the load balancer can select the virtual machine according to certain rules, for example, according to the load of the backend virtual machine. In the present invention, no limitation is imposed on the specific selection process.
  • the load balancer in order to ensure that the request message is sent accurately, the load balancer also updates the IP address of the virtual machine stored therein according to the change of the backend virtual machine to ensure that the virtual machine is saved.
  • the IP address of the machine corresponds to the virtual machine at the back end.
  • the virtual machine that receives the second request message processes and generates a first response message. For example, according to the data and operators carried in the second request packet, the calculation is performed, and the calculation result is carried in the first response message.
  • the virtual machine according to the packet generation rule, the destination address and the source address of the first response message are opposite to the destination address and the source address of the received second request message. That is, the source address of the first response message is the IP address of the virtual machine selected by the load balancer, and the destination address is the IP address of the client.
  • source address translation is performed by setting a proxy (agent) in the server or by using firewall software. Set the source address of the received message to the IP address of the load balancer in the proxy or firewall software.
  • the source address of the second response packet generated in this way is the same as the destination address of the first request packet, and can be directly sent back to the client.
  • the proxy Take the proxy as an example. You can bridge the virtual network adapter of the virtual machine on the same server to the specified virtual bridge.
  • the proxy connects the virtual bridge and the physical NIC of the server to send the response packets from each virtual machine to the virtual machine.
  • the proxy performs source address translation and sends it to the client through the physical NIC of the server.
  • the user's data is stored in the virtual machine, so the proxy must not be set in the virtual machine to convert the source address.
  • the source address is the IP address of the load balancer.
  • the client looks as if all the packets pass the same IP address, that is, the IP address of the load balancer. Send and receive. Therefore, the client can correctly receive the response message.
  • the conversion enables the response message to be sent to the load balancer without being sent to the load balancer, and the server directly sends the response message to the client, thereby shortening the transmission of the response message from the server to the client.
  • the path improves the communication efficiency of the system.
  • Embodiment 2 of the present invention further provides a server.
  • the server includes: a virtual machine 21, a source address translation unit 22, and a sending unit 23.
  • the virtual machine 21 is configured to generate a first response packet according to the second request packet sent by the received load balancer, where the second request packet is sent by the load balancer to the client. After the request message is received, the destination address of the first request message is generated by converting the address of the load balancer to the address of the virtual machine 21.
  • the virtual machine 21 is simulated by software on the server, and is used to provide true Real service. Specifically, one or more virtual machines 21 can be simulated on the same server.
  • the load balancer is configured with an IP address. In order for the load balancer to communicate with the virtual machine, a unique IP address is configured on each virtual machine.
  • the client first sends a first request message to the load balancer.
  • the destination address of the first request message is the IP address of the load balancer.
  • the load balancer After receiving the packet, the load balancer does not perform specific processing on the packet, but selects a virtual machine 21 from the backend server, and the packet is based on the IP address of the backend virtual machine 21 saved by itself. The address is modified to the IP address of the selected virtual machine 21, and then sent to the virtual machine 21.
  • the address of the second request message received by the virtual machine 21 is the same as its own IP address, and is processed to generate a first response message. According to the generation rule of the packet, the source address of the first response is the IP address of the virtual machine.
  • the source address translation unit 22 is configured to convert the source address of the first response message from the address of the virtual machine 21 to the IP address of the load balancer to generate a second response message.
  • the specific source address translation unit 22 can be a proxy unit or a firewall. Taking the proxy unit as an example, the connection relationship between the source address translation unit and the virtual machine is as shown in FIG. 3.
  • the virtual machine 211, the virtual machine 212, and the virtual machine 213 on the server are respectively connected to the designated by the respective virtual network cards 214, 215, and 216.
  • the proxy unit 221 connects the virtual bridge 24 and the physical network card 25 of the server.
  • the virtual machine may receive the second request message by using a virtual network card, a virtual bridge, and a physical network card that are sequentially connected.
  • the virtual machine sends the first response message to the source address translation unit through the virtual bridge; the sending unit sends the second response message to the client through the physical network card of the server.
  • the virtual machine 211 when the load balancer selects the virtual machine 211, the virtual machine 211 sends the generated response message to the proxy unit 221 through the virtual network card 214 for source address translation.
  • the source address conversion unit 22 in the present invention is disposed outside the virtual machine 21. Since the user's data is stored in the virtual machine 21, the source address translation unit 22 cannot and should not be set in the virtual machine.
  • the sending unit 23 is configured to send the second response message to the client.
  • the source address of the second response message received by the sending unit 23 is the same as the destination address of the first request message, and thus can be directly sent back to the client.
  • the server provided by the present invention sets the source address translation unit in itself, so that the generated response message does not need to be forwarded through the load balancer, thereby shortening the transmission path of the packet and improving the communication efficiency.
  • Embodiment 3 of the present invention further provides a virtual machine cluster system.
  • the system includes: a load balancer 31 and a server 32.
  • the system can have one or more load balancers 31 on the front end. Specifically, it can be set according to the number of forwarded messages and the number of backend servers 32.
  • the server 32 may also be one or a group, and may be set according to the number of packets to be processed. In the embodiment of the present invention, referring to Fig. 4, a plurality of servers 32 are included.
  • the load balancer 31 is configured to receive a first request message sent by the client, and convert the destination address of the first request message from an address of the load balancer 31 to a virtual state on the server 32.
  • the second request message is generated after the address of the machine.
  • An IP address is configured on the load balancer 31, and the destination address of the first request packet sent by the client is the IP address of the load balancer 31.
  • the load balancer 31 does not actually process the packet, but selects a virtual machine from the backend server 32, and modifies the address of the request packet to the address according to the IP address of the backend virtual machine stored by itself. Send the address of the selected virtual machine.
  • the server 32 includes: a virtual machine 321, a source address translation unit 322, and a transmitting unit 323.
  • a plurality of virtual machines 321 can be simulated on the same server 32.
  • the virtual machine 321 is configured to generate a first response message according to the received second request message. These virtual machines 321 each have their own unique IP address for communicating with the load balancer 31. According to the rule for generating a response packet, the source address of the response packet generated by the virtual machine is the IP address of the virtual machine.
  • the source address translation unit 322 is configured to use the virtual address of the first response>3 ⁇ 4 text by the virtual
  • the address of the machine 321 is converted to the address of the load balancer 31 to generate a second response message.
  • the specific source address translation unit 322 can be a proxy unit or a firewall. Taking the proxy unit as an example, each virtual machine 321 can be bridged to a designated virtual bridge through a respective virtual network card, and the virtual network bridge and the physical network card of the server 32 are connected by the proxy unit. The virtual machine 321 can send the first response message to the source address translation unit 322 through the virtual bridge.
  • the sending unit 323 is configured to send the second response to the client.
  • the second response packet may be sent to the client by using a physical network card of the server.
  • the source address of the second response message received by the sending unit 323 is the IP address of the load balancer. Therefore, the sending unit 323 can directly send the second response message back to the client.
  • the process of creating the virtual machine cluster is as follows:
  • IP address Assign an IP address to the virtual machine by means of DHCP (Dynamic Host Configuration Protocol) or by tampering with the virtual machine image configuration file.
  • DHCP Dynamic Host Configuration Protocol
  • the virtual machine IP address stored in the load balancer may be updated according to the change.
  • the virtual machine cluster system may be an LVS system. It should be noted that the server and system embodiments of the present invention correspond to the method embodiments of the present invention, and the relevant portions may refer to the method embodiments, which are not described in detail herein.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer And Data Communications (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

一种虚拟机集群的负载均衡方法、服务器及***。其中,所述方法包括:接收负载均衡器发来的第二请求报文;根据所述第二请求报文生成第一应答报文;将所述第一应答报文的源地址由所述虚拟机的地址转换为所述负载均衡器的地址,生成第二应答报文;将所述第二应答报文发送至所述客户端。本发明通过在服务器中将虚拟机生成的应答报文进行源地址转换,使得应答报文能够不必发送至负载均衡器,再由负载均衡器发送至客户端,因此,缩短了应答报文从服务器到客户端的发送路径,提高了***的通信效率。

Description

虚拟机集群的负载均衡方法、 服务器及*** 本申请要求于 2011 年 12 月 26 日提交中国专利局、 申请号为 201110441091.9、 发明名称为 "虚拟机集群的负载均衡方法、 服务器及***" 的中国专利申请的优先权, 其全部内容通过引用结合在本申请中。 技术领域
本发明涉及虚拟机集群领域, 尤其是涉及一种虚拟机集群的负载均衡方 法、 服务器及***。 背景技术
随着计算机技术的发展, 尤其是网絡技术的发展和利用, 人们对计算机 ***, 特别是网络服务器提出了更高的要求, 单纯的靠提高单个处理器的处 理能力来提高服务器性能, 正在变得越来越难。 因此, 计算机集群服务得到 了广泛的应用。 计算机集群简称集群, 是一种计算机***, 它通过一组松散 集成的计算机软件或硬件连接起来高度紧密地协作完成计算工作。 当所述集 群是通过在服务器上模拟出的一台或多台虚拟机工作时, 所述计算机集群为 虛拟机集群。
负载均衡是指将负载 (工作任务) 进行平衡、 分摊到多个操作单元上进 行执行, 例如 Web服务器、 FTP服务器、 企业关键应用服务器和其它关键任 务服务器等, 从而共同完成工作任务。
LVS ( Linux Virtual Server, Linux虚拟服务器)项目在 Linux操作***上 提供了最常用的负载均衡软件。 以基于虚拟机的 LVS***为例, LVS***包 含一个前端用以接收客户端发送的请求报文, 进行任务分发的负载均衡器, 和后端的服务器。 在后端的服务器上有一组真正提供服务的虚拟机。 在负载 均衡器上配置有 IP地址, 为和负载均衡器通信, 在每个虚拟机上配置有唯一 的 IP地址。 因为两端的 IP地址不同 , 为使请求艮文能被准确的接收和处理, 现有的 LVS***采用网络地址转换(Network Address Translation, 以下简称 NAT ) 实现负载均衡, 具体为: 客户端发送目的地址为负载均衡器地址的请 求报文至负载均衡器; 负载均衡器从提供真正服务的虚拟机中选定一台虚拟 机并把请求艮文的地址修改为选定的虚拟机的地址后发送至该虚拟机所在的 服务器; 虚拟机对请求报文进行处理获得应答报文, 并通过所在的服务器将 应答报文发送至负载均衡器; 负载均衡器再将应^艮文发送至客户端。
应用上述方法, 在虚拟机集群中, 应答报文需要从服务器发送至负载均 衡器, 再由负载均衡器转发给客户端, 因此, 通信路径长, 通信效率不高。 发明内容
本发明的目的在于提供一种虚拟机集群的负载均衡方法、 服务器及***, 能够使应答报文从服务器直接发送至客户端, 提高了通信效率。 本发明提供 了如下方案:
一种虚拟机集群的负载均衡方法, 应用在服务器中, 所述方法包括: 接收负载均衡器发来的第二请求报文; 所述第二请求报文是所述负载均 衡器接收到客户端发送的第一请求报文后, 将所述第一请求报文的目的地址 由所述负载均衡器的地址转换为所述服务器上一虚拟机的地址后生成的。
根据所述第二请求报文生成第一应答报文。
将所述第一应答报文的源地址由所述虚拟机的地址转换为所述负载均衡 器的地址, 生成第二应答^ ¾文。
将所述第二应答报文发送至所述客户端。
本发明还提供了一种服务器, 所述服务器包括:
源地址转换单元、 发送单元和至少一个虚拟机。
所述虚拟机, 用于根据接收的负载均衡器发来的第二请求报文生成第一 应答报文; 所述第二请求报文是所述负载均衡器接收到客户端发送的第一请 求报文后, 将所述第一请求报文的目的地址由所述负载均衡器的地址转换为 所述虚拟机的地址后生成的。 所述源地址转换单元, 用于将所述第一应答报文的源地址由所述虚拟机 的地址转换为所述负载均衡器的地址, 生成第二应答报文。
所述发送单元, 用于将所述第二应答报文发送至所述客户端。
可选的, 所述虚拟机的虚拟网卡桥接到虚拟网桥上, 所述源地址转换单 元连接所述虚拟网桥和所述服务器的物理网卡。
所述虚拟机将第一应答报文通过虚拟网桥发送到源地址转换单元。
所述发送单元通过服务器的物理网卡将所述第二应答报文发送至所述客 户端。
可选的, 所述虚拟机通过依次连接的虚拟网卡、 虚拟网桥和物理网卡接 收所述第二请求报文。
可选的, 所述源地址转换单元包括防火墙。
本发明还提供了一种虚拟机集群***, 所述***包括:
负载均衡器和服务器。
所述负载均衡器, 用于接收客户端发送的第一请求报文, 并将所述第一 请求报文的目的地址由所述负载均衡器的地址转换为所述服务器上一虚拟机 的地址后生成第二请求报文。
所述服务器包括: 虚拟机, 源地址转换单元和发送单元。
所述虚拟机, 用于根据接收的所述第二请求报文生成第一应答报文。 所述源地址转换单元, 用于将所述第一应答报文的源地址由所述虚拟机 的地址转换为所述负载均衡器的地址, 生成第二应答报文。
所述发送单元, 用于将所述第二应答报文发送至所述客户端。
可选的, 所述虚拟机的虚拟网卡桥接到虚拟网桥上, 所述源地址转换单 元连接所述虚拟网桥和所述服务器的物理网卡;
所述虚拟机将第一应答报文通过虚拟网桥发送到源地址转换单元; 所述发送单元通过服务器的物理网卡将所述第二应答报文发送至所述客 户端。
可选的, 所述源地址转换单元包括防火墙。 可选的, 所述***包括 Linux虚拟服务器***。
根据本发明提供的具体实施例, 本发明公开了以下技术效果:
本发明中, 通过在服务器中进行应答报文的源地址转换, 并直接将转换 后的报文发送至客户端, 解决了现有技术中服务器需将生成的应答报文发送 至负载均衡器进行源地址转换, 从而导致虚拟机集群***通信效率低的问题。 附图说明
为了更清楚地说明本发明实施例或现有技术中的技术方案, 下面将对实 施例中所需要使用的附图作简单地介绍, 显而易见地, 下面描述中的附图仅 仅是本发明的一些实施例, 对于本领域普通技术人员来讲, 在不付出创造性 劳动性的前提下, 还可以根据这些附图获得其他的附图。
图 1是本发明实施例 1的流程图;
图 2是本发明实施例 2的服务器结构图;
图 3是本发明中实施例 2中服务器上各虚拟机和代理单元的连接图; 图 4是本发明中实施例 3的***结构图。 具体实施方式
下面将结合本发明实施例中的附图, 对本发明实施例中的技术方案进行 清楚、 完整地描述, 显然, 所描述的实施例仅仅是本发明一部分实施例, 而 不是全部的实施例。 基于本发明中的实施例, 本领域普通技术人员在没有做 出创造性劳动前提下所获得的所有其他实施例, 都属于本发明保护的范围。
值得注意的是本发明实施例中所述的虚拟机, 负载均衡器和客户端处在 同一个子网范围内, 所述的客户端是指所述子网范围内最后一个从外网接收 请求报文的网络设备。
本发明实施例 1 提供了一种虚拟机集群的负载均衡方法, 应用在服务器 中, 参见图 1 , 该方法包括以下步骤:
Sl、 接收负载均衡器发来的第二请求报文; 所述第二请求报文是所述负 载均衡器接收到客户端发送的第一请求报文后, 将所述第一请求报文的目的 地址由所述负载均衡器的地址转换为所述服务器上一虚拟机的地址后生成 的。
在虚拟机集群***中, 前端是一个或多个负载均衡器, 后端是一个或一 组提供真实服务的服务器。 更确切的说, 后端是一组提供真实服务的在服务 器上通过软件模拟出的虚拟机。 具体的可以是在同一个服务器上模拟出多个 虚拟机的, 也可以在多个服务器上模拟出多个虚拟机。 负载均衡器上配置有
IP地址, 为使负载均衡器和虚拟机通信 , 在每个虚拟机上配置有唯一的 IP地 址。
在负载均衡器中保存有后端所有虚拟机的 IP地址, 因此, 在接收到目的 地址为自身 IP地址的第一请求报文后,负载均衡器会从后端选定一个虚拟机, 并将该第一请求报文的目的地址修改为该虚拟机的地址, 生成第二请求报文 发送至该虚拟机。 虚拟机看到接收的第二请求报文的地址与自身的 IP地址相 同, 就会对其进行处理。 在具体的选择过程中, 负载均衡器可以按照一定的 规则选定虚拟机, 比如根据后端虚拟机的负载情况。 在本发明中, 不对具体 的选定过程做限制。
在本发明的具体实施例中, 为保证请求报文被发送准确, 负载均衡器还 会根据后端虚拟机的变化情况对保存在其中的虚拟机的 IP地址进行更新, 以 确保其保存的虚拟机的 IP地址与后端的虚拟机相对应。
52、 根据所述第二请求报文生成第一应答报文。
接收到第二请求报文的虚拟机会进行处理并生成第一应答报文。 例如根 据第二请求报文中携带的数据和操作符, 进行计算, 并将计算结果携带在第 一应答报文中。 所述虚拟机根据报文的生成规则, 该第一应答报文的目的地 址和源地址与接收的第二请求报文的目的地址和源地址相反。 即该第一应答 报文的源地址为负载均衡器选定的虚拟机的 IP地址, 目的地址为客户端的 IP 地址。
53、 将所述第一应答报文的源地址由所述虚拟机的地址转换为所述负载 均衡器的地址, 生成第二应答报文。
本发明中, 通过在服务器中设置 proxy (代理程序)或利用防火墙软件进行 源地址转换。在 proxy或防火墙软件中设置将接收到的报文的源地址转换为负 载均衡器的 IP地址。 这样生成的第二应答报文的源地址就与第一请求报文的 目的地址相同, 可以被直接发回到客户端。
以 proxy为例,可以将同一服务器上的虚拟机的虚拟网卡桥接到指定的虚 拟网桥上, 由 proxy连接虚拟网桥和所在服务器的物理网卡,从而将各虚拟机 上的应答报文发送至 proxy进行源地址转换,并经过服务器的物理网卡发送至 客户端。 为虛拟机内存储的是用户的数据, 所以不能也不应该在虚拟机内设置 proxy 进行源地址的转换。
S4、 将所述第二应答> ^文发送至所述客户端。
第二应答报文的地址在服务器中进行源地址转换后, 其源地址为负载均 衡器的 IP地址,在客户端看起来好像所有报文都是通过同一个 IP地址即负载 均衡器的 IP地址进行发送和接收的。 因此,客户端能够正确接收该应答报文。 转换, 使得应答报文能够不必发送至负载均衡器, 再由负载均衡器发送至客 户端, 而是服务器直接将应答报文发送给客户端, 因此, 缩短了应答报文从 服务器到客户端的发送路径, 提高了***的通信效率。
本发明实施例 2还提供了一种服务器, 参见图 2, 所述服务器包括: 虚拟机 21 , 源地址转换单元 22和发送单元 23。
所述虚拟机 21 , 用于根据接收的负载均衡器发来的第二请求报文生成第 一应答报文; 所述第二请求报文是所述负载均衡器接收到客户端发送的第一 请求报文后, 将所述第一请求报文的目的地址由所述负载均衡器的地址转换 为所述虚拟机 21的地址后生成的。
所述的虚拟机 21是在所述的服务器上通过软件模拟出来的, 用于提供真 实的服务。 具体的可以在同一服务器上模拟出一个或多个虚拟机 21。 负载均 衡器上配置有 IP地址, 为使负载均衡器和虚拟机通信, 在每个虚拟机上配置 有唯一的 IP地址。
客户端首先会发送第一请求报文至负载均衡器, 该第一请求报文的目的 地址就是该负载均衡器的 IP地址。 负载均衡器接收该报文后并不对该报文做 具体的处理, 而是从后端服务器中选定一虚拟机 21 , 并根据自身保存的后端 虚拟机 21的 IP地址,将该报文的地址修改为该选定的虚拟机 21的 IP地址后, 发送至该虚拟机 21。 虚拟机 21接收的第二请求艮文的地址与自身的 IP地址 相同, 就会对其进行处理生成第一应答报文。 根据报文的生成规则, 该第一 应答 文的源地址为该虚拟机的 IP地址。
所述源地址转换单元 22, 用于将所述第一应答 ·ί艮文的源地址由所述虚拟 机 21的地址转换为所述负载均衡器的 IP地址, 生成第二应答报文。
具体的源地址转换单元 22可以是代理单元或是防火墙。以代理单元为例, 源地址转换单元与虚拟机的连接关系如图 3所示, 服务器上的虚拟机 211 , 虚 拟机 212, 虚拟机 213分别通过各自的虚拟网卡 214,215,216以桥接的方式连 接到指定的虚拟网桥 24上, 代理单元 221连接所述的虚拟网桥 24和所述服 务器的物理网卡 25。
所述虚拟机可以通过依次连接的虚拟网卡、 虚拟网桥和物理网卡接收所 述第二请求报文。 所述虚拟机将第一应答 4艮文通过虚拟网桥发送到源地址转 换单元; 所述发送单元通过服务器的物理网卡将所述第二应答报文发送至所 述客户端。
在本发明的一个具体实施例中, 当负载均衡器选定虚拟机 211 时, 虚拟 机 211通过虚拟网卡 214,虚拟网桥 24将生成的应答 ^艮文发送至代理单元 221 进行源地址转换。
需要明确的是, 本发明中的源地址转换单元 22设置在虚拟机 21外。 因 为虚拟机 21内存储的是用户的数据, 所以不能也不应该在虚拟机内设置源地 址转换单元 22。 所述发送单元 23 , 用于将所述第二应答 4艮文发送至所述客户端。
经过源地址转换, 发送单元 23接收到的第二应答 · ^文的源地址与第一请 求报文的目的地址相同, 因此可以直接发回到客户端。
综上所述, 本发明提供的服务器通过在自身设置源地址转换单元, 使得 生成的应答报文无需再通过负载均衡器进行转发, 缩短了报文的发送路径, 提高了通信效率。
本发明实施例 3还提供了一种虚拟机集群***,参见图 4,所述***包括: 负载均衡器 31和服务器 32。
该***可以在前端设置一个或多个负载均衡器 31。 具体的可以根据报文 的转发数量和后端服务器 32的数量设置。 所述的服务器 32也可以是一个或 一组, 可以根据需要处理的报文数量进行设置。 在本发明的实施例中, 参见 图 4, 包含多个服务器 32。
所述负载均衡器 31 , 用于接收客户端发送的第一请求报文, 并将所述第 一请求报文的目的地址由所述负载均衡器 31 的地址转换为所述服务器 32上 一虚拟机的地址后生成第二请求艮文。
负载均衡器 31上配置有 IP地址,客户端发送的第一请求报文的目的地址 为负载均衡器 31的 IP地址。 负载均衡器 31并不对该报文做实际处理, 而是 从后端服务器 32上选定一台虚拟机,并根据自身存储的后端虚拟机的 IP地址 将该请求报文的地址修改为该选定虚拟机的地址后发送出去。
所述服务器 32包括: 虚拟机 321, 源地址转换单元 322和发送单元 323。 在本发明的具体实施例中, 参见图 4, 可在同一个服务器 32上可以模拟 多个虚拟机 321。
所述虚拟机 321 , 用于根据接收的所述第二请求报文生成第一应答报文。 这些虚拟机 321都拥有各自唯一的 IP地址, 用于与负载均衡器 31通信。 根据应答报文的生成规则, 虚拟机生成的应答报文的源地址为该虚拟机的 IP 地址。
所述源地址转换单元 322,用于将所述第一应答 >¾文的源地址由所述虚拟 机 321的地址转换为所述负载均衡器 31的地址, 生成第二应答报文。
具体的源地址转换单元 322 可以是代理单元或是防火墙。 以代理单元为 例, 各虚拟机 321 可以通过各自的虚拟网卡桥接到指定的虚拟网桥上, 由代 理单元连接所述的虚拟网桥和所述服务器 32的物理网卡。 虚拟机 321可以将 第一应答报文通过虚拟网桥发送到源地址转换单元 322上。
所述发送单元 323 , 用于将所述第二应答 文发送至所述客户端。 具体的 可通过服务器的物理网卡将所述第二应答报文发送至所述客户端。
经过源地址转换后, 发送单元 323接收到的第二应答报文的源地址为负 载均衡器的 IP地址, 因此, 发送单元 323可以直接将第二应答报文发回到客 户端。
在本发明的具体实施例中, 该虚拟机集群的创建过程如下:
为负载均衡器分配 IP地址;
在服务器上设置源地址转换单元并启动;
创建多个虚拟机, 并将虛拟机的虚拟网卡绑定到虚拟网桥;
通过 DHCP ( Dynamic Host Configuration Protocol, 动态主机设置协议 ) 或爹改虚拟机镜像配置文件的方式为虚拟机分配 IP地址;
定义虚拟机集群***, 将虚拟机加入其中, 并将虚拟机的 IP地址保存到 负载均衡器中;
启动虚拟机集群服务。
在具体的实施过程中, 还可以在后端虚拟机发生变化时, 根据该变化对 保存在负载均衡器中的虚拟机 IP地址进行更新。
在本发明的上述实施例中, 所述的虚拟机集群***可以为 LVS***。 需要说明的是, 本发明的服务器和***实施例与本发明方法实施例相对 应, 相关部分参照方法实施例即可, 此处不再故详细介绍。
以上对本发明所提供的一种虚拟机集群的负载均衡方法、 服务器和***, 进行了详细介绍, 本文中应用了具体个例对本发明的原理及实施方式进行了 阐述, 以上实施例的说明只是用于帮助理解本发明的方法及其核心思想; 同 时, 对于本领域的一般技术人员, 依据本发明的思想, 在具体实施方式及应 用范围上均会有改变之处。 综上所述, 本说明书内容不应理解为对本发明的 限制。

Claims

权 利 要 求
1、 一种虚拟机集群的负载均衡方法, 应用在服务器中, 其特征在于, 所 述方法包括:
接收负载均衡器发来的第二请求报文; 所述第二请求报文是所述负载均 衡器接收到客户端发送的第一请求报文后, 将所述第一请求报文的目的地址 由所述负载均衡器的地址转换为所述服务器上一虚拟机的地址后生成的; 根据所述第二请求报文生成第一应答报文;
将所述第一应答报文的源地址由所述虚拟机的地址转换为所述负载均衡 器的地址, 生成第二应答 文;
将所述第二应答报文发送至所述客户端。
2、 一种服务器, 其特征在于, 所述服务器包括:
源地址转换单元、 发送单元和至少一个虚拟机;
所述虚拟机, 用于根据接收的负载均衡器发来的第二请求报文生成第一 应答报文; 所述第二请求报文是所述负载均衡器接收到客户端发送的第一请 求报文后, 将所述第一请求报文的目的地址由所述负载均衡器的地址转换为 所述虚拟机的地址后生成的;
所述源地址转换单元, 用于将所述第一应答报文的源地址由所述虚拟机 的地址转换为所述负载均衡器的地址, 生成第二应答报文;
所述发送单元, 用于将所述第二应答报文发送至所述客户端。
3、 根据权利要求 2所述的服务器, 其特征在于, 所述虚拟机的虚拟网卡 桥接到虚拟网桥上, 所述源地址转换单元连接所述虚拟网桥和所述服务器的 物理网卡;
所述虚拟机将第一应答报文通过虚拟网桥发送到源地址转换单元; 所述发送单元通过服务器的物理网卡将所述第二应答报文发送至所述客 户端。
4、 根据权利要求 2所述的服务器, 其特征在于, 所述虚拟机通过依次连 接的虚拟网卡、 虚拟网桥和物理网卡接收所述第二请求报文。
5、 根据权利要求 2-4任一所述的服务器, 其特征在于, 所述源地址转换 单元包括防火墙。
6、 一种虚拟机集群***, 其特征在于, 所述***包括:
负载均衡器和服务器;
所述负载均衡器, 用于接收客户端发送的第一请求报文, 并将所述第一 请求报文的目的地址由所述负载均衡器的地址转换为所述服务器上一虚拟机 的地址后生成第二请求 4艮文;
所述服务器包括: 虚拟机, 源地址转换单元和发送单元;
所述虚拟机, 用于根据接收的所述第二请求报文生成第一应答报文; 所述源地址转换单元, 用于将所述第一应答报文的源地址由所述虚拟机 的地址转换为所述负载均衡器的地址, 生成第二应答报文;
所述发送单元, 用于将所述第二应答报文发送至所述客户端。
7、 根据权利要求 6所述的***, 其特征在于, 所述虚拟机的虛拟网卡桥 接到虚拟网桥上, 所述源地址转换单元连接所述虚拟网桥和所述服务器的物 理网卡;
所述虚拟机将第一应答报文通过虚拟网桥发送到源地址转换单元; 所述发送单元通过服务器的物理网卡将所述第二应答报文发送至所述客 户端。
8、 根据权利要求 6或 7所述的***, 其特征在于, 所述源地址转换单元 包括防火墙。
9、 根据权利要求 6或 7所述的***, 其特征在于, 所述***包括 Linux 虚拟服务器***。
PCT/CN2012/081175 2011-12-26 2012-09-10 虚拟机集群的负载均衡方法、服务器及*** WO2013097484A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201110441091.9A CN102523302B (zh) 2011-12-26 2011-12-26 虚拟机集群的负载均衡方法、服务器及***
CN201110441091.9 2011-12-26

Publications (1)

Publication Number Publication Date
WO2013097484A1 true WO2013097484A1 (zh) 2013-07-04

Family

ID=46294089

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2012/081175 WO2013097484A1 (zh) 2011-12-26 2012-09-10 虚拟机集群的负载均衡方法、服务器及***

Country Status (2)

Country Link
CN (1) CN102523302B (zh)
WO (1) WO2013097484A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2021083284A1 (zh) * 2019-10-31 2021-05-06 贵州白山云科技股份有限公司 一种负载均衡方法、装置、介质和设备

Families Citing this family (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102523302B (zh) * 2011-12-26 2015-08-19 华为数字技术(成都)有限公司 虚拟机集群的负载均衡方法、服务器及***
CN103441944B (zh) * 2013-08-20 2017-03-08 深信服网络科技(深圳)有限公司 基于负载均衡设备处理数据的方法和负载均衡设备
CN104780115B (zh) * 2014-01-14 2019-06-18 上海盛大网络发展有限公司 云计算环境中负载均衡方法及***
CN105162883B (zh) 2015-09-25 2019-06-07 网宿科技股份有限公司 网络负载均衡处理***及其方法和装置
CN106027388B (zh) * 2016-05-13 2019-04-12 清华大学 一种sdn域间路由信息传递方法
CN106230992B (zh) * 2016-09-28 2019-04-26 ***股份有限公司 一种负载均衡方法和负载均衡节点
CN106686085B (zh) * 2016-12-29 2020-06-16 华为技术有限公司 一种负载均衡的方法、装置和***
CN107087023B (zh) 2017-04-06 2019-11-05 平安科技(深圳)有限公司 数据转发方法和***
CN107786669B (zh) * 2017-11-10 2021-06-22 华为技术有限公司 一种负载均衡处理的方法、服务器、装置及存储介质
CN110730205B (zh) * 2019-09-06 2023-06-20 深圳平安通信科技有限公司 集群***部署的方法、装置、计算机设备和存储介质
CN111131439A (zh) * 2019-12-20 2020-05-08 浪潮电子信息产业股份有限公司 基于iSCSI的报文传输方法、装置、设备及存储介质
CN111641724B (zh) * 2020-06-04 2023-02-21 山东汇贸电子口岸有限公司 一种lvs负载均衡器在云下的应用方法
CN114697338A (zh) * 2020-12-28 2022-07-01 北京金山云网络技术有限公司 云计算的数据传输方法、装置以及服务端设备
CN113067824B (zh) * 2021-03-22 2023-04-07 平安科技(深圳)有限公司 数据调度方法、***、虚拟主机及计算机可读存储介质

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1859313A (zh) * 2006-04-30 2006-11-08 西安交通大学 一种多机服务器***中双向负载均衡机制的实现方法
CN101252591A (zh) * 2008-04-03 2008-08-27 中国科学技术大学 实现上下行数据分离的方法和装置
CN102523302A (zh) * 2011-12-26 2012-06-27 成都市华为赛门铁克科技有限公司 虚拟机集群的负载均衡方法、服务器及***

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6578066B1 (en) * 1999-09-17 2003-06-10 Alteon Websystems Distributed load-balancing internet servers
CN101159721B (zh) * 2007-11-12 2010-06-09 华为技术有限公司 互通网关***、设备和业务代理方法
CN101729606A (zh) * 2008-10-22 2010-06-09 华为技术有限公司 一种实现网络地址转换的方法及相关设备
CN101984623B (zh) * 2010-11-02 2013-09-18 北京天融信科技有限公司 防火墙网络地址转换动态负载均衡方法及装置

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1859313A (zh) * 2006-04-30 2006-11-08 西安交通大学 一种多机服务器***中双向负载均衡机制的实现方法
CN101252591A (zh) * 2008-04-03 2008-08-27 中国科学技术大学 实现上下行数据分离的方法和装置
CN102523302A (zh) * 2011-12-26 2012-06-27 成都市华为赛门铁克科技有限公司 虚拟机集群的负载均衡方法、服务器及***

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2021083284A1 (zh) * 2019-10-31 2021-05-06 贵州白山云科技股份有限公司 一种负载均衡方法、装置、介质和设备

Also Published As

Publication number Publication date
CN102523302B (zh) 2015-08-19
CN102523302A (zh) 2012-06-27

Similar Documents

Publication Publication Date Title
WO2013097484A1 (zh) 虚拟机集群的负载均衡方法、服务器及***
CN108449282B (zh) 一种负载均衡方法及其装置
CN112470436A (zh) 使用srv6和bgp的多云连通性
EP3225014B1 (en) Source ip address transparency systems and methods
JP2018523932A (ja) 負荷バランシングコンピュータデバイス、システム、および方法
US9143421B2 (en) Network system capable of implementing stun with the assistance of two network devices and method thereof
JP5220920B2 (ja) クライアント・アプリケーション・プログラムがインターネット・プロトコル(ip)ネットワーク上でサーバ・アプリケーション・プログラム・インスタンスにアクセスするための方法、装置、及びソフトウェア
KR20180108708A (ko) 서버 클러스터에 기초한 메시지 생성 방법 및 부하 균형기
US10771309B1 (en) Border gateway protocol routing configuration
EP2499787A2 (en) Smart client routing
US20120011230A1 (en) Utilizing a Gateway for the Assignment of Internet Protocol Addresses to Client Devices in a Shared Subset
US10237235B1 (en) System for network address translation
US11153269B2 (en) On-node DHCP implementation for virtual machines
US11936613B2 (en) Port and loopback IP addresses allocation scheme for full-mesh communications with transparent TLS tunnels
JP2015503158A (ja) データ・センターにおけるロール・インスタンス到達可能性
US9697173B2 (en) DNS proxy service for multi-core platforms
CN112968965B (zh) Nfv网络节点的元数据服务方法、服务器及存储介质
CN108141704B (zh) 先前网络消息处理器的位置标识
Wolinsky et al. On the design of scalable, self-configuring virtual networks
WO2023133344A1 (en) Nat-based traffic steering
TW202044805A (zh) 網路位址轉譯方法及系統
US10791088B1 (en) Methods for disaggregating subscribers via DHCP address translation and devices thereof
CN105516121B (zh) 无线局域网中ac与ap通信的方法及***
JP2013126219A (ja) 転送サーバおよび転送プログラム
JP2011239082A (ja) 通信装置及びアドレス変換方法

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 12861997

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 12861997

Country of ref document: EP

Kind code of ref document: A1

122 Ep: pct application non-entry in european phase

Ref document number: 12861997

Country of ref document: EP

Kind code of ref document: A1