A database master-slave synchronization method, device, equipment, medium and product

By obtaining and parsing the Data Definition Language (DDL) logs and redo logs from the master database, the problem of only being able to synchronize data pages in existing technologies is solved, and the synchronization of DDL logs is realized, thereby improving the efficiency and latency performance of master-slave database synchronization.

CN118012955BActive Publication Date: 2026-06-23CHINA MOBILE (SUZHOU) SOFTWARE TECH CO LTD +1

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHINA MOBILE (SUZHOU) SOFTWARE TECH CO LTD
Filing Date
2024-02-27
Publication Date
2026-06-23

AI Technical Summary

Technical Problem

In existing technologies, database master-slave synchronization based on redo logs can only achieve synchronous modification of data pages, but cannot achieve DDL synchronization.

Method used

The system retrieves the Data Definition Language (DDL) logs and redo logs generated by the master database from the database side. It then uses a log parsing thread to determine the log type and obtain the binary logs, and combines these with the redo logs to synchronize the DDL logs.

Benefits of technology

It enables synchronization of Data Definition Language logs, reduces disk I/O and communication I/O pressure, and improves the efficiency and latency performance of master-slave synchronization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118012955B_ABST
    Figure CN118012955B_ABST
Patent Text Reader

Abstract

The application provides a database master-slave synchronization method, device, equipment, medium and product, wherein the method comprises the following steps: obtaining a first redo log including a first globally unique number generated by a master database end for a first log as a data definition language log; in the case that a log analysis thread judges that the log type of the first redo log is the first occurrence, obtaining a corresponding first binary log cached in a relay log file according to the first globally unique number, and applying the binary log to a slave database through a database language thread. The database master-slave synchronization is realized based on the binary log and the redo log, and the method of generating the log based on the globally unique number is supplemented, so that the replication delay problem caused by the method of realizing the database master-slave synchronization based on the binary log only is solved, and the synchronization of the data definition language log is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of database technology, and in particular to a database master-slave synchronization method, apparatus, device, medium, and product. Background Technology

[0002] A master-slave database cluster consists of one master database instance and multiple slave database instances. The master database instance is read-write, while the slave database instances are read-only. Data synchronization between the master and slave database instances requires data synchronization technology. Existing master-slave synchronization methods based on binlog (Binary Log) logs only transmit logs to the slave database after a transaction on the master database is committed. This results in a significant replication latency issue, as the slave database needs to wait one transaction's execution time before receiving and replaying the transaction. Furthermore, flushing large amounts of binlog logs to disk increases the pressure on disk I / O (Input / Output) and communication I / O. While redolog-based master-slave database synchronization cannot completely replace native replication, it can only synchronize modifications to data pages, thus only handling specific scenarios such as DML (Data Manipulation Language) synchronization, and cannot handle DDL (Data Definition Language) synchronization. Summary of the Invention

[0003] The purpose of this invention is to provide a database master-slave synchronization method, apparatus, device, medium, and product to solve the problem that existing database master-slave synchronization methods based solely on redo logs can only achieve synchronized modification of data pages and cannot achieve DDL synchronization.

[0004] To achieve the above objectives, embodiments of the present invention provide a database master-slave synchronization method, wherein the method is applied to the slave database end and includes:

[0005] Obtain the first redo log generated by the main database for the first log; wherein, the first log is a data definition language log, and the first redo log includes a first globally unique number;

[0006] If the log parsing thread determines that the log type of the first redo log is the first occurrence, it retrieves the first binary log from the relay log file based on the first globally unique number; wherein, the first binary log is generated by the main database for the first log, and the first binary log includes the first globally unique number; the relay log file is a cached file of the first binary log;

[0007] The first binary log is applied to the slave database via the database language thread.

[0008] Optionally, the method further includes:

[0009] If it is determined that the log type of the first redo log is not the first occurrence, the first redo log is parsed and stored in a hash table;

[0010] The storage state of the hash table is checked repeatedly.

[0011] If the storage state is not empty, the logs to be applied in the hash table are sequentially applied to the corresponding data pages of the slave database; wherein, the logs to be applied include the parsed first redo logs.

[0012] Optionally, the method further includes:

[0013] Obtain the second redo log sent by the master database terminal for the second log; wherein, the second log is a data manipulation language log;

[0014] The second redo log is parsed and stored in a hash table;

[0015] The storage state of the hash table is checked repeatedly.

