Database synchronization method and related equipment

By constructing a CDC synchronization task plan with a single Source operator and multiple Sink operators, the problems of resource waste and complex management when synchronizing a large number of tables are solved, reducing resource consumption and improving synchronization efficiency.

CN118673084APending Publication Date: 2024-09-20SHENZHEN SHENXIN INFORMATION SECURITY CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410873872.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-28
Publication Date
2024-09-20

AI Technical Summary

Technical Problem

Existing database synchronization methods consume too much resources when synchronizing a large number of tables, resulting in resource waste, complicated management, and difficult to maintain.

Method used

By constructing a CDC synchronization task plan with a single Source operator and multiple Sink operators, the change data of multiple source tables can be captured in real time, and synchronized to multiple destination tables based on field mapping relationships, sharing the parent JobManager and reducing the use of JobManager and TaskManager.

Benefits of technology

It reduces resource consumption when synchronizing a large number of tables, simplifies the management and maintenance of CDC synchronization tasks, reduces resource usage, and improves synchronization efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118673084A
    Figure CN118673084A
Patent Text Reader

Abstract

The embodiment of the invention discloses a database synchronization method and related equipment, which are used for performing database synchronization under the condition of reducing resource waste of database synchronization. The method comprises the steps of obtaining a configuration file of a CDC synchronization task, constructing a first CDC synchronization task plan comprising a single Source operator and multiple Sink operators according to the configuration file under the condition that a source database supports a function of capturing multi-table data in real time or the change frequency of multiple source tables meets a preset condition, executing the first CDC synchronization task plan, and executing the first CDC synchronization task plan according to the first CDC synchronization task plan. The first CDC synchronization task plan is used for synchronizing change data of a plurality of source tables of the source database to a single Source operator, synchronizing the change data in the single Source operator to each Sink operator, and synchronizing the change data of each Sink operator to a target table corresponding to each Sink operator in the target database according to the field mapping relationship.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present application relate to the field of database synchronization, and more specifically, to a database synchronization method, a database synchronization apparatus, a database synchronization device, a computer-readable storage medium, and a computer program product including instructions or a computer program. Background Art

[0002] With the rapid development of database synchronization, there is an increasing need to apply change data capture (CDC) to database synchronization technology. Change data capture is a technology used to capture and track data changes in a database. It can transmit data changes to other systems or applications in real time to achieve functions such as data replication, data integration, and data synchronization.

[0003] The current database synchronization method is single-table synchronization, that is, the same task only supports data synchronization from a single source table to a single destination table. Specifically, a synchronization task will be created first to specify the source table and destination table. The synchronization task will connect to the source database and destination database through connection information. The synchronization task will capture data changes in the source table in real time, and the captured data will be synchronized to the destination table after parsing. For example, suppose the source database has a source table A, and the destination database has a destination table B. The changed data of source table A needs to be synchronized to table B. At this time, you need to create a synchronization task, specify source table A and destination table B, execute the synchronization task to capture the changed data of source table A in real time, and synchronize the changed data to destination table B.

[0004] However, for the existing database synchronization method, when it is necessary to synchronize a large number of tables (such as hundreds of thousands), it is necessary to create a large number of synchronization tasks (such as hundreds of thousands). Taking the offline synchronization job based on Flink as an example, the synchronization of a table is carried by a Flink job. A Flink job consists of a JobManager and multiple TaskManagers. Each JobManager consumes one core, and each TaskManager consumes at least one core. To complete the synchronization of a table, at least two cores are required. In the context of large-scale table synchronization, a large amount of resources are required. For example, if there are 1,000 tables, 2,000 cores are required to complete it. When it is necessary to synchronize a large number of tables, the database synchronization consumes more computing resources, the resource consumption of database synchronization is more, and the resource occupation of the synchronization task of the whole database synchronization is more. Therefore, there is a lot of waste of resources in database synchronization. Summary of the invention

[0005] Embodiments of the present application provide a database synchronization method, a database synchronization apparatus, a database synchronization device, a computer-readable storage medium, and a computer program product including instructions or a computer program, for performing database synchronization while reducing resource waste in database synchronization.

[0006] In a first aspect, an embodiment of the present application provides a database synchronization method, comprising:

[0007] Obtain a configuration file for a data change capture CDC synchronization task; wherein the configuration file includes a field mapping relationship between multiple source tables of a source database and multiple target tables of a target database;

[0008] In the case where the source database supports a function of capturing multi-table data in real time or the change frequency of the multiple source tables meets a preset condition, constructing a first CDC synchronization task plan including a single Source operator and multiple Sink operators according to the configuration file;

[0009] Execute the first CDC synchronization task plan, where the first CDC synchronization task plan is used to: synchronize the changed data of multiple source tables in the source database to a single Source operator, synchronize the changed data in the single Source operator to each of the Sink operators respectively, and synchronize the changed data of each of the Sink operators to the destination table corresponding to each of the Sink operators in the destination database according to the field mapping relationship.

[0010] Optionally, synchronizing the changed data of multiple source tables of the source database to a single Source operator, and synchronizing the changed data in the single Source operator to each of the Sink operators, includes:

[0011] Capturing the changed data of multiple source tables of the source database in real time, and transferring the changed data of multiple source tables of the source database to a single Source operator;

[0012] A single Source operator classifies the change data of multiple source tables of the source database according to multiple target tables of the target database to obtain the change data corresponding to each target table; and synchronizes the change data corresponding to each target table to the Sink operator corresponding to each target table.

[0013] Optionally, executing the first CDC synchronization task plan includes:

[0014] The first CDC synchronization task plan is sent to a third-party platform, and the third-party platform deploys the first CDC synchronization task plan to a target node whose resources meet preset conditions, so that the target node executes the first CDC synchronization task plan.

[0015] Optionally, when the source database supports a function of capturing multi-table data in real time, before constructing a first CDC synchronization task plan including a single Source operator and multiple Sink operators according to the configuration file, the method further includes:

[0016] According to the configuration information of the source database, it is determined whether the source database supports a function of capturing multi-table data in real time.

[0017] Optionally, obtaining a configuration file of a data change capture CDC synchronization task includes:

[0018] The configuration information of the CDC synchronization task is obtained, and a configuration file in a target format is generated based on the configuration information of the CDC synchronization task.

[0019] Optionally, also include:

[0020] In the case that the source database does not support the function of real-time capture of multi-table data or the change frequency of the multiple source tables does not meet the preset condition, constructing a second CDC synchronization task plan including multiple Source operators and multiple Sink operators according to the configuration file;

[0021] Execute the second CDC synchronization task plan, wherein the second CDC synchronization task plan is used to: synchronize the changed data of multiple source tables in the source database to the multiple Source operators, synchronize the changed data in the multiple Source operators to each of the Sink operators, and synchronize the changed data of each of the Sink operators to the destination table corresponding to each Sink operator in the destination database.

[0022] Optionally, synchronizing the changed data of the multiple source tables of the source database to the multiple Source operators, and synchronizing the changed data in the multiple Source operators to each of the Sink operators includes:

[0023] Constructing a plurality of subtasks in the second CDC synchronization task plan, wherein the subtasks correspond one-to-one to source tables in the source database;

[0024] Each subtask captures the change data of the corresponding source table in the source database in real time, and transmits the change data of the source table to a single Source operator;

[0025] Each of the Source operators synchronizes the changed data of the respective source tables to the Sink operators corresponding to each of the target tables.

[0026] Optionally, executing the second CDC synchronization task plan includes:

