Data synchronization system, method and device
By using the assignment mechanism in the data synchronization system to determine the master and standby status of the node, the data synchronization error problem caused by node duplication in the prior art is solved, and the reliability and high availability of data synchronization are achieved.
Patent Information
- Application Number
- CN202410444219.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2023-12-22
- Filing Date
- 2024-04-12
- Publication Date
- 2025-06-24
AI Technical Summary
In the existing data synchronization system, the communication status between nodes and abnormalities in the management and scheduling system lead to the existence of two main synchronization task nodes or two backup synchronization task nodes at the same time, causing data synchronization errors.
By introducing an assignment mechanism in the data synchronization system, the first node determines itself as the main synchronization task node or the backup synchronization task node based on the size relationship between the second assignment corresponding to the second task session in the source database and the first assignment corresponding to the first synchronization task, thereby avoiding node duplication and ensuring uniqueness.
It effectively avoids duplication of the primary synchronization task node or the standby synchronization task node, solves the problem of data synchronization errors, and ensures the reliability and high availability of data synchronization.
Smart Images

Figure CN120196676A_ABST
Abstract
Description
[0001] This application claims the priority of a Chinese patent application with the application number 202311785342.4 and the title "A Task Processing Method, Device and Computing Equipment Cluster" submitted to the National Intellectual Property Administration on December 22, 2023, the entire content of which is incorporated herein by reference. Technical Field
[0002] This application relates to the storage field, and in particular, to a data synchronization system, method and device. Background Art
[0003] The data synchronization function can synchronize the data to be synchronized (such as incremental data, etc.) in the source database to the target database. Therefore, the data synchronization function is applied to master-slave replication of databases, database disaster recovery, timely aggregation of database incremental data, etc. To ensure business continuity, the data synchronization function needs to meet its own high-availability requirements, achieving fast fault recovery or fault transfer at the second or even millisecond level.
[0004] The existing data synchronization function uses a management and scheduling system to manage the configuration and switching of the primary synchronization task node and the standby synchronization task node. However, due to problems such as the communication status between nodes and the exception of the management and scheduling system, there are problems of simultaneously having two primary synchronization task nodes or two standby synchronization task nodes, resulting in data synchronization errors. Summary of the Invention
[0005] This application provides a data synchronization system, method and device, thereby solving the problem that data synchronization errors occur due to simultaneously having two primary synchronization task nodes or two standby synchronization task nodes.
[0006] In a first aspect, this application provides a data synchronization system, including a first node, a second node, a source database and a target database. The first node is respectively connected to the source database and the target database, and the second node is respectively connected to the source database and the target database. A first synchronization task runs on the first node, and a second synchronization task runs on the second node. The source database is used to store the data to be synchronized. The first node is used to obtain a second assignment corresponding to the second task session in the source database. The first node is further used to determine whether the first node is a primary synchronization task node or a standby synchronization task node according to the magnitude relationship between the second assignment and a first assignment corresponding to the first synchronization task. The first node is further used to control the service connection of the first synchronization task to be in a connected state when the first node is the primary synchronization task node, so as to synchronize the data to be synchronized to the target database; when the first node is the standby synchronization task node, control the service connection of the first synchronization task to be in a disconnected state.
[0007] Based on the above data synchronization method, the first node identifies itself as the primary synchronization task node or the secondary synchronization task node through assignment. Since the assignments corresponding to different synchronization tasks are different, the unique primary synchronization task node and the secondary synchronization task node can be determined according to the magnitude relationship of the assignments, avoiding the duplication of the primary synchronization task node or the secondary synchronization task node, and solving the problem that data synchronization errors occur due to the simultaneous existence of two primary synchronization task nodes or two secondary synchronization task nodes.
[0008] As a possible implementation, the first node is specifically configured to: determine that the first node is the primary synchronization task node when the second assignment is greater than the first assignment
[0009] Optionally, the first assignment and the second assignment can only decrease. In this way, when the node with a smaller assignment is the primary synchronization task node, based on the decreasing mechanism of the assignment, the assignment allocated to the primary synchronization task node is a smaller value, which can avoid the situation of two primary synchronization task nodes appearing simultaneously.
[0010] As a possible implementation, the first node is specifically configured to: determine that the first node is the primary synchronization task node when the second assignment is less than the first assignment; the first assignment and the second assignment increase.
[0011] Optionally, the first assignment and the second assignment can only increase. In this way, when the node with a larger assignment is the primary synchronization task node, based on the increasing mechanism of the assignment, the assignment allocated to the primary synchronization task node is a larger value, which can avoid the situation of two primary synchronization task nodes appearing simultaneously.
[0012] As a possible implementation, when the first node is the primary synchronization task node, it waits for the second node to stop the service connection of the second synchronization task and then starts the service connection of the first synchronization task. In this way, the first node and the second node do not execute the synchronization task simultaneously, further avoiding the situation of two primary synchronization task nodes appearing simultaneously, and at the same time avoiding the situation of high permissions required by the synchronization task user to kill the database session.
[0013] In a possible embodiment of the present application, the assignment allocation source has a single mechanism, but the assignment allocation source is not limited, so that based on the single mechanism of the assignment allocation source, the situation of two primary synchronization task nodes appearing simultaneously due to assignment confusion is avoided, and at the same time, a flexible deployment form is supported, avoiding strong dependence on the management node.
[0014] As a possible implementation, the data synchronization system further includes a management control node, which can be used to configure the deployment type of the first node and adjust the assignment. The first node is further configured to: receive the configuration file sent by the management control node; determine the deployment type of the first node according to the configuration file; the deployment type includes a primary synchronization task node or a standby synchronization task node; receive the first assignment sent by the management control node; the first assignment is used to indicate that the first node is a primary synchronization task node or a standby synchronization task node.
[0015] As a possible implementation, if the first node is a standby synchronization task node, after the first node controls the service connection of the first synchronization task to be in a disconnected state, and the management control node switches the first node to a primary synchronization task node, the first node is further configured to: receive the start command sent by the management control node; the start command includes a third assignment, and the third assignment is used to indicate that the first node is a primary synchronization task node; start the service connection of the first synchronization task according to the third assignment.
[0016] Optionally, if the node with a larger assignment is the primary synchronization task node, the third assignment is greater than the second assignment.
[0017] Optionally, if the node with a smaller assignment is the primary synchronization task node, the third assignment is less than the second assignment.
[0018] As a possible implementation, the source database includes a connection information table, and the connection information table includes task information and the assignment corresponding to the task information. Before the first node obtains the second assignment corresponding to the second task session, the first node is further configured to: send the task information to the source database according to the configuration file; obtain the first assignment in the connection information table based on the task information; the first assignment is used to indicate that the first node is a primary synchronization task node or a standby synchronization task node.
[0019] Optionally, the first node queries the second assignment corresponding to the second task session in the connection information table.
[0020] As a possible implementation, the first node and the second node are communicatively connected, and the first node and the second node align the assignments. The first node is further configured to: receive the second assignment corresponding to the second task session sent by the second node.
[0021] Optionally, if the first node is a primary synchronization task node and needs to be configured as a standby synchronization task node, the first node is specifically configured to: stop the service connection of the first synchronization task, and send a notification message to the second node, the notification message includes a fourth assignment, and the fourth assignment is used to indicate that the second node is a primary synchronization task node, so that the second node starts the service connection of the second synchronization task according to the fourth assignment.
[0022] As a possible implementation, there is only one business connection for the synchronization task in the source database at the same time. In this way, since the connections of different synchronization tasks to the source database are mutually exclusive, the situation where the primary synchronization task and the secondary synchronization task connect to the source database simultaneously is avoided, and the situation where two primary synchronization task nodes appear simultaneously is also avoided.
[0023] In a second aspect, the present application provides a data synchronization method, which is applied to the first node of a data synchronization system. The first node is connected to a source database and a target database, and the source database and the target database are also connected to a second node. The first node runs a first synchronization task, and the second node runs a second synchronization task. In the process of this data synchronization method, the first node obtains the second task session of the second synchronization task in the source database, determines the second assignment corresponding to the second task session, and determines whether the first node is the primary synchronization task node or the secondary synchronization task node according to the size relationship between the second assignment and the first assignment. Here, the first assignment is the assignment corresponding to the first task session of the first synchronization task. Then, when the first node is the primary synchronization task node, the first node controls the business connection of the first synchronization task to be in a connected state to synchronize the data to be synchronized in the source database to the target database; when the first node is the secondary synchronization task node, the first node controls the business connection of the first synchronization task to be in a disconnected state to stop the synchronization of the data to be synchronized from the source database to the target database.
[0024] Based on the above data synchronization method, the first node identifies itself as the primary synchronization task node or the secondary synchronization task node through the assignment. Since the assignments corresponding to different synchronization tasks are different, the unique primary synchronization task node and the secondary synchronization task node can be determined according to the size relationship of the assignments, avoiding the duplication of the primary synchronization task node or the secondary synchronization task node, and solving the problem of data synchronization errors caused by the simultaneous existence of two primary synchronization task nodes or two secondary synchronization task nodes.
[0025] As a possible implementation, when the second assignment is greater than the first assignment, the first node determines that itself is the primary synchronization task node.
[0026] Optionally, both the first assignment and the second assignment can only decrease. In this way, when the node with the smaller assignment is the primary synchronization task node, based on the decreasing mechanism of the assignment, the smaller value is assigned to the primary synchronization task node, which can avoid the situation where two primary synchronization task nodes appear simultaneously.
[0027] As a possible implementation, when the second assignment is less than the first assignment, the first node determines that itself is the primary synchronization task node.
[0028] Optionally, the first assignment and the second assignment can only be incremented. In this way, when the node with the larger assignment is the primary synchronization task node, based on the increment mechanism of the assignment, the larger value is assigned to the primary synchronization task node, which can avoid the situation of two primary synchronization task nodes appearing simultaneously.
[0029] As a possible implementation, when the first node is the primary synchronization task node, it waits for the second node to stop the service connection of the second synchronization task and then starts the service connection of the first synchronization task. In this way, the first node and the second node do not execute the synchronization task simultaneously, further avoiding the situation of two primary synchronization task nodes appearing simultaneously and also avoiding the situation of the high privilege of the synchronization task user requesting to kill the database session.
[0030] In a possible embodiment of the present application, the assignment source has a singularity mechanism, but the assignment source is not limited, so based on the singularity mechanism of the assignment source, the situation of two primary synchronization task nodes appearing simultaneously due to assignment chaos can be avoided, and at the same time, a flexible deployment form is supported, avoiding strong dependence on the management node.
[0031] As a possible implementation, the data synchronization system further includes a management control node, which can be used to configure the deployment type of the first node and adjust the assignment. The first node determines the deployment type of the first node according to the configuration file, and the deployment type includes the primary synchronization task node or the standby synchronization task node. Then, the first node receives the first assignment sent by the management control node.
[0032] Optionally, the deployment type of the first node can be sent by the management control node.
[0033] As a possible implementation, when the first node is the standby synchronization task node, after stopping the service connection of the first synchronization task, the management control node switches the first node to the primary synchronization task node, and then the first node receives the start command sent by the management control node. The start command includes a third assignment, and the third assignment is used to indicate that the first node is the primary synchronization task node. Then, the first node starts the service connection of the synchronization task according to the third assignment.
[0034] Optionally, if the node with the larger assignment is the primary synchronization task node, the third assignment is greater than the second assignment.
[0035] Optionally, if the node with the smaller assignment is the primary synchronization task node, the third assignment is less than the second assignment.
[0036] As a possible implementation, the source database includes a connection information table, and the connection information table includes task information and the corresponding assignment for the task information. Before obtaining the second task session, the first node sends the task information to the source database so that the source database determines the first assignment of the first synchronization task of the first node according to the task information, and then the first node receives the first assignment sent by the source database according to the task information.
[0037] Optionally, the first node queries the second assignment corresponding to the second task session in the connection information table.
[0038] As a possible implementation, the first node and the second node are communicatively connected, and the first node and the second node align the assignments. The first node receives the second assignment corresponding to the second task session sent by the second node.
[0039] Optionally, if the first node is the primary synchronization task node and needs to be configured as the standby synchronization task node, the first synchronization node stops the service connection of the first synchronization task and sends a notification message to the second node. The notification message includes a fourth assignment, and the fourth assignment is used to indicate that the second node is the primary synchronization task node, so that the second node starts the service connection of the synchronization task according to the fourth assignment.
[0040] Optionally, if the first node is the standby synchronization task node and the second task session is disconnected and the first node needs to be switched to the primary synchronization task node, then the service connection of the synchronization task is started according to a fifth assignment, and the fifth assignment is used to indicate that the first node is the primary synchronization task node.
[0041] As a possible implementation, there is only one service connection for the synchronization task in the source database at the same time. In this way, since the connections of different synchronization tasks to the source database are mutually exclusive, the situation where the primary synchronization task and the standby synchronization task connect to the source database at the same time is avoided, and the situation where there are two primary synchronization task nodes at the same time is avoided.
[0042] In a third aspect, the present application provides a data synchronization device, including a transceiver module and a processing module. The transceiver module is used to obtain the second task session of the second synchronization task in the source database. The processing module is used to determine the second assignment corresponding to the second task session. The processing module is further used to determine whether the first node is the primary synchronization task node or the standby synchronization task node according to the magnitude relationship between the second assignment and the first assignment corresponding to the first task session of the first synchronization task. The processing module is further used to control the service connection of the first synchronization task to be in a connected state when the first node is the primary synchronization task node, so as to synchronize the data to be synchronized in the source database to the target database; and control the service connection of the first synchronization task to be in a disconnected state when the first node is the standby synchronization task node.
[0043] As a possible implementation, the processing module is specifically configured to: when the second assignment is greater than the first assignment, determine that the first node is the primary synchronization task node.
[0044] Optionally, the first assignment and the second assignment can only decrease.
[0045] As a possible implementation, the processing module is specifically configured to: when the second assignment is less than the first assignment, determine that the first node is the primary synchronization task node.
[0046] Optionally, the first assignment and the second assignment can only increase.
[0047] As a possible implementation, the processing module is specifically configured to: when the first node is the primary synchronization task node, wait for the second node to stop the service connection of the second synchronization task, and then start the service connection of the first synchronization task.
[0048] As a possible implementation, the data synchronization system further includes a management control node. The processing module is further configured to: determine the deployment type of the first node according to the configuration file; the deployment type includes the primary synchronization task node or the standby synchronization task node. The transceiver module is further configured to: receive the first assignment sent by the management control node.
[0049] Optionally, the transceiver module is further configured to: receive a start command sent by the management control node; the start command includes a third assignment, and the third assignment is used to indicate that the first node is the primary synchronization task node. The processing module is further configured to: start the service connection of the synchronization task according to the third assignment.
[0050] As a possible implementation, the source database includes a connection information table, and the connection information table includes task information and the assignment corresponding to the task information. The transceiver module is further configured to: send the task information to the source database; receive the first assignment sent by the source database according to the task information.
[0051] Optionally, the processing module is further configured to: query the second assignment corresponding to the second task session in the connection information table.
[0052] Optionally, the transceiver module is further configured to: receive the second assignment corresponding to the second task session sent by the second node.
[0053] Optionally, the processing module is further configured to: when the first node needs to be configured as the standby synchronization task node, stop the service connection of the first synchronization task. The transceiver module is further configured to: send a notification message to the second node; the notification message includes a fourth assignment, and the fourth assignment is used to indicate that the second node is the primary synchronization task node, so that the second node starts the service connection of the synchronization task according to the fourth assignment.
[0054] Optionally, the processing module is further configured to: when the second task session is disconnected, initiate a service connection for the synchronization task according to the fifth assignment; the fifth assignment is used to indicate that the first node is the primary synchronization task node.
[0055] As a possible implementation, there is only one service connection for the synchronization task in the source database at the same time.
[0056] As a possible implementation, the data synchronization device may further include other modules that perform the operation steps of the data synchronization method described in the second aspect.
[0057] Regarding the technical principles and beneficial effects of the third aspect, reference may be made to the relevant descriptions of the foregoing first aspect or second aspect, which will not be elaborated herein.
[0058] In a fourth aspect, a computing device is provided. The computing device includes a processor and a memory. The processor of the computing device is configured to execute instructions stored in the memory of the computing device so that the computing device executes the data synchronization method described in any one of the possible implementation manners in the second aspect above.
[0059] In a fifth aspect, a computer program product is provided. The computer program product includes a computer program or instructions. When the computer program or instructions are run on a computer, the computer is caused to execute the data synchronization method described in any one of the possible implementation manners in the second aspect above.
[0060] In a sixth aspect, a computer-readable storage medium is provided. The readable storage medium includes: a computer program or instructions; when the computer program or instructions are run on a computer, the computer is caused to execute the data synchronization method described in any one of the possible implementation manners in the second aspect above. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] Figure 1 It is a schematic diagram of the architecture of a data synchronization system provided by the present application;
[0062] Figure 2 It is a schematic diagram of the flow of a data synchronization method provided by the present application;
[0063] Figure 3 It is a schematic diagram of the process of using the management control node as the allocation source provided by the present application;
[0064] Figure 4 It is a schematic diagram of the process of using the source database as the allocation source provided by the present application;
[0065] Figure 5 It is a schematic diagram of the architecture of using the synchronization task node as the allocation source provided by the present application;
[0066] Figure 6Structural schematic diagram of a data synchronization device provided by this application;
[0067] Figure 7 Structural schematic diagram of a computing device provided by this application;
[0068] Figure 8 Structural schematic diagram of a computing device cluster provided by this application;
[0069] Figure 9 Structural schematic diagram of the connection between computing devices through a network provided by this application. Detailed implementation manners
[0070] The data synchronization method provided by the embodiments of this application can be applied to the database synchronization scenario in the storage field. In the existing primary and standby synchronization task conversion schemes based on shared storage and the primary and standby synchronization task conversion schemes based on lease protocols, the problem of simultaneously having two primary synchronization task nodes or two standby synchronization task nodes cannot be completely avoided.
[0071] This application provides a data synchronization system, which includes a first node, a second node, a source database, and a target database. The first node is respectively connected to the source database and the target database, and the second node is respectively connected to the source database and the target database. A first synchronization task runs on the first node, and a second synchronization task runs on the second node. The source database is used to store data to be synchronized. The first node is used to obtain a second assignment corresponding to the second task session in the source database. The first node is further used to determine whether the first node is a primary synchronization task node or a standby synchronization task node according to the magnitude relationship between the second assignment and a first assignment corresponding to the first synchronization task. The first node is further used to, when the first node is a primary synchronization task node, control the service connection of the first synchronization task to be in a connected state to synchronize the data to be synchronized to the target database; when the first node is a standby synchronization task node, control the service connection of the first synchronization task to be in a disconnected state.
[0072] The present application provides a data synchronization method, in particular, a "data synchronization method based on assignment to identify the primary synchronization task node". This method can be applied to any synchronization task node in a data synchronization system. For example, the data synchronization system includes a first node and a second node. The first node is respectively connected to a source database and a target database, and the second node is respectively connected to the source database and the target database. A first synchronization task runs on the first node, and a second synchronization task runs on the second node. In the process of this method, the first node obtains the second task session of the second synchronization task in the source database, determines the second assignment corresponding to the second task session, and determines whether the first node is the primary synchronization task node or the standby synchronization task node according to the size relationship between the second assignment and the first assignment. Among them, the first assignment is the assignment corresponding to the first task session of the first synchronization task. Then, when the first node is the primary synchronization task node, the first node controls the service connection of the first synchronization task to be in a connected state to perform the synchronization of the data to be synchronized from the source database to the target database; when the first node is the standby synchronization task node, it controls the service connection of the first synchronization task to be in a disconnected state to stop the synchronization of the data to be synchronized from the source database to the target database.
[0073] Based on the above data synchronization system and method, the first node identifies itself as the primary synchronization task node or the standby synchronization task node through assignment. Since the assignments corresponding to different synchronization tasks are different, the unique primary synchronization task node and standby synchronization task node can be determined according to the size relationship of the assignments, avoiding the duplication of the primary synchronization task node or the standby synchronization task node, and solving the problem that data synchronization errors occur when there are two primary synchronization task nodes or two standby synchronization task nodes at the same time.
[0074] The implementation manners of the embodiments of the present application will be described in detail below with reference to the accompanying drawings.
[0075] Figure 1 It is a schematic diagram of the architecture of a data synchronization system provided by the present application. As Figure 1 shown, the data synchronization system 100 includes a source database 110, a target database 120, a first node 130, and a second node 140.
[0076] The source database 110 is a database server configured with a source database system for storing and processing business data. The source database 110 is respectively connected to the first node 130 and the second node 140.
[0077] As a possible implementation manner, when the assignment is maintained by the source database 110 as the distribution source, the source database 110 stores a connection information table, and the connection information table includes task information and the assignment corresponding to the task information.
[0078] Optionally, the task information and assignments are stored in a connection information table in tabular form. The task information includes a task identifier, which is used to indicate the synchronization task. For example, the task identifier of the first synchronization task is Task 1, the assignment corresponding to Task 1 is Assignment 1, the task identifier of the second synchronization task is Task 2, and the assignment corresponding to Task 2 is Assignment 2. In the connection information table, Task 1 and Task 2 are used as keys, Assignment 1 is the value corresponding to Task 1, and Assignment 2 is the value corresponding to Task 2.
[0079] The target database 120 is a database server, configured with a source database system for storing and processing business data, such as data to be synchronized. The target database 120 is respectively connected to the first node 130 and the second node 140. The synchronization tasks of the first node 130 and the second node 140 are used to synchronize the business data of the source database 110 to the target database 120.
[0080] Both the first node 130 and the second node 140 are synchronization task nodes. In the primary and standby synchronization task scenario, one of the first node 130 and the second node 140 is a primary synchronization task node and the other is a standby synchronization task node. For example, the first node 130 is the primary synchronization task node and the second node 140 is the standby synchronization task node, or the first node 130 is the standby synchronization task node and the second node 140 is the primary synchronization task node.
[0081] As a possible implementation, if the first node 130 is the primary synchronization task node, then the first node 130 is a primary synchronization task server, configured with a control proxy module 131, a data pulling module 132, and a data playback module 133.
[0082] The control proxy module 131 is used to manage the synchronization task information (task information) on its own side (such as the first node 130), and to schedule the data pulling module 132 and the data playback module 133. The control proxy module 131 can also be used to communicate with the synchronization tasks on the opposite side (such as the second node 140).
[0083] The data pulling module 132 is used to pull the incremental data of the source database 110 to the synchronization task server (such as the first node 130). The data pulling module 132 is also used to identify the connections and assignments of the synchronization tasks in the source database 110, and to control the connection between its own side (such as the first node 130) and the database.
[0084] The data playback module 133 is used to playback the incremental data pulled from the source database 110 to the target database 120.
[0085] As a possible implementation, the structure of the second node 140 is the same as that of the first node 130, including a control proxy module 141, a data pulling module 142, and a data playback module 143, which will not be elaborated here.
[0086] As a possible implementation, the first node 130 and the second node 140 respectively store configuration files for registering deployment types, including the primary synchronization task node or the standby synchronization task node, so that the first node 130 or the second node 140 executes the synchronization task in the manner corresponding to the deployment type.
[0087] The source database 110, the target database 120, the first node 130, and the second node 140 in the data synchronization system 100 cooperate to execute the data synchronization method. For the specific actions and functions of the source database 110, the target database 120, the first node 130, and the second node 140 in the data synchronization method, please refer to steps 201 - 205 of the data synchronization method shown later, which will not be elaborated here. Figure 2 Steps 201 - 205 of the data synchronization method shown will not be elaborated here.
[0088] It should be noted that Figure 1 The example shown above is only for the data synchronization system 100 and should not be construed as a limitation of this application. For example, the data synchronization system 100 may further include a management control node 150, which is used for the management of overall synchronization task information and the scheduling of synchronization task behaviors. For example, the management control node 150 is respectively connected to the control agent module 131 and the control agent module 141, and serves as the assignment source to be responsible for the scheduling of synchronization tasks and the conversion between primary and standby tasks. Another example is that the first node 130 and the second node 140 in the data synchronization system 100 are directly communicatively connected, and the first node 130 and the second node 140 negotiate and assign values to serve as the assignment source.
[0089] Next, the data synchronization method provided in this embodiment will be specifically described with reference to the accompanying drawings.
[0090] The steps of the data synchronization method provided in this application are executed by a certain device or several devices in the data synchronization system 100. Next, Figure 2 , taking the first node 130 as an example, the data synchronization method provided in the embodiments of this application will be described.
[0091] Step 201: The first node 130 obtains the second task session of the second synchronization task in the source database 110.
[0092] The second task session is the session when the second synchronization task interacts with the source database 110, representing the interaction process between the second synchronization task of the second node 140 and the source database 110. This process can be continuous or intermittent.
[0093] Step 202: The first node 130 determines the second assignment corresponding to the second task session.
[0094] As a possible implementation, when the management control node 150 serves as the assignment source, the first node 130 queries the second assignment corresponding to the second task session from the management control node 150, and the management control node 150 sends the second assignment corresponding to the second task session to the first node 130 according to the correspondence between the task session and the assignment.
[0095] As a possible implementation, when the source database 110 serves as the assignment source, the first node 130 queries the second assignment corresponding to the second task session from the connection information table of the source database 110, and the source database 110 sends the second assignment corresponding to the second task session to the first node 130 according to the correspondence between the task session and the assignment in the connection information table.
[0096] As a possible implementation, when the first node 130 and the second node 140 serve as the assignment source, the first node 130 obtains the second assignment corresponding to the second task session from the second node 140, and the second node 140 sends the second assignment corresponding to the second task session of the second synchronization task to the first node 130.
[0097] Step 203: The first node 130 determines whether the first node is the primary synchronization task node or the secondary synchronization task node according to the magnitude relationship between the second assignment and the first assignment corresponding to the first task session of the first synchronization task.
[0098] As a possible implementation, when the second assignment is greater than the first assignment, the first node 130 determines that the first node is the primary synchronization task node.
[0099] Optionally, the assignment (such as the first assignment and the second assignment) can only decrease.
[0100] As a possible implementation, when the second assignment is less than the first assignment, the first node 130 determines that the first node is the primary synchronization task node.
[0101] Optionally, the assignment (such as the first assignment and the second assignment) can only increase.
[0102] Step 204: When the first node 130 is the primary synchronization task node, control the service connection of the first synchronization task to be in a connected state to synchronize the data to be synchronized in the source database 110 to the target database 120.
[0103] As a possible implementation, if the first node 130 is the secondary synchronization task node before step 204, start the service connection of the first synchronization task.
[0104] As a possible implementation, if the first node 130 is the primary synchronization task node before step 204, keep the service connection of the first synchronization task in a connected state.
[0105] Step 205: When the first node 130 is a standby synchronization task node, control the service connection of the first synchronization task to be in a disconnected state.
[0106] As a possible implementation, if the first node 130 is a standby synchronization task node before step 204, keep the service connection of the first synchronization task in a disconnected state.
[0107] As a possible implementation, if the first node 130 is a primary synchronization task node before step 204, disconnect the service connection of the first synchronization task.
[0108] For the second node 140, the second node 140 can also perform similar steps 201 - 205 to identify whether the second node 140 is a primary synchronization task node or a standby synchronization task node, so as to control the service connection of the second synchronization task to be in a connected state or a disconnected state, which will not be elaborated here.
[0109] Based on the above steps 201 - 205, any node in the data synchronization system 100 can identify itself as a primary synchronization task node or a standby synchronization task node through the assignment of its own synchronization task, and can also identify other nodes as primary synchronization task nodes or standby synchronization task nodes through the assignment corresponding to the task session of other nodes' synchronization tasks in the source database 110. Since the assignment has a unique allocation source, there is only one unique assignment corresponding to the unique primary synchronization task among the assignments corresponding to the synchronization tasks of each node in the data synchronization system 100. Thus, the unique primary synchronization task node is determined according to the assignments corresponding to different synchronization tasks, avoiding duplication of primary synchronization task nodes or standby synchronization task nodes, and solving the problem of data synchronization errors caused by the simultaneous existence of two primary synchronization task nodes or two standby synchronization task nodes.
[0110] As described above in conjunction with Figure 2 the overall process of the data synchronization method has been described. Next, exemplary descriptions will be given for scenarios with different assignment sources. Figures 3 - 5 For scenarios where the assignment sources are different.
[0111] Please refer to Figure 3 , Figure 3 for the assignment of the management control node 150, as well as the scheduling of synchronization tasks, the conversion of primary and standby nodes, etc.
[0112] Step 301: The management control node 150 sends configuration files to the first node 130 and the second node 140.
[0113] When the synchronization task of the data synchronization system 100 is deployed in the system, the management control node 150 registers the deployment type in the configuration file and sends the configuration file to the first node 130 and the second node 140.
[0114] For example, the deployment type of the configuration file received by the first node 130 is the primary synchronization task node, and the deployment type of the configuration file received by the second node 140 is the standby synchronization task node. When the first node 130 and the second node 140 are started, they read their respective configuration files to determine their own deployment types.
[0115] Step 302, the management control node 150 assigns values to the first node 130 and the second node 140.
[0116] When the synchronization task is started, the management control node 150 assigns a first value to the first node 130 and a second value to the second node 140. Among them, the first value is used to indicate the primary synchronization task node.
[0117] As a possible implementation, taking the deployment type of the configuration file of the first node 130 as the primary synchronization task node as an example, the larger value among the assigned values of each node represents the primary synchronization task node, so the first value is greater than the second value.
[0118] As a possible implementation, taking the deployment type of the configuration file of the first node 130 as the primary synchronization task node as an example, the smaller value among the assigned values of each node represents the primary synchronization task node, so the first value is less than the second value.
[0119] Step 303, the first node 130 starts the first synchronization task.
[0120] Step 304, the second node 140 controls the second synchronization task to wait.
[0121] After the first node 130 starts the first synchronization task, the first node 130 connects to the source database 110 and the target database 120 to execute the first synchronization task. The second node 140 controls the second synchronization task to be in a stopped running state.
[0122] Step 305, the management control node 150 sends a start command to the second node 140.
[0123] The start command includes a third value, and the third value is used to indicate that the second node is the primary synchronization task node. For example, the synchronization task with a larger value is the primary synchronization task, and the third value is greater than the first value and the second value.
[0124] Step 306, the second node 140 waits for the first node 130 to disconnect the first task session and then starts a service connection according to the third value.
[0125] Step 307: The first node 130 commits suicide for the first task session.
[0126] As a possible implementation, when the connection control component of the data pulling module and the data playback module of the first node 130 connects to the source database 110, it establishes a dedicated detection connection to continuously detect the existing synchronization task sessions in the source database 110. If there is only a task session with an assignment value less than its own assignment value, the first node 130 determines that it is the primary synchronization task node. If there is a task session with an assignment value greater than its own assignment value, the first node 130 determines that it is the standby synchronization task node and immediately commits suicide for the first task session.
[0127] As a possible implementation, the second node 140 can also continuously detect the existing synchronization task sessions in the source database 110 in the same way as the first node 130. If there is only a task session with an assignment value less than its own assignment value, the first node 130 determines that it is the primary synchronization task node and waits for the first node 130 to disconnect the first task session before starting the service connection for the second synchronization task. If there is a task session with an assignment value greater than its own assignment value, the second node 140 determines that it is the standby synchronization task node and immediately commits suicide for the second task session. If there are no other synchronization task sessions, it immediately starts the service connection for the second synchronization task.
[0128] In a possible embodiment of the present application, the above first task session and the second task session are mutually exclusive, that is, the source database 110 can only maintain one task session running at the same time.
[0129] Please refer to Figure 4 , Figure 4 the management of the assignment by the connection information table of the source database 110.
[0130] Step 401: Create a dedicated connection information table for the synchronization task in the source database 110 in advance.
[0131] The connection information table includes the identifier of the synchronization task, the Internet Protocol (IP) address, the task status information, the breakpoint information, and the assignment value. When the first node 130 and the second node 140 connected to the source database 110 start the synchronization task, they insert or update the task information of their corresponding synchronization tasks in the connection information table of the source database 110 and associate the task session with the assignment value.
[0132] Step 402: The first node 130 configures the deployment type.
[0133] Step 403: The second node 140 configures the deployment type.
[0134] When the synchronization task of the data synchronization system 100 is deployed in the system, the first node 130 and the second node 140 register the deployment type in the configuration file. For example, the deployment type of the configuration file of the first node 130 is the primary synchronization task node, and the deployment type of the configuration file of the second node 140 is the standby synchronization task node. The first node 130 and the second node 140 read their respective configuration files at startup to determine their own deployment types.
[0135] Step 404, the first node 130 starts the first synchronization task according to the first assignment.
[0136] Step 405, the second node 140 controls the second synchronization task to wait according to the second assignment.
[0137] The above steps 404 and 405 take the example that the first node 130 is deployed as the primary synchronization task node and the second node 140 is deployed as the standby synchronization task node. The first assignment is used to indicate that the first node 130 is the primary synchronization task node, and the second assignment is used to indicate that the second node 140 is the standby synchronization task node.
[0138] As a possible implementation, the first node 130 and the second node 140 can also continuously detect the task sessions of other nodes to achieve the conversion between the primary and standby synchronization nodes, which will not be elaborated here.
[0139] As a possible implementation, when the standby synchronization task node in the first node 130 and the second node 140 is converted into the primary synchronization task node, it updates the corresponding assignment in the connection information table to a value larger than the assignment corresponding to the task session of the primary synchronization task node, and then starts the service connection to perform data pulling and data playback, thus completing the primary and standby conversion.
[0140] Please refer to Figure 5 , Figure 5 for the management of assignments through communication negotiation between the first node 130 and the second node 140.
[0141] The first node 130 and the second node 140 are communicatively connected. When the synchronization task is initialized and started, the node with a larger randomly generated assignment is used as the primary synchronization task node. During the synchronization process, the first node 130 and the second node 140 perform information interaction in real time to align assignments, task status information, etc.
[0142] The steps of the first node 130 and the second node 140 for deployment type registration, primary and standby task switching, etc. are all similar to the specific methods shown above Figure 3 , Figure 4 and will not be elaborated here.
[0143] To cooperate with the data synchronization method provided in the above embodiments of this application, this application also provides a data synchronization device 600, which can be used to implement the functions of the first node 130 or the second node 140 in the data synchronization method shown above. As Figures 2 - 5 shown, the data synchronization device 600 includes a transceiver module 610 and a processing module 620. Figure 6 shown, the data synchronization device 600 includes a transceiver module 610 and a processing module 620.
[0144] The transceiver module 610 is used to obtain the second task session of the second synchronization task in the source database.
[0145] The processing module 620 is used to determine the second assignment corresponding to the second task session.
[0146] The processing module 620 is further used to determine whether the first node is the primary synchronization task node or the standby synchronization task node according to the magnitude relationship between the second assignment and the first assignment corresponding to the first task session of the first synchronization task.
[0147] The processing module 620 is further used to control the service connection of the first synchronization task to be in a connected state when the first node is the primary synchronization task node, so as to synchronize the data to be synchronized in the source database to the target database.
[0148] The processing module 620 is further used to control the service connection of the first synchronization task to be in a disconnected state when the first node is the standby synchronization task node.
[0149] As a possible implementation, the processing module 620 is specifically used to: when the second assignment is greater than the first assignment, determine that the first node is the primary synchronization task node.
[0150] Optionally, both the first assignment and the second assignment can only decrease.
[0151] As a possible implementation, the processing module 620 is specifically used to: when the second assignment is less than the first assignment, determine that the first node is the primary synchronization task node.
[0152] Optionally, both the first assignment and the second assignment can only increase.
[0153] As a possible implementation, the processing module 620 is specifically used to: when the first node is the primary synchronization task node, wait for the second node to stop the service connection of the second synchronization task and then start the service connection of the first synchronization task.
[0154] As a possible implementation, the data synchronization system 100 further includes a management control node 150. The processing module 620 is further configured to: determine the deployment type of the first node according to the configuration file; the deployment type includes a primary synchronization task node or a standby synchronization task node. The transceiver module 610 is further configured to: receive the first assignment sent by the management control node.
[0155] Optionally, the transceiver module 610 is further configured to: receive a start command sent by the management control node; the start command includes a third assignment, and the third assignment is used to indicate that the first node is a primary synchronization task node. The processing module 620 is further configured to: start the service connection of the synchronization task according to the third assignment.
[0156] As a possible implementation, the source database 110 includes a connection information table, and the connection information table includes task information and the assignment corresponding to the task information. The transceiver module 610 is further configured to: send the task information to the source database; receive the first assignment sent by the source database according to the task information.
[0157] Optionally, the processing module 620 is further configured to: query the second assignment corresponding to the second task session in the connection information table.
[0158] Optionally, the transceiver module 610 is further configured to: receive the second assignment corresponding to the second task session sent by the second node.
[0159] Optionally, when the first node needs to be configured as a standby synchronization task node, the processing module 620 is further configured to: stop the service connection of the first synchronization task. The transceiver module 610 is further configured to: send a notification message to the second node; the notification message includes a fourth assignment, and the fourth assignment is used to indicate that the second node is a primary synchronization task node, so that the second node starts the service connection of the synchronization task according to the fourth assignment.
[0160] Optionally, when the second task session is disconnected, the processing module 620 is further configured to: start the service connection of the synchronization task according to the fifth assignment; the fifth assignment is used to indicate that the first node is a primary synchronization task node.
[0161] As a possible implementation, there is only one service connection for the synchronization task in the source database at the same time.
[0162] Among them, both the transceiver module 610 and the processing module 620 can be implemented by software or can be implemented by hardware. Exemplarily, next, taking the transceiver module 610 as an example, the implementation manner of the transceiver module 610 is introduced. Similarly, the implementation manner of the processing module 620 can refer to the implementation manner of the transceiver module 610.
[0163] As an example of a software functional unit, the transceiver module 610 may include code running on a computing instance. The computing instance may include at least one of a physical host (computing device), a virtual machine, and a container. Further, the above computing instance may be one or more. For example, the transceiver module 610 may include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers for running the code may be distributed in the same region or in different regions. Further, the multiple hosts / virtual machines / containers for running the code may be distributed in the same availability zone (AZ) or in different AZs, and each AZ includes one data center or multiple geographically proximate data centers. Usually, one region may include multiple AZs.
[0164] Similarly, the multiple hosts / virtual machines / containers for running the code may be distributed in the same virtual private cloud (VPC) or in multiple VPCs. Usually, one VPC is set within one region. For cross-region communication between two VPCs within the same region and between VPCs in different regions, a communication gateway needs to be set in each VPC, and the interconnection between VPCs is achieved through the communication gateway.
[0165] As an example of a hardware functional unit, the transceiver module 610 may include at least one computing device, such as a server, etc. Alternatively, the transceiver module 610 may also be a device implemented using an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). Among them, the above PLD may be implemented by a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.
[0166] The multiple computing devices included in the transceiver module 610 can be distributed in the same region or in different regions. The multiple computing devices included in the transceiver module 610 can be distributed in the same availability zone (AZ) or in different AZs. Similarly, the multiple computing devices included in the transceiver module 610 can be distributed in the same virtual private cloud (VPC) or in multiple VPCs. Among them, the multiple computing devices can be any combination of computing devices such as servers, application-specific integrated circuits (ASICs), programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs), and generic array logic (GALs).
[0167] It should be noted that in other embodiments, either the transceiver module 610 or the processing module 620 can be used to execute any step in the data synchronization method. The steps to be implemented by the transceiver module 610 and the processing module 620 can be specified as needed. By implementing different steps in the data synchronization method through the transceiver module 610 and the processing module 620 respectively, all functions of the data synchronization device 600 can be realized.
[0168] This application also provides a computing device 700. As Figure 7 shown, the computing device 700 includes: a bus 702, a processor 704, a memory 706, and a communication interface 708. The processor 704, the memory 706, and the communication interface 708 communicate with each other through the bus 702. The computing device 700 can be a server or a terminal device. It should be understood that this application does not limit the number of processors and memories in the computing device 700.
[0169] The bus 702 can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of convenience of representation, Figure 7 only one line is shown in the figure, but it does not mean that there is only one bus or one type of bus. The bus 702 can include a path for transmitting information between various components of the computing device 700 (for example, the memory 706, the processor 704, and the communication interface 708).
[0170] The processor 704 can include any one or more of processors such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0171] The memory 706 may include volatile memory, such as random access memory (RAM). The processor 704 may also include non-volatile memory, such as read-only memory (ROM), flash memory, a hard disk drive (HDD), or a solid state drive (SSD).
[0172] Executable program code is stored in the memory 706, and the processor 704 executes the executable program code to implement the functions of the respective modules included in the aforementioned data synchronization device 600, thereby implementing the data processing method. That is, instructions for executing the data synchronization method are stored on the memory 706.
[0173] Alternatively, executable code is stored in the memory 706, and the processor 704 executes the executable code to implement the functions of the aforementioned service nodes, thereby implementing the data synchronization method. That is, instructions for executing the data synchronization method are stored on the memory 706.
[0174] The communication interface 708 uses a transceiver module such as, but not limited to, a network interface card or a transceiver to implement communication between the computing device 700 and other devices or a communication network.
[0175] Considering that the data synchronization method provided in this application is applied to the data synchronization system 100, the respective infrastructures of the first node 130, the second node 140, etc. of the data synchronization system 100 usually include multiple computing devices. Therefore, this application also provides a computing device cluster. The computing device cluster includes at least one computing device. The computing device may be a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, the computing device may also be a terminal device such as a desktop computer, a laptop computer, or a smart phone.
[0176] As Figure 8 shown, the computing device cluster includes at least one computing device 700. Instructions for executing the data synchronization method may be stored in the same manner in the memory 706 of one or more of the computing devices 700 in the computing device cluster.
[0177] In some possible implementation manners, instructions for executing the data synchronization method may also be separately stored in the memory 706 of one or more of the computing devices 700 in the computing device cluster. In other words, a combination of one or more computing devices 700 may jointly execute the instructions for executing the data synchronization method.
[0178] It should be noted that the memories 706 in different computing devices 700 in the computing device cluster may store different instructions, which are respectively used to execute partial functions of the data synchronization device 600. That is to say, the instructions stored in the memories 706 in different computing devices 700 can implement the functions of one or more modules included in the data synchronization device 600.
[0179] In some possible implementation manners, one or more computing devices in the computing device cluster may be connected through a network. Among them, the network may be a wide area network, a local area network, or the like. Figure 9 A possible implementation manner is shown. As Figure 9 shown, two computing devices 700A and 700B are connected through a network. Specifically, they are connected to the network through the communication interfaces in each computing device. In this type of possible implementation manners, the memory 706 in the computing device 700A stores instructions for executing the functions of one or more of the transceiver module 610 and the processing module 620. Figure 9 Taking the memory 706 in the computing device 700A storing instructions for executing the function of the transceiver module 610 as an example. At the same time, the memory 706 in the computing device 700B stores instructions for executing the functions of one or more of the transceiver module 610 and the processing module 620. Figure 9 Taking the memory 706 in the computing device 700B storing instructions for executing the function of the processing module 620 as an example.
[0180] It should be understood that Figure 9 the functions of the computing device 700A shown may also be completed by multiple computing devices 700. Similarly, the functions of the computing device 700B may also be completed by multiple computing devices 700.
[0181] The embodiment of the present application also provides a computer program product including instructions. The computer program product may be a software or program product including instructions that can run on a computing device or be stored in any available medium. When the computer program product runs on at least one computing device, it causes at least one computing device to execute the steps performed by the first node 130 or the second node 140 in the data synchronization method as Figures 2 - 5 shown.
[0182] An embodiment of the present application also provides a computer-readable storage medium. The computer-readable storage medium may be any available medium that can be stored by a computing device or a data storage device such as a data center including one or more available media. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a magnetic tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid state drive), etc. The computer-readable storage medium includes instructions that direct the computing device to perform the data synchronization method as Figures 2 - 5 shown.
[0183] The above embodiments can be implemented in whole or in part by software, hardware (such as circuits), firmware, or any arbitrary combination thereof. When implemented using software, the above embodiments can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, the processes or functions described in the embodiments of the present application are generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center by wired (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server or a data center including one or more available media. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a magnetic tape), an optical medium (e.g., a DVD), or a semiconductor medium. The semiconductor medium may be a solid state drive.
[0184] Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be implemented by electronic hardware or a combination of computer software and electronic hardware. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. A professional technician can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present application.
[0185] Those skilled in the art can clearly understand that for the convenience and conciseness of description, the specific working processes of the systems, devices, and units described above can refer to the corresponding processes in the foregoing method embodiments and will not be elaborated herein.
[0186] In several embodiments provided in this 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 merely illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, 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 displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces. The indirect couplings or communication connections of the devices or units can be in electrical, mechanical, or other forms.
[0187] The units described as separate components may or may not be physically separated. The components displayed as units may or may not be physical units, that is, they can be located in one place or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0188] In addition, in each embodiment of this application, the functional units can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit.
[0189] If the function 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 this application, in essence, or the part that contributes to the prior art or part of this technical solution can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in each embodiment of this application. The aforementioned storage medium includes: USB flash drives, mobile hard disks, read-only memories, random access memories, magnetic disks, or optical discs and other various media that can store program codes.
[0190] In this application, "at least one" means one or more, and "a plurality" means two or more. "And / or" describes the relationship between related objects and indicates that there can be three relationships. For example, A and / or B can represent the situations of A existing alone, A and B existing simultaneously, and B existing alone, where A and B can be singular or plural. The character " / " generally indicates that the related objects before and after are in an "or" relationship. "At least one (item)" or its similar expression refers to any combination of these items, including any combination of a single item or multiple items. For example, at least one (item) of a, b, or c can represent: a, b, c, a and b, a and c, b and c, or a, b, and c, where a, b, and c can be single or multiple.
[0191] It should be noted that in this application, words such as "exemplary" or "for example" are used to give examples, illustrations, or explanations. Any embodiment or design solution described as "exemplary" or "for example" in this application should not be construed as being more preferred or having more advantages than other embodiments or design solutions. Rather, the use of words such as "exemplary" or "for example" is intended to present relevant concepts in a specific manner.
[0192] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments or perform equivalent replacements for some of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the protection scope of the technical solutions of the various embodiments of the present invention.
Claims
1. A data synchronization system, characterized in that: It includes a first node, a second node, a source database and a target database, wherein the first node is connected to the source database and the target database respectively, the second node is connected to the source database and the target database respectively, the first node runs a first synchronization task, and the second node runs a second synchronization task; The source database is used to store the data to be synchronized; The first node is used to obtain a second assignment corresponding to the second task session in the source database; The first node is further used to determine whether the first node is a main synchronization task node or a backup synchronization task node according to a size relationship between the second assignment and the first assignment corresponding to the first synchronization task; The first node is also used to control the business connection of the first synchronization task to be in a connected state when the first node is a primary synchronization task node, so as to synchronize the data to be synchronized to the target database; and to control the business connection of the first synchronization task to be in a disconnected state when the first node is a backup synchronization task node.
2. The system according to claim 1, characterized in that The determining, according to the magnitude relationship between the second assignment and the first assignment corresponding to the first synchronization task, that the first node is a primary synchronization task node or a backup synchronization task node comprises: When the second assignment is greater than the first assignment, the first node determines that the first node is the main synchronization task node; the first assignment and the second assignment are decreased in sequence.
3. The system according to claim 1, characterized in that The determining, according to the magnitude relationship between the second assignment and the first assignment corresponding to the first synchronization task, that the first node is a primary synchronization task node or a backup synchronization task node comprises: When the second assignment is less than the first assignment, the first node determines that the first node is the main synchronization task node; the first assignment and the second assignment are incremented.
4. The system according to any one of claims 1 to 3, characterized in that: When the first node is the primary synchronization task node, controlling the service connection of the first synchronization task to be in a connected state includes: In the case where the first node is a primary synchronization task node, the first node starts the service connection of the first synchronization task after waiting for the second node to stop the service connection of the second synchronization task.
5. The system according to any one of claims 1 to 4, characterized in that: The data synchronization system further includes a management control node. Before acquiring the second value corresponding to the second task session in the source database, the first node is further configured to: Receiving a configuration file sent by the management control node; Determining a deployment type of the first node according to the configuration file; the deployment type includes a primary synchronization task node or a backup synchronization task node; The first assignment sent by the management control node is received; the first assignment is used to indicate that the first node is a primary synchronization task node or a backup synchronization task node.
6. The system according to claim 5, characterized in that In the case where the first node is a standby synchronization task node, after controlling the service connection of the first synchronization task to be in a disconnected state, the first node is further used to: receiving a start command sent by the management control node; the start command includes a third assignment, and the third assignment is used to indicate that the first node is a main synchronization task node; The service connection of the first synchronization task is started according to the third assignment.
7. The system according to any one of claims 1 to 4, characterized in that: The source database includes a connection information table, the connection information table includes task information and a value corresponding to the task information, the first node includes a configuration file, and before obtaining a second value corresponding to the second task session in the source database, the first node is further used to: Sending the task information to the source database according to the configuration file; The first assignment is obtained in the connection information table based on the task information; the first assignment is used to indicate that the first node is a primary synchronization task node or a backup synchronization task node.
8. The system according to claim 7, characterized in that The obtaining of the second assignment corresponding to the second task session in the source database, wherein the first node is further configured to: The connection information table is searched for a second value corresponding to the second task session.
9. The system according to any one of claims 1 to 4, characterized in that: The first node is connected to the second node, and the second assignment corresponding to the second task session in the source database is obtained, and the first node is further used for: Receive the second assignment corresponding to the second task session sent by the second node.
10. The system according to claim 9, characterized in that In the case where the first node is a main synchronization task node, after controlling the service connection of the first synchronization task to be in a connected state, the first node is further used to: When the first node needs to be configured as a standby synchronization task node, stopping the service connection of the first synchronization task; Send a notification message to the second node; the notification message includes a fourth assignment, the fourth assignment is the corresponding assignment before the first synchronization task is stopped, so that the second node starts the business connection of the second synchronization task according to the fourth assignment.
11. The system according to claim 9, characterized in that In the case where the first node is a standby synchronization task node, after controlling the service connection of the first synchronization task to be in a disconnected state, the first node is further used to: When the second task session is disconnected, the service connection of the first synchronization task is started according to the fifth assignment; the fifth assignment is used to indicate that the first node is the main synchronization task node.
12. The system according to any one of claims 1 to 11, characterized in that: The source database has only one business connection for a synchronization task at the same time.
13. A data synchronization method, characterized in that: A first node applied to a data synchronization system, wherein the first node is connected to a source database and a target database respectively, and the source database and the target database are also connected to a second node, The first node runs a first synchronization task, and the second node runs a second synchronization task, including: Acquire a second task session of the second synchronization task in the source database; determining a second assignment corresponding to the second task session; Determine whether the first node is a primary synchronization task node or a backup synchronization task node according to a size relationship between the second assignment and a first assignment corresponding to the first task session of the first synchronization task; In the case where the first node is a primary synchronization task node, controlling the service connection of the first synchronization task to be in a connected state, so as to synchronize the to-be-synchronized data of the source database to the target database; In the case where the first node is a standby synchronization task node, the service connection controlling the first synchronization task is in a disconnected state.
14. The method according to claim 13, characterized in that The determining, according to the magnitude relationship between the second assignment and the first assignment corresponding to the first task session of the first synchronization task, that the first node is a primary synchronization task node or a backup synchronization task node comprises: When the second assigned value is greater than the first assigned value, the first node is determined to be the main synchronization task node; and the first assigned value and the second assigned value are decreased in sequence.
15. The method according to claim 13, characterized in that The determining, according to the magnitude relationship between the second assignment and the first assignment corresponding to the first task session of the first synchronization task, that the first node is a primary synchronization task node or a backup synchronization task node comprises: When the second assignment is less than the first assignment, the first node determines that the first node is the main synchronization task node; the first assignment and the second assignment are incremented.
16. The method according to any one of claims 13 to 15, characterized in that When the first node is a primary synchronization task node, controlling the service connection of the first synchronization task to be in a connected state includes: In the case where the first node is a primary synchronization task node, the first node starts the service connection of the first synchronization task after waiting for the second node to stop the service connection of the second synchronization task.
17. The method according to any one of claims 13 to 16, characterized in that The data synchronization system further includes a management control node. Before acquiring the second task session of the second synchronization task in the source database, the method further includes: The first node receives the configuration file sent by the management control node; The first node determines a deployment type of the first node according to the configuration file; the deployment type includes a primary synchronization task node or a backup synchronization task node; The first node receives the first assignment sent by the management control node; the first assignment is used to indicate that the first node is a primary synchronization task node or a backup synchronization task node.
18. The method according to claim 17, characterized in that When the first node is a standby synchronization task node, after controlling the service connection of the first synchronization task to be in a disconnected state, the method further includes: The first node receives a start command sent by the management control node; the start command includes a third assignment, and the third assignment is used to indicate that the first node is a main synchronization task node; The first node starts a service connection for the first synchronization task according to the third assignment.
19. The method according to any one of claims 13 to 16, characterized in that: The source database includes a connection information table, the connection information table includes task information and a value corresponding to the task information, the first node includes a configuration file, and before obtaining the second task session of the second synchronization task in the source database, the method further includes: The first node sends the task information to the source database according to the configuration file; The first node obtains the first value in the connection information table based on the task information; the first value is used to indicate that the first node is a primary synchronization task node or a backup synchronization task node.
20. The method according to claim 19, characterized in that The determining a second value corresponding to the second task session includes: The first node searches the connection information table for a second value corresponding to the second task session.
21. The method according to any one of claims 13 to 16, characterized in that: The first node is connected to the second node, and the determining a second value corresponding to the second task session includes: The first node receives the second assignment corresponding to the second task session sent by the second node.
22. The method according to claim 21, characterized in that In the case where the first node is a primary synchronization task node, after controlling the service connection of the first synchronization task to be in a connected state, the method further includes: When the first node needs to be configured as a standby synchronization task node, the first node stops the service connection of the first synchronization task; The first node sends a notification message to the second node; the notification message includes a fourth assignment, and the fourth assignment is the corresponding assignment before the first synchronization task is stopped, so that the second node starts the business connection of the second synchronization task according to the fourth assignment.
23. The method according to claim 21, characterized in that In the case where the first node is a standby synchronization task node, after controlling the service connection of the first synchronization task to be in a disconnected state, the method further includes: When the second task session is disconnected, the first node starts the service connection of the first synchronization task according to the fifth assignment; the fifth assignment is used to indicate that the first node is the main synchronization task node.
24. The method according to any one of claims 13 to 23, characterized in that The source database has only one business connection for a synchronization task at the same time.
25. A data synchronization device, characterized in that: include: A transceiver module, used for acquiring a second task session of a second synchronization task in a source database; a processing module, configured to determine a second assignment corresponding to the second task session; The processing module is further used to determine whether the first node is a primary synchronization task node or a backup synchronization task node according to a size relationship between the second assignment and a first assignment corresponding to a first task session of the first synchronization task; The processing module is also used to control the business connection of the first synchronization task to be in a connected state when the first node is a primary synchronization task node, so as to synchronize the data to be synchronized of the source database to the target database; and to control the business connection of the first synchronization task to be in a disconnected state when the first node is a backup synchronization task node.
26. A computing device cluster, characterized in that: comprising at least one computing device, each computing device comprising a processor and a memory; The processor of the at least one computing device is configured to execute instructions stored in the memory of the at least one computing device, so that the computing device cluster executes the method according to any one of claims 13-24.
27. A computer program product comprising instructions, characterized in that When the instructions are executed by a computing device cluster, the computing device cluster executes the method according to any one of claims 13 to 24.
28. A computer-readable storage medium, characterized in that: The method comprises computer program instructions, and when the computer program instructions are executed by a computing device cluster, the computing device cluster performs the method as claimed in any one of claims 13 to 24.