Database recovery method and device for distributed database and computer equipment

By mounting the snapshot data to the standby machine when the host fails and rolling back, the problem of low recovery efficiency of Oracle Standby database is solved, and rapid recovery and service replacement are achieved.

CN119440913AInactive Publication Date: 2025-02-14GUANGZHOU DINGJIA COMPUTER TECHNOLOGY CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411497482.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-25
Publication Date
2025-02-14
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Oracle Standby database is not recovered quickly enough after the main library fails to quickly replace the main library to provide services.

Method used

When the host fails, the host snapshot data is used as the backup machine's data volume, and the storage area network is used to mount and roll back to quickly restore the backup machine to the state before the host failure.

Benefits of technology

It significantly reduces the synchronization time and resource consumption required after activating the standby machine, so that the standby machine can quickly and timely replace the host to provide distributed database services.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119440913A_ABST
    Figure CN119440913A_ABST
Patent Text Reader

Abstract

The invention relates to a database recovery method and device for a distributed database, computer equipment, a storage medium and a computer program product. The method comprises the following steps: mounting a block device for synthesizing a backup pool to a host through a storage area network; executing a snapshot operation on a data volume of the host according to a preset synthesis period through the synthesis backup pool, and storing host snapshot data obtained by executing the snapshot operation in a block device of the synthesis backup pool; under the condition that the host has a fault, activating the standby machine, and mounting the block equipment which is synthesized into the backup pool to the standby machine through the storage area network, so as to take the snapshot data of the host as a data volume of the standby machine; rolling back a data volume of the standby machine by synthesizing a backup pool snapshot, and restoring the standby machine to a target state, so that the standby machine replaces the host to provide a distributed database service; the target state is the state of the host before the fault. By adopting the method, the recovery efficiency after the standby machine is activated can be improved under the condition that the main database of the database fails.
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 recovery method, apparatus, computer equipment, storage medium and computer program product for a distributed database. Background Art

[0002] The Oracle Standby database provides a disaster recovery function. However, in the prior art, the Oracle Standby database does not have the ability to recover to a specific point in time. In actual applications, when using the Standby database, it is still necessary to back up the Oracle master database. Then, after activating the standby machine, if the standby machine needs to be synchronized back to the master database state, full data synchronization is usually required, which consumes a lot of time and resources and cannot provide services quickly to the outside world.

[0003] Therefore, in the traditional technology, when the main database fails, the recovery efficiency after activating the backup server is not fast enough. Summary of the invention

[0004] Based on this, it is necessary to provide a database recovery method, device, computer equipment, computer-readable storage medium and computer program product for a distributed database that can improve the recovery efficiency after activating a backup machine when a database master database fails in order to solve the above technical problems.

[0005] A database recovery method for a distributed database is applied to a distributed database, where the distributed database is deployed with a master and a backup machine, and the method includes:

[0006] Mount the synthetic backup pool's block device to the host through the storage area network;

[0007] By synthesizing the backup pool, a snapshot operation is performed on the data volume of the host according to a preset synthesis period, and the host snapshot data obtained by performing the snapshot operation is stored in the block device of the synthetic backup pool;

[0008] In the event of a host failure, the standby is activated and the block devices of the synthetic backup pool are mounted to the standby through the storage area network to use the host snapshot data as the data volume of the standby;

[0009] The data volume of the standby machine is rolled back by synthesizing the backup pool snapshot to restore the standby machine to the target state so that the standby machine can take over the host machine to provide distributed database services; the target state is the state of the host machine before the failure.

[0010] In one embodiment, before the step of performing a snapshot operation on the data volume of the host according to a preset synthesis period through the synthetic backup pool, the method further includes:

[0011] Synchronize the archive logs of the master machine to the standby machine according to the preset synchronization cycle;

[0012] The archive log is used to redo database modification operations in the standby machine in the event of a failure of the main machine, so as to restore the standby machine to the target state.

[0013] In one embodiment, the data volume of the standby machine is rolled back by synthesizing the backup pool snapshot to restore the standby machine to a target state, and the method further includes:

