Backup and recovery method and device of cloud native database, electronic equipment and medium

Through cloud native database snapshot flashback technology and REDO log real-time flashing mechanism, data snapshot chains are generated and rapid recovery is achieved, solving the problems of real-time and specified point-in-time restoration in database backup and recovery, and improving the reliability and efficiency of the database .

CN119322701APending Publication Date: 2025-01-17武汉达梦数据技术有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411316192.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-20
Publication Date
2025-01-17

AI Technical Summary

Technical Problem

Existing database backup and recovery methods cannot solve both real-time problems and restores at specified point-in-time.

Method used

Using cloud native database snapshot flashback technology, through snapshot support for database storage layer, plus real-time flashing of database REDO logs, a backup data snapshot chain is generated and restored to Specifies the status of the time point.

Benefits of technology

It realizes dynamic and real-time data backup and recovery, reduces storage space usage, is fast, and can quickly restore to a specified time point, solving the problem of real-time and restore at specified time point.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119322701A_ABST
    Figure CN119322701A_ABST
Patent Text Reader

Abstract

The invention provides a cloud native database backup and recovery method and device, electronic equipment and a medium, and belongs to the technical field of databases, the method comprises the steps of generating a log event based on a data write-in statement, and writing the log event into an RODO log file; writing the corresponding data page into a buffer pool based on the data writing statement; refreshing the modified data page in the buffer pool into a data file on a data persistence layer of the cloud native database, and generating a data snapshot chain for backup based on the RODO log file and the data file on the data persistence layer; and under the condition that the cloud native database needs to be recovered, recovering the cloud native database to a state when the snapshot is created based on the flash-back snapshot. According to the method, a snapshot storage technology and support of a front-mounted and rear-mounted real-time notification mechanism for database REDO log real-time disk refreshing are adopted, a database snapshot flash-back function is achieved, and the technical problem that an existing database cannot solve the real-time problem and the technical problem that restoration at a specified time point cannot be achieved at the same time is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of database technology, and in particular to a method, device, electronic device and medium for backing up and restoring a cloud native database. Background Art

[0002] There are two main traditional database backup and recovery methods: one is "backup-restore" and the other is "real-time data synchronization and recovery". "Backup-restore" is a more commonly used data backup and recovery method, but it may have problems such as downtime, cold backup, cold restore, long full data recovery, and long incremental recovery time. "Real-time data synchronization and recovery" solves the real-time problem, but may face the problem of introducing additional database synchronization resources and the inability to restore at a specified time point. Therefore, the existing database backup and recovery methods cannot solve both the real-time problem and the problem of restoring at a specified time point at the same time. Summary of the invention

[0003] In view of this, it is necessary to provide a cloud native database backup and recovery method, device, electronic device and medium to solve the technical problem that existing databases cannot simultaneously solve real-time problems and restore to a specified time point.

[0004] In order to solve the above problems, on the one hand, the present invention provides a method for backing up and restoring a cloud native database, comprising: Generate a log event based on a data write statement, and write the log event into a RODO log file; Based on the data writing statement, writing the corresponding data page into the buffer pool; Refresh the modified data pages in the buffer pool to the data files on the data persistence layer of the cloud native database, and generate a data snapshot chain for backup based on the RODO log file and the data files on the data persistence layer; When the cloud native database needs to be restored, the cloud native database is restored to the state when the snapshot was created based on the flashback snapshot.

[0005] In a possible implementation, generating a log event based on a data write statement includes: A data write statement is obtained, and when it is determined that the syntax of the data write statement is correct and the required permissions are available, a log event is generated based on the data write statement.

[0006] In a possible implementation, generating a data snapshot chain for backup based on the RODO log file and the data file on the data persistence layer includes: Sending a disk flushing event message to the data persistence layer based on the RODO log file, so as to generate a snapshot based on the data persistence layer according to the source data corresponding to the data file; Send a disk flushing completion message to the data persistence layer, so as to splice the generated snapshots based on the data persistence layer to obtain a data snapshot chain.