[0027] The second CDC synchronization task plan is sent to a third-party platform, and the third-party platform deploys the second CDC synchronization task plan to a target node whose resources meet preset conditions, so that the target node executes the second CDC synchronization task plan.

[0028] In a second aspect, an embodiment of the present application provides a database synchronization device, including:

[0029] An obtaining unit, configured to obtain a configuration file of a data change capture CDC synchronization task; wherein the configuration file includes a field mapping relationship between multiple source tables of a source database and multiple target tables of a target database;

[0030] A construction unit, configured to construct, according to the configuration file, a first CDC synchronization task plan including a single Source operator and multiple Sink operators, when the source database supports a function of capturing multi-table data in real time or the change frequency of the multiple source tables meets a preset condition;

[0031] An execution unit is used to execute the first CDC synchronization task plan, wherein the first CDC synchronization task plan is used to: synchronize the change data of multiple source tables in the source database to the single Source operator, synchronize the change data in the single Source operator to each of the Sink operators respectively, and synchronize the change data of each of the Sink operators to the destination table corresponding to each of the Sink operators in the destination database according to the field mapping relationship.

[0032] In a third aspect, an embodiment of the present application provides a database synchronization device, including:

[0033] CPU, memory, input and output interfaces, wired or wireless network interfaces, and power supply;

[0034] The memory is a short-term storage memory or a persistent storage memory;

[0035] The central processor is configured to communicate with the memory and execute instructions in the memory to perform the aforementioned database synchronization method.

[0036] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which includes instructions. When the instructions are executed on a computer, the computer executes the aforementioned database synchronization method.

[0037] In a fifth aspect, an embodiment of the present application provides a computer program product comprising instructions, which, when the computer program product is run on a computer, enables the computer to execute the aforementioned database synchronization method.

[0038] It can be seen from the above technical solution that the embodiment of the present application has the following advantages: a configuration file for a data change capture CDC synchronization task can be obtained, wherein the configuration file includes a field mapping relationship between multiple source tables of a source database and multiple destination tables of a destination database, and when the source database supports real-time capture of multi-table data or the change frequency of multiple source tables meets preset conditions, a first CDC synchronization task plan including a single Source operator and multiple Sink operators is constructed according to the configuration file, and the first CDC synchronization task plan is executed, wherein the first CDC synchronization task plan is used to: synchronize the change data of multiple source tables of the source database to a single Source operator, synchronize the change data in a single Source operator to each Sink operator respectively, and synchronize the change data of each Sink operator to the destination table corresponding to each Sink operator in the destination database according to the field mapping relationship. In the database synchronization method of this embodiment, each table only needs one subtask to capture the changed data and synchronize, and these subtasks share a parent JobManager, so there is no need to occupy a JobManager resource for each table. When a large number of tables need to be synchronized, the number of synchronization tasks for the entire database synchronization is small, the use of JobManager and TaskManager is small, the computing resources required for database synchronization are small, the resource consumption of database synchronization is small, and the resource usage of database synchronization is small. The entire database synchronization reduces the resource occupation of the synchronization task, so the resource waste of database synchronization is small. Further, the user's CDC synchronization task can be made easy to maintain and use. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] Figure 1 A schematic diagram of the architecture of a database synchronization system disclosed in an embodiment of the present application;

[0040] Figure 2 A flowchart of a database synchronization method disclosed in an embodiment of the present application;

[0041] Figure 3 A flowchart of another database synchronization method disclosed in an embodiment of the present application;

[0042] Figure 4 A flowchart of a method for executing a single-source multi-sink task disclosed in an embodiment of the present application;

[0043] Figure 5 A flowchart of another database synchronization method disclosed in an embodiment of the present application;

[0044] Figure 6 A flowchart of a method for executing a multi-source and multi-sink task disclosed in an embodiment of the present application;

[0045] Figure 7 A flowchart of another database synchronization method disclosed in an embodiment of the present application;

[0046] Figure 8 A flowchart of another database synchronization method disclosed in an embodiment of the present application;

[0047] Fig. 9 A schematic diagram of the structure of a database synchronization device disclosed in an embodiment of the present application;

[0048] Fig.10 A schematic diagram of the structure of another database synchronization device disclosed in an embodiment of the present application;

[0049] Fig.11 A schematic diagram of the structure of a database synchronization device disclosed in an embodiment of the present application. DETAILED DESCRIPTION

[0050] Embodiments of the present application provide a database synchronization method, a database synchronization apparatus, a database synchronization device, a computer-readable storage medium, and a computer program product including instructions or a computer program, for performing database synchronization while reducing resource waste in database synchronization.

[0051] See also Figure 1 , the architecture of the database synchronization system in the embodiment of the present application includes:

[0052] Database synchronization device 101, third-party platform 102 and target node 103. When performing database synchronization, database synchronization device 101 can be connected to third-party platform 102, third-party platform 102 can be connected to target node 103, database synchronization device 101 can obtain a configuration file of a CDC synchronization task, and when the source database supports the function of real-time capture of multi-table data or the change frequency of multiple source tables meets the preset conditions, a first CDC synchronization task plan including a single Source operator and multiple Sink operators is constructed according to the configuration file, and the first CDC synchronization task plan can be sent to the third-party platform 102, and the third-party platform 102 deploys the first CDC synchronization task plan to the target node 103 whose resources meet the preset conditions, so that the target node 103 executes the first CDC synchronization task plan.

[0053] Some key terms in the examples of this application are explained as follows:

[0054] CDC (Change Data Capture): A technology used to capture and track data changes in a database. It can transmit data changes to other systems or applications in real time to achieve functions such as data replication, data integration, and data synchronization.

[0055] FlinkCDC: An open source project developed by the Apache Flink community to implement CDC functionality. FlinkCDC provides a reliable and efficient way to capture and process database change events. It can be integrated with various common relational databases (such as MySQL, PostgreSQL, Oracle, etc.) and capture data changes by listening to database logs or polling. Once a data change event occurs, FlinkCDC converts the change event into a Flink data stream and sends it to the Flink job for real-time processing.

[0056] Flink: An open source stream processing and batch processing framework for processing large-scale data streams and batch data. It was originally developed by the Apache Software Foundation and became an Apache top-level project in 2014. Flink provides efficient, scalable, and fault-tolerant data processing capabilities that can handle real-time data streams and offline batch processing jobs.

[0057] JobManager: The master node of the Flink cluster, responsible for coordinating and managing the execution of the entire job.

[0058] TaskManager: A working node in a Flink cluster, responsible for executing specific tasks.

[0059] Flink operator: In a Flink task, an operator is a function or combination of functions that performs a specific operation. Operators are the core components of Flink data stream processing, used to transform, aggregate, filter, and other operations on input data to generate output data. The Source and Sink in this article are both operators in a FlinkCDC task.

[0060] Debezium: An open source distributed platform for capturing and converting database changes into event streams. It can monitor changes in multiple databases (such as MySQL, PostgreSQL, MongoDB, etc.) and convert these changes into consumable event streams so that other applications can use these events for real-time processing, analysis, and storage. FlinkCDC captures and processes database changes based on Debezium.

[0061] based on Figure 1See the database synchronization system shown in Figure 2 , Figure 2 A flowchart of a database synchronization method disclosed in an embodiment of the present application is provided, wherein the method comprises:

[0062] 201. Obtain a configuration file of a data change capture CDC synchronization task, where the configuration file includes field mapping relationships between multiple source tables of a source database and multiple target tables of a target database.

[0063] In this embodiment, when performing database synchronization, a configuration file of a data change capture CDC synchronization task may be obtained; wherein the configuration file includes field mapping relationships between multiple source tables of a source database and multiple target tables of a target database.