[0014] Roll back the standby machine's data volume through the synthetic backup pool snapshot, and restore the standby machine to the host's most recent snapshot state; the host's most recent snapshot state is the state of the host at the last snapshot point; the last snapshot point is the time point when the last snapshot operation was performed;

[0015] Reapply the archive logs after the last snapshot point on the standby machine to restore the standby machine to the target state.

[0016] In one embodiment, the preset synthesis period is the same as the preset synchronization period, and the method further includes:

[0017] The steps of performing a snapshot operation on the data volume of the host according to a preset synthesis cycle and synchronizing the archive log of the host to the standby machine according to a preset synchronization cycle are performed in parallel.

[0018] In one embodiment, after the step of restoring the standby machine to the target state, the method further includes:

[0019] A snapshot operation is performed on the data volume of the standby machine according to a preset synthesis cycle through the synthetic backup pool, and the standby machine snapshot data obtained by performing the snapshot operation is stored in a block device of the synthetic backup pool;

[0020] The block device of the synthetic backup pool is mounted to the host through the storage area network to achieve reverse synchronization of snapshot data.

[0021] In one embodiment, the method further comprises:

[0022] Create a standby database on the standby machine and perform an initial synchronization operation on the standby machine and the master machine so that the data of the standby machine and the master machine are updated according to the preset synchronization cycle.

[0023] A database recovery device for a distributed database is applied to a distributed database, where a main machine and a backup machine are deployed. The device includes:

[0024] A mounting module, used for mounting the block device of the synthetic backup pool to the host through a storage area network;

[0025] The storage module is used to perform a snapshot operation on the data volume of the host according to a preset synthesis period based on the synthetic backup technology through the synthetic backup pool, and store the host snapshot data obtained by performing the snapshot operation in the block device of the synthetic backup pool;

[0026] An activation module is used to activate the standby machine in case of a failure of the main machine, and to mount the block device of the synthetic backup pool to the standby machine through the storage area network so as to use the main machine snapshot data as the data volume of the standby machine;

[0027] The recovery module is used to roll back the data volume of the standby machine through the synthetic backup pool snapshot and restore the standby machine to the target state so that the standby machine can take over the main machine to provide distributed database services; the target state is the current state of the main machine.

[0028] A computer device includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above method when executing the computer program.

[0029] A computer-readable storage medium stores a computer program, which implements the steps of the above method when executed by a processor.

[0030] A computer program product comprises a computer program, which implements the steps of the above method when executed by a processor.

[0031] The database recovery method, apparatus, computer equipment, storage medium and computer program product of the above-mentioned distributed database first mount the block device of the synthetic backup pool to the host through the storage area network, periodically perform synthetic backup on the data volume in the host through the synthetic backup pool (i.e., periodically perform snapshot operations on the data volume of the host), obtain host snapshot data, and store the host snapshot data in the synthetic backup pool, and mount the block device of the synthetic backup pool to the standby machine through the storage area network, so that the standby machine can use the host snapshot data stored in the synthetic backup pool as the data volume of the standby machine, so that in the event of a failure of the host, the standby machine is activated, and the data volume of the standby machine is rolled back through the synthetic backup pool snapshot, so that the standby machine can quickly recover to the state of the host before the failure, reducing the synchronization time and resource consumption required after activating the standby machine, so that the standby machine can quickly and timely take over the host to provide services to the outside. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0033] FIG1 is an application environment diagram of a database recovery method for a distributed database in one embodiment;

[0034] Figure 2 A schematic diagram of a flow chart of a database recovery method for a distributed database in one embodiment;

[0035] Figure 3 A schematic diagram of the technical principle of a database recovery method for a distributed database in one embodiment;

[0036] Figure 4 It is a flowchart of a database recovery method of a distributed database in another embodiment;

[0037] Figure 5 It is a structural block diagram of a database recovery device of a distributed database in one embodiment;

[0038] Figure 6 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0039] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0040] The database recovery method of the distributed database provided in the embodiment of the present application can be applied to the distributed database 102 shown in Figure 1. The distributed database 102 can be an Oracle database, and the distributed database 102 is deployed with a master and a backup machine.

