Disclosure of Invention
Aiming at the defects in the prior art, the invention aims to provide a cross-node data backup synchronization method which can simultaneously backup a plurality of service data without distinguishing a main device and a standby device.
In order to achieve the above purposes, the technical scheme adopted by the invention is as follows:
a method for synchronizing data backup across nodes comprises the following steps:
establishing backup synchronous links with the IP of a sending end, the IP of a receiving end and a UDP port as identifiers, wherein one backup synchronous link is used for backup synchronization of a service to be backed up;
the established backup synchronous links are separated by configuring a sending end IP, a receiving end IP and a UDP port;
and carrying out data backup synchronization between the sending end and the receiving end by utilizing the separated backup synchronization link.
On the basis of the technical scheme, the method also comprises the step of creating a plurality of backup channels which are identified by ID numbers and correspond to the interfaces for sending data for a backup synchronous link.
On the basis of the above technical solution, the performing data backup synchronization between the sending end and the receiving end by using the separated backup synchronization link specifically includes:
determining data to be backed up and initiating data backup according to the type of the backup;
and adding the data to be backed up into the corresponding backup channels according to the interfaces for sending the data, and synchronizing the data in each backup channel from the sending end to the receiving end based on a confirmation mechanism between the sending end and the receiving end.
On the basis of the above technical solution, the determining data to be backed up and initiating data backup according to the type of backup specifically includes:
when the type of backup is incremental backup, taking a newly added data table entry as data to be backed up, and initiating data backup by a sending end;
and when the type of backup is full backup, all data table entries of the sending end are used as data needing backup, and the receiving end initiates data backup based on the backup channel.
On the basis of the above technical solution, according to an interface for sending data, adding data to be backed up into a corresponding backup channel, and synchronizing the data in each backup channel from a sending end to a receiving end based on a confirmation mechanism between the sending end and the receiving end, specifically including:
adding data to be backed up into a queue to be backed up of a corresponding backup channel according to an interface for sending the data;
the sending end sends the data in the queue to be backed up to the receiving end and transfers the data in the queue to be backed up to the queue to be confirmed of the backup channel;
the sending end judges whether the ACK of the receiving end is received or not, and if the ACK is not received, the sending end resends the data in the queue to be confirmed; if the data in the queue to be backed up is not received, the data in the queue to be backed up is continuously sent to a receiving end, and the data in the queue to be backed up is transferred to the queue to be backed up of the backup channel until no data exists in the queue to be backed up and the queue to be backed up, and the data in the queue to be backed up is removed, and the data in the queue to be backed up is further judged whether the data in the queue to be backed up is empty or not.
On the basis of the technical scheme, the method for separating the multiple backup synchronous links established by configuring the IP of the sending end, the IP of the receiving end and the UDP port specifically comprises the following steps:
the established backup synchronous links are separated by changing the configuration directions of the IP of the sending end and the IP of the receiving end and selecting different UDP ports, or selecting different IP of the receiving end and different UDP ports.
The invention aims to provide a cross-node data backup synchronization system which can simultaneously backup a plurality of service data without distinguishing a main device and a standby device.
In order to achieve the above purposes, the technical scheme adopted by the invention is as follows:
a cross-node data backup synchronization system, comprising:
the link establishing module is used for establishing a backup synchronous link with the transmitting end IP, the receiving end IP and the UDP port as identifiers, wherein one backup synchronous link is used for backing up and synchronizing a service to be backed up;
the configuration module is used for separating the established backup synchronous links by configuring the IP of the sending end, the IP of the receiving end and the UDP port;
and the data synchronization module utilizes the separated backup synchronization link to perform data backup synchronization between the sending end and the receiving end.
On the basis of the above technical solution, the link creating module is further configured to create, for a backup synchronous link, a plurality of backup tunnels identified by ID numbers and corresponding to interfaces for sending data.
On the basis of the technical scheme, the data synchronization module performs data backup synchronization between the sending end and the receiving end by using the separated backup synchronization link, and the specific process comprises the following steps:
determining data to be backed up and initiating data backup according to the type of the backup;
and adding the data to be backed up into the corresponding backup channels according to the interfaces for sending the data, and synchronizing the data in each backup channel from the sending end to the receiving end based on a confirmation mechanism between the sending end and the receiving end.
On the basis of the technical scheme, the data synchronization module adds the data to be backed up into the corresponding backup channel according to the interface for sending the data, synchronizes the data in each backup channel from the sending end to the receiving end based on the confirmation mechanism between the sending end and the receiving end, and the specific process comprises the following steps:
adding data to be backed up into a queue to be backed up of a corresponding backup channel according to an interface for sending the data;
the sending end sends the data in the queue to be backed up to the receiving end and transfers the data in the queue to be backed up to the queue to be confirmed of the backup channel;
the sending end judges whether the ACK of the receiving end is received or not, and if the ACK is not received, the sending end resends the data in the queue to be confirmed; if the data in the queue to be backed up is not received, the data in the queue to be backed up is continuously sent to a receiving end, and the data in the queue to be backed up is transferred to the queue to be backed up of the backup channel until no data exists in the queue to be backed up and the queue to be backed up, and the data in the queue to be backed up is removed, and the data in the queue to be backed up is further judged whether the data in the queue to be backed up is empty or not.
Compared with the prior art, the invention has the advantages that:
the cross-node data backup synchronization method of the invention establishes a backup synchronization link based on UDP protocol, identifies a backup synchronization link by a triple (a sending end IP, a receiving end IP and a UDP port), and separates a plurality of established backup synchronization links by configuring the sending end IP, the receiving end IP and the UDP port, thereby shielding the concepts of main equipment and standby equipment, leading the equipment at two ends to be equal and simultaneously sending backup synchronization data to the opposite end. The invention is not limited to dual-computer backup and synchronization, and can be expanded to data synchronization among multiple devices. In addition, different backup synchronous links are used for different services without mutual interference, concurrence of different services is achieved, and performance is improved.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples.
Referring to fig. 1, an embodiment of the present invention provides a cross-node data backup synchronization method, where the method includes the following steps:
s1, establishing backup synchronous links with transmitting end IP, receiving end IP and UDP ports as identifiers, wherein one backup synchronous link is used for backup synchronization of a service to be backed up.
The backup synchronization link is created based on a User Datagram Protocol (UDP), in this embodiment, a backup synchronization link is identified by a triplet (a sending end IP, a receiving end IP, and a UDP port), and one backup synchronization link is used for backup synchronization of one type of service to be backed up.
The service to be backed up in this embodiment includes an ARP service and an ND service, where ARP is an Address Resolution Protocol (Address Resolution Protocol) used in an IPv4 Address family, and may obtain a corresponding MAC Address according to an IP Address of a network neighbor.
ND is a Neighbor Discovery and management protocol (Neighbor Discovery) used by IPv6 addresses, which functions similarly to the ARP protocol in IPv4 networks. The service to be backed up can be expanded to the backup of more table entries with the same structure according to the requirement.
Preferably, this embodiment further includes the step of creating a plurality of backup tunnels identified by ID numbers for a backup synchronization link corresponding to the interface transmitting data.
One backup synchronous link can create a plurality of backup channels, so that the multiplexing of the backup synchronous links is realized, and the expandability is provided for the identification and classification of data in the same service. The reason why the data is identified and classified is that in the backup process, it is sometimes necessary to determine which specific interface the data comes from.
And S2, separating the plurality of established backup synchronous links by configuring the IP of the sending end, the IP of the receiving end and the UDP port.
In this embodiment, the established multiple backup synchronous links may be separated by changing the configuration directions of the sending end IP and the receiving end IP and selecting different UDP ports.
Specifically, see fig. 2 for a representation:
the interfaces 1 and 2 in fig. 2 are abstracts of network devices, and are ports through which the network devices communicate with the outside world. It may be an actual physical port (rj45, optical port, etc.) or a logical virtual port (vlan subinterface, lookback port, lag port, etc.).
When the device A backs up data to the device B, the back-up synchronous link is configured to be IP _ A, IP _ B and Port _1, wherein the Port _1 is a UDP Port of the device B;
if device B needs to back up data to device a at the same time, it only needs to configure its backup synchronization link as IP _ B, IP _ a, Port _2, and Port _2 is the UDP Port of device a.
Therefore, different links can be distinguished due to different IP configuration directions and different UDP ports, different data can be backed up by different links, the links are separated, and the separation of the service and the backup direction can be realized. The concept of shielding the main device and the standby device is equivalent, the devices at the two ends are equivalent, and the backup synchronous data can be sent to the opposite end, so that the bidirectional mutual backup is realized.
In this embodiment, the established multiple backup synchronous links may be separated by selecting different receiving end IPs and different UDP ports.
Specifically, see fig. 3 for a representation:
when the device A backs up data to the device B, the back-up synchronous link is configured to be IP _ A, IP _ B and Port _1, wherein the Port _1 is a UDP Port of the device B.
If the device a needs to back up data to the device C at the same time, it only needs to configure its backup synchronous link as IP _ a, IP _ C, Port _2, and Port _2 is the UDP Port of the device C.
Similarly, if the device a needs to backup data to the device D at the same time, it only needs to configure its backup synchronous link as IP _ a, IP _ D, Port _3, and Port _3 is the UDP Port of the device D.
Therefore, the IP of the local terminal is unchanged, and different links can be distinguished when the IP of the opposite terminal is different from the UDP port, so that the technical scheme is expanded to data synchronization among a plurality of devices.
And S3, carrying out data backup synchronization between the sending end and the receiving end by utilizing the separated backup synchronization link.
Specifically, the method comprises the following steps:
s31, firstly, determining data to be backed up and initiating data backup according to the type of the backup;
and S32, adding the data to be backed up into the corresponding backup channels according to the interfaces for sending the data, and synchronizing the data in each backup channel from the sending end to the receiving end based on a confirmation mechanism between the sending end and the receiving end.
The validation mechanism in this embodiment is mainly implemented by the queue to be backed up and the queue to be validated.
In this embodiment, the format of the channel data packet is defined as the following table:
wherein:
and (4) version identification is carried out on the format of the message so as to be convenient for carrying out compatibility judgment on message formats of different versions in the future, and as shown in the table, the length of a version field is 2Bytes, the lengths of other fields are also shown in the table, and the following description is omitted.
msg _ len is used to identify the length of the entire message, which is typically a variable length structure that requires a length field to inform the other party that the end of the message can be identified.
msg _ type: the type of service backed up by the message is described.
backup _ id: the backup tunnel ID used by the message is described.
And the msg _ ver is a subfield version and is used for identifying version information of the msg field and processing version compatibility problems which may occur in the future.
msg _ cmd: the type of message (Request/Reply/Update/ACK/…) is described.
item _ count: the number of data table entries that the message is packed at one time is described.
SN: the message is described using a sequence number SN for finding the corresponding data item at the time of Acknowledgement (ACK).
item [ ], which represents the specific backed-up table entry data, is an array.
Although this embodiment disclosure describes and illustrates a particular channel data message format, this embodiment disclosure contemplates any suitable channel data message format.
In this embodiment, the types of backup mainly include incremental backup and full backup:
the following describes data backup synchronization during incremental backup and full backup, respectively:
referring to fig. 4, when the type of backup is incremental backup, a newly added data entry is used as data to be backed up, and the sending end initiates data backup. The incremental backup initiative is at the sending end, the sending end can send data at any time, and the receiving end is responsible for passively receiving data and receiving and processing the data.
A sending end:
s321, firstly, adding data to be backed up into a queue to be backed up of a corresponding backup channel according to an interface for sending the data;
when a new data entry is generated at a sending end, a backup channel of a backup synchronous link corresponding to the data is found according to configuration, and the backup channel is added into a queue to be backed up of the corresponding backup channel. The queue to be backed up is a linked list and follows the principle of first-in first-out.
S322, then, the sending end sends the data in the queue to be backed up to the receiving end, and transfers the data in the queue to be backed up to the queue to be confirmed of the backup channel;
as a better implementation manner, in this embodiment, the packing module is notified to pack and send the data of the queue to be backed up. The purpose of packing and sending is to assemble a plurality of adjacent data table items in the queue to be backed up into a UDP message, thereby avoiding one-time sending of one data table item and improving the performance. The packed message has three contents: 1. SN of the message; 2. ID number of backup channel to which message belongs; 3. the packed data payload.
And after the packaging and sending are completed, transferring the packaged data of the batch from the queue to be backed up to the queue to be confirmed of the corresponding backup channel at one time. The data table entry of the queue to be confirmed corresponds to the SN of the UDP packet sent this time, and there is only the packed data table entry in the queue.
S323, finally, the sending end judges whether an acknowledgement character ACK (Acknowledgecharacter) of the receiving end is received, and if not, the sending end resends the data in the queue to be acknowledged; if the data in the queue to be backed up is not received, the data in the queue to be backed up is continuously sent to a receiving end, and the data in the queue to be backed up is transferred to the queue to be backed up of the backup channel until no data exists in the queue to be backed up and the queue to be backed up, and the data in the queue to be backed up is removed, and the data in the queue to be backed up is further judged whether the data in the queue to be backed up is empty or not.
Receiving end:
when the backup synchronous link is established, the receiving end and the transmitting end agree which UDP ports of the receiving end correspond to different backup synchronous links in advance, a UDP socket of the receiving end processes and monitors a data state all the time, and when data are received, data receiving processing is immediately carried out.
After receiving the data, the receiving end generates a corresponding ACK message according to the message SN and responds to the sending end; on the other hand, to unpack the received data and the ID number of the channel to which the data is associated, split the packed data entry of one of the data entries and store the split data entry to the corresponding module, and perform subsequent processing according to the configured channel ID number.
In this embodiment, with two queues set: the queue to be backed up, the queue to be confirmed and a sending and confirming mechanism ensure the consistency of the backup synchronous data at two ends.
Referring to fig. 5, when the type of backup is full backup, all data entries of the sending end are used as data to be backed up, and the receiving end initiates data backup based on the backup channel.
Generally, when a node is newly on-line, it needs to request all data from the opposite node, or when it needs to initiate a request for full backup.
Different from incremental backup, full backup needs to be initiated by a receiving end, an initiating instruction is a Request, and after receiving the Request instruction, an opposite end responds to a Reply and simultaneously starts a backup process.
Specifically, the initiation process is as follows:
s321', the receiving end initiates a Request (the Request is based on a backup channel and includes the ID of the backup channel), and prepares to receive data.
And S322', after receiving the Request, the sending end responds to Reply and prepares to send data. The subsequent steps are consistent with the incremental backup, namely:
s323', firstly, adding data to be backed up into a queue to be backed up of a corresponding backup channel according to an interface for sending the data;
s324', the sending end sends the data in the queue to be backed up to the receiving end, and transfers the data in the queue to be backed up to the queue to be confirmed of the backup channel;
s325', the sending end judges whether the ACK of the receiving end is received, if not, the data in the queue to be confirmed is sent again; if the data in the queue to be backed up is not received, the data in the queue to be backed up is continuously sent to a receiving end, and the data in the queue to be backed up is transferred to the queue to be backed up of the backup channel until no data exists in the queue to be backed up and the queue to be backed up, and the data in the queue to be backed up is removed, and the data in the queue to be backed up is further judged whether the data in the queue to be backed up is empty or not.
Receiving end:
when the backup synchronous link is established, the receiving end and the transmitting end agree in advance which UDP ports of the receiving end correspond to different backup synchronous links. After receiving the Reply response, the receiving end processes the data monitoring state by the UDP socket, and immediately receives and processes the data when the data is received.
After receiving the data, the receiving end generates a corresponding ACK message according to the message SN and responds to the sending end; on the other hand, to unpack the received data and the ID number of the channel to which the data is associated, split the packed data entry of one of the data entries and store the split data entry to the corresponding module, and perform subsequent processing according to the configured channel ID number.
As can be seen from the above, in this embodiment, not only incremental backup synchronization of data but also full backup synchronization of data can be realized, that is, the cross-node data backup synchronization method in the present invention can initiate real-time backup, and can actively pull data of the other side without waiting passively, thereby well expanding the application range.
In summary, in the cross-node data backup synchronization method of the present invention, a backup synchronization link is created based on a UDP protocol, a backup synchronization link is identified by a triplet (a sending end IP, a receiving end IP, and a UDP port), and the sending end IP, the receiving end IP, and the UDP port are configured to separate multiple backup synchronization links that are created, so that the concept of a primary device and a backup device can be shielded, devices at both ends are allowed to be equal to each other, and backup synchronization data can be sent to an opposite end at the same time. The invention is not limited to dual-computer backup and synchronization, and can be expanded to data synchronization among multiple devices. In addition, different backup synchronous links are used for different services without mutual interference, concurrence of different services is achieved, and performance is improved.
The embodiment of the invention provides a cross-node data backup synchronization system, which comprises a link creation module, a configuration module and a data synchronization module.
And the link establishing module is used for establishing a backup synchronous link with the transmitting end IP, the receiving end IP and the UDP port as identifiers, wherein one backup synchronous link is used for backup synchronization of a service to be backed up.
And the configuration module is used for separating the plurality of established backup synchronous links by configuring the IP of the sending end, the IP of the receiving end and the UDP port.
And the data synchronization module utilizes the separated backup synchronization link to perform data backup synchronization between the sending end and the receiving end.
Further, the link creating module is further configured to create, for a backup synchronization link, a plurality of backup tunnels identified by ID numbers and corresponding to interfaces for sending data.
Further, the data synchronization module performs data backup synchronization between the transmitting end and the receiving end by using the separated backup synchronization link, and the specific process includes:
determining data to be backed up and initiating data backup according to the type of the backup;
and adding the data to be backed up into the corresponding backup channels according to the interfaces for sending the data, and synchronizing the data in each backup channel from the sending end to the receiving end based on a confirmation mechanism between the sending end and the receiving end.
Further, the data synchronization module adds the data to be backed up into the corresponding backup channel according to the interface for sending the data, and synchronizes the data in each backup channel from the sending end to the receiving end based on the confirmation mechanism between the sending end and the receiving end, and the specific process includes:
adding data to be backed up into a queue to be backed up of a corresponding backup channel according to an interface for sending the data;
the sending end sends the data in the queue to be backed up to the receiving end and transfers the data in the queue to be backed up to the queue to be confirmed of the backup channel;
the sending end judges whether the ACK of the receiving end is received or not, and if the ACK is not received, the sending end resends the data in the queue to be confirmed; if the data in the queue to be backed up is not received, the data in the queue to be backed up is continuously sent to a receiving end, and the data in the queue to be backed up is transferred to the queue to be backed up of the backup channel until no data exists in the queue to be backed up and the queue to be backed up, and the data in the queue to be backed up is removed, and the data in the queue to be backed up is further judged whether the data in the queue to be backed up is empty or not.
Further, the configuring module separates the multiple backup synchronous links by configuring the sending end IP, the receiving end IP, and the UDP port, and specifically includes:
the established backup synchronous links are separated by changing the configuration directions of the IP of the sending end and the IP of the receiving end and selecting different UDP ports, or selecting different IP of the receiving end and different UDP ports.
The present invention is not limited to the above-described embodiments, and it will be apparent to those skilled in the art that various modifications and improvements can be made without departing from the principle of the present invention, and such modifications and improvements are also considered to be within the scope of the present invention. Those not described in detail in this specification are within the skill of the art.