A method for realizing MySQL incremental data synchronization based on message queue
Through a message queue-based method, log parsing tools and Zookeeper are used to achieve MySQL incremental data synchronization, which solves the problem of low data synchronization efficiency between different systems, achieves real-time, accurate and convenient data synchronization, and adapts to multi-table associations and table structures. Changing needs.
Patent Information
- Application Number
- CN202110773554.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-08
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2041-07-08
AI Technical Summary
Existing technology is difficult to achieve incremental data synchronization between different systems, especially when multi-platform and multi-table structures change, resulting in low efficiency and inconvenience of data migration and synchronization.
Using a message queue-based method, create a MySQL configuration table through log parsing tools, monitor the data messages pushed by the message queue, and query the specific synchronization method according to the configuration table to achieve incremental data synchronization, and use the C/S structure to build message queue data production and On the consumer side, Zookeeper is used for cluster deployment to ensure the scalability of the middleware for data transmission.
It realizes real-time and manual data synchronization, improves synchronization efficiency and accuracy, has high fault tolerance and convenience, and adapts to the needs of multi-table association and table structure changes.
Smart Images

Figure CN113505175B
Abstract
Description
Technical Field
[0001] The invention discloses a method, which relates to the technical field of information processing, and in particular to a method for realizing MySQL incremental data synchronization based on a message queue. Background Art
[0002] Major enterprises and manufacturers are building their own data warehouses for data migration, and are facing various challenges such as software and hardware platforms, operating systems, and distributed management. When transmitting and processing data between multiple platforms, multiple projects, or systems, it is currently difficult to synchronize incremental data between different systems in response to different needs, and convenient distributed data synchronization cannot be achieved in a timely manner. Summary of the invention
[0003] In view of the problems of the prior art, the present invention provides a method for realizing MySQL incremental data synchronization based on message queue, realizing convenient distributed data synchronization, and according to different needs, it is necessary to monitor different business tables in the database to realize incremental synchronization of data corresponding to different table structures between systems, while satisfying the migration of multi-table related data and facilitating data processing when the table structure changes due to subsequent system iterations.
[0004] The specific scheme proposed by the present invention is:
[0005] A method for realizing MySQL incremental data synchronization based on message queue, using a data consumer to create an information configuration table for monitoring MySQL through a log parsing tool, listening to data messages of different platforms pushed by the message queue in the corresponding message queue, querying the specific synchronization method of data of different platforms according to the information configuration table, and performing incremental data synchronization by calling the corresponding specific synchronization method.
[0006] Furthermore, in the method for realizing MySQL incremental data synchronization based on message queue, the data producer and data consumer of the message queue are built through the C / S structure, the offset of the message push is configured by the server of the data producer, the data producer's client is used to extract data, and the data is pushed to the message queue, and the log parsing tool of the client of the data consumer is used to create an information configuration table for monitoring MySQL, and listen to the data messages of different platforms pushed by the message queue.
[0007] Furthermore, in the method for realizing MySQL incremental data synchronization based on a message queue, the client of the data producer extracts the original data according to the table structure in the original MySQL, and sends the data to the message queue in groups.
[0008] Furthermore, in the method for realizing MySQL incremental data synchronization based on message queue, the original data of different platforms in the data message is extracted by the client of the data consumer, the specific synchronization method of the data of different platforms is queried according to the information configuration table, and the incremental data synchronization is performed by calling the corresponding specific synchronization method.
[0009] Furthermore, in the method for realizing MySQL incremental data synchronization based on a message queue, a query method for writing an information configuration table through an SQL statement is described.
[0010] Furthermore, in the method for realizing MySQL incremental data synchronization based on a message queue, a message queue is built as a middleware for data transmission, and Zookeeper is used for cluster deployment.
[0011] A system for implementing MySQL incremental data synchronization based on message queues, including a creation module, a monitoring module, a query module and a data synchronization module.
[0012] The creation module uses the data consumer to create an information configuration table for monitoring MySQL through the log parsing tool. The monitoring module listens to the data messages of different platforms pushed by the message queue in the corresponding message queue. The query module queries the specific synchronization methods of data on different platforms according to the information configuration table. The data synchronization module performs incremental data synchronization by calling the corresponding specific synchronization methods.
[0013] A device for implementing MySQL incremental data synchronization based on a message queue, comprising at least one memory and at least one processor;
[0014] The at least one memory is used to store a machine-readable program;
[0015] The at least one processor is used to call the machine-readable program to execute the method for realizing MySQL incremental data synchronization based on a message queue.
[0016] The benefits of the present invention are:
[0017] The present invention provides a method for realizing MySQL incremental data synchronization based on message queue. The method uses a log parsing tool to create a MySQL configuration information table for data management on a data consumer side, monitors a MySQL database, pushes and listens to the monitored data through a message queue, and then realizes query and specific synchronization methods according to different types in the configuration table, performs incremental synchronization, thereby realizing real-time incremental synchronization and manual data synchronization. The method can synchronize data in real time, has high efficiency, high accuracy, and has the advantages of strong architecture scalability, and has obvious advantages in data accuracy, real-time performance, convenience, fault tolerance, etc. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 It is a schematic diagram of the application process of the method of the present invention.
[0019] Figure 2 It is a schematic diagram of the business process of implementing the method of the present invention. DETAILED DESCRIPTION
[0020] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments so that those skilled in the art can better understand the present invention and implement it, but the embodiments are not intended to limit the present invention.
[0021] The present invention provides a method for realizing MySQL incremental data synchronization based on message queue. The method comprises the following steps: a data consumer creates an information configuration table for monitoring MySQL through a log parsing tool, and monitors data messages of different platforms pushed by the message queue in the corresponding message queue. The specific synchronization method of data of different platforms is queried according to the information configuration table, and incremental data synchronization is performed by calling the corresponding specific synchronization method.
[0022] The method of the present invention utilizes a log parsing tool to create a MySQL configuration information table for data management on the data consumer side, monitors the MySQL database, pushes and listens to the monitored data through a message queue, and then implements query and specific synchronization methods according to different types in the configuration table to perform incremental synchronization, thereby realizing real-time incremental synchronization and manual data synchronization. The method can synchronize data in real time with high efficiency and accuracy, and has the advantages of strong architecture scalability, and has obvious advantages in data accuracy, real-time performance, convenience, fault tolerance, etc.
[0023] In specific applications, in some embodiments of the present invention, a log parsing tool + message queue + log parsing tool management method can be used to produce, consume, and manage services, which can synchronize data in real time, has high efficiency, high accuracy, and strong scalability of the later architecture.
[0024] Among them, building a message queue + log parsing tool environment: building and deploying a server as a middleware for data transmission between multiple platforms or systems, and configuring corresponding services.
[0025] Implement database monitoring and message push: The data producer and consumer servers need to configure the offset of message push and the relevant original data table. The data producer client needs to extract the original data according to the table structure and push it to the message queue; the consumer client needs to listen to the messages of different platforms in the queue, extract, convert and load the original data in the message, and finally synchronize the data required by different platforms to the data table of the corresponding database.
[0026] Implement incremental data synchronization processing: On the data consumer side, the client uses log parsing tools to create a configuration table for data management; based on the types of different SQL statements, write configuration table query methods and corresponding SQL type implementation methods on the back end. Since personalized data information can be configured in the configuration table, there is no need to perform separate processing and corresponding synchronization logic implementation for each personalized table; call this method in the corresponding queue listener or interface to achieve real-time incremental synchronization and manual data synchronization.
[0027] On the basis of the above implementation, in other embodiments of the present invention, when building a message queue + log parsing tool environment, a new set of servers is built between multiple platforms or systems as middleware for data transmission, and Zookeeper can be installed and configured for cluster deployment, the log parsing tool configuration file can be imported and the corresponding configuration can be modified, the corresponding instance information of the log parsing tool can be written, and the MySQL database monitoring settings can be performed.
[0028] When monitoring the database and pushing messages, the server of the data producer only needs to configure the displacement of the message push through the log parsing tool. The client of the data producer uses the log parsing tool to extract the original data according to the original table structure in MySQL, and sends it to the message queue in groups so that the data receiving side can consume it by category.
[0029] The data consumer's service configures the relevant original data table through the log parsing tool. The data consumer client listens to the messages in each group of queues through the log parsing tool, extracts, converts and loads the original data of different platforms in the message, and finally synchronizes the required data to the corresponding data table of the MySQL database. Among them, in the MySQL information configuration table on the data consumption side, the fields in the table include at least: information about the original database and the required table, the library and table information corresponding to the table to be synchronized, as well as the SQL type method and the field information in the corresponding SQL statement. According to the type of SQL statement, the configuration table query method and the implementation method of the corresponding SQL type are written in the backend. Since personalized data information can be configured in the configuration table, there is no need to perform separate processing and implementation of the corresponding synchronization logic for each personalized table. Calling this method in the corresponding queue monitor can complete real-time incremental synchronization. The information configuration table can refer to Table 1.
[0030] Table 1
[0031]
[0032] The present invention also provides a system for realizing MySQL incremental data synchronization based on a message queue, including a creation module, a monitoring module, a query module and a data synchronization module.
[0033] The creation module uses the data consumer to create an information configuration table for monitoring MySQL through a log parsing tool, the monitoring module monitors the data messages of different platforms pushed by the message queue in the corresponding message queue, the query module queries the specific synchronization method of the data of different platforms according to the information configuration table, and the data synchronization module performs data incremental synchronization by calling the corresponding specific synchronization method. The information interaction, execution process and other contents between the modules in the above system are based on the same concept as the embodiment of the method of the present invention. The specific contents can be referred to the description in the embodiment of the method of the present invention, and will not be repeated here. Similarly, the system of the present invention can also use the log parsing tool to create a MySQL configuration information table for data management on the data consumer side, monitor the MySQL database, push and monitor the monitored data through the message queue, and then implement the query and specific synchronization method according to the different types in the configuration table, perform incremental synchronization, thereby realizing real-time incremental synchronization and manual data synchronization, which can synchronize data in real time, with high efficiency, high accuracy, and strong architecture scalability, and has obvious advantages in data accuracy, real-time, convenience, fault tolerance, etc.
[0034] The present invention also provides a device for implementing MySQL incremental data synchronization based on a message queue, comprising at least one memory and at least one processor;
[0035] The at least one memory is used to store a machine-readable program;
[0036] The at least one processor is used to call the machine-readable program to execute the method for realizing MySQL incremental data synchronization based on a message queue. The information interaction of the processor in the above-mentioned device, the execution process of the readable program, etc., are based on the same concept as the embodiment of the method of the present invention. The specific contents can be found in the description of the embodiment of the method of the present invention, and will not be repeated here. Similarly, the device of the present invention can use the log parsing tool to create a MySQL configuration information table for data management on the data consumer side, monitor the MySQL database, push and listen to the monitored data through the message queue, and then implement the query and specific synchronization method according to the different types in the configuration table, and perform incremental synchronization, thereby realizing real-time incremental synchronization and manual data synchronization, which can synchronize data in real time, with high efficiency, high accuracy, and strong architectural scalability, and has obvious advantages in data accuracy, real-time, convenience, fault tolerance, etc.
[0037] It should be noted that not all steps and modules in each process and each system structure in the above preferred embodiments are necessary, and some steps or modules can be ignored according to actual needs. The execution order of each step is not fixed and can be adjusted as needed. The system structure described in the above embodiments can be a physical structure or a logical structure, that is, some modules may be implemented by the same physical entity, or some modules may be implemented by multiple physical entities, or some components in multiple independent devices may be implemented together.
[0038] The above-described embodiments are only preferred embodiments for fully illustrating the present invention, and the protection scope of the present invention is not limited thereto. Equivalent substitutions or changes made by those skilled in the art based on the present invention are within the protection scope of the present invention. The protection scope of the present invention shall be subject to the claims.
Claims
1. A method for realizing MySQL incremental data synchronization based on message queue, Its characteristics are The data producer and data consumer of the message queue are built through the C / S structure. The offset of the message push is configured by the server of the data producer. The data producer's client is used to extract data and push the data to the message queue. The original data is extracted by the client of the data producer according to the original table structure in MySQL and sent to the message queue in groups. Use the log parsing tool of the data consumer's client to create a monitoring MySQL information configuration table and listen to the data messages of different platforms pushed by the message queue. The original data of different platforms in the data message are extracted through the client of the data consumer, and the specific synchronization method of the data of different platforms is queried according to the information configuration table, and the incremental data synchronization is performed by calling the corresponding specific synchronization method.
2. According to claim 1, a method for realizing MySQL incremental data synchronization based on a message queue, Its characteristics are Write the query method of the information configuration table through SQL statements.
3. According to claim 1, a method for realizing MySQL incremental data synchronization based on a message queue, Its characteristics are Build a message queue middleware for data transmission and use Zookeeper for cluster deployment.
4. A system for implementing MySQL incremental data synchronization based on message queues. Its characteristics are The method for realizing MySQL incremental data synchronization based on a message queue as described in any one of claims 1 to 3 comprises a creation module, a monitoring module, a query module and a data synchronization module. By creating a module, the data consumer uses the log parsing tool to create an information configuration table for monitoring MySQL. The monitoring module listens to the data messages of different platforms pushed by the message queue in the corresponding message queue. The query module queries the specific synchronization methods of data on different platforms according to the information configuration table. The data synchronization module performs incremental data synchronization by calling the corresponding specific synchronization method.
5. A device for realizing MySQL incremental data synchronization based on message queue, Its characteristics are comprising at least one memory and at least one processor; The at least one memory is used to store a machine-readable program; The at least one processor is used to call the machine-readable program to execute a method for implementing MySQL incremental data synchronization based on a message queue as described in any one of claims 1 to 3.
Citation Information
Patent Citations
Data synchronization processing method, mobile terminal and computer readable storage medium
CN107180116A
Method and device for synchronous processing of distributed databases
CN107783975A
Resource monitoring method and device
CN108540341A
Data synchronization method and system based on multi-cloud management, terminal and storage medium
CN112000737A
Full-amount and incremental synchronization method and device for Clickhouse and storage medium
CN112988916A