[0041] In an exemplary embodiment, Figure 2 As shown, a database recovery method for a distributed database is provided, and the method is applied to the distributed database 102 in FIG. 1 as an example for description, including the following steps S202 to S206. Among them:

[0042] Step S202: Mount the block device of the synthetic backup pool to the host through the storage area network.

[0043] Among them, the storage area network refers to SAN (Storage Area Network, a high-speed network dedicated to storage operations).

[0044] The synthetic backup pool may be pre-created and used for synthetic backup of the host.

[0045] Among them, the database on the host is the main database of the distributed database.

[0046] Optionally, after the synthetic backup pool is created, a block device of the synthetic backup pool is mounted to a host through a storage area network.

[0047] Step S204: Performing a snapshot operation on the data volume of the host according to a preset synthesis period through the synthetic backup pool, and storing the host snapshot data obtained by performing the snapshot operation in a block device of the synthetic backup pool.

[0048] The preset synthesis period may be a snapshot operation execution period pre-set for the data volume of the host.

[0049] The data volume of the host may be an Oracle data volume.

[0050] The host snapshot data may be host status record data at any time point.

[0051] Optionally, a snapshot operation is performed on a data volume of the host according to a preset synthesis period through a pre-created synthetic backup pool, and host snapshot data obtained by performing the snapshot operation is stored in a block device of the synthetic backup pool.

[0052] Step S206, in the case of a failure of the host, the standby host is activated, and the block device of the synthetic backup pool is mounted to the standby host through the storage area network, so that the host snapshot data is used as the data volume of the standby host.

[0053] Among them, the database on the standby machine is the standby database of the distributed database.

[0054] Optionally, in the event of a host failure, the standby machine is activated, and the block device snapshot of the synthetic storage pool used for synthetic backup of the host is shared via a storage area network and then mounted to the standby machine, so that the host snapshot data is used as the data volume of the standby machine.

[0055] Step S208 , rolling back the data volume of the standby machine by synthesizing the backup pool snapshot, and restoring the standby machine to the target state, so that the standby machine takes over the main machine to provide distributed database services.

[0056] The target state is the state of the host before the failure.

[0057] The distributed database service may be a service provided by an Oracle database.

[0058] Optionally, since the block device of the synthetic backup pool has been mounted to the standby machine, the host snapshot data becomes the data volume of the standby machine. The data volume of the standby machine can be rolled back through the synthetic backup pool snapshot to restore the standby machine to the state of the host before the failure, and then the standby machine can take over the host to provide external services.

[0059] In the above-mentioned database recovery method of the distributed database, the block device of the synthetic backup pool is first mounted to the host through the storage area network, the data volume in the host is periodically synthetically backed up through the synthetic backup pool (that is, snapshot operations are periodically performed on the data volume of the host) to obtain host snapshot data, and the host snapshot data is stored in the synthetic backup pool, and the block device of the synthetic backup pool is mounted to the standby machine through the storage area network, so that the standby machine can use the host snapshot data stored in the synthetic backup pool as the data volume of the standby machine, so that in the event of a failure of the host, the standby machine is activated, and the data volume of the standby machine is rolled back through the synthetic backup pool snapshot, so that the standby machine can quickly recover to the state of the host before the failure, reducing the synchronization time and resource consumption required after activating the standby machine, so that the standby machine can quickly and timely take over the host to provide services to the outside.

[0060] In an exemplary embodiment, before the step of performing a snapshot operation on the data volume of the host through a synthetic backup pool according to a preset synthesis period, the method also includes: synchronizing the archive log of the host to the standby machine according to a preset synchronization period; wherein the archive log is used to redo the database modification operation in the standby machine in the event of a failure of the host to restore the standby machine to a target state.

[0061] The preset synchronization period may be an archive log synchronization period set in advance for the synchronization process of synchronizing the archive logs of the master machine to the backup machine.

[0062] The database modification operation refers to the operation of changing the data stored in the distributed database.

[0063] Optionally, the archive logs of the host are synchronized to the standby machine according to a preset synchronization cycle. In actual applications, after the archive logs of the host are synchronized to the standby machine, snapshot operations are performed on the data volumes of the host according to the preset synthesis cycle through the synthetic backup pool.