[0016] If the storage state is not empty, the logs to be applied in the hash table are sequentially applied to the corresponding data pages of the slave database; wherein, the logs to be applied include the parsed second redo logs.

[0017] Optionally, the method further includes:

[0018] Send the event application completion information with the first globally unique number to the log parsing thread;

[0019] The database language thread is set to a waiting state.

[0020] To achieve the above objectives, embodiments of the present invention also provide a database master-slave synchronization method, wherein the method is applied to the master database and includes:

[0021] Obtain the first database language statement sent by the client for the first log; wherein, the first log is a data definition language log;

[0022] A first redo log is generated based on the first database language statement; wherein, the first redo log includes a first globally unique number.

[0023] Optionally, the method further includes:

[0024] Obtain the second database language statement sent by the client for the second log; wherein, the second log is a data manipulation language log;

[0025] A second redo log is generated based on the second database language statement;

[0026] Send the second redo log to the slave database.

[0027] Optionally, the method, wherein generating the first redo log includes:

[0028] Obtain the operation type of the first log;

[0029] Obtain the corresponding first globally unique ID for the operation type of the first log;

[0030] The first redo log is generated based on the first globally unique number.

[0031] To achieve the above objectives, embodiments of the present invention also provide a database master-slave synchronization device, wherein the device is applied to the slave database end and includes:

[0032] The first acquisition module is used to acquire the first redo log generated by the main database in response to the first log; wherein, the first log is a data definition language log and the first redo log includes a first globally unique number.

[0033] The second acquisition module is used to acquire the first binary log in the relay log file based on the first globally unique number when the log parsing thread determines that the log type of the first redo log is the first occurrence; wherein, the first binary log is generated by the main database for the first log, and the first binary log includes the first globally unique number; the relay log file is a file cached with the first binary log;

[0034] The first processing module is used to apply the first binary log to the slave database via a database language thread.

[0035] To achieve the above objectives, embodiments of the present invention also provide a database master-slave synchronization device, wherein the device is applied to the master database and includes:

[0036] The third acquisition module is used to acquire the first database language statement sent by the client for the first log; wherein, the first log is a data definition language log;

[0037] The first generation module is used to generate a first redo log based on the first database language statement; wherein the first redo log includes a first globally unique number.

[0038] To achieve the above objectives, embodiments of the present invention also provide a network device, including: a transceiver, a processor, a memory, and a program or instructions stored in the memory and executable on the processor; wherein, when the processor executes the program or instructions, it implements the database master-slave synchronization method applied to the slave database as described above, or implements the database master-slave synchronization method applied to the master database as described above.

[0039] To achieve the above objectives, embodiments of the present invention also provide a readable storage medium storing a program or instructions thereon, wherein the program or instructions, when executed by a processor, implement the steps of the database master-slave synchronization method applied to a slave database as described above, or implement the steps of the database master-slave synchronization method applied to a master database as described above.

[0040] To achieve the above objectives, embodiments of the present invention also provide a computer program product, comprising computer instructions, wherein when the computer instructions are executed by a processor, they implement the steps described above in the database master-slave synchronization method applied to a slave database, or implement the steps described above in the database master-slave synchronization method applied to a master database.

[0041] The beneficial effects of the above-described technical solution of the present invention are as follows:

[0042] In this embodiment of the invention, the slave database actively retrieves the first logs, which serve as the data definition language logs, from the master database. These include a first binary log with a first globally unique number and a first redo log. When the log parsing thread determines that the log type of the first redo log is appearing for the first time, it retrieves the corresponding first binary log based on the first globally unique number and applies it to the slave database. Thus, the synchronization of the data definition language logs is achieved based on both the binary logs and the redo logs. This avoids the situation where the master-slave database synchronization method based solely on redo log replication can only achieve synchronous modification of data pages and cannot achieve synchronization of the data definition language logs. Attached Figure Description

[0043] Figure 1 This is a schematic diagram illustrating the database master-slave synchronization method applied to the database end according to an embodiment of the present invention;

[0044] Figure 2 This is a flowchart illustrating database master-slave synchronization as described in an embodiment of the present invention;

[0045] Figure 3 This is a schematic diagram illustrating a database master-slave synchronization method applied to the master database in an embodiment of the present invention;

[0046] Figure 4This is a schematic diagram of a database master-slave synchronization device applied to a database end, as described in an embodiment of the present invention.

[0047] Figure 5 This is a schematic diagram of a database master-slave synchronization device applied to the master database as described in an embodiment of the present invention. Detailed Implementation

