Database disaster recovery method, device, equipment and system

By storing the log data of the first storage device in the computer device and using the second storage device to read the target log data from the computer device in the event of a failure, the problem of data loss in long-distance database replication is solved, and data integrity and write performance are guaranteed.

CN120653485APending Publication Date: 2025-09-16HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410317362.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-03-15
Publication Date
2025-09-16

AI Technical Summary

Technical Problem

Between a remote primary database and a standby database, asynchronous replication causes data lag, resulting in some data not being copied to the standby database in time when the primary database fails, leading to data loss.

Method used

By storing the log data of the first storage device on the computer device and using the second storage device to read the target log data from the computer device to supplement the log data of the second storage device when the first storage device fails, the integrity of the data is ensured, and the RDMA protocol and persistent memory or high-speed non-volatile memory are used to reduce latency.

Benefits of technology

It effectively prevents data loss, ensures data write performance, and maintains normal system operation in the event of a failure.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120653485A_ABST
    Figure CN120653485A_ABST
Patent Text Reader

Abstract

The invention discloses a disaster recovery method, device, equipment and system for a database, and belongs to the technical field of databases. The method comprises the steps that computer equipment stores first log data of first storage equipment to back up data of the first storage equipment, and the computer equipment is not affected by the first storage equipment; meanwhile, regularly storing the log data of the first storage device through the second storage device to serve as a backup device of the first storage device; under the condition that the first storage device breaks down, the computer device can still work normally. At the moment, the second storage device reads the target log data from the computer device to supplement the log data of the second storage device so as to replace the first storage device to provide data for the application, so that data loss is effectively prevented, and meanwhile, the writing performance of the data of the first storage device is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of database technology, and in particular to a database disaster recovery method, apparatus, device, and system. Background Art

[0002] In industries such as finance and telecommunications, data reliability requirements are high, such as the requirement that data not be lost. In a database disaster recovery method provided by a related technology, data from a primary database (or data center) is replicated to a standby database (or disaster recovery cluster).

[0003] In one scenario, the distance between the primary database and the standby database is typically hundreds to thousands of kilometers, and the network communication latency can typically be tens of milliseconds. Therefore, asynchronous replication is required to replicate data between the primary and standby databases.

[0004] However, the data bits sent by the primary database to the standby database may significantly lag behind the logical length of the data. Data bits can be understood as the number of bits actually contained in a set of data. If the primary database fails, some data may not be replicated to the standby database in a timely manner, resulting in data loss. Clearly, the aforementioned database disaster recovery method still poses the risk of data loss. Summary of the Invention

[0005] This application provides a database disaster recovery method, apparatus, device, and system to solve the problems provided by related technologies. The technical solution is as follows:

[0006] In a first aspect, a database disaster recovery method is provided, which is applied to a computer device, wherein the computer device is used to store first log data of a first database of a first storage device, the first storage device is used to provide data for an application, and the first storage device is also used to request a second storage device to store log data at fixed time intervals, and the second storage device is a backup device of the first storage device; the method comprises: in the event of a failure of the first storage device, receiving a first request sent by the second storage device, the first request being used to request reading target log data on the computer device, the target log data comprising differential data between the first log data and the second log data, the second log data being log data copied from the first storage device by the second storage device, and the second log data being a part of the first log data; sending the target log data to the second storage device according to the first request; the target log data being used to supplement the log data of the second database of the second storage device, so that the second storage device provides data for the application after the log data of the second database is supplemented.

[0007] In this application, a computer device stores the first log data of a first storage device to back up the data of the first storage device, and the computer device is not affected by the first storage device. At the same time, a second storage device regularly stores the log data of the first storage device to serve as a backup device for the first storage device. In the event of a failure of the first storage device, the computer device can still operate normally. At this time, the second storage device reads the target log data from the computer device to supplement the log data of the second storage device, replacing the first storage device to provide data to the application, thereby effectively preventing data loss and ensuring the data write performance of the first storage device.

[0008] In one possible implementation, the first request carries the data bits of the second log data; the sending of the target log data to the second storage device according to the first request includes: comparing the first log data and the second log data according to the data bits of the second log data, the data bits of the first log data, and the logical length of the first log data to obtain differential data between the first log data and the second log data; and sending the differential data as the target log data to the second storage device. In the present application, by determining the differential data between the first log data and the second log data, the differential data is sent to the second storage device to supplement the log data of the second storage device, thereby effectively preventing the loss of the log data of the first storage device in the event of a failure of the first storage device.

[0009] In one possible implementation, the first request carries the identifier of the second log data; and the target log data is sent to the second storage device according to the first request, including: determining the first log data according to the identifier of the second log data and the identifier relationship between the stored data; and sending the first log data as the target log data to the second storage device. In the present application, by searching for the first log data associated with the identifier of the second log data according to the identifier of the second log data, and sending the first log data to the second storage device to supplement the log data of the second storage device, the loss of the log data of the first storage device in the event of a failure of the first storage device is effectively prevented.

[0010] In one possible implementation, the method further includes: receiving a second request from the first storage device when the first storage device is not faulty, the second request being used to request storage of the first log data; and storing the first log data based on the second request to store backup data for the first storage device. In the present application, by storing the first log data requested to be copied by the first storage device when the first storage device is not faulty, backup data is stored for the first storage device, providing an effective risk avoidance solution for the log data of the first storage device.

[0011] In one possible implementation, the first storage device is deployed in a first area, and the computer device is deployed in a second area different from the first area; in the event of a failure of the first storage device, the devices in the second area are not affected by the first storage device. In the present application, by deploying the first storage device and the computer device in different areas, in the event of a failure of the first storage device, the computer device will not be affected by the failure of the first storage device, effectively ensuring the security of the log data backed up on the computer device and providing an effective risk avoidance solution for the log data of the first storage device.

[0012] In one possible implementation, the distance between the first storage device and the computer device is smaller than the distance between the first storage device and the second storage device. In this application, by making the distance between the first storage device and the computer device smaller than the distance between the first storage device and the second storage device, the latency of copying log data from the first storage device to the computer device is effectively ensured to be smaller than the latency of copying log data from the first storage device to the second storage device, thereby ensuring data write performance while ensuring that data is not lost.

[0013] In one possible implementation, the first storage device and the computer device communicate using a Remote Direct Address Access (RDMA) protocol. In this application, by using the Remote Direct Address Access (RDMA) protocol for communication between the first storage device and the computer device, latency can be further reduced, thereby ensuring data write performance while preventing data loss.

[0014] In one possible implementation, the computer device deploys persistent memory or high-speed non-volatile memory (NVME). In this application, by deploying persistent memory or high-speed non-volatile memory in the computer device, the storage performance of persistent memory and high-speed non-volatile memory is utilized to further reduce latency, thereby ensuring data write performance while ensuring data is not lost.

[0015] In a second aspect, a database disaster recovery method is provided, which is applied to a first storage device, and the first storage device is used to provide data for an application. The method includes: sending a second request to a computer device, the second request is used to request storage of first log data of a first database of the first storage device, and the first log data is log data corresponding to a transaction requested to be submitted by the application; periodically sending a third request to a second storage device, the third request is used to request storage of part of the first log data, and the second storage device is a backup device of the first storage device; receiving a first response message fed back by the computer device, the first response message is used to indicate that the first log data has been stored on the computer device; receiving a second response message fed back by the second storage device, the second response message is used to indicate that the part of the data has been stored on the second storage device; in the event that the first storage device fails, second log data is stored on the second storage device, and the second log data is part of the first log data; the second storage device is used to read target log data from the computer device to supplement the log data of the second database of the second storage device, and the target log data includes differential data between the first log data and the second log data.

[0016] In one possible implementation, sending a second request to a computer device includes: sending a fourth request to a first disk corresponding to the first storage device, and sending the second request to the computer device in parallel, wherein the fourth request is used to request storage of the first log data, and the first disk is a carrier of the first database; the method further includes: receiving a third response message fed back by the first disk, wherein the third response message is used to indicate that the first log data has been stored on the first disk. In the present application, the first storage device stores the first log data on the computer device while storing the first log data on its own disk, thereby effectively reducing latency and improving the efficiency of data backup of the first storage device.

