Data synchronization method, system and device for ETCD cluster configuration and storage medium
By first synchronizing the data of the main ETCD cluster in multiple computer rooms and synchronizing the subcluster based on polling rules, the problem of heavy deployment burden and inefficiency is solved, efficient and consistent management of ETCD cluster configuration is realized, and operation and maintenance is reduced The workload of the personnel and improves the user experience and system stability.
Patent Information
- Application Number
- CN202411129956.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-16
- Publication Date
- 2024-12-20
AI Technical Summary
In the case of following the "two places and three centers" multi-computer room layout strategy, the existing ETCD cluster configuration model leads to heavy deployment burden and low deployment efficiency, and there are problems such as configuration inconsistency and service consistency.
By performing data synchronization operations on the main ETCD cluster in multiple computer rooms, when the data changes successfully, data synchronization of the sub-ETCD cluster is based on the preset polling rules, monitoring in real time and changing API data of the sub-cluster based on the monitoring results. Ensure that the API configurations of all computer rooms are consistent.
It realizes the completion of API configuration updates to all related computer room ETCD clusters at one time, shortens the time for new service deployment or adjustment, reduces the work burden of operation and maintenance personnel, avoids omissions or errors caused by manual operations, and ensures that all computer room APIs are Consistency of configuration data.
Smart Images