[0064] For example, there is a source database A and a destination database B, where A has two tables, table1 and table2, and B has two tables, table3 and table4. The data in table1 and table2 need to be synchronized to table3 and table4. In this case, you can first define a configuration file to specify the field mapping relationship between multiple source tables in the source database and multiple destination tables in the destination database.

[0065] 202. When the source database supports the function of capturing multi-table data in real time or the change frequency of multiple source tables meets the preset conditions, a first CDC synchronization task plan including a single Source operator and multiple Sink operators is constructed according to the configuration file.

[0066] After obtaining the configuration file of the data change capture CDC synchronization task, you can build the first CDC synchronization task plan including a single Source operator and multiple Sink operators according to the configuration file if the source database supports the real-time capture of multi-table data or the change frequency of multiple source tables meets the preset conditions.

[0067] It should be understood that databases that support real-time capture of multi-table data may include but are not limited to MySQL, Oracle, SQL Server, and PostgreSQL, and the change frequency refers to the frequency of changes in tables in the source database.

[0068] Specifically, for example, if the source database is a source database that supports the real-time capture of multi-table data function (including but not limited to MySQL, Oracle, SQLServer and PostgreSQL, etc.), or the change frequency of multiple source tables reaches a preset change frequency threshold, it can be determined that the source database supports the real-time capture of multi-table data function or the change frequency of multiple source tables meets the preset conditions. Then, if the source database supports the real-time capture of multi-table data function or the change frequency of multiple source tables meets the preset conditions, a first CDC synchronization task plan can be constructed according to the configuration file.

[0069] 203. Execute the first CDC synchronization task plan, where the first CDC synchronization task plan is used to: synchronize the changed data of multiple source tables in the source database to a single Source operator, synchronize the changed data in the single Source operator to each Sink operator respectively, and synchronize the changed data of each Sink operator to the target table corresponding to each Sink operator in the target database according to the field mapping relationship.

[0070] After constructing the first CDC synchronization task plan including a single Source operator and multiple Sink operators according to the configuration file, the first CDC synchronization task plan can be executed, where the first CDC synchronization task plan is used to: synchronize the changed data of multiple source tables in the source database to a single Source operator, synchronize the changed data in the single Source operator to each Sink operator respectively, and synchronize the changed data of each Sink operator to the destination table corresponding to each Sink operator in the destination database according to the field mapping relationship.

[0071] Specifically, the first CDC synchronization task plan can be executed, where the first CDC synchronization task plan is used to synchronize the changed data of table1 and table2 to a single Source operator, and then synchronize the changed data to the Sink operators of table3 and table4 respectively according to the field mapping relationship, and finally synchronize to the corresponding target table in the target database B.

[0072] It is worth mentioning that a single task can be used to synchronize multiple tables, which reduces the management of synchronization tasks and resource usage, avoids resource waste, and improves synchronization efficiency. Execute the first CDC synchronization task plan to synchronize the change data of multiple source tables in the source database to a single Source operator, and then synchronize the change data in the single Source operator to each Sink operator respectively, and finally synchronize the change data of each Sink operator to the destination table corresponding to each Sink operator in the destination database according to the field mapping relationship. This diversion method can reduce the resource load, improve task concurrency, and reduce synchronization time and resource usage. Secondly, it can make the user's CDC synchronization task easy to maintain and use.

[0073] In an embodiment of the present application, a configuration file for a data change capture CDC synchronization task can be obtained, wherein the configuration file includes a field mapping relationship between multiple source tables of a source database and multiple destination tables of a destination database. When the source database supports a real-time capture function of multi-table data or the change frequency of multiple source tables meets a preset condition, a first CDC synchronization task plan including a single Source operator and multiple Sink operators is constructed according to the configuration file, and the first CDC synchronization task plan is executed, wherein the first CDC synchronization task plan is used to: synchronize the change data of multiple source tables of the source database to a single Source operator, synchronize the change data in a single Source operator to each Sink operator respectively, and synchronize the change data of each Sink operator to the destination table corresponding to each Sink operator in the destination database according to the field mapping relationship. In the database synchronization method of this embodiment, each table only needs one subtask to capture the changed data and synchronize, and these subtasks share a parent JobManager, so there is no need to occupy a JobManager resource for each table. When a large number of tables need to be synchronized, the number of synchronization tasks for the entire database synchronization is small, the use of JobManager and TaskManager is small, the computing resources required for database synchronization are small, the resource consumption of database synchronization is small, and the resource usage of database synchronization is small. The entire database synchronization reduces the resource occupation of the synchronization task, so the resource waste of database synchronization is small. Further, the user's CDC synchronization task can be made easy to maintain and use.

[0074] In an embodiment of the present application, during the process of database synchronization, a configuration file for a data change capture CDC synchronization task can be obtained, and then based on whether the source database supports the function of real-time capture of multi-table data, or whether the change frequency of multiple source tables meets preset conditions, different CDC synchronization task plans for corresponding situations are constructed according to the configuration file. The CDC synchronization task plan may include a first CDC synchronization task plan with a single Source operator and multiple Sink operators, and / or a second CDC synchronization task plan with multiple Source operators and multiple Sink operators, which are described separately below.

[0075] 1. The CDC synchronization task plan includes the first CDC synchronization task plan with a single Source operator and multiple Sink operators.

[0076] In the embodiment of the present application, if the source database supports the function of real-time capture of multi-table data or the change frequency of multiple source tables meets the preset conditions, a first CDC synchronization task plan including a single Source operator and multiple Sink operators can be constructed according to the configuration file. For details, please refer to Figure 3 , Figure 3 This is a flow chart of another database synchronization method disclosed in an embodiment of the present application, the method comprising:

[0077] 301. Obtain configuration information of a CDC synchronization task, and generate a configuration file in a target format based on the configuration information of the CDC synchronization task, wherein the configuration file includes field mapping relationships between multiple source tables of a source database and multiple target tables of a target database.

[0078] Step 301 in this embodiment is similar to the aforementioned Figure 2 Step 201 in the illustrated embodiment is similar, and please refer to step 201 for details.

[0079] More specifically, the method for obtaining the configuration information of the CDC synchronization task may include but is not limited to the following methods:

[0080] (1) Directly obtain the configuration information of the CDC synchronization task;

[0081] Specifically, the configuration information of the CDC synchronization task can be obtained by calling an API interface or directly from a database.

[0082] (2) Obtain the configuration information of the CDC synchronization task through the interface.

[0083] Specifically, the configuration information of the CDC synchronization task can be obtained by the user setting the connection information of the source database and the destination database, selecting the source table and the destination table, setting the field mapping relationship, etc. on the visual interface, for example, using a visual tool to configure the CDC synchronization task.

[0084] 302. When the change frequency of multiple source tables meets the preset conditions, or when it is determined based on the configuration information of the source database that the source database supports the function of capturing multi-table data in real time, a first CDC synchronization task plan including a single Source operator and multiple Sink operators is constructed based on the configuration file.

[0085] After obtaining the configuration information of the CDC synchronization task and generating a configuration file in the target format based on the configuration information of the CDC synchronization task, if the change frequency of multiple source tables meets the preset conditions, or if it is determined based on the configuration information of the source database that the source database supports the function of capturing multi-table data in real time, a first CDC synchronization task plan including a single Source operator and multiple Sink operators can be constructed according to the configuration file.