[0017] In one possible implementation, the first storage device is deployed in a first area, and the computer device is deployed in a second area different from the first area; in the event of a failure of the first storage device, the devices in the second area are not affected by the first storage device. In the present application, by deploying the first storage device and the computer device in different areas, in the event of a failure of the first storage device, the computer device will not be affected by the failure of the first storage device, effectively ensuring the security of the log data backed up on the computer device and providing an effective risk avoidance solution for the log data of the first storage device.

[0018] In one possible implementation, the distance between the first storage device and the computer device is smaller than the distance between the first storage device and the second storage device. In this application, by making the distance between the first storage device and the computer device smaller than the distance between the first storage device and the second storage device, the latency of copying log data from the first storage device to the computer device is effectively ensured to be smaller than the latency of copying log data from the first storage device to the second storage device, thereby ensuring data write performance while ensuring that data is not lost.

[0019] In one possible implementation, the first storage device and the computer device communicate using a Remote Direct Address Access (RDMA) protocol. In this application, by using the Remote Direct Address Access (RDMA) protocol for communication between the first storage device and the computer device, latency can be further reduced, thereby ensuring data write performance while preventing data loss.

[0020] In one possible implementation, the computer device deploys persistent memory or high-speed non-volatile memory (NVME). In this application, by deploying persistent memory or high-speed non-volatile memory in the computer device, the storage performance of persistent memory and high-speed non-volatile memory is utilized to further reduce latency, thereby ensuring data write performance while ensuring data is not lost.

[0021] In a third aspect, a database disaster recovery method is provided, which is applied to a second storage device, wherein the second storage device is used to store log data of a first storage device, the second storage device is a backup device of the first storage device, and the first storage device is used to provide data for an application when the first storage device has not failed. The method includes: in the event of a failure of the first storage device, the second storage device stores second log data through a second database, and the second log data is a part of the first log data; sending a first request to a computer device, wherein the computer device is used to store first log data of a first database of the first storage device, and the first request is used to request to read target log data on the computer device, wherein the target log data includes differential data between the first log data and the second log data; receiving the target log data sent by the computer device; and supplementing the log data of the second database of the second storage device according to the target log data to provide data for the application.

[0022] In one possible implementation, the first request carries the data bits of the second log data; the computer device is further used to compare the first log data and the second log data based on the data bits of the second log data, the data bits of the first log data, and the logical length of the first log data, to obtain the differential data between the first log data and the second log data, and send the differential data as the target log data to the second storage device. In the present application, by determining the differential data between the first log data and the second log data, the differential data is sent to the second storage device to supplement the log data of the second storage device, thereby effectively preventing the loss of the log data of the first storage device in the event of a failure of the first storage device.

[0023] In one possible implementation, the sending of the first request to the computer device includes: receiving a fifth request sent by an arbitration device, the fifth request being used to request database switching, the fifth request being generated when the first storage device fails, and the arbitration device being used to monitor the working status of each storage device; in response to the fifth request, sending the first request to the computer device; after supplementing the log data of the second storage device, the method further includes: sending a fourth response message to the arbitration device, the fourth response message being used to indicate that the device providing data for the application has been switched to the second storage device. In the present application, the arbitration device detects that the first storage device has failed. In this case, the first storage device provides data for the application, and the second storage device is switched to provide data for the application. At this time, the second storage device needs to read the target log data from the computer device to supplement the log data of the second storage device, thereby effectively preventing data loss.

[0024] In one possible implementation, the first storage device is deployed in a first area, and the computer device is deployed in a second area different from the first area; in the event of a failure of the first storage device, the devices in the second area are not affected by the first storage device. In the present application, by deploying the first storage device and the computer device in different areas, in the event of a failure of the first storage device, the computer device will not be affected by the failure of the first storage device, effectively ensuring the security of the log data backed up on the computer device and providing an effective risk avoidance solution for the log data of the first storage device.

[0025] In one possible implementation, the distance between the first storage device and the computer device is smaller than the distance between the first storage device and the second storage device. In this application, by making the distance between the first storage device and the computer device smaller than the distance between the first storage device and the second storage device, the latency of copying log data from the first storage device to the computer device is effectively ensured to be smaller than the latency of copying log data from the first storage device to the second storage device, thereby ensuring data write performance while ensuring that data is not lost.

[0026] In one possible implementation, the first storage device and the computer device communicate using a Remote Direct Address Access (RDMA) protocol. In this application, by using the Remote Direct Address Access (RDMA) protocol for communication between the first storage device and the computer device, latency can be further reduced, thereby ensuring data write performance while preventing data loss.

[0027] In one possible implementation, the computer device deploys persistent memory or high-speed non-volatile memory (NVME). In this application, by deploying persistent memory or high-speed non-volatile memory in the computer device, the storage performance of persistent memory and high-speed non-volatile memory is utilized to further reduce latency, thereby ensuring data write performance while ensuring data is not lost.

[0028] In a fourth aspect, a disaster recovery device for a database is provided, which is applied to a computer device, wherein the computer device is used to store first log data of a first database on a first storage device, the first storage device is used to provide data for an application, and the first storage device is also used to request a second storage device to store log data at fixed time intervals, and the second storage device is a backup device of the first storage device; the device includes: a first receiving module, which is used to receive a first request sent by a second storage device in the event of a failure of the first storage device, the first request is used to request to read target log data on the computer device, the target log data includes differential data between the first log data and the second log data, the second log data is log data copied from the first storage device by the second storage device, and the second log data is a part of the first log data; a first sending module is used to send the target log data to the second storage device according to the first request; the target log data is used to supplement the log data of the second database of the second storage device, so that the second storage device provides data for the application after the log data of the second database is supplemented.

[0029] In one possible implementation, the first request carries the data bits of the second log data; the first sending module is used to: compare the first log data and the second log data based on the data bits of the second log data, the data bits of the first log data and the logical length of the first log data, to obtain differential data between the first log data and the second log data; and send the differential data as the target log data to the second storage device.

[0030] In one possible implementation, the first request carries an identifier of the second log data; the first sending module is used to: determine the first log data based on the identifier of the second log data and the identification relationship between the stored data; and send the first log data as the target log data to the second storage device.

[0031] In one possible implementation, the method further includes: a first storage module. The first receiving module is configured to receive, when the first storage device is not faulty, a second request sent by the first storage device, the second request being for storing the first log data. The first storage module is configured to store the first log data in accordance with the second request to store backup data for the first storage device.

[0032] In one possible implementation, the first storage device is deployed in a first area, and the computer device is deployed in a second area different from the first area; in the event that the first storage device fails, the devices in the second area are not affected by the first storage device.

[0033] In a possible implementation, a distance between the first storage device and the computer device is smaller than a distance between the first storage device and the second storage device.

[0034] In a possible implementation, the first storage device communicates with the computer device using a Remote Direct Address Access (RDMA) protocol.

[0035] In one possible implementation, a persistent memory or a high-speed non-volatile memory NVME is deployed in the computer device.

[0036] In a fifth aspect, a disaster recovery device for a database is provided, which is applied to a first storage device, and the first storage device is used to provide data for an application. The device includes: a first sending module, used to send a second request to a computer device, the second request is used to request the storage of first log data of a first database of the first storage device, and the first log data is the log data corresponding to the transaction submitted by the application request; periodically sending a third request to a second storage device, the third request is used to request the storage of part of the first log data, and the second storage device is a backup device of the first storage device; a first receiving module, used to receive a first response message fed back by the computer device, the first response message is used to indicate that the first log data has been stored on the computer device; receiving a second response message fed back by the second storage device, the second response message is used to indicate that the storage of the part of the data on the second storage device has been completed; in the event that the first storage device fails, second log data is stored on the second storage device, and the second log data is part of the first log data; the second storage device is used to read target log data from the computer device to supplement the log data of the second database of the second storage device, and the target log data includes differential data between the first log data and the second log data.

[0037] In one possible implementation, the first sending module is used to send a fourth request to the first disk corresponding to the first storage device, and in parallel send the second request to the computer device, wherein the fourth request is used to request storage of the first log data, and the first disk is the carrier of the first database; the first receiving module is used to receive a third response message fed back by the first disk, and the third response message is used to indicate that the first log data has been stored on the first disk.

[0038] In one possible implementation, the first storage device is deployed in a first area, and the computer device is deployed in a second area different from the first area; in the event that the first storage device fails, the devices in the second area are not affected by the first storage device.

[0039] In a possible implementation, a distance between the first storage device and the computer device is smaller than a distance between the first storage device and the second storage device.

[0040] In a possible implementation, the first storage device communicates with the computer device using a Remote Direct Address Access (RDMA) protocol.

