A database data synchronization method, system, device and storage medium
By adopting multi-target disk synchronous replication and database asynchronous replication technology in the financial system, the problem of data loss in off-site disaster recovery replication is solved, and the system-level zero data loss and rapid disaster recovery recovery is achieved, which is suitable for long-distance disaster recovery scenarios .
Patent Information
- Application Number
- CN202011337993.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-25
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2040-11-25
AI Technical Summary
In the disaster recovery and recovery of the financial system, the off-site disaster recovery and replication solution has the problem of non-zero RPO, resulting in data loss. The disk replication technology restricts the use of the same city, making it impossible to achieve zero data loss in long-distance disaster recovery scenarios.
Multi-target disk synchronous replication technology and database asynchronous replication technology are used to synchronously copy data through the same city center and then asynchronously transmit it to the disaster recovery center to achieve system-level zero data loss without the need to deploy hosts in the same city center.
It realizes the minute-level disaster recovery system to recover external services, avoids data loss, and simplifies the deployment of disaster recovery solutions, meeting the financial system's demand for data consistency.
Smart Images

Figure CN112433887B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data disaster recovery and backup, and in particular to a database data synchronization method, system, device and storage medium. Background Art
[0002] Currently, most domestic financial systems employ off-site disaster recovery solutions, with the primary and disaster recovery centers located in separate locations. This allows production systems to be restored at the more distant disaster recovery center in the event of a disaster at the primary center, allowing external services to continue. Common technical indicators for disaster recovery are recovery time object (RTO) and recovery point object (RPO). Ideally, an RPO of 0 is ideal, and the shorter the RTO, the better.
[0003] The disaster recovery replication solution for IBM mainframe systems is mainly based on disk replication technology or database replication technology. (1) Regarding the time required for disaster recovery (RTO): Since the target disk for disk replication in current mainframe systems is usually not available online, when the disaster recovery replication technology used is disk replication technology, the disaster recovery recovery system needs to be restarted, and the time required for disaster recovery (RTO) is longer. When the disaster recovery replication technology used is database replication technology, there is no need to restart the system, and the time required for disaster recovery (RTO) is shorter. (2) Regarding the disaster recovery data point RPO: In order to avoid disasters occurring in two locations at the same time, the disaster recovery center is usually far away from the main center. The long distance will also make it difficult for the technical solution of disaster recovery data replication in different locations to achieve an RPO of 0; if replication is done through disk technology, due to the long replication distance and large delay, synchronous replication cannot be achieved for financial systems with high business timeliness, which will result in data loss during off-site recovery; if asynchronous database replication is used, the asynchronous solution naturally cannot avoid data loss during off-site recovery.
[0004] Figure 1 This is a schematic diagram of a disaster recovery solution provided by existing technology. Please refer to Figure 1, a technical solution provided by the existing technology is based on XRC asynchronous replication technology, which reads the production system data through the SDM host and writes it to the disaster recovery data disk, realizing long-distance and remote data replication. The disaster recovery recovery system uses the disaster recovery data obtained by data replication to provide external services. The current implementation effect is RPO < 2 minutes, RTO < 2 hours. This technical solution has the following shortcomings: 1. It is necessary to deploy a system data mover (System Data Mover, SDM) host separately on the disaster recovery side for XRC data replication; 2. The XRC target disk is unreadable during the normal replication process, so when the disaster recovery system is restored, the system needs to be restarted, resulting in a longer disaster recovery time; 3. The technical principle of XRC's asynchronous replication determines that data loss cannot be avoided, and the RPO is not zero. After the disaster recovery system is restored, it needs to be supplemented by other means.
[0005] Figure 2 This is a schematic diagram of another disaster recovery solution provided by existing technology. Please refer to Figure 2 One existing technical solution is based on multi-target disk synchronous replication technology and database asynchronous replication technology. It synchronously replicates a database log from site A to site B, reads the log at site B, and asynchronously appends it to the database at site B. This achieves zero-loss data replication between the two sites in the same city. Because the system at site B is online and available, there is no need to restart the system, thus enabling rapid switching between sites A and B. The current implementation effect is RPO = 0, and RTO is at the minute level. However, due to the distance limitations of disk synchronous replication technology, this technical solution can only be used in the same city and is not suitable for long-distance disaster recovery scenarios.
[0006] Figure 3 This is another principle diagram of a disaster recovery solution provided by existing technology. Please refer to Figure 3 One existing solution is based on asynchronous database replication technology. After reading the production system's database log from the production center, it is transmitted to a remote disaster recovery center via a message queue and asynchronously appended to the recovery system, thus enabling long-distance data replication between the production center and the disaster recovery center. Because the disaster recovery system is always available online, there's no need to restart the system, enabling rapid disaster recovery switching. The current implementation results in an RPO > 0 and an RTO of minutes. However, the drawback is that asynchronous database replication technology means this solution can't prevent data loss, requiring other solutions to compensate. Summary of the Invention
[0007] The present invention aims to solve at least one of the technical problems existing in the prior art. To this end, the present invention provides a database data synchronization method in a first aspect, comprising:
[0008] Synchronously copy the database logs and key files written to the master disk of the first site to the slave disk of the first site, synchronously copy the database logs written to the master disk to the database log disk of the second site, and synchronously copy the key files written to the master disk to the key file disk of the second site;
[0009] When the database log disk at the second site receives the database log copied from the primary disk, asynchronously copying the database log copied to the database log disk at the second site to a third site;
[0010] When the key file disk at the second site receives the key file copied from the master disk, the key file copied to the key file disk at the second site is asynchronously copied to the third site;
[0011] The geographical distance between the first site and the second site is smaller than the geographical distance between the first site and the third site.
[0012] Furthermore, it also includes:
[0013] When the slave disk receives the database logs and key files copied from the master disk, the database logs and key files copied to the slave disk are copied to the recovery system disk of the third site using a disk asynchronous replication technology;
[0014] When the recovery system disk receives the database log and key files copied from the slave disk, the recovery system database of the third site is initialized according to the database log and key files copied from the slave disk to the recovery system disk.
[0015] Furthermore, the step of asynchronously copying the database logs copied to the database log disk of the second site to the third site includes:
[0016] Copying the database logs copied to the database log disk of the second site to the database log disk of the third site using disk asynchronous replication technology;
[0017] When the database log disk at the third site receives the database log copied from the database log disk at the second site, the database log copied to the database log disk at the third site is copied to the recovery system disk using database asynchronous replication technology.
[0018] Furthermore, the step of copying the database logs copied to the database log disk of the third site to the recovery system disk using a database asynchronous replication technology includes:
[0019] The log reading process reads the database log copied to the database log disk of the third site, and transmits the read database log to the log appending process through the message queue;
[0020] When receiving the read database log, the append log process parses the received read database log and rewrites the data into the recovery system database of the third site.
[0021] Furthermore, after asynchronously copying the key files copied to the key file disk of the second site to the third site, the method further includes:
[0022] When it is detected that the first site stops providing external services and the connection between the first site and the peripheral system is disconnected, detecting whether the data of the second site is completely synchronized with the third site;
[0023] If fully synchronized, determine whether the third site has completed reading and appending all database logs;
[0024] If completed, the peripheral system will be connected to the third-site recovery system, and the disaster recovery system will be opened to external services.
[0025] Furthermore, after determining whether the third site has completed reading and appending all database logs, the method further includes:
[0026] If completed, check whether the data of the third site is consistent with the first site;
[0027] When the data at the third site is consistent with the data at the first site, the steps of connecting the peripheral system to the recovery system at the third site and opening the disaster recovery system to external services are performed;
[0028] When the data of the third site is inconsistent with that of the first site, a reason causing the data inconsistency between the third site and the first site is analyzed.
[0029] Furthermore, after detecting whether the data of the second site is completely synchronized with the third site, the method further includes: if not completely synchronized, performing the step of detecting whether the data of the second site is completely synchronized with the third site again;
[0030] After determining whether the third site has completed reading and appending all database logs, the method further includes: if not completed, executing again the step of determining whether the third site has completed reading and appending all database logs.
[0031] A second aspect of the present invention provides a database data synchronization system, comprising a synchronous replication module, a first asynchronous replication module, and a second asynchronous replication module;
[0032] The synchronous replication module is used to synchronously replicate the database logs and key files written to the master disk of the first site to the slave disk of the first site, synchronously replicate the database logs written to the master disk to the database log disk of the second site, and synchronously replicate the key files written to the master disk to the key file disk of the second site;
[0033] The first asynchronous replication module is configured to asynchronously replicate the database logs replicated to the database log disk of the second site to a third site when the database log disk of the second site receives the database logs replicated from the primary disk;
[0034] The second asynchronous replication module is configured to asynchronously replicate the key files copied to the key file disk of the second site to the third site when the key file disk of the second site receives the key files copied from the master disk;
[0035] The geographical distance between the first site and the second site is smaller than the geographical distance between the first site and the third site.
[0036] The third aspect of the present invention proposes a device, which includes a processor and a memory, wherein the memory stores at least one instruction, at least one program, code set or instruction set, and the at least one instruction, at least one program, code set or instruction set is loaded and executed by the processor to implement the database data synchronization method proposed in the first aspect of the present invention.
[0037] The fourth aspect of the present invention proposes a computer-readable storage medium, which stores at least one instruction, at least one program, code set or instruction set. The at least one instruction, the at least one program, the code set or instruction set is loaded and executed by a processor to implement the database data synchronization method proposed in the first aspect of the present invention.
[0038] The database data synchronization method, system, device and storage medium proposed in the embodiments of the present invention retain the "hot backup" and short recovery time characteristics of the current database replication technology. By utilizing disk replication technology, the synchronously replicated data is first landed in the same-city center and then asynchronously transmitted to the disaster recovery center, thereby realizing a large-scale mainframe disaster recovery replication solution with zero data loss at the system level. There is no need for application participation in data replenishment, and there is no need to deploy a host in the same-city center. The disaster recovery system can restore external services within minutes.
[0039] Additional aspects and advantages of the present invention will be set forth in part in the description which follows and, in part, will be obvious from the description which follows, or may be learned by practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0041] Figure 1 This is a schematic diagram of a disaster recovery solution provided by existing technology;
[0042] Figure 2 This is a schematic diagram of another disaster recovery solution provided by existing technology;
[0043] Figure 3 This is a schematic diagram of another disaster recovery solution provided by existing technology;
[0044] Figure 4 This is a flowchart of a database data synchronization method provided by an embodiment of the present invention;
[0045] Figure 5 This is a schematic diagram of a database data synchronization method provided by an embodiment of the present invention;
[0046] Figure 6 This is the process of step S102;
[0047] Figure 7 This is a schematic diagram of the disaster recovery process disclosed in an embodiment of the present invention;
[0048] Figure 8 This is a schematic diagram of the planned disaster recovery drill process disclosed in an embodiment of the present invention;
[0049] Figure 9 This is a structural block diagram of a database data synchronization system provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0050] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention. Examples of the embodiments are shown in the accompanying drawings, where the same or similar numbers throughout represent the same or similar elements or elements with the same or similar functions.
[0051] The following are explanations of terms that may be used in the embodiments of the present invention:
[0052] Recovery Point Object (RPO) refers to the number of times a disaster recovery system can restore data to the point in time before the disaster occurs.
[0053] Recovery Time Object (RTO) refers to the time period after a disaster, from the moment the IT system crashes, causing business interruption, to the moment the IT system recovers to the point where it can support the operations of various departments and business resumes.
[0054] Peer-to-Peer Remote Copy (PPRC) is a disk replication technology based on disk microcode. The main technical principle is that a complete write operation includes the following steps:
[0055] 1. Write to the primary disk;
[0056] 2. Write to the target disk;
[0057] 3. Return to the operating system;
[0058] Ensures that the data on the primary disk and the target disk are completely consistent.
[0059] Multi-target PPRC (MT-PPRC) is a disk replication technology that allows data on a disk to be replicated to two or more target disks simultaneously.
[0060] PPRC-XD (PPRC-Extended Distance Feature) is an asynchronous replication technology of PPRC. The main technical principle is that a complete write operation does not include writing to the target disk. Data synchronization between the primary disk and the target disk is completed asynchronously.
[0061] Asynchronous Extended Remote Copy (XRC) is an asynchronous data replication technology that combines hardware microcode and software. The main technical principle is to initiate a replication request through the host software on the disaster recovery side, capture the disk data on the production side through the disk microcode, and sort it on the disaster recovery side, ultimately providing data with a consistent time point for disaster recovery.
[0062] System Data Mover (SDM) refers to the product component in XRC replication technology that interacts with the storage subsystem to replicate data.
[0063] Example
[0064] Figure 4This is a flowchart of a database data synchronization method provided by an embodiment of the present invention. Figure 5 It is a schematic diagram of a database data synchronization method provided by an embodiment of the present invention. This specification provides method operation steps such as the embodiment or flowchart, but may include more or fewer operation steps based on conventional or non-creative work. The order of steps listed in the embodiment is only one way of executing the steps among many steps, and does not represent the only execution order. When the actual system or server product is executed, it can be executed in sequence or in parallel according to the method shown in the embodiment or the accompanying drawings (for example, in a parallel processor or multi-threaded processing environment). Specifically, Figure 4 and Figure 5 As shown, the method may include the following steps:
[0065] S101: Synchronously copying the database logs and key files written to the master disk of the first site to the slave disk of the first site, synchronously copying the database logs written to the master disk to the database log disk of the second site, and synchronously copying the key files written to the master disk to the key file disk of the second site;
[0066] The first site is Figure 5 The primary disk of the first site is the production center shown in Figure 5 The production master disk, the slave disk at the first site, and Figure 5 Shown is production from disc.
[0067] The second site is Figure 5 The database log disk of the second site is Figure 5 The disk marked with "Database Log" is the key file disk of the second site. Figure 5 The disk marked with "Critical Files";
[0068] Specifically, the database log written to the master disk of the first site is copied to the slave disk of the first site and the database log disk of the second site using a multi-target disk synchronous replication technology.
[0069] Specifically, the key files written to the master disk are copied to the slave disk and the key file disk of the second site using a multi-target disk synchronous replication technology.
[0070] S102: When the database log disk at the second site receives the database log copied from the primary disk, the database log copied to the database log disk at the second site is asynchronously copied to the third site;
[0071] Figure 6 This is the process of step S102, specifically as follows Figure 6 As shown, step S102 includes the following sub-steps:
[0072] S1021: When the database log disk at the second site receives the database log copied from the primary disk, the database log copied to the database log disk at the second site is copied to the database log disk at the third site using disk asynchronous replication technology;
[0073] Among them, the database log disk of the third site is Figure 5 The disk labeled "Asynchronous replication to database log".
[0074] S1022: When the database log disk at the third site receives the database log copied from the database log disk at the second site, the database log copied to the database log disk at the third site is copied to the recovery system disk using database asynchronous replication technology.
[0075] Database asynchronous replication technology refers to the Q Replication technology based on the IBM DB2 system. The main technical principle is to read the database log of the main production center, transmit it to the disaster recovery end through the Websphere MQ system, and re-execute it in the disaster recovery database, thereby realizing the replication of the database content between the main center and the disaster recovery center.
[0076] Specifically, step S1022 includes the following sub-steps:
[0077] The log reading process reads the database log copied to the database log disk of the third site, and transmits the read database log to the log appending process through the message queue;
[0078] When receiving the read database log, the append log process parses the received read database log and rewrites the data into the recovery system database of the third site.
[0079] S103: When the key file disk at the second site receives the key file copied from the master disk, the key file copied to the key file disk at the second site is asynchronously copied to the third site. Specifically, step S103 includes the following sub-steps:
[0080] The key files copied to the key file disk of the second site are copied to the recovery system disk of the third site using disk asynchronous replication technology.
[0081] The geographical distance between the first site and the second site is smaller than the geographical distance between the first site and the third site. In a specific example, the distance between the first site (production center) and the third site (disaster recovery center) is approximately 1,500 kilometers, and the distance between the first site (production center) and the second site (same-city center) is approximately 60 kilometers.
[0082] Optionally, the geographical distance between the first site and the second site is less than a first preset distance, the geographical distance between the first site and the third site is less than a second preset distance, and the first preset distance is much smaller than the second preset distance.
[0083] Please continue to refer to Figure 5 The database data synchronization method proposed in the embodiment of the present invention further includes the following steps:
[0084] When the slave disk receives the database logs and key files copied from the primary disk, the database logs and key files copied to the slave disk are copied to the recovery system disk at the third site using the disk asynchronous replication technology;
[0085] When the recovery system disk receives the database log and key files copied from the slave disk, the content of the recovery system database at the third site is initialized according to the database log and key files copied from the slave disk to the recovery system disk.
[0086] That is, using the secondary disk as the data source, the production database data is copied to the third site through the disk asynchronous replication technology, and the database content of the recovery system is initialized.
[0087] Before executing the database data synchronization method provided by an embodiment of the present invention, the following steps are also included:
[0088] 1. Build a second site (i.e., the city center)
[0089] Deploy disks and disk-related peripherals (without deploying hosts) and data transmission-related equipment at the second site. Figure 1 Compared with the disaster recovery solutions provided by the disclosed prior art, the embodiments of the present invention do not require the deployment of hosts in the city center.
[0090] 2. Build a third site (i.e., disaster recovery center)
[0091] Build a recovery system at the third site and deploy log reading processes, log appending processes, message transmission queues, etc.
[0092] 3. Establish disk replication relationship
[0093] Establish a multi-target synchronous replication relationship between the production master disk, slave disk, and the database log and key file disks at the second site. The production master disk and slave disk are fully replicated, while the second site only replicates partial data.
[0094] The database log and key file disks of the second site establish an asynchronous replication relationship with the third site. The database log is asynchronously replicated to the third site and serves as the data source for reading the log. The key files are asynchronously replicated to the third site and serve as part of the system data recovery.
[0095] Data consistency and replication management for multi-target synchronous replication and asynchronous file replication are controlled by IBM mainframe GDPS (Geographically Dispersed Parallel Sysplex, a disaster recovery product based on the IBM z platform).
[0096] Figure 7 This is a schematic diagram of the disaster recovery process disclosed in the embodiment of the present invention, specifically as follows Figure 7 As shown in the figure, the disaster recovery process includes the following steps:
[0097] S201: When it is detected that the first site (i.e., the production center) stops providing external services and the connection between the first site and the peripheral system is disconnected, it is detected whether the data of the second site (i.e., the same-city center) is completely synchronized with the data of the third site (i.e., the disaster recovery center);
[0098] When an unplanned disaster occurs, the first site and its external connections are passively stopped. Due to the disaster at the first site, the database logs and file data at the second site are no longer updated.
[0099] S202: If the synchronization is complete, determine whether the third site has completed reading and appending all database logs; if the synchronization is not complete, perform the step of detecting whether the data of the second site is completely synchronized with the third site again;
[0100] S203: If completed, connect the peripheral system to the third site recovery system and open the disaster recovery system to external services; if not completed, perform again the step of determining whether the third site has completed reading and appending all database logs.
[0101] Specifically, since the data consistency check is time-consuming, it is usually performed in disaster recovery drills. During actual switching, in order to complete the switching in the shortest possible time, the data consistency check step is usually not performed.
[0102] Figure 8 This is a schematic diagram of the planned disaster recovery drill process disclosed in an embodiment of the present invention, specifically as follows Figure 8 As shown in the figure, the disaster recovery process includes the following steps:
[0103] S300: Actively stop the first site (ie, the production center) from providing external services, and simultaneously stop the peripheral systems from continuing to access the host of the first site.
[0104] S301: When it is detected that the first site stops providing external services and the connection between the first site and the peripheral system is disconnected, it is detected whether the data of the second site (i.e., the same-city center) is completely synchronized with the data of the third site (i.e., the disaster recovery center);
[0105] S302: If the synchronization is complete, determine whether the third site has completed reading and appending all database logs; if the synchronization is not complete, execute step S301 again;
[0106] S303: If completed, check whether the data of the third site is consistent with the first site; if not completed, perform again the step of determining whether the third site has completed reading and appending all database logs.
[0107] S304: When the data at the third site is consistent with the data at the first site, the peripheral system is connected to the recovery system at the third site, and the disaster recovery system is opened to external services;
[0108] S305: When the data of the third site is inconsistent with that of the first site, analyze the cause of the inconsistency between the data of the third site and the first site.
[0109] Figure 9 This is a structural block diagram of a database data synchronization system provided by an embodiment of the present invention, specifically as follows Figure 9 As shown, a database data synchronization system proposed in an embodiment of the present invention includes a synchronous replication module 401, a first asynchronous replication module 402 and a second asynchronous replication module 403;
[0110] Synchronous replication module 401, for synchronously replicating the database logs and key files written to the master disk of the first site to the slave disk of the first site, synchronously replicating the database logs written to the master disk to the database log disk of the second site, and synchronously replicating the key files written to the master disk to the key file disk of the second site;
[0111] The first asynchronous replication module 402 is configured to asynchronously replicate the database logs replicated to the database log disk of the second site to the third site when the database log disk of the second site receives the database logs replicated from the primary disk;
[0112] The second asynchronous replication module 403 is configured to asynchronously replicate the key files copied to the key file disk of the second site to the third site when the key file disk of the second site receives the key files copied from the primary disk;
[0113] The geographical distance between the first site and the second site is smaller than the geographical distance between the first site and the third site.
[0114] An embodiment of the present invention also provides a device, comprising a processor and a memory, wherein the memory stores at least one instruction, at least one program, code set or instruction set, and the at least one instruction, at least one program, code set or instruction set is loaded and executed by the processor to implement a database data synchronization method as described in the method embodiment.
[0115] An embodiment of the present invention also provides a storage medium, which can be set in a server to store at least one instruction, at least one program, code set or instruction set related to the database data synchronization method in the method embodiment. The at least one instruction, the at least one program, the code set or instruction set is loaded and executed by the processor to implement the database data synchronization method provided by the above-mentioned method embodiment.
[0116] Optionally, in this embodiment, the storage medium may be located in at least one of a plurality of network servers in a computer network. Optionally, in this embodiment, the storage medium may include, but is not limited to, various media capable of storing program code, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disk.
[0117] It can be seen from the embodiments of the database data synchronization method, system, device or storage medium provided by the present invention that the database data synchronization method, system, device and storage medium proposed in the embodiments of the present invention utilize database asynchronous replication technology, multi-target disk synchronization, and asynchronous replication technology to build a two-site three-center disaster recovery solution with zero data loss. The main technical principle is to synchronously back up the database log of the production system (first site) to the same-city center (second site) through multi-target synchronous replication technology, and use the data of the same-city center (second site) as the data source, and asynchronously copy the production data to the disaster recovery system in a different location through database asynchronous replication technology. This solution completely achieves zero data loss through a system-level disaster recovery solution, and does not require application participation in data complementation.
[0118] It should be noted that the order in which the embodiments of the present invention are described above is for illustrative purposes only and does not represent the superiority or inferiority of the embodiments. The above description is of specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps described in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or sequential order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0119] The various embodiments in this specification are described in a progressive manner. Similar portions between the various embodiments can be referenced to each other. Each embodiment focuses on the differences between the other embodiments. In particular, the device and server embodiments are generally similar to the method embodiments, so their descriptions are relatively simple. For relevant portions, refer to the descriptions of the method embodiments.
[0120] Those skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware, or by a program to instruct the relevant hardware, and the program may be stored in a computer-readable storage medium, which may be a read-only memory, a disk, or an optical disk, etc.
[0121] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A method for synchronizing database data, characterized in that: include: Synchronously copying the database log and key files written to the master disk of the first site to the slave disk of the first site, synchronously copying the database log written to the master disk to the database log disk of the second site, and synchronously copying the key files written to the master disk to the key file disk of the second site; When the database log disk at the second site receives the database log copied from the primary disk, asynchronously copying the database log copied to the database log disk at the second site to a third site; When the key file disk at the second site receives the key file copied from the master disk, asynchronously copying the key file copied to the key file disk at the second site to the third site; wherein the geographical distance between the first site and the second site is less than the geographical distance between the first site and the third site; The step of asynchronously copying the database logs copied to the database log disk of the second site to the third site comprises: The database logs copied to the database log disk of the second site are copied to the database log disk of the third site by using the disk asynchronous replication technology; When the database log disk at the third site receives the database log copied from the database log disk at the second site, the database log copied to the database log disk at the third site is copied to the recovery system disk using a database asynchronous replication technology; The step of asynchronously copying the key file copied to the key file disk of the second site to the third site comprises: The key files copied to the key file disk of the second site are copied to the recovery system disk of the third site by using the disk asynchronous copy technology.
2. The method according to claim 1, characterized in that Also includes: When the slave disk receives the database logs and key files copied from the master disk, the database logs and key files copied to the slave disk are copied to the recovery system disk of the third site by using the disk asynchronous replication technology; When the recovery system disk receives the database log and key files copied from the slave disk, the content of the recovery system database of the third site is initialized according to the database log and key files copied from the slave disk to the recovery system disk.
3. The method according to claim 1, characterized in that The step of copying the database logs copied to the database log disk of the third site to the recovery system disk using a database asynchronous replication technology comprises: The log reading process reads the database log copied to the database log disk of the third site, and transmits the read database log to the log appending process through the message queue; When receiving the read database log, the log appending process parses the received read database log and rewrites the received read database log into the recovery system database of the third site.
4. The method according to claim 1, characterized in that: After the key files copied to the key file disk of the second site are asynchronously copied to the third site, the method further includes: When it is detected that the first site stops providing external services and the connection between the first site and the peripheral system is disconnected, detecting whether the data of the second site is completely synchronized with the third site; If fully synchronized, determine whether the third site has completed reading and appending all database logs; If completed, the peripheral system will be connected to the third site recovery system, and the disaster recovery system will be opened to external services.
5. The method according to claim 4, characterized in that After determining whether the third site has completed reading and appending all database logs, the method further includes: If completed, check whether the data of the third site is consistent with that of the first site; When the data of the third site is consistent with that of the first site, the steps of connecting the peripheral system to the recovery system of the third site and opening the disaster recovery system to external services are performed; When the data of the third site is inconsistent with that of the first site, the reasons causing the data inconsistency between the third site and the first site are analyzed.
6. The method according to claim 5, characterized in that After the step of detecting whether the data of the second site is completely synchronized with the third site, the method further includes: if not completely synchronized, executing the step of detecting whether the data of the second site is completely synchronized with the third site again; After determining whether the third site has completed reading and appending all database logs, the method further includes: if not completed, executing again the step of determining whether the third site has completed reading and appending all database logs.
7. A database data synchronization system, characterized in that: It includes a synchronous replication module, a first asynchronous replication module and a second asynchronous replication module; The synchronous replication module is used to synchronously replicate the database log and key files written to the master disk of the first site to the slave disk of the first site, synchronously replicate the database log written to the master disk to the database log disk of the second site, and synchronously replicate the key files written to the master disk to the key file disk of the second site; The first asynchronous replication module is used to asynchronously replicate the database logs replicated to the database log disk of the second site to a third site when the database log disk of the second site receives the database logs replicated from the primary disk; The second asynchronous replication module is used to asynchronously replicate the key files copied to the key file disk of the second site to the third site when the key file disk of the second site receives the key files copied from the master disk; wherein the geographical distance between the first site and the second site is less than the geographical distance between the first site and the third site; The step of asynchronously copying the database logs copied to the database log disk of the second site to the third site comprises: The database logs copied to the database log disk of the second site are copied to the database log disk of the third site by using the disk asynchronous replication technology; When the database log disk at the third site receives the database log copied from the database log disk at the second site, the database log copied to the database log disk at the third site is copied to the recovery system disk using a database asynchronous replication technology; The step of asynchronously copying the key file copied to the key file disk of the second site to the third site comprises: The key files copied to the key file disk of the second site are copied to the recovery system disk of the third site by using the disk asynchronous copy technology.
8. A device, characterized in that The device includes a processor and a memory, wherein the memory stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by the processor to implement the database data synchronization method as described in any one of claims 1-6.
9. A computer-readable storage medium, characterized in that: The storage medium stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by the processor to implement the database data synchronization method as described in any one of claims 1-6.