[0064] In this embodiment, the archive logs of the main machine are synchronized to the standby machine according to a preset synchronization cycle, so that in the event of a failure of the main machine, the archive logs can be reapplied in the standby machine and the database modification operations can be redone to quickly restore the standby machine to the state before the main machine failed.

[0065] In an exemplary embodiment, the data volume of the standby machine is rolled back through a synthetic backup pool snapshot to restore the standby machine to a target state. The method also includes: rolling back the data volume of the standby machine through a synthetic backup pool snapshot to restore the standby machine to the most recent snapshot state of the host; the most recent snapshot state of the host is the state of the host corresponding to the last snapshot point; the last snapshot point is the time point when the last snapshot operation is performed; and reapplying the archived logs after the last snapshot point in the standby machine to restore the standby machine to the target state.

[0066] Optionally, by rolling back the standby machine's data volumes through a synthetic backup pool snapshot, the standby machine can be restored to the host's most recent snapshot state, that is, the snapshot state corresponding to the last snapshot point. Then, the archived logs since the last snapshot point are reapplied in the standby machine to restore the standby machine to the state of the host before the failure.

[0067] In this embodiment, the data volume of the standby machine is rolled back by synthesizing the backup pool snapshot to restore the standby machine to the most recent snapshot state of the host; the most recent snapshot state of the host is the state of the host corresponding to the last snapshot point; the last snapshot point is the time point when the last snapshot operation is performed; the archive logs after the last snapshot point are reapplied in the standby machine to restore the standby machine to the target state; in this way, when the host fails, the standby machine can be activated, the standby machine can be quickly rolled back to the state before the host fails, and the archive logs can be reapplied to achieve quasi-real-time synchronization, so that the database of the standby machine can quickly take over the database of the host and continue to provide business services to the outside world, without having to wait for the database of the host to recover before taking over the business services.

[0068] In an exemplary embodiment, the preset synthesis cycle is the same length as the preset synchronization cycle, and the method further includes: executing in parallel the step of performing a snapshot operation on the data volume of the host according to the preset synthesis cycle, and the step of synchronizing the archive log of the host to the standby machine according to the preset synchronization cycle.

[0069] Optionally, the step of performing a snapshot operation on the data volume of the host according to a preset synthesis cycle and the step of synchronizing the archive log of the host to the standby machine according to a preset synchronization cycle are performed in parallel. The two steps are performed in parallel to ensure that the implementation of the two steps does not affect each other. In actual applications, the synthesis cycle and the synchronization cycle are the same, and the synthesis cycle and the synchronization cycle can be adjusted according to actual needs. Generally, the snapshot operation is performed after the archive log is synchronized.

[0070] In this embodiment, by executing in parallel the step of performing a snapshot operation on the data volume of the host according to a preset synthesis cycle and the step of synchronizing the archive log of the host to the standby machine according to a preset synchronization cycle, it can be ensured that the synthesis cycle and the synchronization cycle are independent of each other. The database of the host can be backed up during the synchronization of the archive log, so that after the standby machine is activated, it can be quickly resynchronized using the most recent host snapshot data, instead of starting the synthesis backup and synchronization using the snapshot data after the standby machine is activated. When a host failure occurs, the standby machine can be quickly restored to the state before the host failure occurs.

[0071] In order to facilitate the understanding of those skilled in the art, Figure 3The technical principle of a database recovery method for a distributed database is provided by way of example, wherein, first, archive logs are periodically applied to a standby database (standby machine database) through a main database (host database) synchronously, and a snapshot is periodically synthesized and stored in a synthetic backup pool through the main database (host database), and then, in the event of a failure of the main database (host database), the snapshot stored in the synthetic backup pool is mounted to the standby database (standby machine database) after the standby database is activated, and the standby database (standby machine database) is restored to the state before the failure of the main database (host database) through snapshot rollback. In this way, rapid disaster recovery can be achieved while reducing the storage and I / O consumption of backup and standby databases.

