Multi-source heterogeneous data synchronization method, device, equipment and readable storage medium

By reading data from multi-source heterogeneous databases and storing them in message queues, writing them to the target database in batches, processing the insertion, update, and deletion sequences of incremental data, and using active and standby message queue comparison and fault recovery, multi-source heterogeneous problems are solved. It solves the problem of low structural data synchronization efficiency and achieves efficient and reliable data synchronization.

CN118445348BActive Publication Date: 2024-09-24CHANGJIANG SECURITIES
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410921399.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-10
Publication Date
2024-09-24
Estimated Expiration
2044-07-10

AI Technical Summary

Technical Problem

The existing technology is inefficient when synchronizing multi-source heterogeneous data and requires data conversion, resulting in reduced synchronization efficiency.

Method used

By reading data from multi-source heterogeneous databases and storing them in the target message queue, writing them into the target database in batches based on user configuration information, inserting, updating, and deleting sequential processing of incremental data, and using the active and standby message queues for data comparison. and failure recovery to ensure data consistency and efficient synchronization.

Benefits of technology

It improves the efficiency of multi-source heterogeneous data synchronization, ensures data consistency, and enables data breakpoint resumption in case of failure, reducing the processing pressure on the target database.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118445348B
    Figure CN118445348B
Patent Text Reader

Abstract

A multi-source heterogeneous data synchronization method, device, equipment and readable storage medium, which stores target multi-source heterogeneous data in a target message queue; reads target full data and target incremental data from the target message queue according to user configuration information; writes the target full data in batches to a target library; if the target incremental data has only insertion and update operation types, grouping the data to obtain insertion incremental data and update incremental data, writing the insertion incremental data in batches to the target library and then writing the update incremental data to the target library; otherwise, traversing the target incremental data in sequence, adding incremental data with the same operation type in the target incremental data to a target list, and if traversing to data with a different operation type from that in the target list, writing the incremental data in the target list in batches to the target library and clearing the target list, and continuing to traverse the target incremental data until all target incremental data are written to the target library, thereby ensuring data consistency and improving the efficiency of multi-source heterogeneous data synchronization.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of computer database data exchange, and in particular to a multi-source heterogeneous data synchronization method, device, equipment and readable storage medium. Background Art

[0002] With the rapid advancement of informatization construction, information systems have become an indispensable support for the operation of corporate business. Therefore, it is urgent to enhance the stability of information systems to ensure business continuity and minimize the losses that may be caused by disasters or failures; at the same time, the diversification of business types has led to increasingly complex data access requirements, and the rapid growth of data volume has also brought heavy pressure to database servers, so there is an urgent need to improve the operating efficiency of information systems. Among them, based on mature relational data models and standard interfaces, the database real-time synchronization system can achieve real-time data synchronization in seconds with less system overhead to effectively improve the operating efficiency of information systems. This system is widely used in emergency systems, disaster recovery and backup, load balancing, data migration, online maintenance, and multi-business centers.

[0003] In the related technology, the operation information of real-time data, including DML (Data Manipulation Language) operations and DDL (Data Definition Language) operations, is obtained by parsing the source database log, and then the operation information is converted into SQL (Structured Query Language) statements. Then, the operation corresponding to the SQL statement is executed directly through the database connection target library to write the data into the target library one by one, thereby realizing the synchronization of the real-time database.

[0004] When synchronizing homogeneous data, the above method can achieve efficient synchronization because the data model and interface are consistent; however, when synchronizing multi-source heterogeneous data, data conversion must be performed before synchronization, and then the converted data must be written into the target database one by one, which greatly reduces the synchronization efficiency. It can be seen that how to effectively improve the synchronization efficiency between multi-source heterogeneous data is an urgent problem to be solved. Summary of the invention

[0005] The present application provides a multi-source heterogeneous data synchronization method, apparatus, device and readable storage medium to effectively improve the synchronization efficiency between multi-source heterogeneous data.

[0006] In a first aspect, an embodiment of the present application provides a multi-source heterogeneous data synchronization method, comprising the following steps:

[0007] Reading target multi-source heterogeneous data from a multi-source heterogeneous database based on preset database information, and storing the target multi-source heterogeneous data in a target message queue;

[0008] When receiving the user configuration information, reading the target data from the target message queue according to the user configuration information, the target data including the target full data and / or the target incremental data;

[0009] For the target full amount of data, the target full amount of data is written in batches to the target database;

[0010] For the target incremental data, if the operation type of the target incremental data only includes insert and update, the target incremental data is grouped according to the operation type to obtain insert incremental data and update incremental data, and after the insert incremental data is written to the target database in batches, the update incremental data is written to the target database in batches;

[0011] If the operation types of the target incremental data include insertion, update and deletion, the target incremental data is traversed in a preset order, and the incremental data with the same operation type in the target incremental data is added to the target list in turn, until the incremental data with a different operation type corresponding to the target list is traversed, the incremental data in the target list is batch written to the target library and the target list is cleared, and the step of traversing the target incremental data in a preset order is continued until all target incremental data are written to the target library.