[0041] In one possible implementation, a persistent memory or a high-speed non-volatile memory NVME is deployed in the computer device.

[0042] In a sixth aspect, a disaster recovery device for a database is provided, which is applied to a second storage device, the second storage device is used to store the second log data of the first storage device, the second storage device is a backup device of the first storage device, and the first storage device is used to provide data for the application when the first storage device does not fail. The device includes: a first sending module, which is used to store the second log data through the second database of the second storage device when the first storage device fails, and the second log data is part of the first log data; and send a first request to a computer device, the computer device is used to store the first log data of the first database of the first storage device, the computer device is not affected by the first storage device, and the first request is used to request to read the target log data on the computer device, the target log data including the differential data between the first log data and the second log data; a first receiving module, which is used to receive the target log data sent by the computer device, the target log data is determined by the computer device according to the first request and sent to the second storage device; a supplementing module, which is used to supplement the log data of the second database of the second storage device according to the target log data to provide data for the application.

[0043] In one possible implementation, the first request carries the data bits of the second log data; the computer device is also used to compare the first log data and the second log data based on the data bits of the second log data, the data bits of the first log data and the logical length of the first log data, obtain the differential data between the first log data and the second log data, and send the differential data as the target log data to the second storage device.

[0044] In one possible implementation, the first receiving module is configured to receive a fifth request, the fifth request being for requesting a database switch, the fifth request being generated when the first storage device fails. The first sending module is configured to send the first request to the computer device in response to the fifth request. After replenishing the log data of the second storage device, the first sending module is configured to send a fourth response message to the other components, the fourth response message being used to indicate that the device providing data for the application has been switched to the second storage device.

[0045] In one possible implementation, the first storage device is deployed in a first area, and the computer device is deployed in a second area different from the first area; in the event that the first storage device fails, the devices in the second area are not affected by the first storage device.

[0046] In a possible implementation, a distance between the first storage device and the computer device is smaller than a distance between the first storage device and the second storage device.

[0047] In a possible implementation, the first storage device communicates with the computer device using a Remote Direct Address Access (RDMA) protocol.

[0048] In one possible implementation, a persistent memory or a high-speed non-volatile memory NVME is deployed in the computer device.

[0049] In the seventh aspect, an electronic device is provided, comprising a memory and a processor; at least one instruction is stored in the memory, and the at least one instruction is loaded and executed by the processor to enable the electronic device to implement the method described in the first aspect, the method described in the second aspect, or the method described in the third aspect.

[0050] In the eighth aspect, a disaster recovery system for a database is provided, the system comprising: a first storage device for executing the method described in the second aspect; a computer device for communicating with the first storage device for executing the method described in the first aspect; and a second storage device for communicating with the first storage device and the computer device respectively for executing the method described in the third aspect.

[0051] In a ninth aspect, a computer program (product) is provided, which includes: computer program code, which, when executed by a computer, enables the computer to execute the methods in the above aspects.

[0052] In a tenth aspect, a computer-readable storage medium is provided, which stores a program or instruction. When the program or instruction runs on a computer, the methods in the above aspects are executed.

[0053] In an eleventh aspect, a chip is provided, comprising a processor for calling and executing instructions stored in a memory from the memory, so that a device equipped with the chip executes the methods in the above aspects.

[0054] In the twelfth aspect, another chip is provided, comprising: an input interface, an output interface, a processor and a memory, wherein the input interface, the output interface, the processor and the memory are connected via an internal connection path, and the processor is used to execute the code in the memory. When the code is executed, the processor is used to execute the methods in the above aspects.

[0055] It should be understood that the beneficial effects achieved by the technical solutions of the fourth to twelfth aspects of this application and the corresponding possible implementation methods can be referred to the above-mentioned technical effects of the first, second and third aspects and their corresponding possible implementation methods, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] Figure 1 A schematic diagram of the structure of a database disaster recovery system in a related art;

[0057] Figure 2 A schematic diagram of the structure of a database disaster recovery method provided in an embodiment of the present application;

[0058] Figure 3 A schematic diagram of a database disaster recovery method provided in an embodiment of the present application;

[0059] Figure 4 A flowchart of another database disaster recovery method provided in an embodiment of the present application;

[0060] Figure 5 A flowchart of another database disaster recovery method provided in an embodiment of the present application. DETAILED DESCRIPTION

[0061] The terms used in the implementation section of this application are only used to explain the specific embodiments of this application and are not intended to limit this application.

[0062] In basic industries such as finance and telecommunications, there are high requirements for data reliability, such as the requirement that data should not be lost. In order to prevent data loss, it is usually necessary to perform data disaster recovery on the database (or master database), or in other words, to back up the data of the master database. Exemplarily, the following methods can be used to back up data: for example, in one case, the disaster recovery system may include: deploying a standby database within 50 km of the master database, and the master database can copy data to the standby database. Since the distance between the master database and the standby database is less than 50 km, it takes 1-5 ms for the master database to copy data to the disaster recovery cluster (or standby database). It can be seen that the write performance of the master database is within an acceptable range, while effectively preventing data loss.

[0063] However, the above disaster recovery method only supports data disaster recovery at short distances. Figure 1 The disaster recovery system shown may include: a first site and a second site. The distance between the first site and the second site may be greater than 100 km. A first data center and a second data center are deployed at the first site. The first data center includes a first database and a first disk. The second data center includes a second database and a second disk. A third data center is deployed at the second site, and the third data center includes a third database and a third disk. Synchronous replication is used to replicate data between the second database and the first database, and asynchronous replication is used to replicate data between the third database and the first database. Synchronous replication can be understood as simultaneous replication. Asynchronous replication can be understood as non-simultaneous replication.

[0064] That is, the first database replicates data to the second database in real time, and then replicates data to the third database at regular intervals. However, the network latency of the first database can typically reach tens of milliseconds. Replicating data from the first database to the third database takes tens of milliseconds, significantly reducing the write performance of the first database. Therefore, if the first database fails, the second database will also fail, and some data from the first database will not be replicated to the third database in a timely manner, resulting in data loss.

[0065] In order to solve the above technical problems, an embodiment of the present application provides a disaster recovery method for a database, which can be applied to a disaster recovery system, and the method includes: a first storage device writes log data to a computer device in real time, the first storage device writes log data to a second storage device at time intervals, and the second storage device is a backup device for the first storage device. In the case where the first storage device does not send a fault, the first storage device provides data for the application. In the case of a failure of the first storage device, the first log data is stored in the computer device, and the second log data is stored in the second storage device, and the second log data is part of the first log data. At this time, the second storage device sends a first request to the computer device, and the first request is used to request to read the target log data, and the target log data includes the differential data between the first log data and the second log data. The computer device sends the target log data to the second storage device according to the first request. The second storage device supplements the log data of the second storage device according to the target log data. Afterwards, the second storage device replaces the first storage device to provide data for the application.

[0066] In this application, a computer device stores the first log data of a first storage device to back up the data of the first storage device, and the computer device is not affected by the first storage device. At the same time, a second storage device regularly stores the log data of the first storage device to serve as a backup device for the first storage device. In the event of a failure of the first storage device, the computer device can still operate normally. At this time, the second storage device reads the target log data from the computer device to supplement the log data of the second storage device, replacing the first storage device to provide data to the application, thereby effectively preventing data loss and ensuring the data write performance of the first storage device.

[0067] In some embodiments, a first storage device is deployed in a first area, a computer device is deployed in a second area, and a second storage device is deployed in a third area. The first and second areas are different failure zones. In other words, if the first storage device fails, the devices in the second area are not affected by the first storage device. The distance between the first and second areas is smaller than the distance between the first and third areas.

[0068] The first storage device and the second storage device may include but are not limited to databases, and the computer device may include but are not limited to applications for storing data, such as storage services, etc. In the embodiment of the present application, the computer device is used as a storage service and the storage device is used as a database for example.

[0069] The database disaster recovery method provided in the embodiments of the present application can be applied not only to the database field, but also to disaster recovery products that adopt write-ahead logging (WAL) persistence solutions, such as KV (key-value) storage products, file / object storage products, message queue products, cache products, etc., which can use computer devices (such as storage services) to cache log data and use asynchronous replication to achieve long-distance disaster recovery capabilities.