[0007] In a possible implementation, sending a flush event message to a data persistence layer based on the RODO log file, so as to generate a snapshot based on the data persistence layer according to source data corresponding to the data file, includes: A disk flushing thread is generated based on the cloud native database. In the disk flushing thread, a disk flushing event message is sent to the data persistence layer based on the RODO log file, so as to generate a snapshot based on the data persistence layer according to the source data corresponding to the data file.

[0008] In a possible implementation, the generating a snapshot based on the data persistence layer according to the source data corresponding to the data file includes: Based on the data persistence layer and in a copy-on-write manner, a snapshot is generated of the source data corresponding to the data file.

[0009] In a possible implementation, restoring the cloud native database to a state at the time of snapshot creation based on the flashback snapshot includes: Generate a flashback thread based on the cloud native database, and read snapshot information of a time point to be restored based on the flashback thread; The data corresponding to the snapshot information at the time point to be restored is written into the cloud native database to restore the cloud native database to the state when the snapshot was created.

[0010] In a possible implementation, writing data corresponding to the snapshot information at a time point to be restored into the cloud native database to restore the cloud native database to a state at the time when the snapshot was created also includes: After reading the snapshot information of the time point to be restored, locking the source volume of the cloud native database; A logical address corresponding to the snapshot information at the time point to be restored is determined, and after writing data corresponding to the snapshot information at the time point to be restored to the source volume based on the logical address, the source volume is unlocked.

[0011] On the other hand, the present invention also provides a cloud native database backup and recovery device, including: A log generation module, used to generate log events based on data write statements, and write the log events into a RODO log file; A cache module, used for writing corresponding data pages into a buffer pool based on the data writing statement; A snapshot generation module, used to refresh the modified data pages in the buffer pool into the data files on the data persistence layer of the cloud native database, and generate a data snapshot chain for backup based on the RODO log file and the data files on the data persistence layer; The flashback module is used to restore the cloud native database to the state when the snapshot was created based on the flashback snapshot when the cloud native database needs to be restored.

[0012] On the other hand, the present invention also provides an electronic device, including a memory and a processor, wherein: The memory is used to store programs; The processor is coupled to the memory and is used to execute the program stored in the memory to implement the steps of the cloud native database backup and recovery method as described in any one of the above items.

[0013] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the cloud-native database backup and recovery method as described in any one of the above items are implemented.

[0014] The beneficial effects of adopting the above implementation method are: the backup and recovery method, device, electronic device and medium of the cloud native database provided by the present invention, through the cloud native database snapshot flashback technology, through the snapshot support for the storage of the cloud native database, plus the support for the database REDO log real-time disk flushing pre- and post-real-time notification mechanism, can obtain database data changes more dynamically and in real time, so as to make snapshot operations, thereby completing data backup. The snapshot is only a data location mark for data storage. Each snapshot object contains a reference to the previous snapshot. When the data is modified, the new snapshot object will only contain these modified data without changing the content of the previous snapshot object. This method realizes the incremental storage of snapshots, making the snapshot chain efficient, and can create a large number of snapshots without taking up too much storage space, and the speed is very fast. When flashing back, that is, switching the data to the location of the specified time point, the speed is also very fast, and the backup and recovery operations of the cloud native database are completed by this snapshot flashback technology. Therefore, the present invention solves the technical problem that the existing database cannot solve the real-time problem and the restoration of the specified time point at the same time. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0016] Figure 1 A flowchart of an embodiment of a method for backing up and restoring a cloud native database provided by the present invention; Figure 2 A schematic diagram of the snapshot flashback technology architecture of the cloud native database provided by the present invention; Figure 3 A flow chart of generating a data snapshot chain for backup provided by the present invention; Figure 4 A flowchart of restoring the cloud native database to the state at the time of snapshot creation based on the flashback snapshot provided by the present invention; Figure 5 A principle block diagram of an embodiment of a cloud native database backup and recovery device provided by the present invention; Figure 6 A schematic structural diagram of an embodiment of an electronic device provided by the present invention. DETAILED DESCRIPTION