[0012] In combination with the first aspect, in one implementation, the target message queue includes a primary message queue and a backup message queue.

[0013] In combination with the first aspect, in one implementation, before the step of reading target data from the target message queue according to the user configuration information, the method further includes:

[0014] Comparing the target multi-source heterogeneous data in the main message queue and the backup message queue one by one;

[0015] If it is determined according to the comparison result that data is missing in the main message queue, the step of reading target data from the target message queue according to the user configuration information is performed based on the backup message queue.

[0016] In combination with the first aspect, in one implementation, storing the target multi-source heterogeneous data in a target message queue includes:

[0017] For each target multi-source heterogeneous data, the data is assembled based on the database table name, operation type, target identifier, data operation timestamp and number of records and then stored in the target message queue. The target identifier is a full identifier or an incremental identifier.

[0018] In combination with the first aspect, in one embodiment, if a failure occurs during the writing of target data, the first data corresponding to the preset time length before the failure and the second data corresponding to the failure after the failure are read from the target message queue according to the data operation timestamp and the number of records, and the first data and the second data are used as target data.

[0019] In combination with the first aspect, in one implementation, when the target data includes target full data and target incremental data, after the step of reading the target data from the target message queue according to the user configuration information, it further includes:

[0020] The target full data and the target incremental data are written into the target database in batches respectively according to the writing order of full data first and incremental data later.

[0021] In combination with the first aspect, in one implementation, a target message queue is deployed on each server node.

[0022] In a second aspect, an embodiment of the present application provides a multi-source heterogeneous data synchronization device, including:

[0023] A data acquisition module, which is used to read target multi-source heterogeneous data from a multi-source heterogeneous database based on preset database information;

[0024] A data cache module, which is used to store the target multi-source heterogeneous data into a target message queue;

[0025] A data subscription module, which is used to read target data from the target message queue according to the user configuration information when receiving the user configuration information, wherein the target data includes target full data and / or target incremental data;

[0026] A data distribution module is used to write the target full data in batches into a target library; for target incremental data, if the operation type of the target incremental data only includes insertion and update, the target incremental data is grouped according to the operation type to obtain insertion incremental data and update incremental data, and after the insertion incremental data is written in batches to the target library, the update incremental data is written in batches to the target library; if the operation type of the target incremental data includes insertion, update and deletion, the target incremental data is traversed in a preset order, and the incremental data with the same operation type in the target incremental data is added to the target list in turn, until the incremental data with a different operation type corresponding to the target list is traversed, the incremental data in the target list is written in batches to the target library and the target list is cleared, and the step of traversing the target incremental data in a preset order is continued until all the target incremental data are written to the target library.

[0027] In combination with the second aspect, in one implementation, the target message queue includes a primary message queue and a backup message queue.

[0028] In conjunction with the second aspect, in one implementation, the data cache module is further used to:

[0029] Comparing the target multi-source heterogeneous data in the main message queue and the backup message queue one by one;

[0030] If it is determined according to the comparison result that data is missing in the main message queue, the data subscription module is enabled to execute the step of reading target data from the target message queue according to the user configuration information based on the backup message queue.

[0031] In conjunction with the second aspect, in one implementation, the data subscription module is specifically used to:

[0032] For each target multi-source heterogeneous data, the data is assembled based on the database table name, operation type, target identifier, data operation timestamp and number of records and then stored in the target message queue. The target identifier is a full identifier or an incremental identifier.

[0033] In combination with the second aspect, in one embodiment, the data subscription module is also used to: if a failure occurs during the target data writing process, read the first data corresponding to the preset time length before the failure and the second data corresponding to the failure from the target message queue according to the data operation timestamp and the number of records, and use the first data and the second data as the target data.

[0034] In conjunction with the second aspect, in one implementation, when the target data includes target full data and target incremental data, the data distribution module is further configured to:

[0035] The target full data and the target incremental data are written into the target database in batches respectively according to the writing order of full data first and incremental data later.

[0036] In conjunction with the second aspect, in one implementation, a target message queue is deployed on each server node.

[0037] In a third aspect, an embodiment of the present application provides a multi-source heterogeneous data synchronization device, which includes a processor, a memory, and a multi-source heterogeneous data synchronization program stored in the memory and executable by the processor, wherein when the multi-source heterogeneous data synchronization program is executed by the processor, the steps of the multi-source heterogeneous data synchronization method as described above are implemented.

[0038] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a multi-source heterogeneous data synchronization program is stored, wherein when the multi-source heterogeneous data synchronization program is executed by a processor, the steps of the multi-source heterogeneous data synchronization method as described above are implemented.

[0039] The beneficial effects brought by the technical solution provided in the embodiments of the present application include:

[0040] The source database and the target database are decoupled by storing the target multi-source heterogeneous data read from the multi-source heterogeneous database into the target message queue; when the user configuration information is received, the target full data and / or target incremental data are read from the target message queue according to the user configuration information; for the target full data, the target full data is written to the target database in batches to improve the synchronization efficiency of the multi-source heterogeneous data; for the target incremental data, if the operation type of the target incremental data only includes insert and update, the target incremental data is grouped according to the operation type to obtain insert incremental data and update incremental data, and the insert incremental data is written to the target database in batches After that, the updated incremental data are written into the target library in batches; if the operation types of the target incremental data include insert, update and delete, the target incremental data are traversed in a preset order, and the incremental data with the same operation type in the target incremental data are added to the target list in sequence, until the incremental data with a different operation type corresponding to the target list is traversed, the incremental data in the target list are written into the target library in batches and the target list is cleared, and the step of traversing the target incremental data in a preset order is continued until all the target incremental data are written into the target library, so as to ensure data consistency while improving the synchronization efficiency of multi-source heterogeneous data. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] Figure 1 This is a flow chart of an embodiment of a multi-source heterogeneous data synchronization method of the present application;

[0042] Figure 2 This is a schematic diagram of comparing the primary and standby message queue data involved in the embodiment of the present application;

[0043] Figure 3 This is a schematic diagram of the first incremental data processing involved in the embodiment of the present application;

[0044] Figure 4 This is a schematic diagram of the second incremental data processing involved in the embodiment of the present application;

[0045] Figure 5 This is a schematic diagram of the hardware structure of a multi-source heterogeneous data synchronization device involved in the embodiment of the present application. DETAILED DESCRIPTION

[0046] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0047] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.

[0048] In a first aspect, an embodiment of the present application provides a multi-source heterogeneous data synchronization method.

[0049] In one embodiment, referring to Figure 1 , Figure 1 This is a flow chart of an embodiment of the multi-source heterogeneous data synchronization method of the present application. Figure 1 As shown, the multi-source heterogeneous data synchronization method includes:

[0050] Step S10: reading target multi-source heterogeneous data from a multi-source heterogeneous database based on preset database information, and storing the target multi-source heterogeneous data in a target message queue.

[0051] Exemplarily, in this embodiment, the preset database information includes but is not limited to the database type, database name, database address and database port; it should be understood that the multi-source heterogeneous database includes different types of databases and multiple databases of the same type with different data sources. For example, assuming that there are three types of databases, MySQL, Oracle and SQL Server, and the total number of MySQL databases is N, the total number of Oracle databases is M and the total number of SQL Server databases is S, then for the MySQL database, the multi-source heterogeneous database includes N MySQL databases, M Oracle data sets and S SQL Server databases.

[0052] The data acquisition module can collect and read data from different types of databases and different data sources for multi-source heterogeneous databases through database information to obtain multiple target multi-source heterogeneous data including full data and incremental data. It should be understood that when this embodiment collects and reads data, it first collects the full data at the current time point, and then obtains the incremental data after parsing the database log according to the time point.

[0053] Specifically, for the reading of full data, it can be obtained directly by reading the data from the database; for incremental data, it is necessary to obtain operation information including DML operations (such as inserting INSERT, updating UPDATE, deleting DELETE, etc.), DDL operations (such as creating CREATE, modifying ALTER, deleting DROP, etc.) by reading and parsing the database log, and the incremental data can be determined based on the operation information. It should be noted that when collecting incremental data, this embodiment directly reads the database log by performing a database connection operation through the preset permission account provided by the source database, without installing an agent program on the source database and the cache.

[0054] After the data acquisition module reads the target multi-source heterogeneous data, the target multi-source heterogeneous data is transmitted to the data cache module; the data cache module stores the received target multi-source heterogeneous data in the target message queue, so that subsequent data synchronization can be directly based on the target message queue, solving the coupling problem between the source database and the target database.

[0055] Furthermore, in one embodiment, the target message queue includes a main message queue and a backup message queue.

[0056] Exemplarily, in this embodiment, in order to ensure the dual activity of data and improve the fault tolerance and robustness of the system, a dual activity mechanism for dual cluster deployment of data is proposed, that is, a main message queue and a backup message queue are set, and then the target multi-source heterogeneous data are stored in the main message queue and the backup message queue respectively, so as to achieve the purpose of data dual activity. It should be understood that the target multi-source heterogeneous data includes the data corresponding to the source main database and the source backup database. Therefore, the data corresponding to the source main database can be stored in the main message queue, and the data corresponding to the source backup database can be stored in the backup message queue.

[0057] Furthermore, in one embodiment, storing the target multi-source heterogeneous data in a target message queue includes:

[0058] For each target multi-source heterogeneous data, the data is assembled based on the database table name, operation type, target identifier, data operation timestamp and number of records and then stored in the target message queue. The target identifier is a full identifier or an incremental identifier.

