Background technology
Have the target that a large amount of visits and user are the information service providers.But a large amount of visit capacities can be brought white elephant to server, and along with user number constantly increases, server becomes and sinks beneath one's burden, if can't in time handle a large number of users service request, will the situation of service disruption occur.When addressing these problems, can only adopt the server of stronger computing capability to replace original server, even so in the past, the load capacity of separate unit server also is limited, impossible infinite expanding, simultaneously, the price of server also rises along with server performance presents exponential type.Therefore, the scheme that adopts many low-cost servers to form the load balancing system day by day becomes main flow.
Form the load balancing systems with many low-cost servers and forms a server set by multiple servers with symmetrical manner, every station server all has the status of equality, service can externally be provided separately and need not assisting of other servers.And the request that load balancing equipment sends the outside is evenly distributed on a certain station server in the symmetrical structure, and receives the request that the requested service device is responded the client independently.
Fig. 1 is the schematic diagram of the server load balancing system of NAT mode of the prior art.Referring to Fig. 1, server load balancing comprises following basic element:
Load-balancing device: be responsible for the various service requests of distribution to each server;
Server: be responsible for response and handle various service requests;
VSIP: the virtual ip address that server cluster externally provides, use during for user request service;
Server ip address corresponding to the IP A among Fig. 1, IP B and IP C, uses during for the request of load-balancing device distribution services.
Fig. 2 is the flow chart of the server load balancing system handles service request of NAT mode shown in Figure 1.As shown in Figure 2, may further comprise the steps:
Step 201, client host is the load-balancing device that the service request of VSIP sends to the server cluster front end with destination address.
Step 202, load-balancing device are selected one server by dispatching algorithm.
Step 203, load-balancing device be by network address translation, behind the destination address with the address rewrite service request messages of selected server, service request messages sent to selected server.
Step 204, server sends to load-balancing device with the service response message, and wherein, the source IP address of this service response message is the IP of this server itself.
Step 205, load-balancing device is reduced to the empty VSIP that serves with the source IP address of service response message, returns to client host again, finishes whole load dispatch process.
Though the load-balancing technique of NAT mode has advantages such as high-performance, high likelihood, the transparency and extensibility are strong, also following shortcoming: load-balancing device is a separate equipment, and costs an arm and a leg.At present, the load-balancing device on the market all is specialized vendor's a autonomous device, and price is very expensive, and for most of middle-size and small-size data center servers, so expensive equipment is unable to reach.
Summary of the invention
The invention provides a kind of method that realizes server load balancing, this method makes it possible to realize server load balancing on three layers of access switch with low cost, and need not expensive special-purpose load-balancing device.
The present invention also provides a kind of three-tier switch, and this three-tier switch can be realized server load balancing.
For achieving the above object, technical scheme of the present invention specifically is achieved in that
The invention discloses a kind of method that realizes server load balancing, this method is applied to three-tier switch and connects to form the networking of the plural server of described server cluster as the gateway of server cluster, and this method comprises:
With the port trunking of described two the above servers of the connection on the three-tier switch together, form the aggregation port group, and to specify a port in the aggregation port group be master port;
Be identical Internet protocol IP address and the mutually different medium access control MAC addresses of plural server-assignment of forming described server cluster;
Described three-tier switch is saved in the MAC Address correspondence of server ip address and master port institute Connection Service device in the ARP table, and the MAC Address correspondence of the server that each port and each port connected in the aggregation port group is saved in the aggregation port group MAC table;
When described three-tier switch receives service request messages, purpose IP address search ARP table according to service request messages, when the corresponding MAC Address that finds is the MAC Address of master port, determine that then the outbound port of described service request messages is the aggregation port group from the ARP table;
Described three-tier switch selects a port as outbound port from the aggregation port group according to the load balancing algorithm of being scheduled to for the aggregation port group, and the outbound port of described service request messages by described selection sent to the server that this outbound port connects.
The invention also discloses a kind of three-tier switch, this three-tier switch connects to form the plural server of described server cluster as the gateway of server cluster, and described plural server has identical IP address and mutually different MAC Address, and this three-tier switch comprises:
The aggregation port group, each port in this aggregation port group connects to form the plural server of described server cluster correspondingly, and a designated port in this aggregation port group is a master port;
Memory module, be used to store ARP table and aggregation port group MAC table, corresponding MAC Address of preserving server ip address and master port institute Connection Service device in the described ARP table, corresponding MAC Address of preserving the server that each port and each port connected in the aggregation port group in the described aggregation port group MAC table;
Packet forwarding module, be used for when receiving service request messages, purpose IP address search ARP table according to service request messages, when find corresponding MAC Address from the ARP table is the MAC Address of master port, the outbound port of determining described service request messages is the aggregation port group, then send query requests to the polymerization module, a port in the aggregation port group that the polymerization module is returned sends to server that this outbound port connect with described service request messages by described outbound port as outbound port;
The polymerization module is used for after receiving the query requests that packet forwarding module sends, according to selecting a port to return to packet forwarding module from the aggregation port group for the predetermined load balancing algorithm of aggregation port group.
As seen from the above technical solution, this port that connection on the three-tier switch is had a plurality of servers of identical ip addresses and different MAC Address of the present invention is formed the aggregation port group; The MAC Address correspondence of server ip address and master port institute Connection Service device is saved in the ARP table, and the MAC Address correspondence of the server that each port and each port connected in the aggregation port group is saved in the aggregation port group MAC table; Three-tier switch receives purpose IP address when being the service request messages of server ip address, from the ARP table, find the MAC Address of master port according to server ip address, determining port is the aggregation port group, then from the aggregation port group, select a port as outbound port, from aggregation port group MAC table, find corresponding MAC Address according to described outbound port, behind the target MAC (Media Access Control) address in this MAC Address replacement service request messages, the technical scheme that service request messages is sent by outbound port, make it possible on three layers of access switch with low cost, realize server load balancing, and need not expensive special-purpose load-balancing device.
Embodiment
The present invention mainly is at the extremely expensive problem of the server load balancing equipment cost of specialty in the existing server load balancing scheme, a kind of scheme that realizes server load balancing based on three layers of access switch link aggregation has been proposed, thereby can on access switch with low cost, realize the server load balancing function, and need not expensive professional server load-balancing device, a kind of load balancing scheme of high performance-price ratio is provided for the user.
Fig. 3 is a kind of flow chart of realizing the method for server load balancing of the embodiment of the invention, this method is applied to three-tier switch connects to form the plural server of described server cluster as the gateway of server cluster networking, as shown in Figure 3, this method comprises:
Step 301 with the port trunking of two above servers of the connection on the three-tier switch together, is formed the aggregation port group, and to specify a port in the aggregation port group be master port.
Step 302 is identical Internet protocol IP address and the mutually different medium access control MAC addresses of plural server-assignment of forming described server cluster.
Step 303, described three-tier switch is saved in the MAC Address correspondence of server ip address and master port institute Connection Service device in the ARP table, and the MAC Address correspondence of the server that each port and each port connected in the aggregation port group is saved in the aggregation port group MAC table.
Step 304, described three-tier switch receives purpose IP address when being the service request messages of server ip address, finding corresponding MAC Address according to server ip address from the ARP table is the MAC Address of master port, determining port is the aggregation port group, selects a port as outbound port from the aggregation port group according to predetermined load balancing algorithm; Three-tier switch finds corresponding MAC Address according to the port of described selection from aggregation port group MAC table, after replacing target MAC (Media Access Control) address in the described service request messages with this MAC Address of searching, the port of described service request messages by described selection sent to the server that this port connects.
For making purpose of the present invention, technical scheme and advantage clearer, below enumerate a concrete example, the present invention is described in more detail.
Fig. 4 is an actual networking schematic diagram using method shown in Figure 3.As shown in Figure 4, this networking plan comprises following feature:
A1, n platform externally provide the server of identical services, and (server 1~n) is linked on the three-tier switch by the port one~n on the three-tier switch, and n is the natural number greater than 1.
By static configuration port one~n is condensed together on a2, the three-tier switch, form the aggregation port group, wherein port one is a master port, as the sign of whole aggregation port group.
The IP address of a3, server is manual specifies, and the IP address of n station server is identical, represent with IP1 here, and in same virtual LAN VLAN (this is because each port of aggregation port group all belongs to same VLAN).Need to prove: the IP address of each server is identical, the isolation mech isolation test between the aggregation port of the mutual isolation dependence three-tier switch between each server, and guaranteeing can not intercommunication between each server.
The medium access control MAC addresses of a4, n station server has nothing in common with each other, be respectively MAC1, MAC2 ..., MACn.
A5, three-tier switch are the gateways of each server, dispose the ARP information of three-tier switch (gateway) on each server respectively.Here the ARP information at configuration three-tier switch on the server is specially: the ARP table of the MAC Address of the IP address of three-tier switch and described aggregation port group correspondence is preserved in configuration respectively on each server.The MAC Address of aggregation port group correspondence is specially the pairing MAC Address of VLAN Interface of the affiliated VLAN of this aggregation port group.
In Fig. 4, the ARP/MAC learning process of three-tier switch is:
B1, each server send the ARP request message to three-tier switch;
B2, three-tier switch receive ARP request message from each server by each aggregation port in the aggregation port group, treatment mechanism according to link aggregation, send ARP resume module in the ARP request meeting of having only master port (being port one) to receive, thereby the ARP list item that three-tier switch is learnt be (IP1, MAC1);
B3, switch can be learnt the MAC Address of each server, but according to link set mechanism, have only the MAC Address of learning on the master port just can write content-addressable memory, i.e. (MAC1, port one) when the ARP request of receiving each server; Port one in the content-addressable memory is actually n interior port of the whole aggregation port group of representative.In addition, though the mac address information of learning on each port in the aggregation port group can not write content-addressable memory, but can not be dropped yet, but the ARP request message of receiving according to each port in the aggregation port group is saved in the MAC address correspondence of the server that each port and each port connected in the aggregation port group MAC table, and aggregation port group MAC table is as shown in table 1:
MAC Address |
Port |
MAC1 |
Port one |
MAC2 |
Port 2 |
...... |
...... |
MACn |
Port n |
Table 1
As can be seen, three-tier switch is as the gateway of cluster server, and the ARP broadcast domain of the multiple servers with identical ip addresses in the cluster is controlled in the minimum zone.
In Fig. 4, the flow process of Operational Visit server is as follows:
The service request messages of c1, client-access server arrives three-tier switch earlier; The source IP address of this service request messages is the IP address of client, destination address is the IP address (being IP1) of server, and source MAC is last one MAC Address of jumping of three-tier switch, represents with MACx, target MAC (Media Access Control) address is the external MAC Address that provides of three-tier switch, represents with MACy;
C2, three-tier switch obtain a direct-connected route by routing inquiry, then look into the ARP table of self according to the purpose IP address (being IP1) of service request messages, and obtaining corresponding MAC Address is MAC1;
C3, since MAC1 corresponding port 1 represent the aggregation port group, so three-tier switch as can be known outbound port be an aggregation port group, its master port is a port one; According to predetermined aggregated links load balancing algorithm, for example, do Hash (Hash) algorithm with the source IP address and the source port number of service request messages, from port one~n, select a port as outbound port etc., suppose here to have selected port 2 as outbound port.
C4, three-tier switch are searched the aggregation port group MAC table of self maintained according to outbound port 2, and obtaining corresponding M AC address is MAC2;
C5, three-tier switch replace with MAC2 with the target MAC (Media Access Control) address of service request messages, and the source MAC of service request messages is replaced with the MAC Address of aggregation port group correspondence, send to server 2 from port 2 then.
C6, server 2 are handled service request messages, and generate the service response message.The source IP address of this service response message is the IP address (being IP1) of server 2, and purpose IP address is the IP address of client;
C7, according to the default route on the server 2, next jumps gateway is three-tier switch; According to the ARP table of server 2 self (in the ARP table corresponding be the MAC Address of aggregation port group) configuration with the IP address of three-tier switch, the target MAC (Media Access Control) address of service response message is the MAC Address of aggregation port group, and source MAC is the MAC Address MAC2 of server 2.
After c8, three-tier switch receive this service response message, the source MAC of this message is updated to the MAC Address MACy of three-tier switch external interface, forwards after target MAC (Media Access Control) address being updated to the MAC Address MACx of next jumping.
In Fig. 4, the health detection flow process of three-tier switch is:
Server in d1, the cluster occurs unusual, comprising: server delay machine, network interface card fault, fault or the like; Here it is unusual to suppose that server 2 occurs;
D2, three-tier switch detect port 2 and report thrashing message (DOWN), transfer port 2 to (Standby) state of awaiting orders from active (Active) state, simultaneously port 2 is deleted from the subport pond of aggregation port group, and corresponding renewal ARP table and aggregation port group MAC table.Here content is irrelevant with port 2 in the ARP table, therefore need not to upgrade, and the item corresponding with port 2 in the aggregation port group MAC table needs to delete;
D3, three-tier switch reselect server for the Business Stream of originally delivering to server 2 and handling, and for example, according to increasing progressively principle, selecting server 3 is destination server;
If d4 server 2 returns to normal condition, three-tier switch detects the recovery message (UP) that port 2 reports, transfer port 2 to active (Active) state from (Standby) state of awaiting orders, port 2 is joined in the subport pond of aggregation port group simultaneously, and corresponding renewal ARP table and aggregation port group MAC table.Here content is irrelevant with port 2 in the ARP table, therefore need not to upgrade, and in the aggregation port group MAC table corresponding with port 2 need be by relearning and increasing;
If the server that d5 is connected with master port occurs unusual, be that server 1 occurs unusually, port one is reported DOWN, and then three-tier switch is aggregation port group selection master port again, as select port 2 to be master port, and corresponding renewal ARP table and aggregation port group MAC table.Here ARP table is updated to that (IP1, MAC2), the deletion port one is pairing from aggregation port group MAC table.
By such scheme, can realize utilizing cheaply that the link set characteristic of three layers of access switch provides the load balancing support for server cluster, guarantee basic server health detection mechanism simultaneously, improved the reliability and the utilance of server cluster.
Fig. 5 is the composition structural representation of a kind of three-tier switch of the embodiment of the invention, this three-tier switch connects to form the plural server of described server cluster as the gateway of server cluster, and described plural server has identical IP address and mutually different MAC Address, as shown in Figure 5, this three-tier switch comprises: aggregation port group 501, memory module 502, packet forwarding module 503 and polymerization module 504, wherein
Each port in the aggregation port group 501 connects to form the plural server of described server cluster correspondingly, and a designated port in this aggregation port group is a master port;
Memory module 502, be used to store ARP table and aggregation port group MAC table, corresponding MAC Address of preserving server ip address and master port institute Connection Service device in the described ARP table, corresponding MAC Address of preserving the server that each port and each port connected in the aggregation port group in the described aggregation port group MAC table;
Packet forwarding module 503, be used for when receiving that purpose IP address is the service request messages of server ip address, finding corresponding MAC Address according to server ip address from the ARP table is the MAC Address of master port, determining port is the aggregation port group, then send query requests to the polymerization module, a port in the aggregation port group that the polymerization module is returned is as outbound port; From aggregation port group MAC table, find corresponding MAC Address according to described outbound port, after replacing target MAC (Media Access Control) address in the described service request messages with this MAC Address of searching, described service request messages is sent to the server that this outbound port connects by described outbound port;
Polymerization module 504 is used for selecting a port to return to packet forwarding module 503 from the aggregation port group according to predetermined load balancing algorithm after receiving the query requests that packet forwarding module sends.
In Fig. 5, packet forwarding module 503, when being further used for port from the aggregation port group and receiving service response message from server, its source MAC is replaced with the MAC Address of three-tier switch external interface, forwards after target MAC (Media Access Control) address being replaced with the MAC Address of next-hop device.
As shown in Figure 5, this three-tier switch further comprises: health detection module 505 is used for detecting the thrashing message that each port of aggregation port group reports and recovers message; If detect the thrashing message that the port in the aggregation port group reports, then this port is deleted from the aggregation port group, if what report fail message is master port, then also further specify master port for the aggregation port group again, and corresponding renewal ARP table and aggregation port group MAC table; If three-tier switch detects deleted port and reports recovery message, then this is reported the port that recovers message to join again in the aggregation port group, corresponding renewal ARP table and aggregation port group MAC table.
As shown in Figure 5, this three-tier switch also comprises: ARP module 506; Described polymerization module 504, be further used for port from the aggregation port group and receive ARP request message from each server, the ARP request message of receiving according to each port is saved in the MAC Address correspondence of the server that each port and each port connected in the aggregation port group MAC table, and will send to ARP module 506 from the ARP request message of master port; ARP module 506 is used for according to the ARP request message from master port the IP address of server and the MAC Address correspondence of master port institute Connection Service device being saved in the ARP table.
In sum, this port that connection on the three-tier switch is had a plurality of servers of identical ip addresses and different MAC Address of the present invention is formed the aggregation port group; The MAC Address correspondence of server ip address and master port institute Connection Service device is saved in the ARP table, and the MAC Address correspondence of the server that each port and each port connected in the aggregation port group is saved in the aggregation port group MAC table; Three-tier switch receives purpose IP address when being the service request messages of server ip address, from the ARP table, find the MAC Address of master port according to server ip address, determining port is the aggregation port group, then from the aggregation port group, select a port as outbound port, from aggregation port group MAC table, find corresponding MAC Address according to described outbound port, behind the target MAC (Media Access Control) address in this MAC Address replacement service request messages, the technical scheme that service request messages is sent by outbound port, make it possible on three layers of access switch with low cost, realize server load balancing, and need not expensive special-purpose load-balancing device.
The above is preferred embodiment of the present invention only, is not to be used to limit protection scope of the present invention, all any modifications of being made within the spirit and principles in the present invention, is equal to replacement, improvement etc., all should be included within protection scope of the present invention.