[0048] To make the technical problems, technical solutions and advantages of the present invention clearer, a detailed description will be given below in conjunction with the accompanying drawings and specific embodiments.

[0049] It should be understood that the phrase "one embodiment" or "an embodiment" throughout the specification means that a specific feature, structure, or characteristic related to the embodiment is included in at least one embodiment of the invention. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification do not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments.

[0050] In various embodiments of the present invention, it should be understood that the sequence number of each process described below does not imply 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 invention.

[0051] In addition, the terms "system" and "network" are often used interchangeably in this article.

[0052] In the embodiments provided in this application, it should be understood that "B corresponding to A" means that B is associated with A, and B can be determined based on A. However, it should also be understood that determining B based on A does not mean determining B solely based on A; B can also be determined based on A and / or other information.

[0053] For ease of understanding, the following describes some aspects of the embodiments of the present invention:

[0054] like Figure 1 As shown, an embodiment of the present invention provides a database master-slave synchronization method, wherein the method is applied to the slave database and includes:

[0055] S10, Obtain the first redo log generated by the master database for the first log; wherein, the first log is a data definition language log, and the first redo log includes a first globally unique number;

[0056] It should be noted that, as Figure 2 As shown, the database side creates a redo log receiving thread, requests logs from the main database side at regular intervals, and caches the obtained first redo log in the redo log cache area for parsing by the log parsing thread.

[0057] S20, if the log parsing thread determines that the log type of the first redo log is the first occurrence, the first binary log is obtained from the relay log file according to the first globally unique number; wherein, the first binary log is generated by the main database for the first log, and the first binary log includes the first globally unique number; the relay log file is a file cached with the first binary log;

[0058] It should be noted that, as Figure 2 As shown, after the log parsing thread completes log parsing, further filtering is performed on different types of redo logs. In the log parsing filtering module, newly added redo logs are retrieved from the relay log file according to step S20, based on the first globally unique number. The retrieval of the first binary log from the database side follows the existing MySQL (Relational Database Management System) processing logic, actively retrieving it through the master-slave replication I / O thread and caching the first binary log in the relay log file. Redo log transmission from the database side is performed through the redo log receiving thread, and binary log transmission is performed through the I / O thread. The two threads work independently and do not affect each other. Furthermore, the I / O thread is also responsible for establishing connections with the master database, exchanging information, and registering slave databases. Since the first binary log includes the first globally unique number, it is possible to retrieve the first binary log from the relay log file based on the same first globally unique number.

[0059] S30, the first binary log is applied to the slave database via the database language thread;

[0060] It should be noted that in this embodiment, the synchronization of the first log, which serves as the data definition language log, is achieved by combining the first binary log and the first redo log. This avoids the situation where the master-slave database synchronization method based solely on redo log replication can only achieve synchronized modification of data pages and cannot achieve synchronization of the data definition language log.

[0061] In this embodiment, the database actively retrieves the logs, which are the definition language logs, from the database. These logs include the binary log with the globally unique number and the redo log. When the log parsing thread determines that the log type of the first redo log is the first occurrence, it retrieves the corresponding first binary log based on the first globally unique number and applies it to the database. Thus, the synchronization of the data definition language logs is achieved based on the binary log and the redo log.

[0062] Optionally, the method further includes:

[0063] If it is determined that the log type of the first redo log is not the first occurrence, the first redo log is parsed and stored in a hash table;

[0064] It should be noted that, as Figure 2 As shown, in the log parsing and filtering module, it is determined that the log type of the first redo log is not new. The first redo log is then parsed and stored in the hash table. Figure 2 In the redo hash table.

[0065] The storage state of the hash table is checked repeatedly.

[0066] If the storage state is not empty, the logs to be applied in the hash table are sequentially applied to the corresponding data pages of the slave database; wherein, the logs to be applied include the parsed first redo logs;

[0067] It should be noted that, as Figure 2 As shown, the storage status of the hash table is checked cyclically. When the hash table is empty, the process will continue to check the hash table. Once the hash table is not empty, the logs to be applied in the hash table will be applied to the corresponding data pages of the slave database in sequence.

[0068] Optionally, the method further includes:

[0069] Obtain the second redo log sent by the master database terminal for the second log; wherein, the second log is a data manipulation language log;

[0070] The second redo log is parsed and stored in a hash table;

[0071] The storage state of the hash table is checked repeatedly.