[0086] It is important to understand that the change frequency refers to the frequency at which the tables in the source database change. In database synchronization, if the change frequency of the tables in the source database is too high, it may affect the performance of the synchronization task. Therefore, it is necessary to schedule and optimize the tasks according to the change frequency. For example, if the change frequency of a table is very low, it can be processed separately from the tables with higher change frequencies to reduce the pressure of the task and improve the synchronization performance. For example, suppose there are two tables, table1 and table2, in the source database. The change frequency of table1 is very low, while the change frequency of table2 is very high. When constructing the synchronization task, you can consider splitting table1 and table2 into two different tasks, processing table1 together with other tables with lower change frequencies, and processing table2 together with other tables with higher change frequencies, so as to optimize the performance of the synchronization task.

[0087] To be more specific, for example, suppose there are three tables in the source database, namely table1, table2, and table3, and three tables in the destination database, namely dest_table1, dest_table2, and dest_table3. The configuration file defines that fields a and b in table1 are mapped to fields x and y in dest_table1, fields c and d in table2 are mapped to fields x and z in dest_table2, and fields e and f in table3 are mapped to fields y and z in dest_table3. At this point, if the change frequency of table1, table2, and table3 meets the preset conditions, a CDC synchronization task plan including a single Source operator and multiple Sink operators can be constructed according to the configuration file to synchronize the changed data of the three tables to the corresponding destination tables.

[0088] It should also be understood that databases that support real-time capture of multi-table data may include but are not limited to MySQL, Oracle, SQL Server, and PostgreSQL.

[0089] 303. Execute the first CDC synchronization task plan, where the first CDC synchronization task plan is used to: synchronize the changed data of multiple source tables in the source database to a single Source operator, synchronize the changed data in the single Source operator to each Sink operator respectively, and synchronize the changed data of each Sink operator to the target table corresponding to each Sink operator in the target database according to the field mapping relationship.

[0090] The method for executing the first CDC synchronization task plan may include but is not limited to the following method:

[0091] (1) Sending the first CDC synchronization task plan to a third-party platform, and the third-party platform deploys the first CDC synchronization task plan to a target node whose resources meet preset conditions, so that the target node executes the first CDC synchronization task plan.

[0092] Specifically, the previous steps only build the execution plan of the FlinkCDC task. After the execution task is finally submitted to Yarn, the CDC synchronization task is actually executed to capture the changed data in real time and synchronize it to the destination database.

[0093] More specifically, the first CDC synchronization task plan can be submitted to a third-party platform, which can deploy the task to a target node that meets the preset conditions. For example, the first CDC synchronization task plan can be submitted to an Apache Flink cluster, which can be deployed by the Flink cluster manager to a TaskManager node that meets the resource requirements to execute the task.

[0094] It is worth mentioning that deploying the first CDC synchronization task plan to the node that meets the resource requirements can improve the execution efficiency and speed of the task, and also reduce the error rate and failure rate of the task.

[0095] (2) The database synchronization device executes the first CDC synchronization task plan by itself.

[0096] Specifically, the database synchronization device may execute the first CDC synchronization task plan by itself.

[0097] It is worth mentioning that, since some database synchronization devices have the ability to execute CDC synchronization tasks by themselves without the need for other tools or platforms, the convenience of database synchronization can be improved by having the database synchronization device execute the first CDC synchronization task plan by itself.

[0098] The method for synchronizing the changed data of multiple source tables in the source database to a single Source operator and synchronizing the changed data in a single Source operator to each Sink operator may include but is not limited to the following methods:

[0099] (1) Classification synchronization based on the target table:

[0100] Specifically, the change data of multiple source tables in the source database can be captured in real time, and the change data of multiple source tables in the source database can be transferred to a single Source operator. Then, the single Source operator classifies the change data of multiple source tables in the source database according to multiple destination tables in the destination database to obtain the change data corresponding to each destination table, and finally synchronizes the change data corresponding to each destination table to the Sink operator corresponding to each destination table. For example, the change data of the user information table, order information table, and product information table can be synchronized to the Sink operators corresponding to the user information table, order information table, and product information table, respectively.

[0101] For more details, please refer to Figure 4 , Figure 4 A flowchart of a method for executing a single-source multi-sink task disclosed in an embodiment of the present application is shown in FIG. Figure 4 It can be seen that Debezium can capture changes in multiple tables configured in the CDC task in real time, pass the changed data to the Source operator, and then synchronize the data to the downstream Sink operator and save it to the destination database after data diversion and mapping.

[0102] It is worth mentioning that the classification synchronization method based on the target table can ensure the accuracy of synchronization and avoid data synchronization errors. Secondly, if the source database supports the function of real-time capture of multi-table data or the change frequency of multiple source tables meets the preset conditions, the resource usage of CDC synchronization tasks can be reduced, avoiding the problem of creating multiple synchronization tasks that require a large amount of computing resources.

[0103] (2) Data distribution based on partition key:

[0104] Specifically, the data of the source table can be distributed according to the specified partition key, and then the data with the same partition key can be synchronized to the same Sink operator. For example, the user table can be partitioned according to the user region, and then the user data of each region can be synchronized to the corresponding Sink operator.

[0105] It is worth mentioning that the partition key-based data distribution method can improve synchronization performance and reduce data transmission and storage overhead.

[0106] (3) Data filtering based on data type:

[0107] Specifically, you can filter the data in the source table that meets the specified data type requirements, and then synchronize the data that meets the requirements to the corresponding Sink operator. For example, only synchronize the order data with the order status of paid or completed to the order table, and do not synchronize the data of other order statuses.

[0108] It is worth mentioning that the method of filtering data based on data type can avoid unnecessary data transmission and storage and improve synchronization efficiency.

[0109] In this embodiment, a configuration file for a data change capture CDC synchronization task can be obtained, wherein the configuration file includes a field mapping relationship between multiple source tables of a source database and multiple destination tables of a destination database. When the source database supports a real-time capture function for multiple-table data or the change frequency of multiple source tables meets a preset condition, a first CDC synchronization task plan including a single Source operator and multiple Sink operators is constructed according to the configuration file, and the first CDC synchronization task plan is executed, wherein the first CDC synchronization task plan is used to: synchronize the change data of multiple source tables of the source database to a single Source operator, synchronize the change data in a single Source operator to each Sink operator respectively, and synchronize the change data of each Sink operator to the destination table corresponding to each Sink operator in the destination database according to the field mapping relationship. In the database synchronization method of this embodiment, each table only needs one subtask to capture the changed data and synchronize, and these subtasks share a parent JobManager, so there is no need to occupy the resources of a JobManager for each table. When a large number of tables need to be synchronized, the number of synchronization tasks for the entire database synchronization is small, the use of JobManager and TaskManager is small, the computing resources required for database synchronization are small, the resource consumption of database synchronization is small, and the resource usage of the entire database synchronization is reduced. Therefore, the resource waste of database synchronization is small. Further, the user's CDC synchronization task can be made easy to maintain and use. Then, the first CDC synchronization task plan can be deployed to the node that meets the resource requirements, which can improve the execution efficiency and speed of the task, and also reduce the error rate and failure rate of the task. Furthermore, the first CDC synchronization task plan can be executed by the database synchronization device itself, which can improve the convenience of database synchronization. Finally, the classification synchronization method based on the target table can ensure the synchronization accuracy and avoid data synchronization errors.

[0110] 2. The CDC synchronization task plan includes the second CDC synchronization task plan of multiple Source operators and multiple Sink operators.

[0111] In the embodiment of the present application, if the source database does not support the function of real-time capture of multi-table data or the change frequency of multiple source tables does not meet the preset conditions, a second CDC synchronization task plan including multiple Source operators and multiple Sink operators can be constructed according to the configuration file. For details, please refer to Figure 5 , Figure 5 This is a flowchart of another database synchronization method disclosed in an embodiment of the present application, the method comprising:

[0112] 501. Obtain configuration information of a CDC synchronization task, and generate a configuration file in a target format based on the configuration information of the CDC synchronization task, wherein the configuration file includes field mapping relationships between multiple source tables of a source database and multiple target tables of a target database.

[0113] Step 501 in this embodiment is similar to the aforementioned Figure 3 Step 301 in the illustrated embodiment is similar and will not be described in detail here.

[0114] 502. When the change frequency of multiple source tables does not meet the preset conditions, or when it is determined according to the configuration information of the source database that the source database does not support the function of capturing multi-table data in real time, a second CDC synchronization task plan including multiple Source operators and multiple Sink operators is constructed according to the configuration file.

[0115] After obtaining the configuration information of the CDC synchronization task and generating a configuration file in the target format based on the configuration information of the CDC synchronization task, if the change frequency of multiple source tables does not meet the preset conditions, or if it is determined based on the configuration information of the source database that the source database does not support the function of capturing multi-table data in real time, a second CDC synchronization task plan including multiple Source operators and multiple Sink operators can be constructed based on the configuration file.

[0116] Specifically, databases that do not support real-time capture of single-table databases may include but are not limited to MongoDB, etc. If the change frequency of the multiple source tables does not reach the preset change frequency threshold, it is determined that the change frequency of the multiple source tables does not meet the preset condition.

[0117] 503. Execute the second CDC synchronization task plan, where the second CDC synchronization task plan is used to: synchronize the changed data of multiple source tables in the source database to multiple Source operators, synchronize the changed data in multiple Source operators to each Sink operator, and synchronize the changed data of each Sink operator to the destination table corresponding to each Sink operator in the destination database.

[0118] The method for executing the second CDC synchronization task plan may include but is not limited to the following method:

[0119] (1) Sending the second CDC synchronization task plan to a third-party platform, and the third-party platform deploys the second CDC synchronization task plan to a target node whose resources meet preset conditions, so that the target node executes the second CDC synchronization task plan.

[0120] Specifically, the previous steps only build the execution plan of the FlinkCDC task. After the execution task is finally submitted to Yarn, the CDC synchronization task is actually executed to capture the changed data in real time and synchronize it to the destination database.

[0121] More specifically, the second CDC synchronization task plan can be submitted to a third-party platform, which can deploy it to a target node that meets the preset conditions to execute the task. For example, the second CDC synchronization task plan can be submitted to an Apache Flink cluster, which can be deployed by the Flink cluster manager to a TaskManager node that meets the resource requirements to execute the task.

[0122] It is worth mentioning that deploying the second CDC synchronization task plan to the node that meets the resource requirements can improve the execution efficiency and speed of the task, and also reduce the error rate and failure rate of the task.

[0123] (2) The database synchronization device executes the second CDC synchronization task plan by itself.

[0124] Specifically, the database synchronization device may execute the second CDC synchronization task plan by itself.

[0125] It is worth mentioning that since some database synchronization devices have the ability to execute CDC synchronization tasks by themselves without the need for other tools or platforms, the convenience of database synchronization can be improved by having the database synchronization device execute the second CDC synchronization task plan by itself.

[0126] The method for synchronizing the changed data of multiple source tables in the source database to multiple Source operators and synchronizing the changed data in multiple Source operators to each Sink operator may include but is not limited to the following methods:

[0127] (1) Synchronize the changed data of multiple source tables in the source database to multiple Source operators, and synchronize the changed data in multiple Source operators to each Sink operator.

[0128] Specifically, multiple subtasks can be constructed in the second CDC synchronization task plan, where the subtasks correspond one-to-one to the source tables in the source database. Then, each subtask captures the change data of the corresponding source table in the source database in real time, and transfers the change data of the source table to a single Source operator. Finally, each Source operator synchronizes the change data of its own source table to the Sink operator corresponding to each destination table.

[0129] For more details, please refer to Figure 6 , Figure 6 A flowchart of a method for executing a multi-source and multi-sink task disclosed in an embodiment of the present application is shown in FIG. Figure 6 It can be seen that in the same CDC task, multiple subtasks will be constructed. Each subtask captures the data changes of a table in real time, parses the captured data, synchronizes it to the downstream Sink operator and saves it to the destination database.

[0130] For example, there is a source database that contains three tables A, B, and C, and the target database also contains three tables A, B, and C, and there is a field mapping relationship between these three tables. If the function of real-time capture of multi-table data is not supported, three subtasks can be constructed, each of which corresponds to a source table, to capture the change data of source tables A, B, and C in real time, and transfer the change data of source tables A, B, and C to a single Source operator. Finally, each Source operator synchronizes the change data of its own source table to the Sink operator corresponding to each target table.

[0131] It is worth mentioning that, because each subtask corresponds to a source table in the source database one by one, each subtask will only capture the change data of the corresponding source table, and pass these data to a single Source operator, and then each Source operator will synchronize the change data of the respective source table to the Sink operator corresponding to each destination table. Therefore, the data of different source tables will not be mixed together and synchronized to the same destination table, avoiding the problem of data missynchronization. Secondly, when the source database does not support the function of real-time capture of multi-table data or the change frequency of multiple source tables does not meet the preset conditions, when the number of tables that need to be synchronized by the database is large, if the single-table synchronization method of the prior art is adopted, it is necessary to create hundreds of synchronization tasks, which is not easy to maintain and use, and also requires a large amount of computing resources. By capturing the change data of multiple tables at the same time in this embodiment, the data of multiple tables can be synchronized to the same task, which can reduce the number of tasks and reduce the consumption of computing resources by the number of tasks. Furthermore, each subtask is only responsible for the capture and processing of the change data of a single source table, which can avoid the mutual influence between multiple source tables and reduce the risk of task failure. Finally, the mapping relationship between the source table and the target table is also clearer, easy to use, manage and maintain.

[0132] (2) First, synchronize the changed data of multiple source tables in the source database to a unified Source operator, and then synchronize the changed data in multiple Source operators to each Sink operator by the unified Source operator.

[0133] Specifically, first, a unified Source operator can be used to capture the changed data of the source table, and then the data can be diverted to multiple different Source operators. The changed data of these Source operators are then synchronized to their corresponding Sink operators, and finally the changed data of the Sink operators are synchronized to the destination tables corresponding to each Sink operator in the destination database.

[0134] It is worth mentioning that by capturing the changed data of the source table through a unified Source operator, the data flow can be controlled more flexibly, which improves the scalability and maintainability of the algorithm. Because if the source table is changed or added, only some simple configurations need to be done in the unified Source operator, without rebuilding multiple subtasks.