[0070] Figure 2 A schematic diagram of the structure of a database disaster recovery system provided in an embodiment of the present application is shown in FIG. Figure 2As shown, the system may also include: a first storage device, a second storage device and a first computer device. The first database and the first disk are deployed on the first storage device, and the first disk is the carrier of the first database. The second database and the second disk are deployed on the second storage device, and the second disk is the carrier of the second database. The first computer device and the first storage device do not affect each other. It can be understood that when the first storage device fails, the first computer device still works normally; or, when the first computer device fails, the first storage device still works normally. Among them, the first storage device is used to store the first log data of the first database on the first disk and the first computer device in real time, that is, the first storage device and the first computer device use synchronous replication to copy data. The first storage device is also used to store the log data of the first database on the second storage device at fixed time intervals, that is, the first storage device and the second storage device use asynchronous replication to copy data, and the write performance of the first storage device will not be reduced due to asynchronous replication. The second storage device is a backup device for the first storage device.

[0071] If the first storage device does not fail, the first storage device provides data for the application. Figure 3 As shown, the data writing process of the disaster recovery system may be as follows: Step 1: When an application executes a transaction, the application sends a request to the first storage device to generate log data corresponding to the transaction. The first storage device generates the first log data in the first database based on the request. Step 2: The first storage device sends the first log data to the first disk in real time for storage. Step 3: After the first disk stores the first log data, the first disk returns a response message to the first storage device indicating that the first log data has been stored. Step 4: The first storage device sends the first log data to the first computer device in real time for storage. That is, the first storage device replicates the first log data to the first computer device using synchronous replication. Step 5: After the first computer device stores the first log data, the first computer device returns a response message to the first storage device indicating that the first log data has been stored. Step 6: The first storage device returns a response message to the application indicating that the transaction has been submitted. Step 7: The first storage device also sends the log data to the second storage device at regular intervals. That is, the first storage device replicates the first log data to the second storage device using asynchronous replication. Step 8: After the second storage device stores a portion of the log data, the second storage device returns a response message to the first storage device indicating that the portion of the log data has been stored.

[0072] In some examples, a first storage device is deployed in a first area, a first computer device is deployed in a second area, and a second storage device is deployed in a third area. The first, second, and third areas are all different regions. Different regions can be understood as regions that do not affect each other. For example, these regions may have different geographical locations, deployed different devices, or configured networks. Therefore, if a failure occurs in the first area, the second area will not be affected by the first area.

[0073] In other examples, the distance between the first area and the second area is smaller than the distance between the first area and the third area. For example, the distance between the first area and the second area is 30 km, and the distance between the first area and the third area is 200 km. Figure 2 As shown, the write path for the first storage device to write the log data on the first database to the first computer device is L1. The write path for the first storage device to write the log data on the first database to the second database of the second storage device is L2, and L1 is smaller than L2. Accordingly, the delay T1 for copying data between the first database and the first computer device is smaller than the delay T2 for copying data between the first database and the second database. In particular, the distance between the first area and the second area is much smaller than the distance between the first area and the third area. Here, much smaller than can be understood as the difference between the two being greater than a threshold. For example, the threshold is 200Km. The distance between the first area and the second area is 250Km, the distance between the first area and the third area is 500Km, the difference between the two distances is 250Km, and is greater than 200Km. Then, it can be understood that the distance between the first area and the second area is much smaller than the distance between the first area and the third area.

[0074] In the event of a failure of the first storage device, the second log data is stored in the second database of the second storage device. The second storage device will replace the first storage device to provide data for the application. Figure 4 As shown, the working process of reading data of the disaster recovery system can be: Step ⑨ The arbitration component is used to sense the working status of the first storage device. In the case of sensing that the first storage device has failed, the arbitration device (such as the arbitration component) sends a switching message to the second storage device, and the switching message is used to instruct the second storage device to provide data for the application. The arbitration device is used to monitor the working status of each storage device. Step ⑩ The second storage device sends a request for reading target log data to the first computer device based on the switching message, and the target log data includes differential data of the first log data and the second log data. Accordingly, the first computer device receives the request. Step The first computer device sends the target log data to the second storage device according to the request. Correspondingly, the second storage device receives the target log data. The second storage device supplements the log data in the second database according to the target log data and applies the data. After the second storage device supplements the log data in the second database, the second storage device reports a message indicating that the log data supplementation is complete to the arbitration component.

[0075] visible, Figure 2 The system shown is compared to Figure 1 The system shown differs in that Figure 2 The disaster recovery system shown has been newly added with a first computer device, which can store data from the first database in real time. The first computer device and the first database do not affect each other. In addition, the second storage device can read data from the first computer device to supplement the data in the second database. In this way, if the first storage device fails, the second storage device reads the missing data from the first computer device to supplement the data on the second database and replaces the first storage device to provide data for the application, effectively preventing data loss on the first storage device. At the same time, the data is written to the first computer device through the first storage device, and the first computer device acts as a relay to provide data to the second storage device, which can also ensure the write performance of the first storage device.

[0076] In some embodiments, as Figure 2 As shown, the above-mentioned second storage device can also read data from the first computer device. Of course, a second computer device can also be deployed on the side of the second storage device, and the second computer device is used to store log data on the second database. In a possible implementation, the above-mentioned disaster recovery system can also include a second computer device. The second computer device is deployed in the fourth area. The fourth area is different from the above-mentioned first area, second area and third area. The distance between the fourth area and the third area is less than the distance between the third area and the first area. The write path of the second computer device that the second storage device writes the log data on the second database to is L3, and the write path of the log data on the second database to the first database is L2, and L3 is less than L2. Accordingly, the delay T3 for the second storage device and the second computer device to copy data is less than the delay T2 for copying data between the second storage device and the first storage device. Similarly, in the event of a failure of the second storage device, the first storage device can also read data from the second computer device.

[0077] In particular, the distance between the fourth area and the third area is much smaller than the distance between the third area and the first area. "Much smaller" can be understood as meaning that the difference between the two is greater than a threshold. For example, the threshold is 200 km. The distance between the first and second areas is 60 km, and the distance between the first and third areas is 600 km. The difference between the two distances is 540 km, and is greater than 200 km. Therefore, it can be understood that the distance between the fourth area and the third area is much smaller than the distance between the third area and the first area.

[0078] In other embodiments, the first storage device and the computer device communicate using the Remote Direct Memory Access (RDMA) protocol. Therefore, in embodiments of the present application, by using the Remote Direct Memory Access protocol for communication between the first storage device and the computer device, latency can be further reduced, thereby ensuring data write performance while preventing data loss. Of course, the second storage device and the computer device can also communicate using the RDMA protocol to further reduce latency and ensure data read efficiency.

[0079] In some other embodiments, persistent memory or high-speed non-volatile memory (NVME) is deployed in the computer device. Therefore, in the embodiments of the present application, by deploying persistent memory or high-speed non-volatile memory in the computer device, the storage performance of persistent memory and high-speed non-volatile memory is utilized, which can further reduce latency and ensure data write performance without losing data.

[0080] In some other embodiments, the first log data may be redo log data. Of course, the embodiments of the present application are not limited to redo log data, and may also be specialized replication logs, such as the binary log binlog of MySQL. Therefore, in the embodiments of the present application, the database supports both redo logs and specialized replication logs, thereby achieving the effect of supporting a variety of different commercial databases.

[0081] The following combination Figure 2 The disaster recovery system shown describes in detail the disaster recovery method of the database provided in the embodiment of the present application.

[0082] Figure 5 The flowchart of a database disaster recovery method provided in the embodiment of the present application is as follows. Figure 5 As shown in FIG, the disaster recovery method of the database can be divided into two stages for detailed description.

[0083] The first stage is the data writing stage, such as S500-S505 (some steps are optional).

[0084] S500: When an application executes transaction 1, the application sends request 1 to a first database of a first storage device, where request 1 is a request for executing transaction 1. Correspondingly, the first storage device receives request 1.

[0085] A transaction is a unit of concurrency control and is a user-defined sequence of operations. For example, a transaction can include a transfer transaction, a query transaction, a withdrawal transaction, a start transaction, and a commit transaction.

[0086] Exemplarily, the first request carries a structured query language (SQL). Exemplarily, the first request may carry an SQL insert statement, an SQL update statement, or an SQL delete statement.

[0087] S501: A first storage device generates first log data corresponding to transaction 1 according to request 1.