[0017] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0018] In the description of the embodiments of the present application, unless otherwise specified, “plurality” means two or more than two.

[0019] The terms "including" and "having" and any variations thereof in the embodiments of the present invention are intended to cover non-exclusive inclusions. For example, a process, method, apparatus, product or equipment comprising a series of steps or modules is not necessarily limited to those steps or modules clearly listed, but may include other steps or modules not clearly listed or inherent to these processes, methods, products or equipment.

[0020] The naming or numbering of the steps in the embodiments of the present invention does not mean that the steps in the method flow must be executed in the time / logical sequence indicated by the naming or numbering. The execution order of the named or numbered process steps can be changed according to the technical purpose to be achieved, as long as the same or similar technical effects can be achieved.

[0021] Reference to an "embodiment" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiment may be included in at least one embodiment of the present invention. The appearance of the phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0022] The present invention provides a method, device, electronic device and medium for backing up and restoring a cloud native database, which are described below respectively.

[0023] like Figure 1 As shown, the present invention provides a method for backing up and restoring a cloud native database, which includes: S101, generating a log event based on a data write statement, and writing the log event into a RODO log file; S102, based on the data writing statement, writing the corresponding data page into a buffer pool; S103, refreshing the modified data pages in the buffer pool to the data files on the data persistence layer of the cloud native database, and generating a data snapshot chain for backup based on the RODO log file and the data files on the data persistence layer; S104: When the cloud native database needs to be restored, restore the cloud native database to the state when the snapshot was created based on the flashback snapshot.

[0024] It is understandable that the cloud native database is a cloud native data infrastructure, a database service that fully utilizes the advantages of the public cloud, has extreme elastic scaling capabilities, serverless features, high availability and low cost of global architecture, and can be integrated with other services on the cloud. The method provided by the present invention adopts the cloud native database snapshot flashback technology. By snapshot support for the database storage layer, plus support for the database REDO log real-time disk flushing pre- and post-real-time notification mechanism, the database data changes can be obtained more dynamically and in real time, so as to make snapshot operations, thereby completing data backup. The snapshot is only a data location mark for data storage. Each snapshot object contains a reference to the previous snapshot. When the data is modified, the new snapshot object will only contain these modified data without changing the content of the previous snapshot object. This method realizes the incremental storage of snapshots, making the snapshot chain very efficient, and a large number of snapshots can be created without taking up too much storage space, and the speed will be very fast. When flashing back, the data is switched to the location of the specified time point, and the speed is also very fast. With this snapshot flashback technology, the backup and recovery operations of the cloud native database are completed.

[0025] When the user needs to restore database data, or at time t3 when the source data is damaged due to various reasons (misoperation, system error, etc.), the database sends an event message (RECOVERY CKPT) to the data persistence layer, and restores the source data to the state when the snapshot was created (i.e., time t1) through the flashback snapshot. At this point, the data backup and recovery of the cloud native database based on snapshot flashback is completed. The method provided by the present invention is applied to Figure 2 The technical architecture shown.

[0026] In some embodiments, generating a log event based on a data write statement includes: A data write statement is obtained, and when it is determined that the syntax of the data write statement is correct and the required permissions are available, a log event is generated based on the data write statement.

[0027] It can be understood that the cloud native database snapshot flashback technology provided by the present invention realizes the circulation of database data in the computing layer, storage engine layer, cache layer, and data persistence layer. When the application sends an SQL (Structured Query Language, Structured Query Language database) write statement (i.e., data write statement, such as INSERT, UPDATE, DELETE) to the database server, the database on the database server will first parse and preprocess the statement, check the correctness of the SQL syntax, and determine the permissions required to execute the statement; then the database will generate a binary log event for the content of the SQL write statement and write it to the RODO log file. This REDO log file records all operations that change the database, including write, update, and delete.