[0072] In an exemplary embodiment, after the step of restoring the standby machine to the target state, the method further includes: performing a snapshot operation on the data volume of the standby machine according to a preset synthesis period through a synthetic backup pool, and storing the standby machine snapshot data obtained by performing the snapshot operation in a block device of the synthetic backup pool; mounting the block device of the synthetic backup pool to the host through a storage area network to realize reverse synchronization of the snapshot data.

[0073] The standby machine snapshot data may be the standby machine status record data at any point in time.

[0074] Optionally, after the standby machine is restored to the state before the host machine fails and starts to provide external database services, a snapshot operation is performed on the data volume of the standby machine through the synthetic backup pool according to a preset synthesis period, and the standby machine snapshot data obtained by performing the snapshot operation is stored in the block device of the synthetic backup pool. The block device snapshot share of the synthetic backup pool is mounted to the host through the storage area network, so that the standby machine snapshot data in the synthetic backup pool can be used as the data volume of the host, thereby realizing reverse synchronization from the standby machine to the host.

[0075] In this embodiment, a snapshot operation is performed on the data volume of the standby machine according to a preset synthesis period through a synthetic backup pool, and the standby machine snapshot data obtained by performing the snapshot operation is stored in a block device of the synthetic backup pool; the block device of the synthetic backup pool is mounted to the host through a storage area network to achieve reverse synchronization of the snapshot data; in this way, after the standby machine is activated, the database of the standby machine can be periodically synthetically backed up, and the standby machine snapshot data can be mounted to the host through a storage area network to achieve reverse synchronization.

[0076] In an exemplary embodiment, the method further includes: creating a standby database on the standby machine, and performing an initial synchronization operation on the standby machine and the host machine, so that the data of the standby machine and the data of the host machine are updated according to a preset synchronization cycle.

[0077] The standby database may refer to a Standby database.

[0078] The premise of the initial synchronization operation is that the host database has a synthetic backup. In actual applications, the initial synchronization operation includes: Step 1, synchronizing control file information; Step 2, sharing the host synthetic backup block device volume snapshot; Step 3, mounting the snapshot in Step 2, and renaming the data query to the mounted volume; Step 4, synchronizing the host archive log to the standby machine, repeating this operation to ensure that the standby machine's database is kept updated; Step 5, taking a snapshot of the standby machine's shared snapshot volume. Subsequent periodic synchronization operations only need to repeat Step 4, synchronize the host database archive log to the standby machine's database and recover, and then execute Step 5.

[0079] Optionally, a standby database, such as a Standby database, is created on the standby machine, and an initial synchronization operation is performed on the standby machine and the master machine, so that the data of the standby machine and the data of the master machine are updated according to a preset synchronization cycle.

[0080] In this embodiment, a standby database is created on the standby machine, and an initial synchronization operation is performed on the standby machine and the host machine, so that the data of the standby machine and the host machine are updated according to a preset synchronization cycle, so that the data of the standby machine and the host machine can be kept updated periodically.

[0081] In another embodiment, Figure 4 As shown, a database recovery method for a distributed database is provided, which is described by taking the application of the method to the distributed database 102 in FIG. 1 as an example, and includes the following steps:

[0082] Step S402: Mount the block device of the synthetic backup pool to the host through the storage area network.

[0083] Step S404, synchronizing the archive logs of the master machine to the standby machine according to a preset synchronization cycle; wherein the archive logs are used to redo database modification operations in the standby machine in case of a failure of the master machine, so as to restore the standby machine to a target state.

[0084] Step S406: Perform a snapshot operation on the data volume of the host according to a preset synthesis period through the synthetic backup pool, and store the host snapshot data obtained by performing the snapshot operation in the block device of the synthetic backup pool.

[0085] Step S408, in the case of a failure of the host, the standby host is activated, and the block device of the synthetic backup pool is mounted to the standby host through the storage area network, so that the host snapshot data is used as the data volume of the standby host.

[0086] Step S410, rolling back the data volume of the standby machine by synthesizing the backup pool snapshot, and restoring the standby machine to the most recent snapshot state of the host; the most recent snapshot state of the host is the state of the host corresponding to the last snapshot point; the last snapshot point is the time point when the last snapshot operation is performed.