Figure CN119172397A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of gateway data acquisition technology, and in particular to a data synchronization method, system, device and storage medium for ETCD cluster configuration. Background Art
[0002] Currently, APISIX gateway API configuration data is centrally stored in a high-performance, high-availability ETCD cluster to ensure immediate effectiveness and efficient management of API configuration. Although the use of ETCD clusters can enhance data management capabilities, this model has limitations when following the "two locations, three centers" multi-computer room layout strategy.
[0003] Specifically, each independent computer room needs to be configured with an ETCD cluster to maintain the ultimate high availability of the service, which directly leads to the complexity of resource configuration and maintenance. For example, whenever a new API is ready to be deployed to these three different computer rooms, the operation and maintenance team needs to log in to the APISIX control panel of each computer room one by one and perform three repeated addition operations. As the number of computer rooms increases, the burden of this manual repetitive operation is increased, which is not only inefficient, but also has the risk of inconsistent configuration due to human errors.
[0004] In addition, the following problems still exist in actual operation: 1. When a new API may have been announced to be online, user requests may be rejected due to omissions in the configuration of a certain computer room; 2. The API that needs to be taken offline can still be accessed by users due to delayed configuration updates, thus affecting the consistency and security of the service.
[0005] Based on the above content, there is an urgent need for a data synchronization method for ETCD cluster configuration that can solve the problems of heavy deployment burden and low deployment efficiency in the existing technology. Summary of the invention
[0006] In order to solve the above technical problems, the present application provides a data synchronization method, system, device and storage medium for ETCD cluster configuration, which can solve the problems of heavy deployment burden and low deployment efficiency in the prior art.
[0007] The technical solution provided in this application is described below:
[0008] In a first aspect, the present application provides a data synchronization method for an ETCD cluster configuration, which is applied to the ETCD cluster configuration of multiple computer rooms, each of which is equipped with an ETCD cluster. The data synchronization method includes:
[0009] Acquire configuration content, where the configuration content includes at least one of adding, deleting, modifying, and querying API data;
[0010] Perform data synchronization operations on the main ETCD cluster according to the configuration content;
[0011] When the API data in the main ETCD cluster is changed successfully, a data synchronization operation is performed on several sub-ETCD clusters based on the preset polling rules and the configuration content to obtain an operation result;
[0012] Determine whether all API data in the plurality of sub-ETCD clusters are changed successfully according to the operation result, and if so, obtain the monitoring result of the main ETCD cluster in real time;
[0013] According to the monitoring results, API data of several of the sub-ETCD clusters are changed.
[0014] Optionally, judging whether all API data in the plurality of sub-ETCD clusters are changed successfully according to the operation result includes:
[0015] If the data change fails, determine the type of failure;
[0016] When the failure type is modification failure, re-perform data synchronization operation on the main ETCD cluster according to the configuration content;
[0017] When the failure type is addition or deletion failure, a rollback operation is performed on the main ETCD cluster, and the rollback operation is used to restore the API data in the main ETCD cluster to before the data change is successful.
[0018] Optionally, after determining the failure type if the data change fails, the data synchronization method further includes:
[0019] The failure information is determined according to the operation log, and the failure information is sent through a preset channel.
[0020] Optionally, the real-time acquisition of monitoring results of the primary ETCD cluster includes:
[0021] Use the watch command to monitor the main ETCD cluster.
[0022] Optionally, the data monitored by the watch command on the main ETCD cluster includes API data, service data, and upstream data.
[0023] Optionally, the data synchronization operation on several sub-ETCD clusters based on the preset polling rule and the configuration content includes:
[0024] Determine the order of the plurality of sub-ETCD clusters according to a polling rule from large to small load;
[0025] The configuration contents are sequentially configured into several of the sub-ETCD clusters in the order.
[0026] A second aspect of the present application provides a data synchronization system for ETCD cluster configuration, including:
[0027] An acquisition unit, used to acquire configuration content, wherein the configuration content includes at least one of adding, deleting, modifying, and querying API data;
[0028] A first operation unit, configured to perform data synchronization operation on a primary ETCD cluster according to the configuration content, wherein the primary ETCD cluster represents a first configured ETCD cluster;
[0029] The second operation unit is used to perform data synchronization operations on several sub-ETCD clusters based on preset polling rules and the configuration content to obtain operation results when the data in the main ETCD cluster is successfully changed;
[0030] A judging unit, configured to judge whether all the data in the plurality of sub-ETCD clusters are successfully changed according to the operation result, and if so, to obtain the monitoring result of the API data in the main ETCD cluster in real time;
[0031] The changing unit is used to change the data of the plurality of the sub-ETCD clusters according to the monitoring result.
[0032] Optionally, the judging unit includes:
[0033] A first determination module is used to determine the failure type if a data change fails;
[0034] A first operation module, used for re-performing data synchronization operation on the main ETCD cluster according to the configuration content when the failure type is modification failure;
[0035] The second operation module is used to perform a rollback operation on the main ETCD cluster when the failure type is a failure to add or delete. The rollback operation is used to restore the API data in the main ETCD cluster to the state before the data change is successful.
[0036] Optionally, the judging unit further includes:
[0037] The sending module is used to determine the failure information according to the operation log and send the failure information through a preset channel.
[0038] Optionally, the judging unit includes:
[0039] The acquisition module is used to monitor the main ETCD cluster through the watch command.
[0040] Optionally, the second operating unit includes:
[0041] A second determination module is used to determine the order of the plurality of sub-ETCD clusters according to a polling rule from large to small load;
[0042] A configuration module is used to sequentially configure the configuration content to a plurality of the sub-ETCD clusters in the order described.
[0043] A third aspect of the present application provides a data synchronization device for an ETCD cluster configuration, including:
[0044] Processor, memory, input-output unit, and bus;
[0045] The processor is connected to the memory, the input and output unit, and the bus;
[0046] The memory stores a program, and the processor calls the program to execute the first aspect and any optional method in the first aspect.
[0047] A fourth aspect of the present application provides a computer-readable storage medium, on which a program is stored. When the program is executed on a computer, the program executes the first aspect and any optional method in the first aspect.
[0048] It can be seen from the above technical solutions that this application has the following advantages:
[0049] By first performing data synchronization operations on the main ETCD cluster in multiple computer rooms, when the data in the main ETCD cluster is successfully changed, data synchronization operations are performed on several sub-ETCD clusters based on the preset polling rules. After the data in each sub-ETCD cluster is successfully changed, the data of the main ETCD cluster is monitored in real time, and the API data of each sub-ETCD cluster is changed according to the monitoring results. In this way, compared with the prior art that requires operation and maintenance personnel to go to each computer room to change API data, this application can complete the API configuration update of the ETCD clusters of all associated computer rooms at one time, which not only greatly shortens the time for new service deployment or adjustment, but also greatly reduces the workload of operation and maintenance personnel, and improves configuration efficiency;
[0050] After the main ETCD cluster is configured successfully, the configuration of each sub-ETCD cluster is polled. This multi-cluster synchronization mechanism can avoid omissions or errors that may be caused by manual operations and ensure that the API configuration data of all computer rooms is always consistent. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] In order to more clearly illustrate the technical solution in the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0052] Figure 1 A schematic diagram of an embodiment of a data synchronization method for an ETCD cluster configuration according to the present application;
[0053] Figure 2 A schematic diagram of another embodiment of a data synchronization method for an ETCD cluster configuration according to the present application;
[0054] Figure 3 A schematic diagram of an embodiment of a data synchronization system for an ETCD cluster configuration of the present application;
[0055] Figure 4 A schematic diagram of another embodiment of a data synchronization system for an ETCD cluster configuration according to the present application;
[0056] Figure 5 A schematic diagram of a data synchronization device configured in an ETCD cluster according to the present application. DETAILED DESCRIPTION
[0057] It should be noted that the data synchronization method for ETCD cluster configuration provided in this application can be applied to a terminal, a system, or a server. For example, the terminal can be a smart phone or a computer, a tablet computer, a smart TV, a smart watch, a portable computer terminal, or a fixed terminal such as a desktop computer. However, for the convenience of explanation, this application uses the system as the execution subject for example.
[0058] See also Figure 1 The present application first provides an embodiment of a data synchronization method for an ETCD cluster configuration, the embodiment comprising:
[0059] 101. The system obtains configuration content, where the configuration content includes at least one of adding, deleting, modifying, and querying API data.
[0060] The system can obtain configuration content through methods such as API calls, configuration file reading, database queries, etc. The configuration content is determined by the operation and maintenance personnel based on the actual needs of the update, such as the launch of a new API;
[0061] The system further determines the operation instructions that need to be performed on the API data based on the configuration content, including adding, deleting, modifying, and querying. The configuration content defines what operations need to be performed on the ETCD cluster in the future. The configuration content can be stored in the configuration file, which defines the main ETCD cluster and the sub-ETCD cluster. When the system executes the configuration file, it automatically determines the main ETCD cluster, and then the main ETCD cluster configures (adds, deletes, or modifies) its own API data based on the configuration file.
[0062] 102. The system performs data synchronization operations on the main ETCD cluster according to the configuration content. The main ETCD cluster refers to the first configured ETCD cluster.
[0063] The main ETCD cluster and the sub-ETCD clusters are connected in parallel, that is, the system is connected to the main ETCD cluster and each sub-ETCD cluster respectively; data synchronization refers to changing the API data in the ETCD cluster until it is the same as the data in the configuration content. In practice, the system determines the main ETCD cluster according to the configuration file, that is, the first ETCD cluster to be configured. The system calls each API data in the configuration content (such as deleting A data, changing B data to C data), determines the corresponding data location in the main ETCD cluster, and replaces each API data in the configuration content with the corresponding data in the main ETCD cluster to achieve data synchronization; the sub-ETCD cluster refers to the ETCD cluster other than the first configured one, that is, the second and any one after the second is called a sub-ETCD cluster.
[0064] In this embodiment, after obtaining the configuration content, the system converts the operation instructions corresponding to the configuration content into API calls to the main ETCD cluster (such as PUT requests), and executes the operation instructions on the main ETCD cluster. The main ETCD cluster is the source of data synchronization, and the data of all sub-ETCD clusters will be consistent with the main ETCD cluster.
[0065] During the configuration process, the system first parses the configuration content. By parsing the configuration content, the system converts the configuration into operation instructions that the etcd cluster can understand and execute;
[0066] Then build the ETCD operation request. According to the parsed configuration content, the system builds the corresponding ETCD operation request. The ETCD operation request follows the ETCD API specification, including the request type (such as PUT, DELETE, GET, etc.), request path, and request body (used when modifying or adding data);
[0067] Finally, the ETCD operation is executed. The system sends the constructed ETCD operation request to the main ETCD cluster. After receiving the request, the main ETCD cluster will perform the corresponding operation according to the type and content of the request. For example, if it is a PUT request, the main ETCD cluster will update the data under the specified path; if it is a DELETE request, the corresponding data will be deleted.
[0068] After executing the ETCD operation, the main ETCD cluster will return a response to inform whether the operation is successful and possible error information. In addition, the system can verify whether the data just modified or added has been correctly stored in the main ETCD cluster by executing a GET request to ensure data consistency.
[0069] 103. When the API data in the main ETCD cluster is changed successfully, the system performs data synchronization operations on several sub-ETCD clusters based on the preset polling rules and configuration content to obtain the operation results.
[0070] The system determines whether the data change is successful by receiving the response status code and message returned by the main ETCD cluster. Once the data in the main ETCD cluster is changed successfully, it means that the main ETCD cluster has successfully synchronized the data. At this time, the system will trigger the data synchronization operation on the sub-ETCD cluster. Specifically, it involves traversing all sub-ETCD clusters and determining the synchronization order and method according to the preset polling rules (such as sequential polling, random polling, load-based polling, etc.). Then, the system will send the same operation instructions to the sub-ETCD clusters and collect the operation results of each sub-cluster.
[0071] For each selected sub-ETCD cluster, the system constructs a corresponding ETCD operation request and includes the prepared data in the request body. The ETCD operation request is sent to the API endpoint of the sub-ETCD cluster via HTTP or other protocols. The types of ETCD operation requests may include PUT (for adding or updating key-value pairs), DELETE (for deleting key-value pairs), etc., depending on the type of data change in the main ETCD cluster.
[0072] After receiving the synchronization request, each sub-ETCD cluster will perform the corresponding operation and return a response to the system. The system receives and processes these responses to confirm whether the data is successfully synchronized to the sub-ETCD cluster. The response contains the result of whether the data change of the sub-ETCD cluster is successful.
[0073] 104. The system determines whether all API data in several sub-ETCD clusters have been changed successfully based on the operation results. If so, the system obtains the monitoring results of the main ETCD cluster in real time.
[0074] After all sub-ETCD clusters have successfully synchronized the data changes of the main ETCD cluster, the system will monitor the status or changes of the relevant API data in the main ETCD cluster in real time, so as to ensure the continuous consistency of data and timely discover potential problems.
[0075] The system confirms that the sub-ETCD cluster synchronization is successful by checking the previously recorded sub-ETCD cluster synchronization operation results. Specifically, the system checks the response status of each sub-cluster to ensure that they all return a success status code or message.
[0076] Once it is confirmed that all sub-ETCD clusters have successfully synchronized data, it means that the gateways of all computer rooms have been successfully configured. The system obtains the latest status of the API data in the main ETCD cluster in real time, and indicates the data changes of the sub-ETCD cluster through the latest status, ensuring the data consistency between the main ETCD cluster and the sub-ETCD cluster, so as to achieve real-time tracking of data changes. If the monitoring results show that the data in the main ETCD cluster has changed again, the sub-ETCD cluster will be guided to make corresponding data changes according to these changes.
[0077] During the monitoring process, the system monitors the main ETCD cluster through the watch command. The monitored data includes API data, service data and upstream data. The API data includes API URI address, domain name, routing rules and other information.
[0078] The watch command allows the client to subscribe to changes in specific key-value pairs in the ETCD cluster and be notified immediately when these changes occur. Specifically, the system sends a watch request to the main ETCD cluster, which specifies the path of the key-value pair or directory to be monitored. The ETCD cluster responds and starts a watch session. Once the watch session is established, the ETCD cluster will start monitoring the key-value pairs under the specified path.
[0079] When any matching key-value pair changes (such as adding, updating or deleting), the ETCD cluster will immediately feedback the change event to the system. The system will generate a target configuration file based on these changes and perform data synchronization operations on several sub-ETCD clusters based on the target configuration file.
[0080] 105. The system makes API data changes to several sub-ETCD clusters based on the monitoring results.
[0081] The monitoring results include data changes and unchanged data of the main ETCD cluster. When the data remains unchanged, the monitoring steps continue to be executed, and there is no need to change the data of several sub-ETCD clusters. When the monitoring results indicate that the data in the main ETCD cluster has changed, it means that some data in the main ETCD cluster has been reconfigured. In order to ensure data consistency between the main ETCD cluster and the sub-ETCD clusters, it is necessary to make corresponding API data changes to several sub-ETCD clusters. The change process is described in the above step 103 and will not be repeated here.
[0082] The monitoring results also include key information such as data status, version number, timestamp, etc. By comparing with the previous data status, the system determines whether there is any data change in the main ETCD cluster.
[0083] After data changes occur, the system summarizes and organizes the changed data, generates a configuration file, and then configures the configuration file to several sub-ETCD clusters to implement data changes in several sub-ETCD clusters.
[0084] In this embodiment, firstly, data synchronization is performed in the main ETCD cluster according to the configuration content. When the data change is completed, data synchronization is performed on several sub-ETCD clusters according to the preset polling rules. Then, when data changes occur in each sub-ETCD cluster, and the changed data is consistent with the data in the main ETCD cluster, it is considered that the data of the main ETCD cluster and the sub-ETCD cluster are all configured successfully. Then, the data in the main ETCD cluster is monitored, and several sub-ETCD clusters are guided by the monitoring results. Compared with the manual data configuration of each computer room in the prior art, this application can reduce the cost of manual participation, and can complete the API configuration update of all associated computer room ETCD clusters at one time, abandoning the traditional inefficient process of manually configuring each computer room one by one. The time for deploying or adjusting new services is greatly shortened, and the workload of operation and maintenance personnel is greatly reduced; subsequently, by monitoring the data changes of the main ETCD cluster to guide the data changes of several sub-ETCD clusters, it can reduce the omissions or errors that may be caused by manual operations, and ensure that the API configuration data of all computer rooms is always consistent. In this way, service anomalies caused by configuration asynchrony are effectively avoided, improving user experience and system stability.
[0085] See also Figure 2 The present application also provides another embodiment of a data synchronization method for an ETCD cluster configuration, the embodiment comprising:
[0086] 201. The system obtains configuration content, where the configuration content includes at least one of adding, deleting, modifying, and querying API data.
[0087] 202. The system performs data synchronization operations on the main ETCD cluster according to the configuration content. The main ETCD cluster refers to the first configured ETCD cluster.
[0088] 203. When the API data in the main ETCD cluster is changed successfully, the system performs data synchronization operations on several sub-ETCD clusters based on the preset polling rules and configuration content to obtain the operation results.
[0089] Steps 201 to 203 in this embodiment are Figure 1 Steps 101 to 103 in the embodiment are similar and will not be described again here.
[0090] In addition, in step 203, the system performs data synchronization operations on several sub-ETCD clusters based on the preset polling rules and configuration content. The specific process is as follows:
[0091] First, the system determines the order of several sub-ETCD clusters according to the polling rule from large to small loads, and then the system configures the configuration content to several sub-ETCD clusters in sequence; specifically, the system collects the current load information of each sub-ETCD cluster, which includes key indicators such as CPU usage, memory usage, disk I / O, network bandwidth usage, and the number of requests currently being processed. These key indicators can be obtained through the built-in monitoring tools of the ETCD cluster, third-party monitoring services, or directly queried in the API of the ETCD cluster.
[0092] Based on the collected load information, the system calculates the load weight of each sub-ETCD cluster. This weight can be a simple average, a weighted average, or a more complex algorithm result, aiming to accurately reflect the current load status of the cluster.
[0093] According to the calculated load weight, the system sorts the sub-ETCD clusters in order of load from large to small, thereby ensuring that high-load ETCD clusters are processed first to balance the load distribution of the entire system.
[0094] 204. The system determines whether all API data in several sub-ETCD clusters have been changed successfully based on the operation results.
[0095] In this embodiment, if all the API data in the sub-ETCD cluster are changed successfully, steps 205-206 are executed; if all the API data in the sub-ETCD cluster are not changed successfully, that is, the change fails, steps 207-209 are executed.
[0096] 205. The system obtains the monitoring results of the main ETCD cluster in real time.
[0097] 206. The system changes the API data of several sub-ETCD clusters based on the monitoring results.
[0098] Steps 205 to 206 in this embodiment are Figure 1 Steps 104 to 105 in the embodiment are similar and will not be described again here.
[0099] 207. The system determines the type of failure.
[0100] When data changes to all or part of the sub-ETCD clusters fail, the system needs to determine the failure type, that is, the cause of the failure. The failure causes usually include modification failure and addition or deletion failure. Modification failure usually refers to problems encountered when trying to update existing key-value pairs, while addition or deletion failure refers to problems encountered when trying to add new key-value pairs or delete existing key-value pairs.
[0101] Different measures are taken for different failure types, including modification failure and addition or deletion failure. In this embodiment, if the failure type is modification failure, step 208 is executed; if the failure type is addition or deletion failure, step 209 is executed.
[0102] In addition, when the data change of all or part of the sub-ETCD clusters fails, the system determines the failure information based on the operation log and sends the failure information through the preset channel. In this process, the system first checks the operation log related to the data synchronization operation. The operation log records each step of the operation, timestamp, operation result, and any possible error or exception information in the data synchronization process. The failure information determined in the operation log includes: the specific type of the failed operation (such as modification, addition, deletion), the target sub-ETCD cluster of the failed operation, the timestamp of the failed operation, the error code or error message, etc.; then the system will select the most suitable communication channel to send the failure information according to the preset configuration or strategy. The channels here include email, SMS, instant messaging (such as Slack, Teams), or a dedicated operation and maintenance notification system (such as PagerDuty, AlertManager). So that the operation and maintenance personnel can correct and adjust the next configuration process according to the failure information.
[0103] 208. When the failure type is modification failure, the system re-synchronizes the data of the main ETCD cluster according to the configuration content.
[0104] When the failure type is modification failure, the system first checks the cause of the failure, such as network problems, excessive load on the ETCD cluster, etc. If the problem can be solved immediately, the system can try to re-synchronize the data of the main ETCD cluster according to the configuration content, and try to apply these changes to all sub-ETCD clusters again, or apply these changes to the sub-ETCD cluster where the modification failed, that is, re-synchronize the data between the main ETCD cluster and the sub-ETCD cluster.
[0105] 209. When the failure type is addition or deletion failure, the system performs a rollback operation on the main ETCD cluster. The rollback operation is used to restore the API data in the main ETCD cluster to the state before the data change is successful.
[0106] When the failure type is addition or deletion failure, the system needs to perform a rollback operation to restore the API data in the main ETCD cluster to the state before the data change was successful. This can be understood as undoing the recent data changes and ensuring the data consistency of the main ETCD cluster to prevent inconsistency between the front-end display and the actual data and ensure the accuracy of the interface feedback.
[0107] After the rollback is successful, the system will also feedback the failure message to the front end to guide the operation and maintenance to take the next corrective action.
[0108] In addition, after the rollback operation is completed, the system needs to verify whether the data of the main ETCD cluster has been successfully restored, and can choose to try again to synchronize the correct data to the main ETCD cluster and the sub-ETCD cluster.
[0109] It should be noted that regardless of whether the rollback operation is successful, the system needs to record detailed operation logs and send notifications to relevant personnel so that they can understand the current status and possible follow-up operations.
[0110] See also Figure 3 The present application provides an embodiment of a data synchronization system for an ETCD cluster configuration, the embodiment comprising:
[0111] The acquisition unit 301 is used to acquire configuration content, where the configuration content includes at least one of adding, deleting, modifying, and querying API data;
[0112] The first operation unit 302 is used to perform data synchronization operation on the main ETCD cluster according to the configuration content, and the main ETCD cluster represents the first configured ETCD cluster;
[0113] The second operation unit 303 is used to perform data synchronization operations on several sub-ETCD clusters based on preset polling rules and configuration content when the data in the main ETCD cluster is successfully changed, and obtain an operation result;
[0114] The judging unit 304 is used to judge whether the data in the plurality of sub-ETCD clusters are all changed successfully according to the operation result, and if so, obtain the monitoring result of the API data in the main ETCD cluster in real time;
[0115] The changing unit 305 is used to change the data of several ETCD sub-clusters according to the monitoring results.
[0116] In this embodiment, the system first obtains the configuration content through the acquisition unit 301, and the configuration content includes at least one of adding, deleting, modifying and querying the API data. Then, the first operation unit 302 performs data synchronization operation on the main ETCD cluster according to the configuration content. Then, when the data in the main ETCD cluster is successfully changed, the second operation unit 303 performs data synchronization operation on several sub-ETCD clusters based on the preset polling rules and configuration content to obtain the operation result. Then, the judgment unit 304 judges whether the data in the several sub-ETCD clusters are all changed successfully according to the operation result. If so, the monitoring result of the API data in the main ETCD cluster is obtained. Finally, the change unit performs data change on several sub-ETCD clusters according to the monitoring result. In this way, compared with the manual data configuration of each computer room in the prior art, the present application can reduce the cost of manual participation, and can complete the API configuration update of all associated computer room ETCD clusters at one time, abandoning the traditional inefficient process of manually configuring each computer room one by one. It greatly shortens the time for deploying or adjusting new services and reduces the workload of operation and maintenance personnel. By monitoring the data changes of the main ETCD cluster to guide the data changes of several sub-ETCD clusters, it can reduce omissions or errors that may be caused by manual operations and ensure that the API configuration data of all computer rooms is always consistent. In this way, service anomalies caused by asynchronous configuration are effectively avoided, and user experience and system stability are improved.
[0117] See also Figure 4 The present application provides another embodiment of a data synchronization system for an ETCD cluster configuration, the embodiment comprising:
[0118] The acquisition unit 401 is used to acquire configuration content, where the configuration content includes at least one of adding, deleting, modifying, and querying API data;
[0119] The first operation unit 402 is used to perform data synchronization operation on the main ETCD cluster according to the configuration content, and the main ETCD cluster represents the first configured ETCD cluster;
[0120] The second operation unit 403 is used to perform data synchronization operations on several sub-ETCD clusters based on preset polling rules and configuration content when the data in the main ETCD cluster is successfully changed, and obtain an operation result;
[0121] The second operating unit 403 includes:
[0122] The second determination module 4031 is used to determine the order of several ETCD sub-clusters according to the polling rule from large to small load;
[0123] Configuration module 4032, used to sequentially configure configuration contents to several sub-ETCD clusters;
[0124] The judging unit 404 is used to judge whether the data in the plurality of sub-ETCD clusters are all changed successfully according to the operation result, and if so, obtain the monitoring result of the API data in the main ETCD cluster in real time;
[0125] The judging unit 404 includes:
[0126] The first determination module 4041 is used to determine the failure type if the data change fails;
[0127] The first operation module 4042 is used to re-synchronize the data of the main ETCD cluster according to the configuration content when the failure type is modification failure;
[0128] The second operation module 4043 is used to roll back the main ETCD cluster when the failure type is addition or deletion failure. The rollback operation is used to restore the API data in the main ETCD cluster to the state before the data change is successful.
[0129] The sending module 4044 is used to determine the failure information according to the operation log and send the failure information through a preset channel;
[0130] Acquisition module 4045 is used to monitor the main ETCD cluster through the watch command;
[0131] The changing unit 405 is used to change the data of several ETCD sub-clusters according to the monitoring results.
[0132] See also Figure 5 The present application also provides a data synchronization device for ETCD cluster configuration, including:
[0133] Processor 501, memory 502, input and output unit 503, bus 504;
[0134] The processor 501 is connected to the memory 502, the input and output unit 503 and the bus 504;
[0135] The memory 502 stores a program, and the processor 501 calls the program to execute the above Figure 1-Figure 2 Any method in the embodiments.
[0136] The present application also relates to a computer-readable storage medium, on which a program is stored, wherein when the program is run on a computer, the computer executes the above Figure 1-Figure 2 Any method in the embodiments.
[0137] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0138] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0139] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0140] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0141] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, read-only memory), random access memory (RAM, random access memory), disk or optical disk and other media that can store program code.
Claims
1. A data synchronization method for ETCD cluster configuration, applied to ETCD cluster configuration of multiple computer rooms, each computer room is equipped with an ETCD cluster, characterized in that: include: Acquire configuration content, where the configuration content includes at least one of adding, deleting, modifying, and querying API data; Perform data synchronization operation on the main ETCD cluster according to the configuration content, where the main ETCD cluster represents the first configured ETCD cluster; When the API data in the main ETCD cluster is changed successfully, a data synchronization operation is performed on several sub-ETCD clusters based on the preset polling rules and the configuration content to obtain an operation result; Determine whether all API data in the plurality of sub-ETCD clusters are changed successfully according to the operation result, and if so, obtain the monitoring result of the main ETCD cluster in real time; According to the monitoring results, API data of several of the sub-ETCD clusters are changed.
2. The data synchronization method according to claim 1, characterized in that: The step of judging whether all API data in the plurality of sub-ETCD clusters are successfully changed according to the operation result includes: If the data change fails, determine the type of failure; When the failure type is modification failure, re-perform data synchronization operation on the main ETCD cluster according to the configuration content; When the failure type is addition or deletion failure, a rollback operation is performed on the main ETCD cluster, and the rollback operation is used to restore the API data in the main ETCD cluster to before the data change is successful.
3. The data synchronization method according to claim 2, characterized in that: After determining the failure type if the data change fails, the data synchronization method further includes: The failure information is determined according to the operation log, and the failure information is sent through a preset channel.
4. The data synchronization method according to any one of claims 1 to 3, characterized in that: The real-time acquisition of the monitoring result of the main ETCD cluster includes: Use the watch command to monitor the main ETCD cluster.
5. The data synchronization method according to claim 4, characterized in that: The data monitored by the watch command on the main ETCD cluster includes API data, service data and upstream data.
6. The data synchronization method according to any one of claims 1 to 3, characterized in that: The data synchronization operation on several sub-ETCD clusters based on the preset polling rules and the configuration content includes: Determine the order of the plurality of sub-ETCD clusters according to a polling rule from large to small load; The configuration contents are sequentially configured into several of the sub-ETCD clusters in the order.
7. A data synchronization system for ETCD cluster configuration, characterized in that: include: An acquisition unit, used to acquire configuration content, wherein the configuration content includes at least one of adding, deleting, modifying, and querying API data; A first operation unit, configured to perform data synchronization operation on a primary ETCD cluster according to the configuration content, wherein the primary ETCD cluster represents a first configured ETCD cluster; The second operation unit is used to perform data synchronization operations on several sub-ETCD clusters based on preset polling rules and the configuration content to obtain operation results when the data in the main ETCD cluster is successfully changed; A judging unit, configured to judge whether all the data in the plurality of sub-ETCD clusters are successfully changed according to the operation result, and if so, to obtain the monitoring result of the API data in the main ETCD cluster in real time; The changing unit is used to change the data of the plurality of the sub-ETCD clusters according to the monitoring result.
8. The data synchronization system according to claim 7, characterized in that: The judging unit comprises: A determination module is used to determine the type of failure if a data change fails; A first operation module, used for re-performing data synchronization operation on the main ETCD cluster according to the configuration content when the failure type is modification failure; The second operation module is used to perform a rollback operation on the main ETCD cluster when the failure type is a failure to add or delete. The rollback operation is used to restore the API data in the main ETCD cluster to the state before the data change is successful.
9. A data synchronization device for ETCD cluster configuration, characterized in that: include: Processor, memory, input-output unit, and bus; The processor is connected to the memory, the input and output unit, and the bus; The memory stores a program, and the processor calls the program to execute the method according to any one of claims 1 to 6.
10. A computer-readable storage medium having a program stored thereon, wherein the program, when executed on a computer, performs the method according to any one of claims 1 to 6.