[0059] Exemplarily, in this embodiment, the data will be processed with identifiers according to whether the data is full data or incremental data; wherein, the full identifier is used to characterize the data as full data, and the incremental identifier is used to characterize the data as incremental data. It should be noted that the specific representation of the full identifier and the incremental identifier can be determined according to actual needs and is not limited here. For example, "1" is used as the full identifier and "0" is used as the incremental identifier. If the identifier of data A is "1", it indicates that data A is full data, and if the identifier of data A is "0", it indicates that data A is incremental data. In addition, it should be understood that the operation types include but are not limited to INSERT, UPDATE, and DELETE.

[0060] For each target multi-source heterogeneous data, the source database type, data operation type, data operation timestamp, number of records and target identifier are recorded, and then the data is processed and assembled into JSON format before being stored in the target message queue.

[0061] Specifically, if a certain target multi-source heterogeneous data is full data, after the source database is fully read, the data operation timestamp and the number of records read are marked; then the data is assembled based on the corresponding identifier, operation type, data operation timestamp and number of records and the table name of the database where it is located to obtain the assembled data in json format, and then the assembled data is written to the target message queue.

[0062] If a target multi-source heterogeneous data is incremental data, after parsing the source database log to obtain the operation information, the operation type of the data is determined according to the operation information, and the data operation timestamp and record number are marked; then the data is assembled based on the corresponding identifier, operation type, data operation timestamp and record number and the table name of the database where it is located to obtain the assembled data in json format, and then the assembled data is written to the target message queue.

[0063] It should be understood that data in different database tables will be written to different topics in the target message queue, that is, data in the same database table will be written to the same topic.

[0064] Furthermore, in one embodiment, a target message queue is deployed on each server node.

[0065] For example, in this embodiment, in order to ensure high availability of data, a multi-node deployment mechanism with multiple copies is proposed, that is, the target message queue is deployed on each server node to achieve multi-copy storage of data, thereby improving the fault tolerance and robustness of the system.

[0066] Step S20: When the user configuration information is received, target data is read from the target message queue according to the user configuration information, where the target data includes target full data and / or target incremental data.

[0067] Exemplarily, in this embodiment, the user configuration information includes but is not limited to a table list, a consumption tag, and a data type; wherein the table list is used to store the table name of the database where the data to be read is located, the consumption tag is used to store the time period information of the data to be read, etc., and the data type includes full data and / or incremental data.

[0068] Since each piece of data in the target message queue records the corresponding target identifier, data operation timestamp and number of records, when the data subscription module receives the user configuration information sent by the user, it can consume (i.e. read) different table data from the target message queue according to the table list, consumption tag and data type required by the user to obtain the target data. When reading full data, the corresponding full data can be directly read from the target message queue according to the full identifier; when reading incremental data, the corresponding incremental data needs to be read from the target message queue according to the incremental identifier, data operation timestamp and number of records.

[0069] It can be understood that if the data type only includes full data, it means that only full data needs to be obtained from the target message queue, and the target data only includes full data; if the data type only includes incremental data, it means that only incremental data needs to be obtained from the target message queue, and the target data only includes incremental data; and if the data type includes full data and incremental data, it means that full data and incremental data need to be obtained from the target message queue, and the target data includes full data and incremental data.

[0070] In addition, after completing the data reading, the data subscription module will record the data status read so that the data can be read according to the data status later. It should be noted that the data status includes but is not limited to the record status, the specified data operation timestamp and the specified number of records. For example, the data subscription module pulls data from the target message queue once every X milliseconds. After completing a data pull, the data operation timestamp of the pulled data will be recorded so that the data can be pulled from the recorded data operation timestamp when the next data is pulled.

[0071] Furthermore, in one embodiment, before the step of reading target data from the target message queue according to the user configuration information, the step further includes:

[0072] Comparing the target multi-source heterogeneous data in the main message queue and the backup message queue one by one;

[0073] If it is determined according to the comparison result that data is missing in the main message queue, the step of reading target data from the target message queue according to the user configuration information is performed based on the backup message queue.

[0074] For example, in this embodiment, two message queue clusters, active and standby, are deployed to collect data from the source active and standby databases into two different message queue clusters, and then the data of the two clusters are compared in real time to determine the object for data reading. Figure 2 As shown, the data can be compared by setting a sliding window w with a time length of T (for example, setting a sliding window of T = L milliseconds), such as sliding for Y milliseconds each time (i.e. Figure 2 The time length of sliding windows w1 to w5 in the example is Y milliseconds), the data in the main and backup message queue clusters are read into the memory, and then the data is compared one by one; if there is data missing in the main message queue, the backup message queue is used as the object of data reading to ensure the integrity of the data, and a real-time warning is issued to notify the operation and maintenance personnel to handle it; if there is data missing in the backup message queue, a warning is issued directly to notify the operation and maintenance personnel to handle it. It should be understood that as long as there is no data missing in the main message queue, the main message queue will be the object of data reading.