[0088] The first log data is used to record the data generated during the execution of transaction 1. For example, the first log data can be redo log data. Of course, the embodiments of the present application are not limited to redo log data, and can also be a specialized replication log, such as the binary log binlog of MySQL. This is not specifically limited in the embodiments of the present application.

[0089] In a possible implementation, the implementation of S500-S501 can be found in Figure 3 The description of step ① in .

[0090] After the first log data is generated in the first database of the first storage device, the first storage device needs to store the first log data in the first disk corresponding to the first database. To back up the first log data, the first storage device also needs to store the first log data in the first computer device and the second storage device, as described in S502, S503, and S505.

[0091] S502: The first storage device writes the first log data into the first disk in real time.

[0092] In other words, the first storage device stores the first log data in the first disk in a synchronous replication manner.

[0093] In a possible implementation, S502 may include S5021, S5022, and S5023.

[0094] S5021: The first storage device sends a request 2 to the first disk, where the request 2 is for requesting real-time writing of first log data.

[0095] S5022. The first disk stores the first log data according to request 2.

[0096] S5023: After the first disk completes storing the first log data, the first disk sends a first response message to the first storage device. The first response message is used to indicate that the first disk has completed storing the first log data.

[0097] In one possible implementation, the implementation of S5021-S5023 can be found in Figure 3 The relevant descriptions of steps ② and ③ in .

[0098] To back up the first log data, the first storage device may copy the first log data to the first storage service of the first computer device, as described in S503 .

[0099] S503: The first storage device writes the first log data to the first storage service of the first computer device in real time.

[0100] In other words, the first storage device stores the first log data in the first computer device in a synchronous replication manner.

[0101] The first storage device and the first computer device can communicate with each other using the RDMA protocol. The first computer device is equipped with a persistent memory or a high-speed non-volatile memory (NVME).

[0102] In a possible implementation, S503 may include S5031, S5032, and S5033.

[0103] S5031: The first storage device sends a request 3 to the first storage service, where the request 3 is for requesting to write first log data.

[0104] S5032: The first storage service stores the first log data according to request 3.

[0105] S5033: After the first storage service completes storing the first log data, the first storage service sends a second response message to the first storage device. The second response message is used to indicate that the first storage service has completed storing the first log data.

[0106] In some embodiments, the execution order of S502 and S503 is not specifically limited. In one possible implementation, the execution order of S5021-S5023 and S5031-S5033 is a serial order. For example, after executing S5021-S5023, execute S5031-S5033. Or, after executing S5031-S5033, execute S5021-S5023. In another possible implementation, the execution order of S5021-S5023 and S5031-S5033 is a parallel order. For example, execute S503 while executing S502. Or, execute S5031 while executing S5021, and execute S5033 while executing S5023. In an embodiment of the present application, the first log data is written to the first disk by the first database, and the first log is written to the first storage service at the same time, thereby effectively improving the write performance of the log data of the first database and improving the data storage efficiency.

[0107] In a possible implementation, the implementation of S5031-S5033 can be found in Figure 3 The relevant descriptions of steps ④ and ⑤ in .

[0108] S504: The first storage device feeds back a third response message to the application, where the third response message is used to indicate that the submission of transaction 1 is complete.

[0109] It can be understood that after the first storage device receives the first response message and / or the second response message, the first storage device feeds back a third response message to the application, which means that transaction 1 has been committed.

[0110] In a possible implementation, the implementation of S504 can be found in Figure 3 The relevant description of step ⑥ in .

[0111] In an embodiment of the present application, the first storage device issues write requests to two storage devices (e.g., the first disk and the first computer device) in parallel, and the transaction is successfully committed only after both devices respond. This results in transaction latency, which depends on the longest response time between the two devices. Compared to the serial log writing method, the parallel log writing method ensures that the write latency of the first log is not degraded, and the database write performance is not reduced.

[0112] In order to back up the first log data, the first storage device may further copy the first log data to a second database of the second storage device, as described in S505 .

[0113] S505: The first storage device writes the first log data into the second database of the second storage device at regular time intervals.

[0114] In other words, the first storage device stores the first log data in the second storage device in an asynchronous replication manner.

[0115] The first storage device and the second storage device may also communicate with each other using the RDMA protocol.

[0116] Wherein, fixed time interval can be understood as a write cycle.Therefore, S505 can be understood as the first storage device periodically writing the first log data into the second database. Exemplarily, the logical length of the first log data is writeLsn, and the log sequence number (log sequence number, LSN) of the first log data is 1-100. In the first cycle, the first storage device can write the log data with log sequence number 1-10 into the second database. In the second cycle, the first storage device can write the log data with log sequence number 11-20 into the second database. And so on, until the first log data are all written into the second database.

[0117] In the embodiments of this application, the replication protocol between the first and second storage devices remains unchanged, nor does the network link. This allows for the parallel transmission and parallel application mechanisms between the storage devices to be retained, without compromising the performance and reliability of existing database disaster recovery technology. Furthermore, adaptation to various database brands on the market is simplified, facilitating commercial applications.

[0118] S505 is described in detail below. In a possible implementation, S505 may include: S5051 and S5052.

[0119] S5051: The first storage device sends a request 4 to the second database, where the request 4 is used to request that the first log data be written at a fixed time interval.

[0120] Exemplarily, the log sequence number of the first log data is 1-100. The first storage device periodically sends log data with fixed data bits to the second storage device. For example, in the first cycle, the request 4 sent by the first storage device to the second storage device carries log data with sequence numbers 1-10, and the first storage device sends log data with sequence numbers 1-10 to the second storage device. In the second cycle, the request 4 sent by the first storage device to the second storage device carries log data with sequence numbers 11-20, and the first storage device sends log data with sequence numbers 11-10 to the second storage device. And so on, until the first storage device sends log data with sequence number 100 to the second storage device.

[0121] S5052: The second storage device writes the log data sent by the first storage device according to request 4.

[0122] In a possible implementation, the implementation of S5051-S5052 can be found in Figure 3 The description of step ⑦ in .

[0123] After the second storage device writes the log data, the second storage device feeds back a response message to the first storage device indicating that the log data storage is complete. Figure 3 The relevant description of step ⑧ in .

[0124] Continuing with the above example, the second storage device receives log data periodically sent by the first database. For example, in the first cycle, the second database receives log data with serial numbers 1-10. The second storage device stores the above log data and feeds back a response message to the first storage device indicating that the storage of the above log data is complete. In the second cycle, the second storage device receives log data with serial numbers 11-20 and updates the log data of the second database to log data with serial numbers 1-20. And so on.

[0125] Since the first storage device periodically writes the first log data to the second storage device, in the event that the first storage device fails, the first storage device only writes part of the first log data to the second storage device. Continuing with the above example, assume that after the third cycle, the first storage device fails. At this time, the first storage device has sent the log data of the third cycle to the second storage device, that is, the log data with serial numbers 21-30. Correspondingly, the second storage device receives the log data and updates the log data of the second storage device to the log data with serial numbers 1-30. However, after the third cycle, the first storage device fails to send log data to the second storage device. At this time, the second log data stored in the second database is the log data with serial numbers 1-30.

[0126] Therefore, in an embodiment of the present application, by storing the first log data requested to be copied by the first storage device when the first storage device does not fail, backup data is stored for the first storage device, providing an effective risk avoidance solution for the log data of the first storage device.

[0127] If the first storage device fails, it will be unable to provide data to the application. In this case, the second storage device must be switched to provide data to the application. As mentioned above, the log data stored in the second database of the second storage device is only a portion of the first log data. Therefore, the log data in the second database needs to be supplemented. Therefore, the second storage device needs to read data from the first storage service used to back up the log data of the first database. This is described in S506-S513 of the second stage below.

[0128] The second stage is the data reading stage, such as S506-S513 (some steps are optional).

[0129] S506: The second storage device sends a request 5 to the first storage service, where the request 5 is used to read the target log data on the first storage service.

[0130] The second storage device and the first computer device may also communicate using the RDMA protocol.

[0131] In one possible implementation, S506 may be implemented as follows: the second storage device receives a request for database switching sent by an arbitration device (e.g., an arbitration component), the request being generated when the first storage device fails. The arbitration device is configured to monitor the operating status of each storage device. In response to the request, the second storage device sends Request 5 to the computer device.

[0132] In another possible implementation, the implementation of S506 can be found in Figure 4 See the description of steps ⑨ and ⑩ in the .

[0133] The target log data may include the difference between the first log data and the second log data. That is, the target log data may be all of the first log data or part of the first log data. The following describes different situations in detail.