[0028] In some embodiments, Figure 3 As shown, the step of generating a data snapshot chain for backup based on the RODO log file and the data file on the data persistence layer includes: S301, sending a disk flushing event message to a data persistence layer based on the RODO log file, so as to generate a snapshot based on the data persistence layer according to the source data corresponding to the data file; S302: Send a disk flushing completion message to the data persistence layer, so as to splice the generated snapshots based on the data persistence layer to obtain a data snapshot chain.

[0029] In some embodiments, sending a flush event message to a data persistence layer based on the RODO log file, so as to generate a snapshot based on the data persistence layer according to source data corresponding to the data file, includes: A disk flushing thread is generated based on the cloud native database. In the disk flushing thread, a disk flushing event message is sent to the data persistence layer based on the RODO log file, so as to generate a snapshot based on the data persistence layer according to the source data corresponding to the data file.

[0030] In some embodiments, generating a snapshot based on the data persistence layer according to the source data corresponding to the data file includes: Based on the data persistence layer and in a copy-on-write manner, a snapshot is generated of the source data corresponding to the data file.

[0031] It is understandable that after writing the binary log event to the RODO log file, the database will write the data of the SQL statement to the Buffer_Pool buffer pool instead of directly writing it to the data persistence layer, that is, the disk, which can also be called the data persistence layer. The buffer pool is used to cache data pages, which can speed up the reading and writing of data. Next, the database will periodically refresh the dirty data pages (modified data pages) in the buffer pool to the data files on the data persistence layer. This process is called "checkpoint". At the same time, the REDO buffer will be refreshed to the REDO log file on the persistence layer disk. This "periodicity" is performed by the database reading a number of parameters to configure checkpoint parameters such as CKPT_INTERVAL and CKPT_FLUSH_RATE, so as to perform the "flush" operation. While "flushing", the "flush event (CREATECKPT_FLUSH)" is sent to the data persistence layer. Next, the data persistence layer reads the event message and generates t1 for the snapshot of the source data t0. After waiting for the end of the "flush", the end event (END CKPT_FLUSH) is sent to generate snapshot t2 based on t1 to form a data snapshot chain.

[0032] In some embodiments, Figure 4 As shown, the method of restoring the cloud native database to the state when the snapshot was created based on the flashback snapshot includes: S401, generating a flashback thread based on the cloud native database, and reading snapshot information of a time point to be restored based on the flashback thread; S402: Write data corresponding to the snapshot information at the time point to be restored into the cloud native database to restore the cloud native database to the state when the snapshot was created.

[0033] In some embodiments, writing data corresponding to the snapshot information at the time point to be restored to the cloud native database to restore the cloud native database to the state when the snapshot was created also includes: After reading the snapshot information of the time point to be restored, locking the source volume of the cloud native database; A logical address corresponding to the snapshot information at the time point to be restored is determined, and after writing data corresponding to the snapshot information at the time point to be restored to the source volume based on the logical address, the source volume is unlocked.

[0034] It is understandable that the cloud-native database snapshot flashback technology also enables database recovery to any point in time. Every time a "flush" is performed, the database first generates a checkpoint thread (flush thread), reads the LSN (log sequence number) position of the current REDO log, reads the page offset, and records the start time, source data LSN number and offset, and snapshot information (name, snapshot time point, snapshot offset); after the flush is completed, the flush end time, the end LSN number and offset, and snapshot information are recorded. In the snapshot, when the snapshot is created through the Copy-on-Write (Copy on Write, referred to as COW) technology, the original data is not directly copied, but a snapshot object with metadata pointing to the original data is created. This snapshot object only contains the changed data part, called the "delta set". In this way, the complete original data is not actually copied, saving storage space.

[0035] When an insert, update, or delete (INSERT, UPDATE, or DELETE) operation is initiated and the replica is modified (write operation), COW technology is used to ensure data consistency. Before the write operation, the system will first check whether the replica has been modified. If it has been modified, the original data block will be copied and the modification operation will be applied to the newly copied data block. Now, the replica has been modified and is independent of the original data block, while the original data remains unchanged. In this way, any subsequent modifications between the original data and the replica will not affect each other.