[0075] Step S30: For the target full amount of data, the target full amount of data is written into the target library in batches.

[0076] Exemplarily, in this embodiment, for the target full amount of data, after the data distribution module receives the target full amount of data from the data subscription module, it will directly write it in batches into the target library to effectively improve the synchronization efficiency of multi-source heterogeneous data.

[0077] Step S40: For the target incremental data, if the operation type of the target incremental data only includes insertion and update, the target incremental data is grouped according to the operation type to obtain insert incremental data and update incremental data, and after the insert incremental data is batch written to the target library, the update incremental data is batch written to the target library.

[0078] For example, in this embodiment, for the target incremental data, in order to ensure data consistency during data synchronization, the "consistency algorithm, batch processing strategy" will be adopted to synchronize the incremental data, that is, different synchronization strategies will be adopted based on the different types of operations contained in the incremental data. Figure 3 As shown in the figure, it is assumed that the data distribution module submits a batch write operation every H data or Y milliseconds. For each batch of write operations, the target incremental data submitted in each batch is first sorted according to the data operation timestamp and the number of records, and the sorted incremental data is obtained (for example Figure 3In the figure, I represents INSERT incremental data, U represents UPDATE incremental data, and the arrows represent the synchronization order); if the operation types of the sorted incremental data only include INSERT operation and UPDATE operation, the INSERT operation and UPDATE operation are grouped and processed to obtain insert incremental data (i.e., INSERT incremental data) and update incremental data (i.e., UPDATE incremental data); then, INSERT operations are executed in batches first, and then UPDATE operations are executed in batches, that is, the INSERT incremental data is first written in batches to the target database, and then the UPDATE incremental data is written in batches to the target database, so as to improve the efficiency of data processing on the basis of ensuring data consistency.

[0079] Step S50: If the operation types of the target incremental data include insertion, update and deletion, the target incremental data is traversed in a preset order, and the incremental data with the same operation type in the target incremental data is added to the target list in sequence, until the incremental data with a different operation type corresponding to the target list is traversed, the incremental data in the target list is batch-written into the target library and the target list is cleared, and the step of traversing the target incremental data in a preset order is continued until all the target incremental data are written into the target library.

[0080] Exemplarily, in this embodiment, if the operation types of the sorted incremental data include not only INSERT operations and UPDATE operations, but also deletion operations (i.e., DELETE operations and TRUNCATE operations), the sorted incremental data are traversed; and then the same operations are added to the target list in chronological order; during the traversal process, if incremental data with an operation type different from that corresponding to the target list is traversed, the incremental data in the target list is first written into the target library in batches, and then the target list is cleared, and the sorted incremental data is continued to be traversed, and the incremental data of the new operation type is added to the target list, and the above operations are repeated until the sorted incremental data is traversed and all written into the target library; at this point, the synchronization of multi-source heterogeneous data is completed, which not only ensures data consistency, but also improves transaction processing efficiency.

[0081] For details, see Figure 4As shown, assuming that the sorted incremental data includes incremental data of four operation types, namely, I, U, D (i.e., DELETE incremental data) and C (i.e., TRUNCATE incremental data), traverse them, and add the first incremental data (i.e., the first D data) to the target list. Since the operation type of the first incremental data is DELETE operation, the target list can only store incremental data of the operation type DELETE operation at this time; then continue to traverse the sorted incremental data, since the operation types of the second to fifth incremental data are all DELETE operations, these four D data are added to the target list in turn; when traversing to the sixth incremental data, since its operation type is INSERT operation, which is different from the operation type of the incremental data stored in the target list, the I data is not added to the target list at this time, but the five D data in the target list are first written into the target library in batches, and then the target list is cleared.

[0082] Then continue to traverse and add the sixth incremental data (i.e., I data) to the target list. At this time, the target list can only store incremental data with the operation type of INSERT operation; since the operation type of the seventh and eighth incremental data is also INSERT operation, the seventh and eighth I data are added to the target list; when traversing to the ninth incremental data, since its operation type is UPDATE operation, which is different from the operation type that the target list can store at this time, the three I data in the target list are directly written into the target database in batches, and the target list is cleared again; then Figure 4 The above operation is repeated for the remaining 10 incremental data until the sorted incremental data is traversed and all written to the target database.

[0083] Furthermore, in one embodiment, when the target data includes target full data and target incremental data, after the step of reading the target data from the target message queue according to the user configuration information, the step further includes:

[0084] The target full data and the target incremental data are written into the target database in batches respectively according to the writing order of full data first and incremental data later.