[0087] Step S412, reapplying the archive logs after the last snapshot point in the standby machine to restore the standby machine to the target state, so that the standby machine takes over the main machine to provide distributed database services; the target state is the state of the main machine before the failure.

[0088] It should be noted that the specific definition of the above steps can refer to the specific definition of the database recovery method of a distributed database mentioned above.

[0089] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0090] Based on the same inventive concept, the embodiment of the present application also provides a distributed database recovery device for implementing the above-mentioned distributed database recovery method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above-mentioned method, so the specific limitations in the embodiments of the database recovery device for one or more distributed databases provided below can refer to the above-mentioned limitations on the distributed database recovery method, and will not be repeated here.

[0091] In an exemplary embodiment, Figure 5 As shown, a database recovery device for a distributed database is provided, including: a mounting module 502, a mounting module 502, an activation module 506 and an activation module 506, wherein:

[0092] The mounting module 502 is used to mount the block device of the synthetic backup pool to the host through the storage area network;

[0093] The mounting module 502 is used to perform a snapshot operation on the data volume of the host according to a preset synthesis period based on the synthetic backup technology through the synthetic backup pool, and store the host snapshot data obtained by performing the snapshot operation in the block device of the synthetic backup pool;

[0094] The activation module 506 is used to activate the standby machine when the host machine fails, and mount the block device of the synthetic backup pool to the standby machine through the storage area network to use the host snapshot data as the data volume of the standby machine;

[0095] The activation module 506 is used to roll back the data volume of the standby machine through the synthetic backup pool snapshot to restore the standby machine to the target state so that the standby machine can take over the main machine to provide distributed database services; the target state is the current state of the main machine.

[0096] In one of the embodiments, the device further includes: a synchronization module, which is used to synchronize the archive logs of the host machine to the standby machine according to a preset synchronization period; wherein the archive logs are used to redo database modification operations in the standby machine in the event of a failure of the host machine to restore the standby machine to a target state.

[0097] In one of the embodiments, the recovery module 508 is specifically used to roll back the data volume of the standby machine through a synthetic backup pool snapshot to restore the standby machine to the most recent snapshot state of the host; the most recent snapshot state of the host is the state of the host corresponding to the last snapshot point; the last snapshot point is the time point when the last snapshot operation is performed; and the archived logs after the last snapshot point are reapplied in the standby machine to restore the standby machine to the target state.

[0098] In one of the embodiments, the preset synthesis cycle is the same length as the preset synchronization cycle, and the device also includes: a parallel module for parallelly executing the steps of performing snapshot operations on the data volume of the host according to the preset synthesis cycle, and synchronizing the archive log of the host to the standby machine according to the preset synchronization cycle.

[0099] In one of the embodiments, the device also includes: a reverse synchronization module, which is used to perform a snapshot operation on the data volume of the standby machine according to a preset synthesis period through a synthetic backup pool, and store the standby machine snapshot data obtained by performing the snapshot operation in a block device of the synthetic backup pool; and mount the block device of the synthetic backup pool to the host through a storage area network to realize reverse synchronization of the snapshot data.

[0100] In one of the embodiments, the device further includes: a creation module, configured to create a standby database on the standby machine, and perform an initial synchronization operation on the standby machine and the host machine, so that the data of the standby machine and the data of the host machine are updated according to a preset synchronization cycle.

[0101] Each module in the above-mentioned database recovery device of the distributed database can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above-mentioned modules can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.

[0102] In an exemplary embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as shown in FIG. Figure 6As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store database recovery data of a distributed database. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a database recovery method for a distributed database is implemented.

[0103] Those skilled in the art will understand that Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0104] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the above-mentioned method for recovering a database of a distributed database. The steps of the method for recovering a database of a distributed database may be the steps of the method for recovering a database of a distributed database in each of the above-mentioned embodiments.

[0105] In one embodiment, a computer-readable storage medium is provided, which stores a computer program. When the computer program is executed by a processor, the processor executes the steps of the above-mentioned method for recovering a database of a distributed database. The steps of the method for recovering a database of a distributed database may be the steps of the method for recovering a database of a distributed database in each of the above-mentioned embodiments.