[0134] In case 1, the target log data is all the data of the first log data.

[0135] That is, request 5 is used to request to read the first log data on the first storage service.

[0136] S507: The first storage service sends the first log data to the second database according to request 5. Correspondingly, the second database receives the first log data.

[0137] In one possible implementation, request 5 carries an identifier of the first log data. S507 may be implemented as follows: the first storage service obtains the first log data according to the identifier of the first log data and the identifier relationship between the stored data, and sends the first log data to the second database.

[0138] In another possible implementation, the implementation of S507 can be found in Figure 4 Steps in Related description.

[0139] S508: The second database updates the second log data to the first log data.

[0140] In a possible implementation, the second database directly replaces the log data on the second database with the first log data. Ultimately, the log data on the second database becomes the first log data.

[0141] In another possible implementation, the implementation of S508 can be found in Figure 4 Steps in Related description.

[0142] In an embodiment of the present application, the first log data associated with the identifier of the second log data is searched for, and the first log data is sent to the second storage device to supplement the log data of the second storage device, thereby effectively preventing the loss of the log data of the first storage device in the event of a failure of the first storage device.

[0143] Case 2: The target log data is part of the first log data.

[0144] That is, request 5 is used to request to read part of the first log data on the first storage service.

[0145] S509: The first storage service determines the differential data between the first log data and the second log data according to request 5, which is the target log data.

[0146] In one possible implementation, request 5 carries data bits of the second log data, which can be understood as log sequence numbers. S509 can be implemented as follows: the first storage service compares the first log data and the second log data based on the data bits of the second log data, the data bits of the first log data, and the logical length of the first log data to obtain differential data between the first log data and the second log data.

[0147] S510: The first storage service sends the differential data as target log data to the second storage device. Correspondingly, the second storage device receives the differential data.

[0148] In a possible implementation, the implementation of S509-S510 can be found in Figure 4 Steps in Related description.

[0149] S511: The second storage device updates the log data in the second database to the first log data according to the differential data.

[0150] In one possible implementation, after receiving the differential data between the first and second log data, the second storage device applies the differential data to a local page to restore the data in the second database, ensuring that the log data in the second database is consistent with the log data in the first database. The second storage device then updates the log data in the second database to the first log data.

[0151] In another possible implementation, the implementation of S511 can be found in Figure 4 Steps in Related description.

[0152] In another possible implementation, the second storage device supplements the log data on the second database based on the data bits of the differential data, so that the log data is the first log data. For example, the data bits of the second log data are 1-30. The data bits of the first log data are 1-100. Therefore, the data bits of the differential data between the first log data and the second log data are 31-100. After the second database receives the differential data, the second database supplements the log data of the second database, so that the log data on the second database is 1-100, i.e., the first log data.

[0153] In an embodiment of the present application, by determining the differential data between the first log data and the second log data, the differential data is sent to the second storage device to supplement the log data of the second storage device, thereby effectively preventing the loss of log data of the first storage device in the event of a failure of the first storage device.

[0154] S512: The second storage device sends a fifth response message to the arbitration component, where the fifth response message indicates that the second database switch is successful. Accordingly, the arbitration component receives the fifth response message.

[0155] In a possible implementation, the implementation of S512 can be found in Figure 4 Steps in Related description.

[0156] S513: The second storage device provides data for the application.

[0157] In an embodiment of the present application, a computer device stores the first log data of a first storage device to back up the data of the first storage device, and the computer device is not affected by the first storage device. At the same time, a second storage device regularly stores the log data of the first storage device to serve as a backup device for the first storage device. In the event of a failure of the first storage device, the computer device can still operate normally. At this time, the second storage device reads the target log data from the computer device to supplement the log data of the second storage device, replacing the first storage device to provide data to the application, thereby effectively preventing data loss and ensuring the data write performance of the first storage device.

[0158] An embodiment of the present application provides a database disaster recovery device, which is applied to a computer device. The computer device is used to store first log data of a first database on a first storage device. The first storage device is used to provide data for an application. The first storage device is also used to request a second storage device to store the log data at regular time intervals. The second storage device is a backup device for the first storage device. The device may include:

[0159] The first receiving module is used to receive a first request sent by a second storage device when a failure occurs in the first storage device. The first request is used to request to read target log data on the computer device. The target log data includes differential data between the first log data and the second log data. The second log data is log data copied from the first storage device by the second storage device. The second log data is part of the first log data.

[0160] The first sending module is used to send target log data to the second storage device according to the first request; the target log data is used to supplement the log data of the second database of the second storage device, so that the second storage device provides data for the application after the log data in the second database is supplemented.

[0161] In one possible implementation, the first request carries data bits of the second log data;

[0162] The first sending module is used to: compare the first log data and the second log data according to the data bits of the second log data, the data bits of the first log data and the logical length of the first log data to obtain differential data between the first log data and the second log data; and send the differential data as target log data to the second storage device.

[0163] In a possible implementation, the first request carries an identifier of the second log data;

[0164] The first sending module is used to: determine the first log data according to the identifier of the second log data and the identifier relationship between the stored data; and send the first log data as the target log data to the second storage device.

[0165] In a possible implementation, the method further includes: a first storage module.

[0166] The first receiving module is used to receive a second request sent by the first storage device when the first storage device does not fail, where the second request is used to request to store the first log data.

[0167] The first storage module is configured to store the first log data according to the second request to store backup data for the first storage device.

[0168] In one possible implementation, a first storage device is deployed in a first area, and computer devices are deployed in a second area different from the first area; if the first storage device fails, devices in the second area are not affected by the first storage device.

[0169] In a possible implementation, the distance between the first storage device and the computer device is smaller than the distance between the first storage device and the second storage device.

[0170] In a possible implementation, the first storage device and the computer device communicate with each other using a Remote Direct Address Access (RDMA) protocol.

[0171] In one possible implementation, a persistent memory or a high-speed non-volatile memory (NVME) is deployed in a computer device.

[0172] It should be understood that the above-mentioned device is merely illustrated by the division of the above-mentioned functional modules when implementing its functions. In actual applications, the above-mentioned functions can be distributed and completed by different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the device and method embodiments provided in the above embodiments are based on the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.

[0173] Another database disaster recovery device provided in an embodiment of the present application is applied to a first storage device, which is used to provide data for an application. The device may include:

[0174] The first sending module is used to send a second request to the computer device, where the second request is used to request the storage of first log data of the first database of the first storage device, where the first log data is the log data corresponding to the transaction submitted by the application request; and periodically send a third request to the second storage device, where the third request is used to request the storage of part of the first log data, where the second storage device is a backup device of the first storage device.

[0175] The first receiving module is used to receive a first response message fed back by the computer device, the first response message is used to indicate that the first log data has been stored on the computer device; and receive a second response message fed back by the second storage device, the second response message is used to indicate that part of the data has been stored on the second storage device.

[0176] In the event that the first storage device fails, second log data is stored on the second storage device, and the second log data is part of the first log data; the second storage device is used to read target log data from the computer device to supplement the log data of the second database of the second storage device, and the target log data includes the differential data between the first log data and the second log data.

[0177] In one possible implementation, the first sending module is used to send a fourth request to the first disk corresponding to the first storage device and send a second request to the computer device in parallel, where the fourth request is used to request storage of the first log data, and the first disk is the carrier of the first database.

[0178] The first receiving module is used to receive a third response message fed back by the first disk, where the third response message is used to indicate that the first log data has been completely stored on the first disk.

[0179] In one possible implementation, a first storage device is deployed in a first area, and computer devices are deployed in a second area different from the first area; if the first storage device fails, devices in the second area are not affected by the first storage device.

[0180] In a possible implementation, the distance between the first storage device and the computer device is smaller than the distance between the first storage device and the second storage device.

[0181] In a possible implementation, the first storage device and the computer device communicate with each other using a Remote Direct Address Access (RDMA) protocol.

[0182] In one possible implementation, a persistent memory or a high-speed non-volatile memory (NVME) is deployed in a computer device.

[0183] It should be understood that the above-mentioned device is merely illustrated by the division of the above-mentioned functional modules when implementing its functions. In actual applications, the above-mentioned functions can be distributed and completed by different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the device and method embodiments provided in the above embodiments are based on the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.

[0184] An embodiment of the present application further provides a database disaster recovery device, which is applied to a second storage device, the second storage device being used to store second log data of a first storage device, the second storage device being a backup device of the first storage device, and the first storage device being used to provide data to an application when the first storage device does not fail. The device may include:

[0185] The first sending module is used to, when a first storage device fails, store second log data in a second storage device through a second database, where the second log data is part of the first log data; and send a first request to a computer device, where the computer device is used to store the first log data of the first database of the first storage device, and the computer device is not affected by the first storage device. The first request is used to request to read target log data on the computer device, where the target log data includes differential data between the first log data and the second log data.

[0186] The first receiving module is used to receive target log data sent by the computer device, where the target log data is determined by the computer device according to the first request and sent to the second storage device; the supplementing module is used to supplement the log data of the second database of the second storage device according to the target log data to provide data for the application.

[0187] In one possible implementation, the first request carries the data bits of the second log data; the computer device is also used to compare the first log data and the second log data based on the data bits of the second log data, the data bits of the first log data and the logical length of the first log data, obtain the differential data between the first log data and the second log data, and send the differential data as the target log data to the second storage device.

[0188] In a possible implementation, the first receiving module is configured to receive a fifth request, where the fifth request is used to request database switching, and the fifth request is generated when a failure occurs in the first storage device.

[0189] The first sending module is configured to send the first request to the computer device in response to the fifth request. After replenishing the log data of the second storage device, the first sending module is configured to send a fourth response message to other components, the fourth response message being used to indicate that the device providing data to the application has switched to the second storage device.

[0190] In one possible implementation, a first storage device is deployed in a first area, and computer devices are deployed in a second area different from the first area; if the first storage device fails, devices in the second area are not affected by the first storage device.

[0191] In a possible implementation, the distance between the first storage device and the computer device is smaller than the distance between the first storage device and the second storage device.

[0192] In a possible implementation, the first storage device and the computer device communicate with each other using a Remote Direct Address Access (RDMA) protocol.

[0193] In one possible implementation, a persistent memory or a high-speed non-volatile memory (NVME) is deployed in a computer device.

[0194] It should be understood that the above-mentioned device is merely illustrated by the division of the above-mentioned functional modules when implementing its functions. In actual applications, the above-mentioned functions can be distributed and completed by different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the device and method embodiments provided in the above embodiments are based on the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.

[0195] An embodiment of the present application further provides an electronic device, comprising a processor configured to load and execute at least one instruction to enable the electronic device to implement the database disaster recovery method provided in the embodiment of the present application. Optionally, the device further comprises a memory coupled to the processor and configured to store the at least one instruction.

[0196] The present application also provides a database disaster recovery system, comprising a first storage device, a computer device, and a second storage device. The computer device communicates with the first storage device, and the second storage device communicates with both the first storage device and the computer device. The system executes the corresponding steps and / or processes of the aforementioned method embodiments.

[0197] An embodiment of the present application further provides a computer-readable storage medium, in which at least one instruction is stored. The instruction is loaded and executed by a processor to enable a computer to implement any of the database disaster recovery methods described above.

[0198] The embodiments of the present application further provide a computer program (product), which, when executed by a computer, can enable a processor or computer to execute the corresponding steps and / or processes in the above method embodiments.

[0199] An embodiment of the present application further provides a chip, which includes a processor for calling and executing instructions stored in a memory from the memory, so that a device equipped with the chip executes any of the database disaster recovery methods described above.

[0200] An embodiment of the present application also provides another chip, including: an input interface, an output interface, a processor and a memory, wherein the input interface, the output interface, the processor and the memory are connected via an internal connection path, and the processor is used to execute the code in the memory. When the code is executed, the processor is used to execute any of the database disaster recovery methods described above.

[0201] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware, or any combination thereof. When implemented using software, all or part of the embodiments may be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described herein are generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated therein. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a magnetic tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive).

[0202] It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, storage, display, etc.), and signals involved in this application are all authorized by the user or fully authorized by all parties, and the collection, use, and processing of relevant data must comply with the relevant laws, regulations, and standards of the relevant countries and regions. For example, the setting results involved in this application are all obtained with full authorization.

[0203] Those skilled in the art will appreciate that the various method steps and modules described in conjunction with the embodiments disclosed herein can be implemented in software, hardware, firmware, or any combination thereof. In order to clearly illustrate the interchangeability of hardware and software, the steps and components of each embodiment have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0204] 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 may be accomplished by a program to instruct the relevant hardware, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.

[0205] When software is used for implementation, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer program instructions. As an example, the method of the embodiment of the present application can be described in the context of a machine executable instruction, and the machine executable instruction is such as included in the program module executed in the device on the real or virtual processor of the target. Generally speaking, a program module includes a routine, a program, a library, an object, a class, a component, a data structure, etc., which performs a specific task or realizes a specific abstract data structure. In various embodiments, the function of the program module can be merged or split between the described program modules. The machine executable instruction for the program module can be executed in a local or distributed device. In a distributed device, the program module can be located in both a local and a remote storage medium.

[0206] The computer program code for implementing the method of the embodiment of the present application can be written in one or more programming languages. These computer program codes can be provided to a processor of a general-purpose computer, a special-purpose computer, or a disaster recovery device of another programmable database, so that when the program code is executed by the disaster recovery device of the computer or other programmable database, the functions / operations specified in the flow chart and / or block diagram are implemented. The program code can be executed entirely on the computer, partially on the computer, as an independent software package, partially on the computer and partially on a remote computer, or entirely on a remote computer or server.

[0207] In the context of the embodiments of the present application, computer program code or related data may be carried by any suitable carrier to enable a device, apparatus, or processor to perform the various processes and operations described above. Examples of carriers include signals, computer-readable media, and the like.

[0208] Examples of signals may include electrical, optical, radio, acoustic or other forms of propagated signals, such as carrier waves, infrared signals, etc.

[0209] A machine-readable medium may be any tangible medium that contains or stores a program for or in connection with an instruction execution system, apparatus, or device. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination thereof. More detailed examples of machine-readable storage media include an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical storage device, a magnetic storage device, or any suitable combination thereof.

[0210] Those skilled in the art will clearly understand that, for the sake of convenience and brevity of description, the specific working processes of the above-described systems, devices, and modules can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0211] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the modules is merely a logical function division. In actual implementation, there may be other division methods, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or modules, or can be electrical, mechanical or other forms of connection.

[0212] Modules described as separate components may or may not be physically separate, and components displayed as modules may or may not be physical modules, that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the embodiments of the present application.

[0213] In addition, the functional modules in the various embodiments of the present application may be integrated into a processing module, or each module may exist physically separately, or two or more modules may be integrated into a single module. The above-mentioned integrated modules may be implemented in the form of hardware or software functional modules.

[0214] If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0215] In this application, the terms "first", "second", etc. are used to distinguish between identical or similar items that have substantially the same effects and functions. It should be understood that there is no logical or temporal dependency between "first", "second", and "nth", nor is there any limitation on quantity or order of execution. It should also be understood that although the following description uses the terms first, second, etc. to describe various elements, these elements should not be limited by the terms. These terms are only used to distinguish one element from another. For example, without departing from the scope of the various described examples, a first image may be referred to as a second image, and similarly, a second image may be referred to as a first image. Both the first image and the second image may be images, and in some cases, may be separate and different images.

[0216] It should also be understood that in the various embodiments of the present application, the size of the serial number of each process does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0217] In this application, the term "at least one" means one or more, and the term "plurality" means two or more. For example, "plurality of second messages" means two or more second messages. The terms "system" and "network" are often used interchangeably herein.

[0218] It should be understood that the terminology used in the description of the various examples herein is for the purpose of describing particular examples only and is not intended to be limiting. As used in the description of the various examples and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.

[0219] It should also be understood that the term "and / or" as used herein refers to and encompasses any and all possible combinations of one or more of the listed items. The term "and / or" describes an association between associated objects, indicating that three possible relationships exist. For example, "A and / or B" can represent: A exists alone, A and B exist simultaneously, or B exists alone. Furthermore, the character " / " in this application generally indicates that the associated objects are in an "or" relationship.

[0220] It will also be understood that the term “comprise” (also known as “includes,” “including,” “comprises,” and / or “comprising”) when used in this specification specifies the presence of stated features, integers, steps, operations, elements, and / or components, but does not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof.