[0085] Exemplarily, in this embodiment, after receiving the target data sent by the data subscription module, the data distribution module first writes the target full data in batches to the target library according to the writing order of full data first and incremental data later, and can dynamically adjust the number of concurrency according to the pressure of the target library, and then batch process the write operation of the target incremental data to effectively ensure the integrity and orderliness of the data. It should be noted that if a full identifier or DDL operation is detected during the batch synchronization of incremental data, the write operation of the full data is re-performed, and the synchronization of the incremental data is performed after the full data is synchronized.

[0086] Specifically, if the data type in the user configuration information includes full data and incremental data, the target full data is first read from the target message queue according to the full identifier, and written in batches to the target library, and the last number of records in each database table is recorded; then the incremental data reading is started, that is, the target incremental data is read starting from the number of records currently recorded, and written in batches to the target library to ensure the completeness and orderliness of the data. It should be understood that if the data type in the user configuration information only includes incremental data, that is, the user does not need full data, the data is played back according to the data operation timestamp or the specified number of records specified by the consumption tag in the user configuration information, and the target incremental data is started to be read; if the consumption tag does not specify the data operation timestamp or the number of records, the target incremental data is read from the current time point by default.

[0087] Furthermore, in one embodiment, if a failure occurs during the writing of target data, the first data corresponding to the preset time length before the failure and the second data corresponding to the failure after the failure are read from the target message queue according to the data operation timestamp and the number of records, and the first data and the second data are used as target data.

[0088] For example, since the current real-time database synchronization solution is limited to continuous channel services, once any failure or abnormal situation occurs, the channel needs to be re-established, making it impossible to achieve data breakpoint resumption and data playback functions. This limitation greatly reduces the flexibility and reliability of data synchronization.

[0089] In order to solve the above-mentioned problem of being unable to resume data transmission at breakpoints, the data cache module in this embodiment will mark the data operation timestamp and the number of records for each target data received, so that during the data distribution (i.e., data writing) process, if a database table fails, the timestamp can be pushed forward by a preset time length (for example, 5 minutes) to obtain a new timestamp; then, data reading will be performed from the data in the target message queue with the same data operation timestamp as the new timestamp to obtain new target data, and then data synchronization processing will be performed based on the new target data, effectively realizing data breakpoint resumption without the need to synchronize all database tables in the entire channel at once, thereby enhancing the fault handling capability and reducing the repair time.

[0090] It is understandable that if the current main message queue fails at a certain point in time, you can switch to the backup channel (i.e., the backup message queue) to trace the data, that is, push the current time forward to a time point T1, and then subscribe to the data at and after the T1 time point, and then perform incremental processing according to the aforementioned incremental data synchronization strategy to ensure data integrity and ultimate consistency.

[0091] In summary, this embodiment first extracts the full data and incremental data of the source database into the message queue, decouples the source and target databases, and can not only realize multi-source heterogeneous data synchronization, but also realize the distribution method of one source and multiple target ends to save channel costs; in addition, the "consistency algorithm, batch processing strategy" is adopted to enhance the ability of data batch processing, which improves the efficiency of data processing on the one hand, and on the other hand, the batch processing method can reduce the number of interactions with the target database, thereby reducing the processing pressure of the target database; at the same time, this embodiment also records the data operation timestamp and number of records consumed by each user, so that data can be backtracked and resumed according to the data operation timestamp or the number of records, and supports single-table data backtracking and breakpoint resumption, which enhances the ability to repair channel failures. It can be seen that this embodiment realizes efficient, traceable, and heterogeneous data synchronization.

[0092] In a second aspect, an embodiment of the present application also provides a multi-source heterogeneous data synchronization device.

[0093] In one embodiment, a multi-source heterogeneous data synchronization device includes:

[0094] A data acquisition module, which is used to read target multi-source heterogeneous data from a multi-source heterogeneous database based on preset database information;

[0095] A data cache module, which is used to store the target multi-source heterogeneous data into a target message queue;

[0096] A data subscription module, which is used to read target data from the target message queue according to the user configuration information when receiving the user configuration information, wherein the target data includes target full data and / or target incremental data;

[0097] A data distribution module is used to write the target full data in batches into a target library; for target incremental data, if the operation type of the target incremental data only includes insertion and update, the target incremental data is grouped according to the operation type to obtain insertion incremental data and update incremental data, and after the insertion incremental data is written in batches to the target library, the update incremental data is written in batches to the target library; if the operation type of the target incremental data includes insertion, update and deletion, the target incremental data is traversed in a preset order, and the incremental data with the same operation type in the target incremental data is added to the target list in turn, until the incremental data with a different operation type corresponding to the target list is traversed, the incremental data in the target list is written in batches to the target library and the target list is cleared, and the step of traversing the target incremental data in a preset order is continued until all the target incremental data are written to the target library.

[0098] Furthermore, in one embodiment, the target message queue includes a main message queue and a backup message queue.

[0099] Furthermore, in one embodiment, the data cache module is also used for:

[0100] Comparing the target multi-source heterogeneous data in the main message queue and the backup message queue one by one;