[0106] In one embodiment, a computer program product is provided, including a computer program. When the computer program is executed by a processor, the processor executes the steps of the above-mentioned method for recovering a database of a distributed database. The steps of the method for recovering a database of a distributed database may be the steps of the method for recovering a database of a distributed database in each of the above-mentioned embodiments.

[0107] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0108] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0109] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A database recovery method for a distributed database, characterized in that: Applied to a distributed database, the distributed database is deployed with a master machine and a backup machine, the method includes: Mounting the block device of the synthetic backup pool to the host via a storage area network; By means of the synthetic backup pool, a snapshot operation is performed on the data volume of the host according to a preset synthesis period, and the host snapshot data obtained by performing the snapshot operation is stored in a block device of the synthetic backup pool; In the event of a failure of the host, activating the standby machine, and mounting the block device of the synthetic backup pool to the standby machine through the storage area network, so as to use the host snapshot data as the data volume of the standby machine; The data volume of the standby machine is rolled back through the synthetic backup pool snapshot to restore the standby machine to a target state so that the standby machine takes over the main machine to provide distributed database services; the target state is the state of the main machine before the failure.

2. The method according to claim 1, characterized in that Before the step of performing a snapshot operation on the data volume of the host according to a preset synthesis period through the synthetic backup pool, the method further includes: Synchronize the archive logs of the host to the standby machine according to a preset synchronization period; The archive log is used to redo the database modification operation in the standby machine in the event that the main machine fails, so as to restore the standby machine to the target state.

3. The method according to claim 2, characterized in that Rolling back the data volume of the standby machine by using the synthetic backup pool snapshot to restore the standby machine to a target state, the method further comprising: Rolling back the data volume of the standby machine through the synthetic backup pool snapshot, restoring the standby machine to the most recent snapshot state of the host; the most recent snapshot state of the host is the state of the host corresponding to the last snapshot point; the last snapshot point is the time point when the last snapshot operation is performed; The archive logs after the last snapshot point are reapplied in the standby machine to restore the standby machine to the target state.

4. The method according to claim 3, characterized in that The preset synthesis period is the same as the preset synchronization period, and the method further includes: The step of performing a snapshot operation on the data volume of the host according to a preset synthesis cycle and the step of synchronizing the archive log of the host to the standby machine according to a preset synchronization cycle are performed in parallel.

5. The method according to claim 1, characterized in that After the step of restoring the standby machine to the target state, the method further includes: Performing a snapshot operation on the data volume of the standby machine according to the preset synthesis period through the synthetic backup pool, and storing the standby machine snapshot data obtained by performing the snapshot operation in the block device of the synthetic backup pool; The block device of the synthetic backup pool is mounted to the host through the storage area network to achieve reverse synchronization of snapshot data.

6. The method according to claim 1, characterized in that The method further comprises: A standby database is created on the standby machine, and an initial synchronization operation is performed on the standby machine and the host machine, so that the data of the standby machine and the data of the host machine are updated according to a preset synchronization cycle.

7. A database recovery device for a distributed database, characterized in that: Applied to a distributed database, the distributed database is deployed with a master machine and a backup machine, and the device includes: A mounting module, used for mounting the block device of the synthetic backup pool to the host through a storage area network; A storage module, configured to perform a snapshot operation on the data volume of the host according to a preset synthesis period based on the synthetic backup technology through the synthetic backup pool, and store the host snapshot data obtained by performing the snapshot operation in a block device of the synthetic backup pool; an activation module, configured to activate the standby machine in the event of a failure of the host machine, and mount the block device of the synthetic backup pool to the standby machine via the storage area network, so as to use the host snapshot data as the data volume of the standby machine; The recovery module is used to roll back the data volume of the standby machine through the synthetic backup pool snapshot and restore the standby machine to a target state so that the standby machine can take over the main machine to provide distributed database services; the target state is the current state of the main machine.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Data protection method and system capable of combining with snapshot function based on distributed block storage

    CN105843704A

  • Database synthetic backup and mounting recovery method

    CN107066357A

  • Data backup method and device, equipment and storage medium

    CN116610500A