[0072] If the storage state is not empty, the logs to be applied in the hash table are sequentially applied to the corresponding data pages of the slave database; wherein, the logs to be applied include the parsed second redo logs.

[0073] In this embodiment, when the second log is the data manipulation language log, the master-slave synchronization method is entirely based on redo log synchronization, which can greatly improve the efficiency of master-slave data manipulation language log data synchronization, reduce the master-slave synchronization latency, and thus reduce the pressure of disk I / O and communication I / O required by the binary log synchronization method.

[0074] Optionally, the method further includes:

[0075] Send the event application completion information with the first globally unique number to the log parsing thread;

[0076] The database language thread is set to a waiting state.

[0077] In this embodiment, after the database language thread completes the application of the binary log in the relay log file, it sends an event application completion message with the first globally unique number to the log parsing thread and sets itself to a waiting state. The event with the first globally unique number refers to the action of retrieving the first binary log in the relay log file based on the first globally unique number. After the action is completed, a message needs to be sent to the log parsing thread so that the log parsing thread can continue to process the parsing of the next log.

[0078] like Figure 3 As shown, in order to achieve the above objectives, this embodiment of the invention also provides a database master-slave synchronization method, wherein the method is applied to the master database and includes:

[0079] A10, Obtain the first database language statement sent by the client for the first log; wherein, the first log is a data definition language log;

[0080] It should be noted that, as Figure 2 As shown, the execution logic of the database language statement in step A10 is consistent with the logic of MySQL executing database language statements. The client accesses the main database, the client executes the database language statement, and read and write processing is performed on the main database. Therefore, the main database obtains the first database language statement sent by the client for the first log, which is the data definition language log.

[0081] A20, Generate a first redo log based on the first database language statement; wherein, the first redo log includes a first globally unique number;

[0082] It should be noted that only for the first log, which is a data definition language log, the first redo log is generated according to the first database language statement. At the same time, the first binary log also needs to be generated and cached in the relay log file. The other work of generating binary logs is shielded from the logic of MySQL in the prior art, thereby reducing the log volume of binary logs, which not only reduces the pressure of disk I / O, but also reduces the load of communication I / O.

[0083] Optionally, the method further includes:

[0084] Obtain the second database language statement sent by the client for the second log; wherein, the second log is a data manipulation language log;

[0085] A second redo log is generated based on the second database language statement;

[0086] Send the second redo log to the slave database.

[0087] In this embodiment, the redo log is generated for the second log, which is a data manipulation language log, and sent to the slave database. The data manipulation language log synchronization is implemented entirely based on redo log synchronization, which can greatly improve the efficiency of master-slave data manipulation language log synchronization, reduce master-slave synchronization latency, and reduce disk I / O pressure and communication I / O load by not using a binary log-based synchronization method.

[0088] Optionally, the method, wherein generating the first redo log includes:

[0089] Obtain the operation type of the first log;

[0090] Obtain the corresponding first globally unique ID for the operation type of the first log;

[0091] The first redo log is generated based on the first globally unique number.

[0092] In this embodiment, the implementation of the Data Definition Language (DDL) log language differs from the existing MySQL master-slave synchronization implementation in that it adds different redo log types for different types of DDL log operation types and supplements the logic of writing globally unique codes to the redo log under the transaction. For example, when performing a table creation operation, the log "MLOG CREATE TABLE" is supplemented, and the globally unique code is added; and when performing a database creation operation, the log "MLOG CREATE DATABASE" is supplemented, and the globally unique code is added. Furthermore, the method for writing the binary log of the DDL log adds the writing of globally unique codes compared to the existing technology. To ensure the consistency of the master-slave DDL log synchronization order, the globally unique code synchronization method ensures the synchronization and replay order of binary log and redo log transactions. The logic for writing other binary logs besides the DDL log is masked compared to the existing MySQL logic, reducing the binary log volume, which not only reduces disk I / O pressure but also communication I / O load.

[0093] like Figure 4As shown, in order to achieve the above objectives, this embodiment of the invention also provides a database master-slave synchronization device, wherein the device is applied to the slave database end and includes:

[0094] The first acquisition module 401 is used to acquire the first redo log generated by the main database for the first log; wherein, the first log is a data definition language log and the first redo log includes a first globally unique number.

[0095] The second acquisition module 402 is used to acquire the first binary log in the relay log file based on the first globally unique number when the log parsing thread determines that the log type of the first redo log is the first occurrence; wherein, the first binary log is generated by the main database for the first log, and the first binary log includes the first globally unique number; the relay log file is a file cached with the first binary log;