[0036] When a flashback operation is initiated to the database, the database generates a Flashback thread, reads the snapshot information of the corresponding time point according to the point to be restored specified by the user, locks the source volume, stops IO writing, and then queries the logical address in the mapping table. Based on the address, the data corresponding to the address is written back to the source volume from the snapshot. After writing, the source volume is unlocked and restored to a usable state. At this time, the database flashes back to the data state at the specified time point.

[0037] Cloud-native database snapshot flashback technology also enables database recovery to any cluster location. When it is necessary to flash back the cloud-native database state to another location, for example, when the database needs to be restored to a newly released cloud host or virtual machine, there are two ways to do it: First, you need to create a new cloud-native database instance in the cloud host or virtual machine, and ensure that the system and database versions are the same or compatible. Next, mount the snapshot to the new database instance. After mounting the snapshot, perform a file system check (such as the fsck command) to ensure that the data in the snapshot is complete and there are no file system errors. In this way, the database instance can access the data in the snapshot. Second, based on the newly released database instance, a new independent disk is generated based on the generated snapshot data, the original content and space size are read, and the storage data is copied to the new disk. Then the disk is mounted and flashed back to the state of the source volume snapshot time point, so that the database instance can run normally on it.

[0038] The cloud-native database snapshot flashback technology enhances the reliability and stability of the cloud-native database. Through the database's native event and message mechanism, backup and recovery operations can be performed in a timely and effective manner, which greatly avoids additional resource overhead and untimely data processing, ensuring that data is not lost; at the same time, storage resources are maximized, avoiding network speed, memory space, and storage space occupation similar to real-time synchronization, and avoiding storage resource occupation caused by snapshots that are not generated in time or at the wrong time, truly realizing backup / recovery according to database needs.

[0039] The cloud-native database snapshot flashback technology also enables convenient data backup and recovery, which meets users' psychological expectations of "easy to use" and "dare to use" to the greatest extent, and can "reduce costs and increase efficiency" at the storage level without the need to introduce additional storage resources. It also supports third-party interface access and event push in the form of SQL, which greatly satisfies the openness and flexibility of the cloud-native database.

[0040] In summary, the present invention provides a method for backing up and restoring a cloud native database, including: generating a log event based on a data write statement, and writing the log event into a RODO log file; based on the data write statement, writing the corresponding data page into a buffer pool; refreshing the modified data page in the buffer pool into a data file on a data persistence layer of the cloud native database, and generating a data snapshot chain for backup based on the RODO log file and the data file on the data persistence layer; when the cloud native database needs to be restored, restoring the cloud native database to the state when the snapshot was created based on a flashback snapshot.

[0041] The backup and recovery method of the cloud native database provided by the present invention, through the cloud native database snapshot flashback technology, through the snapshot support for the storage of the cloud native database, plus the support for the database REDO log real-time disk flushing pre- and post-real-time notification mechanism, can obtain database data changes more dynamically and in real time, so as to make snapshot operations, thereby completing data backup. The snapshot is only a data location mark for data storage. Each snapshot object contains a reference to the previous snapshot. When the data is modified, the new snapshot object will only contain these modified data without changing the content of the previous snapshot object. This method realizes the incremental storage of snapshots, making the snapshot chain efficient, and can create a large number of snapshots without taking up too much storage space, and the speed is very fast. When flashing back, that is, switching the data to the position of the specified time point, the speed is also very fast, and the backup and recovery operations of the cloud native database are completed by this snapshot flashback technology. Therefore, the present invention solves the technical problem that the existing database cannot solve the real-time problem and the restoration of the specified time point at the same time.

