Remote copying methods, apparatus, computer equipment, storage media and program products
By generating intermediate data and creating snapshots in the primary data center, storing them in the primary data center, and controlling remote replication from the secondary data center, the problem of data inconsistency between the primary and secondary data centers in traditional remote replication methods is solved, achieving data consistency and efficiency improvement.
Patent Information
- Application Number
- CN202310390651.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-13
- Publication Date
- 2026-11-17
- Estimated Expiration
- 2043-04-13
AI Technical Summary
In traditional remote replication methods, there is a problem of data inconsistency between the master and slave data centers.
After performing data change operations in the main data center, intermediate data is generated and a snapshot is created. The intermediate data and the snapshot are stored in the main data center. The system controls the remote replication of the target intermediate data obtained from the data center based on the target snapshot. Data consistency is ensured through data version and snapshot identifier.
It achieves data consistency between master and slave data centers, improves the efficiency of change operations, and reduces unnecessary data copying.
Smart Images

Figure CN118796930B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of database technology, and in particular to a remote replication method, apparatus, computer equipment, storage medium, and computer program product. Background Technology
[0002] With the development of computer technology, people have placed increasingly higher demands on the disaster recovery and backup capabilities of databases, and remote replication technology is a core technology for improving these capabilities. Remote replication technology refers to the ability to remotely replicate data from the primary data center to the secondary data center, thereby achieving remote data synchronization between the primary and secondary data centers. In this way, even if the primary data center fails, the backup data in the secondary data center will not be affected.
[0003] Traditional methods generate operation logs during file changes in the primary data center. These logs can then be used by the secondary data center for remote replication, enabling remote data synchronization between the primary and secondary data centers. However, traditional remote replication methods suffer from data inconsistencies between the primary and secondary data centers. Summary of the Invention
[0004] Therefore, it is necessary to provide a remote replication method, apparatus, computer equipment, computer-readable storage medium, and computer program product that can ensure data consistency between master and slave data centers in response to the above-mentioned technical problems.
[0005] In a first aspect, this application provides a remote replication method. Applied to a primary data center, wherein the primary data center and a secondary data center are communicatively connected, the method includes:
[0006] Based on the data change request, perform at least one change operation on the original data in the main data center to generate intermediate data corresponding to the at least one change operation;
[0007] Create a snapshot of the intermediate data;
[0008] The intermediate data and a snapshot of the intermediate data are stored in the main data center. The slave data center is controlled to obtain the target intermediate data corresponding to the target snapshot from the main data center according to the target snapshot, and the target intermediate data is remotely copied.
[0009] This application embodiment can obtain intermediate data corresponding to each change operation by performing at least one change operation on the original data in the primary data center, and create snapshots of the intermediate data corresponding to each change operation. Then, the intermediate data corresponding to each change operation and the snapshots of each intermediate data are stored in the primary data center. At this point, the primary data center includes the intermediate data corresponding to each change operation and the snapshots of each intermediate data. Therefore, the slave data center can obtain the target intermediate data corresponding to the target snapshot and requiring remote replication from the primary data center based on the target snapshot, and then remotely replicate the target intermediate data. Thus, in this application embodiment, the slave data center can remotely replicate the intermediate data corresponding to the change operation, thereby ensuring data consistency between the primary and slave data centers.
[0010] In one embodiment, storing the intermediate data and a snapshot of the intermediate data in the main data center includes:
[0011] Obtain the data version identifier of the intermediate data and the snapshot identifier of the snapshot of the intermediate data;
[0012] Based on the data version identifier of the intermediate data and the snapshot identifier of the snapshot, the intermediate data and the snapshot of the intermediate data are stored in the main data center.
[0013] In this embodiment, the data version identifier of the intermediate data and the snapshot identifier of the intermediate data snapshot are obtained. Based on the data version identifier and the snapshot identifier of the intermediate data, the intermediate data and the snapshot of the intermediate data are stored in the main data center. The main data center includes the intermediate data corresponding to each change operation and the snapshot of each intermediate data. Thus, the target intermediate data corresponding to the target snapshot and requiring remote replication can be obtained from the main data center based on the target snapshot, and then the target intermediate data can be remotely replicated. Furthermore, by configuring corresponding identifiers for the data version of the intermediate data and the snapshot of the intermediate data snapshot, the efficiency of change operations can be improved without having to record operation logs during the change operation process.
[0014] In one embodiment, the data version identifier includes a data version serial number, and the snapshot identifier includes a snapshot serial number; the data version serial number of the intermediate data is less than the snapshot serial number of the snapshot of the intermediate data, and the snapshot serial number of the previous intermediate data is less than the data version serial number of the intermediate data;
[0015] The step of storing the intermediate data and its snapshot in the main data center according to the data version identifier of the intermediate data and the snapshot identifier of the snapshot includes:
[0016] The target snapshot sequence number is determined from the snapshot sequence number of the snapshot; the target snapshot sequence number is the sequence number of the snapshot of the target intermediate data;
[0017] Based on the size relationship between the target snapshot sequence number and the data version sequence number of the intermediate data, intermediate data to be stored is determined from the intermediate data, and the intermediate data to be stored is stored in the main data center.
[0018] In this embodiment, the target snapshot sequence number is determined from the snapshot sequence number of the snapshot; the target snapshot sequence number is the sequence number of the snapshot of the target intermediate data. Since each sequence number is globally unique and increments over time, the intermediate data to be stored can be determined from the intermediate data based on the relationship between the target snapshot sequence number and the data version sequence number of the intermediate data, and then stored in the main data center. Thus, the main data center includes the intermediate data to be stored, allowing the data center to retrieve the intermediate data to be remotely replicated from the main data center and perform remote replication of the intermediate data.
[0019] In one embodiment, determining the intermediate data to be stored from the intermediate data based on the size relationship between the target snapshot sequence number and the data version sequence number of the intermediate data includes:
[0020] If the target snapshot sequence number is greater than the data version sequence number of the intermediate data, then the intermediate data is used as candidate intermediate data.
[0021] The number of candidate intermediate data is obtained. If the number of candidate intermediate data exceeds a preset number, intermediate data to be stored is determined from the candidate intermediate data.
[0022] In this embodiment, intermediate data with a data version sequence number less than the target snapshot sequence number is used as candidate intermediate data. Based on the relationship between the number of candidate intermediate data and a preset number, it is determined whether to delay deleting the candidate intermediate data. This allows for the identification of intermediate data to be stored from the candidate intermediate data. Thus, when at least one change operation includes at least one set of intermediate data, the intermediate data to be stored can be stored, thereby ensuring that the main data center includes the intermediate data to be stored.
[0023] In one embodiment, determining the intermediate data to be stored from the candidate intermediate data includes:
[0024] The target data version sequence number is determined from the data version sequence numbers corresponding to the candidate intermediate data; the target data version sequence number is the data version sequence number that is closest to the target snapshot sequence number.
[0025] The candidate intermediate data corresponding to the target data version serial number is used as the intermediate data to be stored.
[0026] In this embodiment, by determining the target data version sequence number closest to the target snapshot sequence number and using the candidate intermediate data corresponding to the target data version sequence number as the intermediate data to be stored, the intermediate data to be stored can be determined from the candidate intermediate data. This allows the intermediate data to be stored to be stored in the intermediate data when at least one change operation includes at least one set of intermediate data, so that the main data center includes the intermediate data to be stored.
[0027] In one embodiment, controlling the acquisition of target intermediate data corresponding to the target snapshot from the primary data center based on the target snapshot, and remotely replicating the target intermediate data, includes:
[0028] In the data center, adjacent snapshots that were previously stored before the snapshot of the target intermediate data were obtained based on the snapshot identifier;
[0029] The difference between the target intermediate data and the intermediate data corresponding to the adjacent snapshot is stored in the target intermediate data;
[0030] The system controls the data acquisition of the difference data from the primary data center based on a snapshot of the target intermediate data, and then remotely replicates the target intermediate data.
[0031] In this embodiment, by recording the differences between intermediate data corresponding to different snapshots of the same data, the target intermediate data can be remotely copied directly based on the recorded differences and the stored intermediate data corresponding to adjacent snapshots. This reduces unnecessary data copying during the remote copying process.
[0032] Secondly, this application also provides a remote replication device. Applied to a primary data center, the primary data center and a secondary data center are communicatively connected. The device includes:
[0033] The change module is used to perform at least one change operation on the original data in the main data center according to the data change request, and generate intermediate data corresponding to the at least one change operation.
[0034] The snapshot creation module is used to create snapshots of the intermediate data;
[0035] The remote replication module is used to store the intermediate data and a snapshot of the intermediate data in the main data center, and to control the slave data center to obtain the target intermediate data corresponding to the target snapshot from the main data center according to the target snapshot, and to remotely replicate the target intermediate data.
[0036] Thirdly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the steps of the method in any of the embodiments of the first aspect described above.
[0037] Fourthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, implements the steps of the method in any of the embodiments of the first aspect described above.
[0038] Fifthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, implements the steps of the method in any of the embodiments of the first aspect described above.
[0039] The aforementioned remote replication method, apparatus, computer equipment, storage medium, and computer program product perform at least one change operation on the original data in the main data center according to a data change request, generating intermediate data corresponding to the at least one change operation; create a snapshot of the intermediate data; store the intermediate data and the snapshot of the intermediate data in the main data center; and control the slave data center to obtain the target intermediate data corresponding to the target snapshot from the main data center according to the target snapshot, and remotely replicate the target intermediate data. In this embodiment, by performing at least one change operation on the original data in the main data center, intermediate data corresponding to each change operation is obtained, and snapshots of each intermediate data corresponding to each change operation are created. Then, the intermediate data corresponding to each change operation and the snapshots of each intermediate data are stored in the main data center. At this point, the main data center includes the intermediate data corresponding to each change operation and the snapshots of each intermediate data. Therefore, the slave data center can obtain the target intermediate data corresponding to the target snapshot and requiring remote replication from the main data center according to the target snapshot, and thus, remotely replicate the target intermediate data. Therefore, in this embodiment, the slave data center can remotely replicate the intermediate data corresponding to the change operation, thereby ensuring data consistency between the main and slave data centers. Attached Figure Description
[0040] Figure 1 This is a diagram illustrating the application environment of a remote replication method in one embodiment;
[0041] Figure 2 This is a flowchart illustrating a remote replication method in one embodiment;
[0042] Figure 3 This is a flowchart illustrating the intermediate data storage steps in one embodiment;
[0043] Figure 4 This is a flowchart illustrating the steps for determining intermediate data to be stored in one embodiment;
[0044] Figure 5 This is a flowchart illustrating the intermediate data filtering step to be stored in one embodiment;
[0045] Figure 6 This is a flowchart illustrating the step of filtering intermediate data to be stored based on the target data version serial number in one embodiment.
[0046] Figure 7 This is a schematic diagram of the structure of intermediate data and snapshots of intermediate data in one embodiment;
[0047] Figure 8 This is a flowchart illustrating the remote copying step based on difference data in one embodiment;
[0048] Figure 9 This is a flowchart illustrating the process of obtaining intermediate data and a snapshot of the intermediate data based on a change operation in one embodiment.
[0049] Figure 10 This is a flowchart illustrating the remote replication method in one optional embodiment;
[0050] Figure 11 This is a structural block diagram of a remote replication device in one embodiment;
[0051] Figure 12 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0052] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0053] With the development of computer technology, people have placed increasingly higher demands on the disaster recovery and backup capabilities of databases, and remote replication technology is a core technology for improving these capabilities. Remote replication technology refers to the ability to remotely replicate data from the primary data center to the secondary data center, thereby achieving remote data synchronization between the primary and secondary data centers. In this way, even if the primary data center fails, the backup data in the secondary data center will not be affected.
[0054] The traditional method involves generating an operation log during file changes in the primary data center. This log can then be used by the secondary data center to perform remote replication, enabling remote data synchronization between the primary and secondary data centers.
[0055] However, during remote replication based on this operation log, the intermediate data version cannot be obtained from the data center. Consequently, the intermediate data version cannot be remotely replicated from the data center. Therefore, traditional remote replication methods suffer from data inconsistency between the master and slave data centers.
[0056] The remote copying method provided in this application embodiment can be applied to, for example... Figure 1 In the application environment shown, the primary data center 102 communicates with the secondary data center 104 via a network, meaning there is a communication connection between them. Both the primary and secondary data centers 102 and 104 can store data. The primary data center 102 performs at least one change operation on the original data in its data center based on a data change request, generating intermediate data corresponding to the change operation. The primary data center 102 creates a snapshot of the intermediate data. The primary data center 102 stores the intermediate data and the snapshot in its data center, and controls the secondary data center to retrieve the target intermediate data corresponding to the target snapshot from the primary data center and remotely replicate the target intermediate data. The primary data center 102 can be a server, and the secondary data center 104 can be implemented using a standalone server or a server cluster consisting of multiple servers.
[0057] In one embodiment, such as Figure 2 As shown, a remote replication method is provided, which can be applied to... Figure 1 Taking the main data center 102 as an example, the explanation includes the following steps:
[0058] S220, Perform at least one change operation on the original data in the main data center according to the data change request, and generate intermediate data corresponding to the at least one change operation.
[0059] In this context, a data change request refers to a request sent by a user to the main data center when the user needs to modify data in the main data center. The original data in the main data center refers to the data already stored in the main data center before the change operation. For example, the original data can be stored in file format or in table format; however, this embodiment does not limit the storage method of the original data. The types of change operations include, but are not limited to, adding data, overwriting data, and deleting data. Intermediate data refers to the data obtained after the change operation.
[0060] Optionally, the main data center 102 can obtain data change requests from the user terminal. Then, the main data center 102 can perform at least one change operation on the original data in the main data center according to the data change request, generating intermediate data corresponding to the at least one change operation. It should be noted that since the change operation is performed at least once, intermediate data corresponding to each change operation will be generated; that is, the number of intermediate data includes at least one.
[0061] S240, create a snapshot of intermediate data.
[0062] Optionally, after generating intermediate data corresponding to the change operation, the main data center 102 can create a snapshot of the intermediate data. Since there is a one-to-one correspondence between intermediate data and change operations, and the number of intermediate data includes at least one, a snapshot of the intermediate data is created whenever a piece of intermediate data is generated; that is, it can be understood that the number of snapshots also includes at least one. The snapshot is used to record the data version at a preset time.
[0063] S260 stores intermediate data and snapshots of intermediate data in the main data center, controls the data center to obtain the target intermediate data corresponding to the target snapshot from the main data center based on the target snapshot, and remotely replicates the target intermediate data.
[0064] Optionally, the main data center 102 may store all intermediate data and all snapshots of intermediate data in the main data center; alternatively, the main data center 102 may also filter out intermediate data that meets preset conditions from all intermediate data, and store the intermediate data that meets the preset conditions and its snapshots in the main data center. The preset conditions may be set based on the relationship between intermediate data and its snapshots, or they may be set by the user according to actual needs. Of course, this embodiment does not limit the preset conditions.
[0065] Next, the target snapshot is determined from data center 104 based on the remote replication requirements. Thus, primary data center 102 can control secondary data center 104 to retrieve the target intermediate data corresponding to the target snapshot from primary data center 104 based on the target snapshot. Primary data center 102 can also control secondary data center 104 to call interfaces within secondary data center 104 to remotely replicate the target intermediate data from primary data center 104. The remote replication requirements may include, but are not limited to, replicating snapshots of adjacent intermediate data and replicating snapshots of non-adjacent intermediate data. Target intermediate data refers to the intermediate data that needs to be remotely replicated, and the target snapshot is a snapshot of the target intermediate data.
[0066] In the aforementioned remote replication method, at least one change operation is performed on the original data in the primary data center according to the data change request, generating intermediate data corresponding to the at least one change operation; a snapshot of the intermediate data is created; the intermediate data and the snapshot of the intermediate data are stored in the primary data center; and the slave data center is controlled to obtain the target intermediate data corresponding to the target snapshot from the primary data center according to the target snapshot, and remotely replicate the target intermediate data. This embodiment of the application can obtain intermediate data corresponding to each change operation by performing at least one change operation on the original data in the primary data center, and create snapshots of each intermediate data corresponding to each change operation. Then, the intermediate data corresponding to each change operation and the snapshots of each intermediate data are stored in the primary data center. At this point, the primary data center includes the intermediate data corresponding to each change operation and the snapshots of each intermediate data. Therefore, the slave data center can obtain the target intermediate data corresponding to the target snapshot and requiring remote replication from the primary data center according to the target snapshot, and thus, remotely replicate the target intermediate data. Therefore, in this embodiment of the application, the slave data center can remotely replicate the intermediate data corresponding to the change operation, thereby ensuring data consistency between the primary and slave data centers.
[0067] In one embodiment, such as Figure 3 As shown, storing intermediate data and snapshots of intermediate data in the main data center includes:
[0068] S320, obtain the data version identifier of the intermediate data and the snapshot identifier of the intermediate data snapshot.
[0069] Optionally, during at least one change operation on the original data in the main data center, the main data center 102 can configure a data version identifier for the intermediate data corresponding to each change operation, and configure a snapshot identifier for each snapshot of the intermediate data. The main data center 102 can also add the type of change operation corresponding to each change operation to the intermediate data. Here, the data version identifier of the intermediate data refers to a symbol used to identify the data version of the intermediate data. The snapshot identifier of the intermediate data snapshot refers to a symbol used to identify the snapshot of the intermediate data. Identifiers may include, but are not limited to, serial numbers, names, etc. For example, the type of change operation may include, but is not limited to, add (ADD) or delete (DEL).
[0070] Optionally, the main data center 102 can then obtain the data version identifier of the configured intermediate data and the snapshot identifier of the intermediate data in real time; or, the main data center 102 can periodically obtain the data version identifier of the configured intermediate data and the snapshot identifier of the intermediate data.
[0071] S340 stores the intermediate data and its snapshot in the main data center according to the data version identifier of the intermediate data and the snapshot identifier of the snapshot.
[0072] Optionally, the main data center 102 can determine the intermediate data to be stored based on the mapping relationship between the data version identifier of the intermediate data and the snapshot identifier of the intermediate data snapshot, and store the intermediate data to be stored and its snapshot in the main data center. The mapping relationship indicates that different data version identifiers of intermediate data correspond to different snapshot identifiers of intermediate data snapshots. Alternatively, the main data center 102 can also determine the intermediate data to be stored based on the size relationship between the data version identifier of the intermediate data and the snapshot identifier of the intermediate data snapshot, and store the intermediate data to be stored and its snapshot in the main data center.
[0073] In this embodiment, the data version identifier of the intermediate data and the snapshot identifier of the intermediate data snapshot are obtained. Based on the data version identifier and the snapshot identifier of the intermediate data, the intermediate data and the snapshot of the intermediate data are stored in the main data center. The main data center includes the intermediate data corresponding to each change operation and the snapshot of each intermediate data. Thus, the target intermediate data corresponding to the target snapshot and requiring remote replication can be obtained from the main data center based on the target snapshot, and then the target intermediate data can be remotely replicated. Furthermore, by configuring corresponding identifiers for the data version of the intermediate data and the snapshot of the intermediate data snapshot, the efficiency of change operations can be improved without having to record operation logs during the change operation process.
[0074] In one embodiment, such as Figure 4 As shown, the data version identifier includes the data version sequence number, and the snapshot identifier includes the snapshot sequence number; the data version sequence number of the intermediate data is less than the snapshot sequence number of the intermediate data's snapshot, and the snapshot sequence number of the previous intermediate data is less than the data version sequence number of the intermediate data.
[0075] Based on the intermediate data version identifier and the snapshot identifier, the intermediate data and its snapshot are stored in the main data center, including:
[0076] S420, determine the target snapshot sequence number from the snapshot sequence number of the snapshot; the target snapshot sequence number is the sequence number of the snapshot of the target intermediate data.
[0077] It should be noted that the data version identifier of intermediate data includes the data version sequence number of the intermediate data, and the snapshot identifier of the snapshot of intermediate data includes the snapshot sequence number of the snapshot of the intermediate data. Furthermore, the data version sequence number of the intermediate data is less than the snapshot sequence number of the snapshot of that intermediate data, and the snapshot sequence number of the previous intermediate data is less than the data version sequence number of the intermediate data. In other words, it can be understood that each sequence number (seq) is globally unique and increments over time.
[0078] Optionally, the primary data center 102 can determine the target snapshot sequence number corresponding to the target intermediate data that needs to be remotely replicated. The target snapshot sequence number is the sequence number of the snapshot of the target intermediate data. Then, the primary data center 102 can find the target snapshot sequence number from the snapshot sequence number of the intermediate data.
[0079] S440 determines the intermediate data to be stored from the intermediate data based on the size relationship between the target snapshot sequence number and the data version sequence number of the intermediate data, and stores the intermediate data to be stored in the main data center.
[0080] Optionally, the main data center 102 can obtain the size relationship between the target snapshot sequence number and the data version sequence number of each intermediate data, so as to determine each intermediate data whose data version sequence number is greater than the target snapshot sequence number, and can determine each intermediate data whose data version sequence number is less than the target snapshot sequence number.
[0081] Subsequently, for example, the main data center 102 can determine, based on the relationship between the target snapshot sequence number and the data version sequence numbers of each intermediate data, all intermediate data whose data version sequence numbers are less than the target snapshot sequence number, and then determine the intermediate data to be stored from among the intermediate data whose data version sequence numbers are less than the target snapshot sequence number, thereby storing the intermediate data to be stored in the main data center. Alternatively, the main data center 102 can also determine, based on the relationship between the target snapshot sequence number and the data version sequence numbers of each intermediate data, all intermediate data whose data version sequence numbers are greater than the target snapshot sequence number, and then determine the intermediate data whose data version sequence numbers are greater than the target snapshot sequence number as the intermediate data to be stored, thereby storing the intermediate data to be stored in the main data center.
[0082] In this embodiment, the target snapshot sequence number is determined from the snapshot sequence number of the snapshot; the target snapshot sequence number is the sequence number of the snapshot of the target intermediate data. Since each sequence number is globally unique and increments over time, the intermediate data to be stored can be determined from the intermediate data based on the relationship between the target snapshot sequence number and the data version sequence number of the intermediate data, and then stored in the main data center. Thus, the main data center includes the intermediate data to be stored, allowing the data center to retrieve the intermediate data to be remotely replicated from the main data center and perform remote replication of the intermediate data.
[0083] In one embodiment, such as Figure 5 As shown, based on the size relationship between the target snapshot sequence number and the data version sequence number of the intermediate data, the intermediate data to be stored is determined from the intermediate data, including:
[0084] S520: If the target snapshot sequence number is greater than the data version sequence number of the intermediate data, then the intermediate data will be used as the candidate intermediate data.
[0085] Optionally, the size relationship between the target snapshot sequence number and the data version sequence number of each intermediate data is detected. If the target snapshot sequence number is found to be smaller than the data version sequence number of the intermediate data, the main data center 102 may not delete the intermediate data whose data version sequence number is greater than the target snapshot sequence number; that is, the intermediate data whose data version sequence number is greater than the target snapshot sequence number is retained in the main data center. If the target snapshot sequence number is found to be greater than the data version sequence number of the intermediate data, the main data center 102 may use the intermediate data whose data version sequence number is smaller than the target snapshot sequence number as candidate intermediate data.
[0086] S540: Obtain the number of candidate intermediate data. If the number of candidate intermediate data exceeds the preset number, determine the intermediate data to be stored from the candidate intermediate data.
[0087] Optionally, the main data center 102 can obtain the number of candidate intermediate data, that is, the number of intermediate data with a data version sequence number less than the target snapshot sequence number. Then, the main data center 102 can also detect whether the number of candidate intermediate data exceeds a preset number. The preset number is a number pre-set based on historical experience, and may include, but is not limited to, 1, 2, or 5. Of course, this embodiment does not limit the preset number. If the number of candidate intermediate data is detected to exceed the preset number, the main data center 102 can determine the candidate intermediate data that needs to be deleted and the intermediate data to be stored from the candidate intermediate data. The candidate intermediate data to be deleted and the intermediate data to be stored are complementary; that is, if the candidate intermediate data is not deleted, it is determined as intermediate data to be stored, and the intermediate data to be stored is stored in the main data center.
[0088] In this embodiment, if the target snapshot sequence number is greater than the data version sequence number of the intermediate data, the intermediate data is used as candidate intermediate data. The number of candidate intermediate data is obtained, and if the number of candidate intermediate data exceeds a preset number, the intermediate data to be stored is determined from the candidate intermediate data. By using intermediate data with a data version sequence number less than the target snapshot sequence number as candidate intermediate data, and determining whether to delay deleting candidate intermediate data based on the relationship between the number of candidate intermediate data and the preset number, the intermediate data to be stored can be determined from the candidate intermediate data. This allows for the storage of intermediate data to be stored even when at least one change operation includes at least one piece of intermediate data, thus ensuring that the main data center includes the intermediate data to be stored.
[0089] In one embodiment, such as Figure 6 As shown, the intermediate data to be stored is determined from the candidate intermediate data, including:
[0090] S620, determine the target data version sequence number from the data version sequence numbers corresponding to the candidate intermediate data; the target data version sequence number is the data version sequence number that is closest to the target snapshot sequence number.
[0091] Optionally, if the number of candidate intermediate data exceeds a preset number, the main data center 102 can find the data version sequence number that is closest to the target snapshot sequence number from the data version sequence numbers corresponding to the candidate intermediate data, and determine that data version sequence number as the target data version sequence number. The target data version sequence number is the data version sequence number that is closest to the target snapshot sequence number.
[0092] S640, the candidate intermediate data corresponding to the target data version serial number is used as the intermediate data to be stored.
[0093] Optionally, the main data center 102 can obtain the candidate intermediate data corresponding to the target data version sequence number and determine the candidate intermediate data corresponding to the target data version sequence number as intermediate data to be stored. In addition, the main data center 102 can also determine other data version sequence numbers besides the target data version sequence number from the data version sequence numbers corresponding to the candidate intermediate data and delete the candidate intermediate data corresponding to the other data version sequence numbers.
[0094] For example, such as Figure 7 As shown, Figure 7 This is a schematic diagram illustrating the structure of intermediate data and its snapshots in one embodiment. For data A, assume that data A includes intermediate data A1, intermediate data A2, and intermediate data A3, and that there exists a snapshot 1 of intermediate data A1, a snapshot 2 of intermediate data A2, and a snapshot 3 of intermediate data A3. Specifically, intermediate data A1 has a data version of A1, a data version sequence number of seq50, a change operation type of A1 (ADD), and a snapshot sequence number of its snapshot (seq100). Intermediate data A2 has a data version of A2, a data version sequence number of seq150, a change operation type of A2 (ADD), and a snapshot sequence number of its snapshot (seq200). Intermediate data A3 has a data version of A3, a data version sequence number of seq250, a change operation type of A3 (DEL), and a snapshot sequence number of its snapshot (seq300).
[0095] Therefore, when the target snapshot sequence number is seq200, meaning the target intermediate data to be remotely replicated is intermediate data A2, the main data center 102 can detect the size relationship between the target snapshot sequence number seq200 and the data version sequence numbers of intermediate data A1, A2, and A3. Since the target snapshot sequence number seq200 is greater than the data version sequence numbers of intermediate data A1 (seq50) and A2 (seq150), the data version sequence numbers of intermediate data A1 (seq50) and A2 (seq150) are determined as candidate intermediate data. Assuming a preset number of 1 and 2 candidate intermediate data, the number of candidate intermediate data exceeds the preset number. Next, from the data version sequence number seq50 of intermediate data A1 and the data version sequence number seq150 of intermediate data A2, the target data version sequence number that is closest to the target snapshot sequence number seq200 is determined, which is the data version sequence number seq150 of intermediate data A2. Then, the intermediate data A2 corresponding to data version sequence number seq150 can be used as the intermediate data to be stored. Alternatively, the intermediate data A1 corresponding to data version sequence number seq50 can be deleted.
[0096] For example, suppose data A includes intermediate data A2 and intermediate data A3, and there are snapshots 2 and 3 of intermediate data A2. Then, when the target snapshot sequence number is seq200, meaning the target intermediate data to be remotely replicated is intermediate data A2, the primary data center 102 can detect the size relationship between the target snapshot sequence number seq200 and the data version sequence numbers of intermediate data A2 and A3. Since the target snapshot sequence number seq200 is only greater than the data version sequence number seq150 of intermediate data A2, the intermediate data A2 corresponding to data version sequence number seq150 can be used as the intermediate data to be stored.
[0097] For example, suppose data A includes intermediate data A2 and intermediate data A3, and only snapshot 3 of intermediate data A3 exists. Then, when the target snapshot sequence number is seq300, meaning the target intermediate data to be remotely replicated is intermediate data A3, the main data center 102 can detect the size relationship between the target snapshot sequence number seq300 and the data version sequence numbers of intermediate data A2 and A3. Since the target snapshot sequence number seq300 is greater than the data version sequence numbers of intermediate data A2 (seq150) and A3 (seq250), the data version sequence numbers of intermediate data A2 (seq150) and A3 (seq250) are identified as candidate intermediate data. Assuming a preset number of 1 and 2 candidate intermediate data, the number of candidate intermediate data exceeds the preset number. Next, from the data version sequence numbers seq150 of intermediate data A2 and seq250 of intermediate data A3, the target data version sequence number that is closest to the target snapshot sequence number seq300 is determined, which is the data version sequence number seq250 of intermediate data A3. Then, the intermediate data A3 corresponding to data version sequence number seq250 can be used as the intermediate data to be stored. Alternatively, the intermediate data A2 corresponding to data version sequence number seq150 can be deleted.
[0098] In this embodiment, a target data version sequence number is determined from the data version sequence numbers corresponding to the candidate intermediate data; the target data version sequence number is the data version sequence number closest to the target snapshot sequence number; and the candidate intermediate data corresponding to the target data version sequence number is used as the intermediate data to be stored. By determining the target data version sequence number closest to the target snapshot sequence number and using the candidate intermediate data corresponding to the target data version sequence number as the intermediate data to be stored, the intermediate data to be stored can be determined from the candidate intermediate data. This allows the intermediate data to be stored to be stored in the intermediate data when at least one change operation includes at least one piece of intermediate data, so that the main data center includes the intermediate data to be stored.
[0099] In one embodiment, such as Figure 8 As shown, the control retrieves the target intermediate data corresponding to the target snapshot from the primary data center based on the target snapshot, and performs remote replication of the target intermediate data, including:
[0100] S820, before obtaining a snapshot of the target intermediate data from the data center based on the snapshot identifier, the adjacent snapshots that have been stored.
[0101] For example, such as Figure 9 As shown, Figure 9This is a schematic diagram illustrating the process of obtaining intermediate data and snapshots of intermediate data based on a change operation in one embodiment. For data A, assume data A includes intermediate data A1, and a snapshot 1 of intermediate data A1 is created. Next, an overwrite operation is performed on intermediate data A1 to generate intermediate data A2, and a snapshot 2 of intermediate data A2 is created. Then, a deletion operation is performed on intermediate data A2 to generate intermediate data A3, and a snapshot 3 of intermediate data A3 is created. If the data in the primary data center and the data in the secondary data center are both synchronized to the state of snapshot 1 (i.e., synchronized to intermediate data A1) at the current moment, then the primary data center 102 can obtain the adjacent snapshots stored before the snapshot of the target intermediate data in the secondary data center based on the snapshot identifier of the intermediate data. That is, the primary data center 102 can determine, in the secondary data center, the adjacent snapshot stored before the snapshot of the target intermediate data as snapshot 1 based on the snapshot sequence number of the stored snapshot 1 of intermediate data A1.
[0102] S840, store the difference data between the target intermediate data and the intermediate data corresponding to the adjacent snapshot into the target intermediate data.
[0103] Optionally, the primary data center 102 can obtain the difference data between the target intermediate data and the intermediate data corresponding to the adjacent snapshots that have been previously stored, and store the difference data between the target intermediate data and the intermediate data corresponding to the adjacent snapshots in the target intermediate data. For example, assuming that the data in the primary data center and the data in the secondary data center are both synchronized to the state of snapshot 1 (i.e., synchronized to intermediate data A1) at the current moment, and the target intermediate data that needs to be remotely replicated is intermediate data A3, then the primary data center 102 can directly obtain the difference data between intermediate data A3 and intermediate data A1, and store the difference data in the target intermediate data.
[0104] The S860 controls the remote replication of the target intermediate data by obtaining differential data from the primary data center based on a snapshot of the target intermediate data from the primary data center.
[0105] Optionally, the primary data center 102 can control the secondary data center 104 to obtain the difference data between the target intermediate data and the intermediate data corresponding to adjacent snapshots from the primary data center 104 based on snapshots of the target intermediate data. Then, the primary data center 102 can also control the secondary data center 104 to call an interface in the secondary data center 104 to remotely replicate the difference data from the primary data center 104. Thus, the secondary data center 104 can remotely replicate the target intermediate data based on the difference data and the stored intermediate data corresponding to adjacent snapshots.
[0106] In this embodiment, adjacent snapshots stored before obtaining the target intermediate data snapshot from the data center based on the snapshot identifier are retrieved; the difference data between the target intermediate data and the intermediate data corresponding to the adjacent snapshots is stored in the target intermediate data; the data center is controlled to retrieve the difference data from the main data center based on the snapshot of the target intermediate data, and remotely replicate the target intermediate data. By recording the differences between the intermediate data corresponding to different snapshots of the same data, the target intermediate data can be remotely replicated directly based on the recorded difference data and the stored intermediate data corresponding to the adjacent snapshots. Therefore, unnecessary data copying can be reduced during the remote replication process.
[0107] To make the solution in this application clearer, the above-described remote copying method is described below with an optional embodiment. In an optional embodiment, such as Figure 10 As shown, a remote replication method is provided, applied to a primary data center 102, wherein the primary data center 102 and the secondary data center 104 communicate with each other, including:
[0108] S1002, Perform at least one change operation on the original data in the main data center according to the data change request, and generate intermediate data corresponding to the at least one change operation;
[0109] S1004, Create a snapshot of intermediate data;
[0110] S1006, Obtain the data version identifier of the intermediate data and the snapshot identifier of the intermediate data snapshot;
[0111] S1008, Determine the target snapshot sequence number from the snapshot sequence number of the snapshot; the target snapshot sequence number is the sequence number of the snapshot of the target intermediate data;
[0112] S1010, If the target snapshot sequence number is greater than the data version sequence number of the intermediate data, then the intermediate data is used as the candidate intermediate data;
[0113] S1012, obtain the number of candidate intermediate data. If the number of candidate intermediate data exceeds the preset number, determine the target data version sequence number from the data version sequence numbers corresponding to the candidate intermediate data. The target data version sequence number is the data version sequence number that is closest to the target snapshot sequence number.
[0114] S1014, take the candidate intermediate data corresponding to the target data version sequence number as the intermediate data to be stored, and store the intermediate data to be stored in the main data center;
[0115] S1016, Before obtaining a snapshot of the target intermediate data from the data center based on the snapshot identifier, the adjacent snapshots that have been stored;
[0116] S1018, Store the difference data between the target intermediate data and the intermediate data corresponding to the adjacent snapshot into the target intermediate data;
[0117] S1020 controls the remote replication of the target intermediate data by obtaining the difference data from the main data center based on a snapshot of the target intermediate data from the data center.
[0118] In the aforementioned remote replication method, intermediate data corresponding to each change operation is obtained by performing at least one change operation on the original data in the primary data center, and snapshots of each intermediate data corresponding to each change operation are created. Then, the intermediate data corresponding to each change operation and the snapshots of each intermediate data are stored in the primary data center. At this point, the primary data center includes the intermediate data corresponding to each change operation and the snapshots of each intermediate data. Therefore, the slave data center can obtain the target intermediate data corresponding to the target snapshot and requiring remote replication from the primary data center based on the target snapshot, and thus, remote replication of the target intermediate data is possible. Therefore, in this embodiment, the slave data center can remotely replicate the intermediate data corresponding to the change operation, thereby ensuring data consistency between the primary and slave data centers.
[0119] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0120] Based on the same inventive concept, this application also provides a remote copying apparatus for implementing the remote copying method described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, the specific limitations in one or more remote copying apparatus embodiments provided below can be found in the limitations of the remote copying method described above, and will not be repeated here.
[0121] In one embodiment, such as Figure 11As shown, a remote replication device 1100 is provided, applied to a primary data center, with a communication connection between the primary and secondary data centers. The remote replication device 1100 includes: a change module 1120, a snapshot creation module 1140, and a remote replication module 1160, wherein:
[0122] The change module 1120 is used to perform at least one change operation on the original data in the main data center according to the data change request, and generate intermediate data corresponding to the at least one change operation.
[0123] The snapshot creation module 1140 is used to create snapshots of intermediate data.
[0124] The remote replication module 1160 is used to store intermediate data and snapshots of intermediate data to the main data center, and to control the data center to obtain the target intermediate data corresponding to the target snapshot from the main data center according to the target snapshot, and to remotely replicate the target intermediate data.
[0125] In one embodiment, the remote replication module 1160 includes:
[0126] The identifier acquisition unit is used to acquire the data version identifier of the intermediate data and the snapshot identifier of the snapshot of the intermediate data;
[0127] The storage unit is used to store intermediate data and its snapshot to the main data center based on the intermediate data version identifier and the snapshot identifier.
[0128] In one embodiment, the version identifier includes a data version sequence number, and the snapshot identifier includes a snapshot sequence number; the data version sequence number of the intermediate data is less than the snapshot sequence number of the snapshot of the intermediate data, and the snapshot sequence number of the previous intermediate data is less than the data version sequence number of the intermediate data.
[0129] The storage unit includes:
[0130] The target snapshot sequence number determination subunit is used to determine the target snapshot sequence number from the snapshot sequence numbers of the snapshots; the target snapshot sequence number is the sequence number of the snapshot of the target intermediate data;
[0131] The storage sub-unit is used to determine the intermediate data to be stored from the intermediate data based on the size relationship between the target snapshot sequence number and the data version sequence number of the intermediate data, and to store the intermediate data to be stored in the main data center.
[0132] In one embodiment, the storage subunit includes:
[0133] The candidate intermediate data determination subunit is used to select intermediate data as candidate intermediate data if the target snapshot sequence number is greater than the data version sequence number of the intermediate data.
[0134] The intermediate data to be stored determination subunit is used to obtain the number of candidate intermediate data. If the number of candidate intermediate data exceeds the preset number, the intermediate data to be stored is determined from the candidate intermediate data.
[0135] In one embodiment, the intermediate data to be stored determination subunit includes:
[0136] The target data version sequence number determination subunit is used to determine the target data version sequence number from the data version sequence numbers corresponding to the candidate intermediate data; the target data version sequence number is the data version sequence number that is closest to the target snapshot sequence number.
[0137] The sub-unit corresponding to the intermediate data to be stored is used to take the candidate intermediate data corresponding to the target data version sequence number as the intermediate data to be stored.
[0138] In one embodiment, the remote replication module 1160 includes:
[0139] The adjacent snapshot acquisition unit is used to acquire adjacent snapshots that have been stored before acquiring a snapshot of the target intermediate data from the data center based on the snapshot identifier;
[0140] The difference data storage unit is used to store the difference data between the target intermediate data and the intermediate data corresponding to the adjacent snapshot into the target intermediate data;
[0141] The remote replication unit is used to control the acquisition of differential data from the primary data center based on a snapshot of the target intermediate data from the primary data center, and to remotely replicate the target intermediate data.
[0142] Each module in the aforementioned remote replication device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can invoke and execute the operations corresponding to each module.
[0143] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 12As shown, this computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores remotely copied data. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements a remote copying method.
[0144] Those skilled in the art will understand that Figure 12 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0145] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:
[0146] Based on the data change request, perform at least one change operation on the original data in the main data center and generate intermediate data corresponding to the at least one change operation.
[0147] Create a snapshot of the intermediate data;
[0148] The intermediate data and its snapshot are stored in the main data center. The control system retrieves the target intermediate data corresponding to the target snapshot from the main data center based on the target snapshot and performs remote replication of the target intermediate data.
[0149] In one embodiment, intermediate data and snapshots of the intermediate data are stored in the main data center, and the processor, when executing the computer program, also performs the following steps:
[0150] Obtain the data version identifier of the intermediate data and the snapshot identifier of the intermediate data snapshot;
[0151] Based on the data version identifier of the intermediate data and the snapshot identifier of the snapshot, the intermediate data and the snapshot of the intermediate data are stored in the main data center.
[0152] In one embodiment, the data version identifier includes a data version sequence number, and the snapshot identifier includes a snapshot sequence number; the data version sequence number of the intermediate data is less than the snapshot sequence number of the snapshot of the intermediate data, and the snapshot sequence number of the previous intermediate data is less than the data version sequence number of the intermediate data.
[0153] Based on the data version identifier of the intermediate data and the snapshot identifier of the snapshot, the intermediate data and its snapshot are stored in the main data center. When the processor executes the computer program, it also performs the following steps:
[0154] The target snapshot sequence number is determined from the snapshot sequence number of the snapshot; the target snapshot sequence number is the sequence number of the snapshot of the target intermediate data.
[0155] Based on the size relationship between the target snapshot sequence number and the data version sequence number of the intermediate data, the intermediate data to be stored is determined from the intermediate data, and the intermediate data to be stored is stored in the main data center.
[0156] In one embodiment, intermediate data to be stored is determined from the intermediate data based on the size relationship between the target snapshot sequence number and the data version sequence number of the intermediate data. The processor, when executing the computer program, further implements the following steps:
[0157] If the target snapshot sequence number is greater than the data version sequence number of the intermediate data, then the intermediate data will be used as the candidate intermediate data.
[0158] Obtain the number of candidate intermediate data. If the number of candidate intermediate data exceeds the preset number, determine the intermediate data to be stored from the candidate intermediate data.
[0159] In one embodiment, when determining intermediate data to be stored from candidate intermediate data, the processor, while executing the computer program, further performs the following steps:
[0160] The target data version sequence number is determined from the data version sequence numbers corresponding to the candidate intermediate data; the target data version sequence number is the data version sequence number that is closest to the target snapshot sequence number.
[0161] The candidate intermediate data corresponding to the target data version serial number is used as the intermediate data to be stored.
[0162] In one embodiment, the control retrieves the target intermediate data corresponding to the target snapshot from the primary data center based on the target snapshot, performs remote replication of the target intermediate data, and the processor also implements the following steps when executing the computer program:
[0163] The adjacent snapshots that were stored before the snapshot of the target intermediate data was obtained from the data center based on the snapshot identifier;
[0164] Store the difference between the target intermediate data and the intermediate data corresponding to the adjacent snapshot into the target intermediate data;
[0165] The system retrieves differential data from the primary data center based on a snapshot of the target intermediate data from the primary data center and remotely replicates the target intermediate data.
[0166] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, the computer program performing the following steps when executed by a processor:
[0167] Based on the data change request, perform at least one change operation on the original data in the main data center and generate intermediate data corresponding to the at least one change operation.
[0168] Create a snapshot of the intermediate data;
[0169] The intermediate data and its snapshot are stored in the main data center. The control system retrieves the target intermediate data corresponding to the target snapshot from the main data center based on the target snapshot and performs remote replication of the target intermediate data.
[0170] In one embodiment, intermediate data and snapshots of the intermediate data are stored in the main data center, and the computer program, when executed by the processor, also performs the following steps:
[0171] Obtain the data version identifier of the intermediate data and the snapshot identifier of the intermediate data snapshot;
[0172] Based on the data version identifier of the intermediate data and the snapshot identifier of the snapshot, the intermediate data and the snapshot of the intermediate data are stored in the main data center.
[0173] In one embodiment, the data version identifier includes a data version sequence number, and the snapshot identifier includes a snapshot sequence number; the data version sequence number of the intermediate data is less than the snapshot sequence number of the snapshot of the intermediate data, and the snapshot sequence number of the previous intermediate data is less than the data version sequence number of the intermediate data.
[0174] Based on the data version identifier of the intermediate data and the snapshot identifier of the snapshot, the intermediate data and its snapshot are stored in the main data center. When the computer program is executed by the processor, the following steps are also performed:
[0175] The target snapshot sequence number is determined from the snapshot sequence number of the snapshot; the target snapshot sequence number is the sequence number of the snapshot of the target intermediate data.
[0176] Based on the size relationship between the target snapshot sequence number and the data version sequence number of the intermediate data, the intermediate data to be stored is determined from the intermediate data, and the intermediate data to be stored is stored in the main data center.
[0177] In one embodiment, intermediate data to be stored is determined from the intermediate data based on the size relationship between the target snapshot sequence number and the data version sequence number of the intermediate data. When the computer program is executed by the processor, the following steps are also performed:
[0178] If the target snapshot sequence number is greater than the data version sequence number of the intermediate data, then the intermediate data will be used as the candidate intermediate data.
[0179] Obtain the number of candidate intermediate data. If the number of candidate intermediate data exceeds the preset number, determine the intermediate data to be stored from the candidate intermediate data.
[0180] In one embodiment, intermediate data to be stored is determined from candidate intermediate data, and the computer program, when executed by a processor, further performs the following steps:
[0181] The target data version sequence number is determined from the data version sequence numbers corresponding to the candidate intermediate data; the target data version sequence number is the data version sequence number that is closest to the target snapshot sequence number.
[0182] The candidate intermediate data corresponding to the target data version serial number is used as the intermediate data to be stored.
[0183] In one embodiment, the control retrieves the target intermediate data corresponding to the target snapshot from the primary data center based on the target snapshot, and remotely replicates the target intermediate data. When the computer program is executed by the processor, it also performs the following steps:
[0184] The adjacent snapshots that were stored before the snapshot of the target intermediate data was obtained from the data center based on the snapshot identifier;
[0185] Store the difference between the target intermediate data and the intermediate data corresponding to the adjacent snapshot into the target intermediate data;
[0186] The system retrieves differential data from the primary data center based on a snapshot of the target intermediate data from the primary data center and remotely replicates the target intermediate data.
[0187] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, performs the following steps:
[0188] Based on the data change request, perform at least one change operation on the original data in the main data center and generate intermediate data corresponding to the at least one change operation.
[0189] Create a snapshot of the intermediate data;
[0190] The intermediate data and its snapshot are stored in the main data center. The control system retrieves the target intermediate data corresponding to the target snapshot from the main data center based on the target snapshot and performs remote replication of the target intermediate data.
[0191] In one embodiment, intermediate data and snapshots of the intermediate data are stored in the main data center, and the computer program, when executed by the processor, also performs the following steps:
[0192] Obtain the data version identifier of the intermediate data and the snapshot identifier of the intermediate data snapshot;
[0193] Based on the data version identifier of the intermediate data and the snapshot identifier of the snapshot, the intermediate data and the snapshot of the intermediate data are stored in the main data center.
[0194] In one embodiment, the data version identifier includes a data version sequence number, and the snapshot identifier includes a snapshot sequence number; the data version sequence number of the intermediate data is less than the snapshot sequence number of the snapshot of the intermediate data, and the snapshot sequence number of the previous intermediate data is less than the data version sequence number of the intermediate data.
[0195] Based on the data version identifier of the intermediate data and the snapshot identifier of the snapshot, the intermediate data and its snapshot are stored in the main data center. When the computer program is executed by the processor, the following steps are also performed:
[0196] The target snapshot sequence number is determined from the snapshot sequence number of the snapshot; the target snapshot sequence number is the sequence number of the snapshot of the target intermediate data.
[0197] Based on the size relationship between the target snapshot sequence number and the data version sequence number of the intermediate data, the intermediate data to be stored is determined from the intermediate data, and the intermediate data to be stored is stored in the main data center.
[0198] In one embodiment, intermediate data to be stored is determined from the intermediate data based on the size relationship between the target snapshot sequence number and the data version sequence number of the intermediate data. When the computer program is executed by the processor, the following steps are also performed:
[0199] If the target snapshot sequence number is greater than the data version sequence number of the intermediate data, then the intermediate data will be used as the candidate intermediate data.
[0200] Obtain the number of candidate intermediate data. If the number of candidate intermediate data exceeds the preset number, determine the intermediate data to be stored from the candidate intermediate data.
[0201] In one embodiment, intermediate data to be stored is determined from candidate intermediate data, and the computer program, when executed by a processor, further performs the following steps:
[0202] The target data version sequence number is determined from the data version sequence numbers corresponding to the candidate intermediate data; the target data version sequence number is the data version sequence number that is closest to the target snapshot sequence number.
[0203] The candidate intermediate data corresponding to the target data version serial number is used as the intermediate data to be stored.
[0204] In one embodiment, the control retrieves the target intermediate data corresponding to the target snapshot from the primary data center based on the target snapshot, and remotely replicates the target intermediate data. When the computer program is executed by the processor, it also performs the following steps:
[0205] The adjacent snapshots that were stored before the snapshot of the target intermediate data was obtained from the data center based on the snapshot identifier;
[0206] Store the difference between the target intermediate data and the intermediate data corresponding to the adjacent snapshot into the target intermediate data;
[0207] The system retrieves differential data from the primary data center based on a snapshot of the target intermediate data from the primary data center and remotely replicates the target intermediate data.
[0208] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data shall comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0209] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0210] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0211] The above embodiments are merely illustrative of several implementation methods of this application, and their descriptions are relatively specific and detailed. However, they should not be construed as limiting the scope of this application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A remote replication method applied to a primary data center, the primary data center being communicatively connected with a secondary data center, the method comprising: The method includes: Based on the data change request, perform at least one change operation on the original data in the main data center to generate intermediate data corresponding to the at least one change operation; Create a snapshot of the intermediate data; The intermediate data and a snapshot of the intermediate data are stored in the main data center. The slave data center is controlled to obtain the target intermediate data corresponding to the target snapshot from the main data center according to the target snapshot, and the target intermediate data is remotely copied. The step of storing the intermediate data and a snapshot of the intermediate data in the main data center includes: Obtain the data version identifier of the intermediate data and the snapshot identifier of the snapshot of the intermediate data; the data version identifier includes a data version serial number, and the snapshot identifier includes a snapshot serial number; the data version serial number of the intermediate data is less than the snapshot serial number of the snapshot of the intermediate data, and the snapshot serial number of the previous intermediate data is less than the data version serial number of the intermediate data. The target snapshot sequence number is determined from the snapshot sequence number of the snapshot; the target snapshot sequence number is the sequence number of the snapshot of the target intermediate data; Based on the size relationship between the target snapshot sequence number and the data version sequence number of the intermediate data, intermediate data to be stored is determined from the intermediate data, and the intermediate data to be stored is stored in the main data center.
2. The method of claim 1, wherein, The step of determining the intermediate data to be stored from the intermediate data based on the size relationship between the target snapshot sequence number and the data version sequence number of the intermediate data includes: If the target snapshot sequence number is greater than the data version sequence number of the intermediate data, then the intermediate data is used as candidate intermediate data. The number of candidate intermediate data is obtained. If the number of candidate intermediate data exceeds a preset number, intermediate data to be stored is determined from the candidate intermediate data.
3. The method of claim 2, wherein, The step of determining the intermediate data to be stored from the candidate intermediate data includes: The target data version sequence number is determined from the data version sequence numbers corresponding to the candidate intermediate data; the target data version sequence number is the data version sequence number that is closest to the target snapshot sequence number. The candidate intermediate data corresponding to the target data version serial number is used as the intermediate data to be stored.
4. The method according to any one of claims 1 to 3, characterized in that, The control of retrieving target intermediate data corresponding to the target snapshot from the primary data center based on the target snapshot from the secondary data center, and remotely replicating the target intermediate data, includes: In the data center, adjacent snapshots that were previously stored before the snapshot of the target intermediate data were obtained based on the snapshot identifier; The difference between the target intermediate data and the intermediate data corresponding to the adjacent snapshot is stored in the target intermediate data; The system controls the data acquisition of the difference data from the primary data center based on a snapshot of the target intermediate data, and then remotely replicates the target intermediate data.
5. A remote replication apparatus applied to a primary data center, the primary data center being communicatively connected with a secondary data center, the remote replication apparatus comprising: The device includes: The change module is used to perform at least one change operation on the original data in the main data center according to the data change request, and generate intermediate data corresponding to the at least one change operation. The snapshot creation module is used to create snapshots of the intermediate data; The remote replication module is used to store the intermediate data and a snapshot of the intermediate data in the main data center, and control the slave data center to obtain the target intermediate data corresponding to the target snapshot from the main data center according to the target snapshot, and remotely replicate the target intermediate data. The remote replication module includes an identifier acquisition unit and a storage unit; The identifier acquisition unit is used to acquire the data version identifier of the intermediate data and the snapshot identifier of the snapshot of the intermediate data; the data version identifier includes a data version serial number, and the snapshot identifier includes a snapshot serial number; the data version serial number of the intermediate data is less than the snapshot serial number of the snapshot of the intermediate data, and the snapshot serial number of the previous intermediate data is less than the data version serial number of the intermediate data. The storage unit includes: a target snapshot sequence number determination subunit, used to determine a target snapshot sequence number from the snapshot sequence number of the snapshot; the target snapshot sequence number is the sequence number of the snapshot of the target intermediate data; and a storage subunit, used to determine intermediate data to be stored from the intermediate data according to the size relationship between the target snapshot sequence number and the data version sequence number of the intermediate data, and store the intermediate data to be stored in the main data center. 6.A computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the computer device is configured to perform the method according to any one of claims 1-5 when the computer program is executed by the processor. When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 4.
7. A computer-readable storage medium having stored thereon a computer program, characterized in that When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 4.
8. A computer program product comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Data transmission method and data transmission device
CN111741038A
Snapshot creation method, computing device and storage medium
CN114328018A