[0135] In this embodiment, a configuration file for a data change capture CDC synchronization task can be obtained, wherein the configuration file includes a field mapping relationship between multiple source tables of a source database and multiple destination tables of a destination database. When the source database supports a real-time capture function for multiple-table data or the change frequency of multiple source tables meets a preset condition, a first CDC synchronization task plan including a single Source operator and multiple Sink operators is constructed according to the configuration file, and the first CDC synchronization task plan is executed, wherein the first CDC synchronization task plan is used to: synchronize the change data of multiple source tables of the source database to a single Source operator, synchronize the change data in a single Source operator to each Sink operator respectively, and synchronize the change data of each Sink operator to the destination table corresponding to each Sink operator in the destination database according to the field mapping relationship. In the database synchronization method of this embodiment, each table only needs one subtask to capture the changed data and synchronize, and these subtasks share a parent JobManager, so there is no need to occupy the resources of a JobManager for each table. When a large number of tables need to be synchronized, the number of synchronization tasks for the entire database synchronization is small, the use of JobManager and TaskManager is small, the computing resources required for database synchronization are small, the resource consumption of database synchronization is small, and the resource usage of the entire database synchronization is reduced. Therefore, the resource waste of database synchronization is small. Further, the user's CDC synchronization task can be made easy to maintain and use. Then, the second CDC synchronization task plan can be deployed to the node that meets the resource requirements, which can improve the execution efficiency and speed of the task, and also reduce the error rate and failure rate of the task. Furthermore, the second CDC synchronization task plan can be executed by the database synchronization device itself, which can improve the convenience of database synchronization. Furthermore, each subtask corresponds to a source table in the source database one by one. Each subtask will only capture the change data of the corresponding source table and pass this data to a single Source operator. Each Source operator will then synchronize the change data of its own source table to the Sink operator corresponding to each destination table. Therefore, data from different source tables will not be mixed together and synchronized to the same destination table, avoiding the problem of missynchronization of data. Furthermore, the change data of multiple tables can be captured at the same time, and the data of multiple tables can be synchronized to the same task, which can reduce the number of tasks and the consumption of computing resources by the number of tasks. Furthermore, each subtask is only responsible for capturing and processing the change data of a single source table, which can avoid mutual influence between multiple source tables and reduce the risk of task failure. Finally, the mapping relationship between the source table and the target table is relatively clear, easy to use, manage and maintain.

[0136] 3. The CDC synchronization task plan includes the first CDC synchronization task plan with a single Source operator and multiple Sink operators, and the second CDC synchronization task plan with multiple Source operators and multiple Sink operators.

[0137] In the embodiment of the present application, if the source database supports the function of real-time capture of multi-table data or the change frequency of multiple source tables meets the preset conditions, a first CDC synchronization task plan including a single Source operator and multiple Sink operators can be constructed according to the configuration file, and if the source database does not support the function of real-time capture of multi-table data or the change frequency of multiple source tables does not meet the preset conditions, a second CDC synchronization task plan including multiple Source operators and multiple Sink operators can be constructed according to the configuration file. For details, please refer to Figure 7 , Figure 7 This is a flowchart of another database synchronization method disclosed in an embodiment of the present application, the method comprising:

[0138] 701. Obtain configuration information of a CDC synchronization task, and generate a configuration file in a target format based on the configuration information of the CDC synchronization task, wherein the configuration file includes field mapping relationships between multiple source tables of a source database and multiple destination tables of a destination database.

[0139] Step 701 in this embodiment is similar to the aforementioned Figure 3 Step 301 in the illustrated embodiment is similar, and please refer to step 301 for details.

[0140] For more details, please refer to Figure 8 , Figure 8 A flowchart of another database synchronization method disclosed in an embodiment of the present application is shown in FIG. Figure 8 It can be seen that when performing database synchronization, the following three steps can be performed:

[0141] (1) The page saves the CDC database synchronization configuration information;

[0142] Specifically, when performing database synchronization, the parameters required for preparing CDC whole database synchronization, such as the configuration of data source and data destination, database connection information, and field mapping relationship between tables, can be obtained by the user input or selected on the page (visual interface). After the user configuration is completed, these configuration information can be saved and configured to the business database.

[0143] (2) Submit the CDC whole database synchronization task;

[0144] Specifically, after the synchronization task is configured, just save the configuration to the business database. If you need to start the task, you need to click Run. After clicking Run, the background will read the configuration of the business database, generate a configuration file (Json file) and save it to the specified path of the server, and use a specific tool (specially used to process CDC synchronization tasks) to submit the task.

[0145] (3) Analyze the CDC whole database synchronization task configuration;

[0146] Specifically, the configuration file (Json file) can be parsed through the specific tool (specially used to process CDC synchronization tasks), and the content can be saved to the memory for use.

[0147] 702. Determine whether the source database supports the function of real-time capture of multi-table data or whether the change frequency of multiple source tables meets the preset conditions. If so, execute steps 703 and 704. If not, execute steps 705 and 706.

[0148] After obtaining the configuration information of the CDC synchronization task and generating a configuration file in the target format based on the configuration information of the CDC synchronization task, it can be determined whether the source database supports the function of capturing multi-table data in real time or whether the change frequency of multiple source tables meets the preset conditions.

[0149] For an example of determining whether the source database supports real-time capture of multi-table data, please continue to refer to Figure 8 ,Depend on Figure 8 It can be seen that after parsing the CDC whole database synchronization task configuration, you can use FlinkCDC to build tasks. Specifically, you can build single-Source or multi-Source tasks based on whether the data source supports real-time capture of multi-table data. The single-Source task represents the first CDC synchronization task plan of a single Source operator and multiple Sink operators, and the multi-Source task represents the second CDC synchronization task plan of multiple Source operators and multiple Sink operators.

[0150] 703. When the source database supports the function of capturing multi-table data in real time or the change frequency of multiple source tables meets the preset conditions, a first CDC synchronization task plan including a single Source operator and multiple Sink operators is constructed according to the configuration file.

[0151] After determining whether the source database supports the function of real-time capture of multi-table data or whether the change frequency of multiple source tables meets the preset conditions, if the source database supports the function of real-time capture of multi-table data or the change frequency of multiple source tables meets the preset conditions, a first CDC synchronization task plan including a single Source operator and multiple Sink operators can be constructed according to the configuration file.

[0152] 704. Execute the first CDC synchronization task plan, where the first CDC synchronization task plan is used to: synchronize the changed data of multiple source tables in the source database to a single Source operator, synchronize the changed data in the single Source operator to each Sink operator respectively, and synchronize the changed data of each Sink operator to the target table corresponding to each Sink operator in the target database according to the field mapping relationship.

[0153] Steps 703 and 704 in this embodiment are similar to those in the previous embodiment. Figure 3 Steps 302 and 303 in the illustrated embodiment are similar and will not be described in detail herein.

[0154] For more details, please continue to refer to Figure 8 ,Depend on Figure 8 As you can see, if the source database supports real-time capture of multi-table data, you can build a single Source operator to process and map the data it receives, and then build multiple Sink operators to synchronize the data to different tables in the destination database. Finally, submit the CDC task for execution.

[0155] 705. When the source database does not support the function of capturing multi-table data in real time or the change frequency of multiple source tables does not meet the preset conditions, a second CDC synchronization task plan including multiple Source operators and multiple Sink operators is constructed according to the configuration file.

[0156] After determining whether the source database supports the function of real-time capture of multi-table data or whether the change frequency of multiple source tables meets the preset conditions, if the source database does not support the function of real-time capture of multi-table data or the change frequency of multiple source tables does not meet the preset conditions, a second CDC synchronization task plan including multiple Source operators and multiple Sink operators can be constructed according to the configuration file.

[0157] 706. Execute the second CDC synchronization task plan, where the second CDC synchronization task plan is used to: synchronize the changed data of multiple source tables in the source database to multiple Source operators, synchronize the changed data in multiple Source operators to each Sink operator, and synchronize the changed data of each Sink operator to the destination table corresponding to each Sink operator in the destination database.

[0158] Steps 705 and 706 in this embodiment are similar to those in the previous Figure 5 Steps 502 and 503 in the illustrated embodiment are similar and will not be described in detail herein.

[0159] For more details, please continue to refer to Figure 8 ,Depend on Figure 8It can be seen that if it is determined that the data source does not support real-time capture of multi-table data, a multi-Source task is constructed, that is, to find the corresponding Sink and do field mapping, and then build multiple Sinks and submit them to execute the FlinkCDC task.