[0042] like Figure 5 As shown, the present invention also provides a cloud native database backup and recovery device 500, which includes: The log generation module 501 is used to generate a log event based on a data write statement and write the log event into a RODO log file; A cache module 502, configured to write corresponding data pages into a buffer pool based on the data write statement; A snapshot generation module 503 is used to refresh the modified data pages in the buffer pool to the data files on the data persistence layer of the cloud native database, and generate a data snapshot chain for backup based on the RODO log file and the data files on the data persistence layer; The flashback module 504 is used to restore the cloud native database to the state when the snapshot was created based on the flashback snapshot when the cloud native database needs to be restored.

[0043] The backup and recovery device for the cloud native database provided in the above embodiment can implement the technical solution described in the above embodiment of the backup and recovery method for the cloud native database. The specific implementation principles of the above modules or units can refer to the corresponding contents in the above embodiment of the backup and recovery method for the cloud native database, which will not be repeated here.

[0044] like Figure 6 As shown, the present invention also provides an electronic device 600. The electronic device 600 includes a processor 601, a memory 602 and a display 603. Figure 6 Only some components of the electronic device 600 are shown, but it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.

[0045] In some embodiments, the memory 602 may be an internal storage unit of the electronic device 600, such as a hard disk or memory of the electronic device 600. In other embodiments, the memory 602 may also be an external storage device of the electronic device 600, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc., equipped on the electronic device 600.

[0046] Furthermore, the memory 602 may include both an internal storage unit of the electronic device 600 and an external storage device. The memory 602 is used to store application software installed in the electronic device 600 and various data.

[0047] In some embodiments, the processor 601 can be a central processing unit (CPU), a microprocessor or other data processing chip, used to run the program code stored in the memory 602 or process data, such as the backup and recovery method of the cloud native database in the present invention.

[0048] In some embodiments, the display 603 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, etc. The display 603 is used to display information on the electronic device 600 and to display a visual user interface. The components 601-603 of the electronic device 600 communicate with each other via a system bus.

[0049] In some embodiments of the present invention, when the processor 601 executes the backup and recovery program of the cloud native database in the memory 602, the following steps may be implemented: Generate a log event based on a data write statement, and write the log event into a RODO log file; Based on the data writing statement, writing the corresponding data page into the buffer pool; Refresh the modified data pages in the buffer pool to the data files on the data persistence layer of the cloud native database, and generate a data snapshot chain for backup based on the RODO log file and the data files on the data persistence layer; When the cloud native database needs to be restored, the cloud native database is restored to the state when the snapshot was created based on the flashback snapshot.

[0050] It should be understood that: when the processor 601 executes the backup and recovery program of the cloud native database in the memory 602, in addition to the above functions, other functions can also be implemented. For details, please refer to the description of the corresponding method embodiment above.

[0051] Furthermore, the embodiment of the present invention does not specifically limit the type of the electronic device 600 mentioned, and the electronic device 600 may be a portable electronic device such as a mobile phone, a tablet computer, a personal digital assistant (PDA), a wearable device, a laptop computer, etc. Exemplary embodiments of portable electronic devices include but are not limited to portable electronic devices equipped with IOS, Android, Microsoft or other operating systems. The above-mentioned portable electronic device may also be other portable electronic devices, such as a laptop computer with a touch-sensitive surface (e.g., a touch panel). It should also be understood that in some other embodiments of the present invention, the electronic device 600 may not be a portable electronic device, but a desktop computer with a touch-sensitive surface (e.g., a touch panel).

[0052] In another aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which is implemented when the computer program is executed by a processor to perform the cloud native database backup and recovery method provided by the above methods, the method comprising: Generate a log event based on a data write statement, and write the log event into a RODO log file; Based on the data writing statement, writing the corresponding data page into the buffer pool; Refresh the modified data pages in the buffer pool to the data files on the data persistence layer of the cloud native database, and generate a data snapshot chain for backup based on the RODO log file and the data files on the data persistence layer; When the cloud native database needs to be restored, the cloud native database is restored to the state when the snapshot was created based on the flashback snapshot.

[0053] Those skilled in the art will appreciate that all or part of the processes of the above-mentioned embodiments can be implemented by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium, wherein the computer-readable storage medium is a disk, an optical disk, a read-only storage memory, or a random access memory, etc.