[0101] If it is determined according to the comparison result that data is missing in the main message queue, the data subscription module is enabled to execute the step of reading target data from the target message queue according to the user configuration information based on the backup message queue.

[0102] Furthermore, in one embodiment, the data subscription module is specifically used for:

[0103] For each target multi-source heterogeneous data, the data is assembled based on the database table name, operation type, target identifier, data operation timestamp and number of records and then stored in the target message queue. The target identifier is a full identifier or an incremental identifier.

[0104] Furthermore, in one embodiment, the data subscription module is also used to: if a failure occurs during the writing of target data, read the first data corresponding to the preset time length before the failure and the second data corresponding to the failure from the target message queue according to the data operation timestamp and the number of records, and use the first data and the second data as target data.

[0105] Furthermore, in one embodiment, when the target data includes target full data and target incremental data, the data distribution module is further configured to:

[0106] The target full data and the target incremental data are written into the target database in batches respectively according to the writing order of full data first and incremental data later.

[0107] Furthermore, in one embodiment, a target message queue is deployed on each server node.

[0108] Among them, the functional implementation of each module in the above-mentioned multi-source heterogeneous data synchronization device corresponds to the various steps in the above-mentioned multi-source heterogeneous data synchronization method embodiment, and its functions and implementation processes are no longer repeated here.

[0109] In a third aspect, an embodiment of the present application provides a multi-source heterogeneous data synchronization device, which may be a personal computer (PC), a laptop computer, a server, or other device with data processing capabilities.

[0110] Reference Figure 5 , Figure 5Schematic diagram of the hardware structure of a multi-source heterogeneous data synchronization device involved in the embodiment of the present application. In the embodiment of the present application, the multi-source heterogeneous data synchronization device may include a processor, a memory, a communication interface, and a communication bus.

[0111] The communication bus may be of any type and is used to interconnect the processor, the memory, and the communication interface.

[0112] Communication interfaces include input / output (I / O) interfaces, physical interfaces, and logical interfaces, which are used to interconnect devices within a multi-source heterogeneous data synchronization device, and interfaces used to interconnect a multi-source heterogeneous data synchronization device with other devices (such as other computing devices or user devices). Physical interfaces can be Ethernet interfaces, optical fiber interfaces, ATM interfaces, etc.; user devices can be display screens (Display), keyboards (Keyboard), etc.

[0113] The memory can be various types of storage media, such as random access memory (RAM), read-only memory (ROM), non-volatile RAM (NVRAM), flash memory, optical storage, hard disk, programmable ROM (PROM), erasable PROM (EPROM), electrically erasable PROM (EEPROM), etc.

[0114] The processor may be a general-purpose processor, which may call the multi-source heterogeneous data synchronization program stored in the memory and execute the multi-source heterogeneous data synchronization method provided in the embodiment of the present application. For example, the general-purpose processor may be a central processing unit (CPU). The method executed when the multi-source heterogeneous data synchronization program is called may refer to the various embodiments of the multi-source heterogeneous data synchronization method of the present application, which will not be described in detail here.

[0115] Those skilled in the art will understand that Figure 5 The hardware structure shown in the figure does not constitute a limitation on the present application, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0116] In a fourth aspect, an embodiment of the present application also provides a computer-readable storage medium.

[0117] The readable storage medium of the present application stores a multi-source heterogeneous data synchronization program, wherein when the multi-source heterogeneous data synchronization program is executed by a processor, the steps of the multi-source heterogeneous data synchronization method as described above are implemented.

[0118] Among them, the method implemented when the multi-source heterogeneous data synchronization program is executed can refer to the various embodiments of the multi-source heterogeneous data synchronization method of the present application, and will not be repeated here.

[0119] It should be noted that the serial numbers of the above-mentioned embodiments of the present application are only for description and do not represent the advantages or disadvantages of the embodiments.

[0120] The terms "including" and "having" and any variations thereof in the specification and claims of this application and the above-mentioned drawings are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices. The terms "first", "second" and "third" are used to distinguish different objects, etc., and do not represent a sequence, nor do they limit "first", "second" and "third" to different types.

[0121] In the description of the embodiments of the present application, "exemplary", "for example" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary", "for example" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary", "for example" or "for example" is intended to present related concepts in a specific way.

[0122] In the description of the embodiments of the present application, unless otherwise specified, “ / ” means or, for example, A / B can mean A or B; the “and / or” in the text is merely a description of the association relationship of associated objects, indicating that three relationships may exist, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, “multiple” refers to two or more than two.

[0123] In some processes described in the embodiments of the present application, multiple operations or steps that appear in a specific order are included, but it should be understood that these operations or steps may not be executed in the order in which they appear in the embodiments of the present application or in parallel, and the sequence number of the operation is only used to distinguish the different operations, and the sequence number itself does not represent any execution order. In addition, these processes may include more or fewer operations, and these operations or steps may be executed in sequence or in parallel, and these operations or steps may be combined.