[0160] In an embodiment of the present application, a configuration file for a data change capture CDC synchronization task can be obtained, wherein the configuration file includes a field mapping relationship between multiple source tables of a source database and multiple destination tables of a destination database. When the source database supports a real-time capture function of multi-table data or the change frequency of multiple source tables meets a preset condition, a first CDC synchronization task plan including a single Source operator and multiple Sink operators is constructed according to the configuration file, and the first CDC synchronization task plan is executed, wherein the first CDC synchronization task plan is used to: synchronize the change data of multiple source tables of the source database to a single Source operator, synchronize the change data in a single Source operator to each Sink operator respectively, and synchronize the change data of each Sink operator to the destination table corresponding to each Sink operator in the destination database according to the field mapping relationship. In the database synchronization method of this embodiment, each table only needs one subtask to capture the changed data and synchronize, and these subtasks share a parent JobManager, so there is no need to occupy the resources of a JobManager for each table. When a large number of tables need to be synchronized, the number of synchronization tasks for the entire database synchronization is small, the use of JobManager and TaskManager is small, the computing resources required for database synchronization are small, the resource consumption of database synchronization is small, and the resource usage of the entire database synchronization is reduced. Therefore, the resource waste of database synchronization is small. Further, the user's CDC synchronization task can be made easy to maintain and use. Then, the first CDC synchronization task plan and / or the second CDC synchronization task plan can be deployed to the node that meets the resource requirements, which can improve the execution efficiency and speed of the task, and also reduce the error rate and failure rate of the task. Furthermore, the first CDC synchronization task plan and / or the second CDC synchronization task plan can be executed by the database synchronization device itself, which can improve the convenience of database synchronization. Furthermore, for the first CDC synchronization task plan, the classification synchronization method based on the target table can ensure the synchronization accuracy, avoid data missynchronization, and reduce the resource usage of the CDC synchronization task when the source database supports the function of real-time capture of multi-table data or the change frequency of multiple source tables meets the preset conditions, avoiding the problem of creating multiple synchronization tasks requiring a large amount of computing resources. Furthermore, for the second CDC synchronization task plan, each subtask corresponds to a source table in the source database one by one, and each subtask only captures the change data of the corresponding source table, and passes these data to a single Source operator, and then each Source operator synchronizes the change data of its own source table to the Sink operator corresponding to each target table. Therefore, the data of different source tables will not be mixed together and synchronized to the same target table, avoiding the problem of data missynchronization. And the change data of multiple tables can be captured at the same time, and the data of multiple tables can be synchronized to the same task, which can reduce the number of tasks and reduce the consumption of computing resources by the number of tasks.And each subtask is only responsible for capturing and processing the change data of a single source table, which can avoid mutual influence between multiple source tables and reduce the risk of task failure. And the mapping relationship between the source table and the target table is relatively clear, easy to use, manage and maintain. In short, the CDC synchronization task plan of this embodiment (including the first CDC synchronization task plan of a single Source operator and multiple Sink operators, and / or the second CDC synchronization task plan of multiple Source operators and multiple Sink operators) all belong to multi-table synchronization, that is, multiple tables perform CDC synchronization in the same task. Specifically, the change data of multiple tables can be captured and synchronized to the destination database at the same time in one CDC synchronization task, which can reduce the resource usage of the CDC synchronization task, avoid resource waste, and make the user's CDC synchronization task easy to maintain and use.

[0161] The above describes the database synchronization method in the embodiment of the present application. The following describes the database synchronization device in the embodiment of the present application. Fig. 9 , an embodiment of the database synchronization device in the embodiment of the present application includes:

[0162] An obtaining unit 901 is used to obtain a configuration file of a data change capture CDC synchronization task; wherein the configuration file includes a field mapping relationship between multiple source tables of a source database and multiple target tables of a target database;

[0163] A construction unit 902 is used to construct a first CDC synchronization task plan including a single Source operator and multiple Sink operators according to the configuration file when the source database supports a function of capturing multi-table data in real time or the change frequency of the multiple source tables meets a preset condition;

[0164] The execution unit 903 is used to execute the first CDC synchronization task plan, wherein the first CDC synchronization task plan is used to: synchronize the change data of multiple source tables in the source database to the single Source operator, synchronize the change data in the single Source operator to each of the Sink operators respectively, and synchronize the change data of each of the Sink operators to the destination table corresponding to each of the Sink operators in the destination database according to the field mapping relationship.

[0165] In an embodiment of the present application, a configuration file for a data change capture CDC synchronization task can be obtained, wherein the configuration file includes a field mapping relationship between multiple source tables of a source database and multiple destination tables of a destination database. When the source database supports a real-time capture function of multi-table data or the change frequency of multiple source tables meets a preset condition, a first CDC synchronization task plan including a single Source operator and multiple Sink operators is constructed according to the configuration file, and the first CDC synchronization task plan is executed, wherein the first CDC synchronization task plan is used to: synchronize the change data of multiple source tables of the source database to a single Source operator, synchronize the change data in a single Source operator to each Sink operator respectively, and synchronize the change data of each Sink operator to the destination table corresponding to each Sink operator in the destination database according to the field mapping relationship. In the database synchronization method of this embodiment, each table only needs one subtask to capture the changed data and synchronize, and these subtasks share a parent JobManager, so there is no need to occupy a JobManager resource for each table. When a large number of tables need to be synchronized, the number of synchronization tasks for the entire database synchronization is small, the use of JobManager and TaskManager is small, the computing resources required for database synchronization are small, the resource consumption of database synchronization is small, and the resource usage of database synchronization is small. The entire database synchronization reduces the resource occupation of the synchronization task, so the resource waste of database synchronization is small. Further, the user's CDC synchronization task can be made easy to maintain and use.

[0166] The following is a detailed description of the database synchronization device in the embodiment of the present application. Fig.10 Another embodiment of the database synchronization device in the embodiment of the present application includes:

[0167] An obtaining unit 1001 is used to obtain a configuration file of a data change capture CDC synchronization task; wherein the configuration file includes a field mapping relationship between multiple source tables of a source database and multiple target tables of a target database;

[0168] A construction unit 1002 is used to construct a first CDC synchronization task plan including a single Source operator and multiple Sink operators according to the configuration file when the source database supports a function of capturing multi-table data in real time or the change frequency of the multiple source tables meets a preset condition;

[0169] The execution unit 1003 is used to execute the first CDC synchronization task plan, wherein the first CDC synchronization task plan is used to: synchronize the change data of multiple source tables in the source database to the single Source operator, synchronize the change data in the single Source operator to each of the Sink operators respectively, and synchronize the change data of each of the Sink operators to the destination table corresponding to each of the Sink operators in the destination database according to the field mapping relationship.

[0170] The execution unit 1003 is specifically used to capture the change data of multiple source tables of the source database in real time, and transfer the change data of multiple source tables of the source database to a single Source operator, and the single Source operator classifies the change data of multiple source tables of the source database according to the multiple target tables of the target database to obtain the change data corresponding to each of the target tables; and synchronizes the change data corresponding to each of the target tables to the Sink operator corresponding to each of the target tables.

[0171] The execution unit 1003 is specifically used to send the first CDC synchronization task plan to a third-party platform, and the third-party platform deploys the first CDC synchronization task plan to a target node whose resources meet preset conditions, so that the target node executes the first CDC synchronization task plan.

[0172] The database synchronization device also includes:

[0173] The determining unit 1004 is configured to determine whether the source database supports a function of capturing multi-table data in real time according to the configuration information of the source database.