[0054] The above is a detailed introduction to the backup and recovery method, device, electronic device and medium of the cloud native database provided by the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for technical personnel in this field, according to the idea of ​​the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A method for backing up and restoring a cloud native database, characterized in that: include: Generate a log event based on a data write statement, and write the log event into a RODO log file; Based on the data writing statement, writing the corresponding data page into the buffer pool; Refresh the modified data pages in the buffer pool to the data files on the data persistence layer of the cloud native database, and generate a data snapshot chain for backup based on the RODO log file and the data files on the data persistence layer; When the cloud native database needs to be restored, the cloud native database is restored to the state when the snapshot was created based on the flashback snapshot.

2. The method for backing up and restoring a cloud native database according to claim 1, characterized in that: The generating of log events based on data writing statements includes: A data write statement is obtained, and when it is determined that the syntax of the data write statement is correct and the required permissions are available, a log event is generated based on the data write statement.

3. The method for backing up and restoring a cloud native database according to claim 1, characterized in that: The step of generating a data snapshot chain for backup based on the RODO log file and the data file on the data persistence layer includes: Sending a disk flushing event message to the data persistence layer based on the RODO log file, so as to generate a snapshot based on the data persistence layer according to the source data corresponding to the data file; Send a disk flushing completion message to the data persistence layer, so as to splice the generated snapshots based on the data persistence layer to obtain a data snapshot chain.

4. The method for backing up and restoring a cloud native database according to claim 3, characterized in that: The sending of the disk flushing event message to the data persistence layer based on the RODO log file, so as to generate a snapshot based on the data persistence layer according to the source data corresponding to the data file, includes: A disk flushing thread is generated based on the cloud native database. In the disk flushing thread, a disk flushing event message is sent to the data persistence layer based on the RODO log file, so as to generate a snapshot based on the data persistence layer according to the source data corresponding to the data file.

5. The method for backing up and restoring a cloud native database according to claim 3, characterized in that: The generating a snapshot based on the data persistence layer according to the source data corresponding to the data file includes: Based on the data persistence layer and in a copy-on-write manner, a snapshot is generated of the source data corresponding to the data file.

6. The method for backing up and restoring a cloud native database according to any one of claims 1 to 5, characterized in that: The restoring the cloud native database to the state at the time of snapshot creation based on the flashback snapshot includes: Generate a flashback thread based on the cloud native database, and read snapshot information of a time point to be restored based on the flashback thread; The data corresponding to the snapshot information at the time point to be restored is written into the cloud native database to restore the cloud native database to the state when the snapshot was created.

7. The method for backing up and restoring a cloud native database according to claim 6, characterized in that: The step of writing data corresponding to the snapshot information at the time point to be restored into the cloud native database to restore the cloud native database to the state when the snapshot was created also includes: After reading the snapshot information of the time point to be restored, locking the source volume of the cloud native database; A logical address corresponding to the snapshot information at the time point to be restored is determined, and after writing data corresponding to the snapshot information at the time point to be restored to the source volume based on the logical address, the source volume is unlocked.

8. A cloud native database backup and recovery device, characterized in that: include: A log generation module, used to generate log events based on data write statements, and write the log events into a RODO log file; A cache module, used for writing corresponding data pages into a buffer pool based on the data writing statement; A snapshot generation module, used to refresh the modified data pages in the buffer pool into the data files on the data persistence layer of the cloud native database, and generate a data snapshot chain for backup based on the RODO log file and the data files on the data persistence layer; The flashback module is used to restore the cloud native database to the state when the snapshot was created based on the flashback snapshot when the cloud native database needs to be restored.

9. An electronic device, characterized in that: comprising a memory and a processor, wherein: The memory is used to store programs; The processor is coupled to the memory and is used to execute the program stored in the memory to implement the steps of the cloud native database backup and recovery method as described in any one of claims 1 to 7.

10. A non-transitory 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 cloud native database backup and recovery method according to any one of claims 1 to 7 are implemented.