[0221] It should also be understood that the terms “if” and “if” may be interpreted to mean “when” or “upon” or “in response to determining” or “in response to detecting.” Similarly, the phrases “if it is determined that ” or “if [stated condition or event] is detected” may be interpreted to mean “upon determining ” or “in response to determining ” or “upon detecting [stated condition or event]” or “in response to detecting [stated condition or event],” depending on the context.

[0222] It should be understood that determining B based on A does not mean determining B based solely on A. B can also be determined based on A and / or other information.

[0223] It should also be understood that references throughout this specification to "one embodiment," "an embodiment," or "one possible implementation" mean that specific features, structures, or characteristics associated with that embodiment or implementation are included in at least one embodiment of the present application. Therefore, the appearance of "in one embodiment," "in an embodiment," or "one possible implementation" throughout this specification does not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.

Claims

1. A database disaster recovery method, characterized in that: The method is applied to a computer device, the computer device being used to store first log data of a first database of a first storage device, the first storage device being used to provide data for an application, the first storage device being further used to request a second storage device to store the log data at regular time intervals, the second storage device being a backup device of the first storage device; the method comprising: In the event that the first storage device fails, receiving a first request sent by the second storage device, the first request being for requesting to read target log data on the computer device, the target log data comprising differential data between the first log data and second log data, the second log data being log data copied from the first storage device by the second storage device, and the second log data being a portion of the first log data; According to the first request, the target log data is sent to the second storage device; the target log data is used to supplement the log data of the second database of the second storage device, so that the second storage device provides data for the application after the second database supplements the log data.

2. The method according to claim 1, characterized in that The first request carries the data bits of the second log data; and sending the target log data to the second storage device according to the first request includes: comparing the first log data and the second log data according to the data bits of the second log data, the data bits of the first log data, and the logical length of the first log data to obtain difference data between the first log data and the second log data; The differential data is sent to the second storage device as the target log data.

3. The method according to claim 1, characterized in that The first request carries an identifier of the second log data; and sending the target log data to the second storage device according to the first request includes: determining the first log data according to the identifier of the second log data and the identifier relationship between the stored data; The first log data is sent to the second storage device as the target log data.

4. The method according to any one of claims 1 to 3, characterized in that The method further comprises: In a case where the first storage device does not fail, receiving a second request sent by the first storage device, where the second request is used to request storage of the first log data; According to the second request, the first log data is stored to store backup data for the first storage device.

5. A database disaster recovery method, characterized in that: The method is applied to a first storage device, where the first storage device is used to provide data for an application, and includes: Sending a second request to a computer device, where the second request is used to request storage of first log data of a first database of the first storage device, where the first log data is log data corresponding to a transaction submitted by an application request; Periodically sending a third request to a second storage device, the third request being used to request storage of part of the first log data, the second storage device being a backup device of the first storage device; receiving a first response message fed back by the computer device, where the first response message is used to indicate that the first log data has been completely stored on the computer device; A second response message fed back by the second storage device is received, where the second response message is used to indicate that storage of the portion of data on the second storage device is complete.

6. The method according to claim 5, characterized in that The sending of the second request to the computer device comprises: Sending a fourth request to a first disk corresponding to the first storage device and concurrently sending the second request to the computer device, wherein the fourth request is for requesting storage of the first log data, and the first disk is a carrier of the first database; The method further comprises: A third response message fed back by the first disk is received, where the third response message is used to indicate that the first log data has been completely stored on the first disk.

7. A database disaster recovery method, characterized in that: The method is applied to a second storage device, the second storage device is used to store log data of a first storage device, the second storage device is a backup device of the first storage device, and the first storage device is used to provide data for an application when the first storage device does not fail. The method includes: In the event that the first storage device fails, the second storage device stores second log data in a second database, where the second log data is a part of the first log data; Sending a first request to a computer device, the computer device being used to store first log data in a first database of the first storage device, the first request being used to request reading target log data on the computer device, the target log data including differential data between the first log data and second log data; receiving the target log data sent by the computer device; The log data of the second database of the second storage device is supplemented according to the target log data to provide data for the application.

8. The method according to claim 7, characterized in that The sending of the first request to the computer device includes: receiving a fifth request sent by an arbitration device, the fifth request being used to request database switching, the fifth request being generated when a failure occurs in the first storage device, the arbitration device being used to monitor the working status of each storage device; In response to the fifth request, sending the first request to the computer device; After supplementing the log data of the second database of the second storage device, the method further includes: A fourth response message is sent to the arbitration device, where the fourth response message is used to indicate that the device providing data for the application has been switched to the second storage device.

9. The method according to any one of claims 1 to 8, characterized in that The first storage device is deployed in a first area, and the computer device is deployed in a second area different from the first area; in the event that the first storage device fails, the devices in the second area are not affected by the first storage device.

10. The method according to claim 9, characterized in that The distance between the first storage device and the computer device is smaller than the distance between the first storage device and the second storage device.

11. The method according to any one of claims 1 to 10, characterized in that The first storage device communicates with the computer device using a Remote Direct Address Access (RDMA) protocol.

12. The method according to any one of claims 1 to 11, characterized in that The computer device is deployed with persistent memory or high-speed non-volatile memory NVME.

13. A database disaster recovery system, characterized in that: The system comprises: a first storage device for executing the method of any one of claims 5, 6, and 9-11; A computer device, in communication with the first storage device, configured to execute the method of any one of claims 1 to 4 and 9 to 11; A second storage device, communicating with the first storage device and the computer device respectively, is used to execute the method according to any one of claims 7 to 12.

14. A database disaster recovery device, characterized in that: The apparatus is applied to a computer device, the computer device being used to store first log data of a first database of a first storage device, the first storage device being used to provide data for an application, the first storage device being further used to request a second storage device to store log data at regular time intervals, the second storage device being a backup device of the first storage device; the apparatus comprising: a first receiving module, configured to receive, in the event that the first storage device fails, a first request sent by the second storage device, the first request being for reading target log data on the computer device, the target log data comprising differential data between the first log data and second log data, the second log data being log data copied from the first storage device by the second storage device, and the second log data being a portion of the first log data; The first sending module is used to send the target log data to the second storage device according to the first request; the target log data is used to supplement the log data of the second database of the second storage device, so that the second storage device provides data for the application after the second database supplements the log data.

15. A database disaster recovery device, characterized in that: The apparatus is applied to a first storage device, the first storage device being used to provide data for an application, and the apparatus includes: a first sending module, configured to send a second request to a computer device, the second request being for requesting storage of first log data of a first database of the first storage device, the first log data being log data corresponding to a transaction submitted by an application request; and periodically sending a third request to a second storage device, the third request being for requesting storage of a portion of the first log data, the second storage device being a backup device of the first storage device; The first receiving module is used to receive a first response message fed back by the computer device, the first response message is used to indicate that the first log data has been stored on the computer device; and receive a second response message fed back by the second storage device, the second response message is used to indicate that the partial data has been stored on the second storage device.

16. A database disaster recovery device, characterized in that: The apparatus is applied to a second storage device, the second storage device is used to store second log data of a first storage device, the second storage device is a backup device of the first storage device, and the first storage device is used to provide data for an application when the first storage device does not fail. The apparatus includes: a first sending module configured to, in the event that the first storage device fails, cause the second storage device to store second log data in a second database, the second log data being a portion of the first log data; and to send a first request to a computer device, the computer device being configured to store the first log data in the first database of the first storage device, the first request being configured to request reading target log data on the computer device, the target log data including differential data between the first log data and the second log data; a first receiving module, configured to receive the target log data sent by the computer device, where the target log data is determined by the computer device according to the first request and sent to the second storage device; The supplementing module is configured to supplement the log data of the second database of the second storage device according to the target log data to provide data for the application.

17. An electronic device, characterized in that: The device includes a memory and a processor; the memory stores at least one instruction, and the at least one instruction is loaded and executed by the processor to enable the electronic device to implement any method described in claims 1-4 and 9-11, or any method described in claims 5, 6 and 9-11, or any method described in claims 7-12.

18. A computer-readable storage medium, characterized in that The computer-readable storage medium stores at least one instruction, which is loaded and executed by the processor to implement the method according to any one of claims 1-4 and 9-11, or the method according to any one of claims 5, 6 and 9-11, or the method according to any one of claims 7-12.

19. A computer program product, characterized in that The computer program product comprises a computer program / instructions, which are executed by a processor to enable a computer to implement the method of any one of claims 1-4 and 9-11, or the method of any one of claims 5, 6 and 9-11, or the method of any one of claims 7-12.