[0124] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, disk, CD) as described above, and includes a number of instructions for a terminal device to execute the methods described in each embodiment of the present application.

[0125] The above are only preferred embodiments of the present application, and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. A multi-source heterogeneous data synchronization method, characterized in that: The following steps are involved: Reading target multi-source heterogeneous data from a multi-source heterogeneous database based on preset database information, and storing the target multi-source heterogeneous data in a target message queue; When receiving the user configuration information, reading the target data from the target message queue according to the user configuration information, the target data including the target full data and / or the target incremental data; For the target full amount of data, the target full amount of data is written in batches to the target database; For the target incremental data, the target incremental data is sorted according to the data operation timestamp and the number of records to obtain the sorted incremental data. If the operation types of the sorted incremental data only include insert and update, the sorted incremental data is grouped according to the operation type to obtain insert incremental data and update incremental data. After the insert incremental data is written to the target database in batches, the update incremental data is written to the target database in batches. If the operation types of the sorted incremental data include insertion, update and deletion, the sorted incremental data are traversed in the preset order, and the incremental data with the same operation type in the sorted incremental data are added to the target list in turn, until the incremental data with a different operation type corresponding to the target list is traversed, the incremental data in the target list are batch written to the target library and the target list is cleared, and the step of traversing the sorted incremental data in the preset order is continued until all the sorted incremental data are written to the target library.

2. The multi-source heterogeneous data synchronization method according to claim 1, characterized in that: The target message queue includes a main message queue and a backup message queue.

3. The multi-source heterogeneous data synchronization method according to claim 2, characterized in that: Before the step of reading target data from the target message queue according to the user configuration information, the method further includes: Comparing the target multi-source heterogeneous data in the main message queue and the backup message queue one by one; If it is determined according to the comparison result that data is missing in the main message queue, the step of reading target data from the target message queue according to the user configuration information is performed based on the backup message queue.

4. The multi-source heterogeneous data synchronization method according to claim 1, characterized in that: The storing the target multi-source heterogeneous data into the target message queue includes: For each target multi-source heterogeneous data, the data is assembled based on the database table name, operation type, target identifier, data operation timestamp and number of records and then stored in the target message queue. The target identifier is a full identifier or an incremental identifier.

5. The multi-source heterogeneous data synchronization method according to claim 4, characterized in that: If a failure occurs during the target data writing process, the first data corresponding to the preset time length before the failure and the second data corresponding to the failure after the failure are read from the target message queue according to the data operation timestamp and the number of records, and the first data and the second data are used as the target data.

6. The multi-source heterogeneous data synchronization method according to claim 1, characterized in that: When the target data includes target full data and target incremental data, after the step of reading the target data from the target message queue according to the user configuration information, the method further includes: The target full data and the target incremental data are written into the target database in batches respectively according to the writing order of full data first and incremental data later.

7. The multi-source heterogeneous data synchronization method according to claim 1, characterized in that: A target message queue is deployed on each server node.

8. A multi-source heterogeneous data synchronization device, characterized in that: include: A data acquisition module, which is used to read target multi-source heterogeneous data from a multi-source heterogeneous database based on preset database information; A data cache module, which is used to store the target multi-source heterogeneous data into a target message queue; A data subscription module, which is used to read target data from the target message queue according to the user configuration information when receiving the user configuration information, wherein the target data includes target full data and / or target incremental data; A data distribution module is used to write the target full data in batches into a target library; for target incremental data, sort the target incremental data according to data operation timestamps and record numbers to obtain sorted incremental data; if the operation types of the sorted incremental data only include insertion and update, the sorted incremental data are grouped according to the operation types to obtain insertion incremental data and update incremental data, and after the insertion incremental data are written in batches to the target library, the update incremental data are written in batches to the target library; if the operation types of the sorted incremental data include insertion, update and deletion, the sorted incremental data are traversed in a preset order, and the incremental data with the same operation type in the sorted incremental data are added to the target list in turn, until the incremental data with a different operation type corresponding to the target list is traversed, the incremental data in the target list are written in batches to the target library and the target list is cleared, and the step of traversing the sorted incremental data in a preset order is continued until all the sorted incremental data are written to the target library.

9. A multi-source heterogeneous data synchronization device, characterized in that: The multi-source heterogeneous data synchronization device includes a processor, a memory, and a multi-source heterogeneous data synchronization program stored in the memory and executable by the processor, wherein when the multi-source heterogeneous data synchronization program is executed by the processor, the steps of the multi-source heterogeneous data synchronization method as described in any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a multi-source heterogeneous data synchronization program, wherein when the multi-source heterogeneous data synchronization program is executed by a processor, the steps of the multi-source heterogeneous data synchronization method according to any one of claims 1 to 7 are implemented.