[0096] The first processing module 403 is used to apply the first binary log to the slave database through the database language thread.

[0097] like Figure 5 As shown, to achieve the above objectives, this embodiment of the invention also provides a database master-slave synchronization device, wherein the device is applied to the master database and includes:

[0098] The third acquisition module 501 is used to acquire the first database language statement sent by the client for the first log; wherein, the first log is a data definition language log;

[0099] The first generation module 502 is used to generate a first redo log based on the first database language statement; wherein the first redo log includes a first globally unique number.

[0100] Optionally, the device further includes:

[0101] The second processing module is used to parse the first redo log and store it in a hash table if it is determined that the log type of the first redo log is not the first time it has appeared.

[0102] The third processing module is used to cyclically check the storage status of the hash table;

[0103] The first application module is configured to sequentially apply the logs to be applied in the hash table to the corresponding data pages of the slave database when the storage state is not empty; wherein the logs to be applied include the parsed first redo logs.

[0104] Optionally, the device further includes:

[0105] The fourth acquisition module is used to acquire the second redo log sent by the main database terminal in response to the second log; wherein the second log is a data manipulation language log;

[0106] The fourth processing module is used to parse the second redo log and store it in a hash table;

[0107] The fifth processing module is used to cyclically check the storage status of the hash table;

[0108] The second application module is used to sequentially apply the logs to be applied in the hash table to the corresponding data pages of the slave database when the storage state is not empty; wherein the logs to be applied include the parsed second redo logs.

[0109] Optionally, the device further includes:

[0110] The first sending module is used to send the event application completion information with the first globally unique number to the log parsing thread;

[0111] The first setting module is used to set the database language thread to a waiting state.

[0112] Optionally, the device further includes:

[0113] The fifth acquisition module is used to acquire the second database language statement sent by the client for the second log; wherein the second log is a data manipulation language log;

[0114] The second generation module is used to generate a second redo log based on the second database language statement;

[0115] The second sending module is used to send the second redo log to the slave database.

[0116] Optionally, in the apparatus, the first generation module 502 includes:

[0117] The first acquisition unit is used to acquire the operation type of the first log;

[0118] The second acquisition unit is used to acquire the first globally unique number corresponding to the operation type of the first log;

[0119] The first generation unit is used to generate the first redo log based on the first globally unique number.

[0120] It should be noted that the apparatus provided in this embodiment of the invention can implement all the method steps implemented in the above method embodiment and can achieve the same technical effect. Therefore, the parts and beneficial effects that are the same as those in the method embodiment will not be described in detail here.

[0121] To achieve the above objectives, embodiments of the present invention also provide a network device, including: a transceiver, a processor, a memory, and a program or instructions stored in the memory and executable on the processor; wherein, when the processor executes the program or instructions, it implements the database master-slave synchronization method applied to a slave database as described above, or implements the database master-slave synchronization method applied to a master database as described above.

[0122] To achieve the above objectives, embodiments of the present invention also provide a readable storage medium storing a program or instructions thereon, wherein the program or instructions, when executed by a processor, implement the steps of the database master-slave synchronization method applied to a slave database as described above, or implement the steps of the database master-slave synchronization method applied to a master database as described above.

[0123] The readable storage medium includes computer-readable storage media, such as computer read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.

[0124] To achieve the above objectives, embodiments of the present invention also provide a computer program product, including computer instructions that, when executed by a processor, implement the above-described objectives. Figure 1 or Figure 3 The various processes of the method embodiments shown can achieve the same technical effect, and will not be described again here to avoid repetition.

[0125] The exemplary embodiments described above are with reference to the accompanying drawings. Many different forms and embodiments are feasible without departing from the spirit and teachings of the invention. Therefore, the invention should not be construed as limiting the exemplary embodiments set forth herein. Rather, these exemplary embodiments are provided to make the invention complete and convey the scope of the invention to those skilled in the art. In these drawings, component dimensions and relative dimensions may be exaggerated for clarity. The terminology used herein is for the purpose of describing particular exemplary embodiments only and is not intended to be limiting. As used herein, unless clearly indicated otherwise, the singular forms “a,” “an,” and “the” are intended to include all such forms. It will be further understood that the terms “comprising” and / or “including”, when used in this specification, indicate the presence of the stated features, integers, steps, operations, components, and / or elements, but do not exclude the presence or addition of one or more other features, integers, steps, operations, components, and / or groups thereof. Unless otherwise indicated, when stated, a range of values ​​includes the upper and lower limits of the range and any subranges in between.