[0174] The obtaining unit 1001 is specifically configured to obtain configuration information of the CDC synchronization task, and generate a configuration file in a target format based on the configuration information of the CDC synchronization task.

[0175] The construction unit 1002 is further configured to construct, according to the configuration file, a second CDC synchronization task plan including multiple Source operators and multiple Sink operators when the source database does not support a function of capturing multiple table data in real time or the change frequency of the multiple source tables does not meet the preset condition;

[0176] The execution unit 1003 is also used to execute the second CDC synchronization task plan, wherein the second CDC synchronization task plan is used to: synchronize the changed data of multiple source tables in the source database to multiple Source operators, synchronize the changed data in the multiple Source operators to each of the Sink operators, and synchronize the changed data of each of the Sink operators to the destination table corresponding to each Sink operator in the destination database.

[0177] The execution unit 1003 is specifically used to construct multiple subtasks in the second CDC synchronization task plan, wherein the subtasks correspond one-to-one to the source tables in the source database, and each subtask captures the change data of the corresponding source table in the source database in real time, and transfers the change data of the source table to a single Source operator, and each Source operator synchronizes the change data of its own source table to the Sink operator corresponding to each destination table.

[0178] The execution unit 1003 is specifically used to send the second CDC synchronization task plan to a third-party platform, and the third-party platform deploys the second CDC synchronization task plan to a target node whose resources meet preset conditions, so that the target node executes the second CDC synchronization task plan.

[0179] In this embodiment, each unit in the database synchronization device performs the above Figures 2 to 8 The operation of the database synchronization device in the illustrated embodiment will not be described in detail here.

[0180] See below Fig.11 In the embodiment of the present application, an embodiment of the database synchronization device 1100 includes:

[0181] CPU 1101, memory 1105, input / output interface 1104, wired or wireless network interface 1103 and power supply 1102;

[0182] The memory 1105 is a temporary storage memory or a permanent storage memory;

[0183] The CPU 1101 is configured to communicate with the memory 1105 and execute the instructions in the memory 1105 to perform the aforementioned Figures 2 to 8 The method in the illustrated embodiment.

[0184] The embodiment of the present application also provides a computer-readable storage medium, the computer-readable storage medium includes instructions, when the instructions are executed on a computer, the computer executes the aforementioned Figures 2 to 8 The method in the illustrated embodiment.

[0185] The present application also provides a computer program product including instructions, which, when executed on a computer, enables the computer to execute the aforementioned Figures 2 to 8 The method in the illustrated embodiment.

[0186] 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.

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

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

[0189] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0190] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

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

Claims

1. A database synchronization method, characterized in that: include: Get the configuration file of the data change capture CDC synchronization task; The configuration file includes field mapping relationships between multiple source tables of the source database and multiple target tables of the target database; In the case where the source database supports a function of capturing multi-table data in real time or the change frequency of the multiple source tables meets a preset condition, constructing a first CDC synchronization task plan including a single Source operator and multiple Sink operators according to the configuration file; Execute the first CDC synchronization task plan, where the first CDC synchronization task plan is used to: synchronize the changed data of multiple source tables in the source database to a single Source operator, synchronize the changed data in the single Source operator to each of the Sink operators respectively, and synchronize the changed data of each of the Sink operators to the destination table corresponding to each of the Sink operators in the destination database according to the field mapping relationship.

2. The method according to claim 1, characterized in that The step of synchronizing the changed data of multiple source tables of the source database to the single Source operator, and synchronizing the changed data in the single Source operator to each of the Sink operators, includes: Capturing the changed data of multiple source tables of the source database in real time, and transferring the changed data of multiple source tables of the source database to a single Source operator; A single Source operator classifies the change data of multiple source tables of the source database according to multiple target tables of the target database to obtain the change data corresponding to each target table; and synchronizes the change data corresponding to each target table to the Sink operator corresponding to each target table.

3. The method according to claim 1, characterized in that The executing the first CDC synchronization task plan includes: The first CDC synchronization task plan is sent to a third-party platform, and the third-party platform deploys the first CDC synchronization task plan to a target node whose resources meet preset conditions, so that the target node executes the first CDC synchronization task plan.

4. The method according to claim 1, characterized in that: In the case where the source database supports the function of real-time capture of multi-table data, before constructing a first CDC synchronization task plan including a single Source operator and multiple Sink operators according to the configuration file, the method further includes: According to the configuration information of the source database, it is determined whether the source database supports a function of capturing multi-table data in real time.

5. The method according to claim 1, characterized in that The configuration file for obtaining the data change capture CDC synchronization task includes: The configuration information of the CDC synchronization task is obtained, and a configuration file in a target format is generated based on the configuration information of the CDC synchronization task.

6. The method according to claim 1, characterized in that Also includes: In the case that the source database does not support the function of real-time capture of multi-table data or the change frequency of the multiple source tables does not meet the preset condition, constructing a second CDC synchronization task plan including multiple Source operators and multiple Sink operators according to the configuration file; Execute the second CDC synchronization task plan, wherein the second CDC synchronization task plan is used to: synchronize the changed data of multiple source tables in the source database to the multiple Source operators, synchronize the changed data in the multiple Source operators to each of the Sink operators, and synchronize the changed data of each of the Sink operators to the destination table corresponding to each Sink operator in the destination database.

7. The method according to claim 6, characterized in that The step of synchronizing the changed data of the multiple source tables of the source database to the multiple Source operators, and synchronizing the changed data in the multiple Source operators to each of the Sink operators includes: Constructing a plurality of subtasks in the second CDC synchronization task plan, wherein the subtasks correspond one-to-one to source tables in the source database; Each subtask captures the change data of the corresponding source table in the source database in real time, and transmits the change data of the source table to a single Source operator; Each of the Source operators synchronizes the changed data of the respective source tables to the Sink operators corresponding to each of the target tables.

8. The method according to claim 6, characterized in that The executing the second CDC synchronization task plan includes: The second CDC synchronization task plan is sent to a third-party platform, and the third-party platform deploys the second CDC synchronization task plan to a target node whose resources meet preset conditions, so that the target node executes the second CDC synchronization task plan.

9. A database synchronization device, characterized in that: include: Get unit, used to get the configuration file of data change capture CDC synchronization task; The configuration file includes field mapping relationships between multiple source tables of the source database and multiple target tables of the target database; A construction unit, configured to construct, according to the configuration file, a first CDC synchronization task plan including a single Source operator and multiple Sink operators, when the source database supports a function of capturing multi-table data in real time or the change frequency of the multiple source tables meets a preset condition; An execution unit is used to execute the first CDC synchronization task plan, wherein the first CDC synchronization task plan is used to: synchronize the change data of multiple source tables in the source database to the single Source operator, synchronize the change data in the single Source operator to each of the Sink operators respectively, and synchronize the change data of each of the Sink operators to the destination table corresponding to each of the Sink operators in the destination database according to the field mapping relationship.

10. A database synchronization device, characterized in that: include: CPU and memory; The memory is a short-term storage memory or a persistent storage memory; The central processing unit is configured to communicate with the memory and execute instructions in the memory to perform the method according to any one of claims 1 to 8.

11. A computer-readable storage medium, characterized in that: The computer-readable storage medium comprises instructions, and when the instructions are executed on a computer, the computer is caused to perform the method according to any one of claims 1 to 8.

12. A computer program product comprising instructions or a computer program, characterized in that When the computer program product is run on a computer, the computer is caused to execute the method according to any one of claims 1 to 8.

Citation Information

Cited By

  • Medical data real-time synchronization method, system and device and medium

    CN119961359A