[0126] The above description represents the preferred embodiments of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. A database master-slave synchronization method, characterized in that, Applications from the database side include: Obtain the first redo log generated by the main database for the first log; wherein, the first log is a data definition language log, and the first redo log includes a first globally unique number; If the log parsing thread determines that the log type of the first redo log is appearing for the first time, that is, after the log parsing thread completes the log parsing, further filtering is performed on redo logs of different types. In the log parsing filtering module, the newly added redo logs are retrieved from the relay log file according to the first globally unique number. The first binary log is generated by the main database for the first log and includes the first globally unique number. The relay log file is a cached file of the first binary log. The first binary log is applied to the slave database via the database language thread.

2. The method according to claim 1, characterized in that, The method further includes: If it is determined that the log type of the first redo log is not the first occurrence, the first redo log is parsed and stored in a hash table; The storage state of the hash table is checked repeatedly. If the storage state is not empty, the logs to be applied in the hash table are sequentially applied to the corresponding data pages of the slave database; wherein, the logs to be applied include the parsed first redo logs.

3. The method according to claim 1, characterized in that, The method further includes: Obtain the second redo log sent by the master database terminal for the second log; wherein, the second log is a data manipulation language log; The second redo log is parsed and stored in a hash table; The storage state of the hash table is checked repeatedly. If the storage state is not empty, the logs to be applied in the hash table are sequentially applied to the corresponding data pages of the slave database; wherein, the logs to be applied include the parsed second redo logs.

4. The method according to claim 1, characterized in that, The method further includes: Send the event application completion information with the first globally unique number to the log parsing thread; The database language thread is set to a waiting state.

5. A database master-slave synchronization method, characterized in that, Applied to the main database, including: Obtain the first database language statement sent by the client for the first log; wherein, the first log is a data definition language log; A first redo log is generated based on the first database language statement; wherein the first redo log includes a first globally unique number; a first binary log is generated for the first log, and the first binary log is cached in a relay log file; the first binary log includes the first globally unique number.

6. The method according to claim 5, characterized in that, The method further includes: Obtain the second database language statement sent by the client for the second log; wherein, the second log is a data manipulation language log; A second redo log is generated based on the second database language statement; Send the second redo log to the slave database.

7. The method according to claim 5, characterized in that, The generation of the first redo log includes: Obtain the operation type of the first log; Obtain the corresponding first globally unique ID for the operation type of the first log; The first redo log is generated based on the first globally unique number.

8. A database master-slave synchronization device, characterized in that, Applications from the database side include: The first acquisition module is used to acquire the first redo log generated by the main database in response to the first log; wherein, the first log is a data definition language log and the first redo log includes a first globally unique number. The second acquisition module is used to further filter redo logs of different types after the log parsing thread determines that the log type of the first redo log is appearing for the first time, i.e., after the log parsing thread completes log parsing. In the log parsing filtering module, the newly added redo log is obtained from the relay log file based on the first globally unique number. The first binary log is generated by the main database for the first log and includes the first globally unique number. The relay log file is a cached file of the first binary log. The first processing module is used to apply the first binary log to the slave database via a database language thread.

9. A database master-slave synchronization device, characterized in that, Applied to the main database, including: The third acquisition module is used to acquire the first database language statement sent by the client for the first log; wherein, the first log is a data definition language log; The first generation module is configured to generate a first redo log based on the first database language statement; wherein the first redo log includes a first globally unique number; generate a first binary log for the first log, and cache the first binary log in a relay log file; the first binary log includes the first globally unique number.

10. A network device, comprising: A transceiver, a processor, a memory, and a program or instructions stored in the memory and executable on the processor; characterized in that, when the processor executes the program or instructions, it implements the database master-slave synchronization method as described in any one of claims 1-4, or implements the database master-slave synchronization method as described in any one of claims 5-7.

11. A readable storage medium having a program or instructions stored thereon, characterized in that, When the program or instructions are executed by the processor, they implement the steps of the database master-slave synchronization method as described in any one of claims 1-4, or implement the steps of the database master-slave synchronization method as described in any one of claims 5-7.

12. A computer program product, characterized in that, The method includes computer instructions that, when executed by a processor, implement the steps of the database master-slave synchronization method as described in any one of claims 1-4, or implement the steps of the database master-slave synchronization method as described in any one of claims 5-7.