A master-slave switching method, device, equipment and readable storage medium
By calculating node weighting values in a distributed system and multicast message notification, the consistency between node and component master-slave roles during master-slave node switching is achieved, and the problem of access exceptions in cluster-level master-slave scheme is solved to ensure business Continuity.
Patent Information
- Application Number
- CN202410853500.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-28
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2044-06-28
AI Technical Summary
In distributed systems, cluster-level master-slave schemes often experience access exceptions during node failover, mainly because the node does not match the master-slave roles of the component.
After detecting the master node failure through the switching mechanism component, the weighted value of the local node is calculated and the weighted value is sent to other nodes in the distributed system through multicast messages. After receiving the weighted values of other nodes, determine the node with the highest weighted value as the new master node, and notify the node of component switching through a multicast message. If the local node has a slave component, then the master processing is performed. After all nodes and components have completed master-slave switching, switch the virtual address to the new master node.
When the master-slave node is switched, the master-slave role consistency between the node and its internal components is achieved, thereby ensuring that the new master node can be accessed normally and avoiding business interruptions.
Smart Images

Figure CN119210997B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of distributed technology, and in particular to a master-slave switching method, device, equipment and readable storage medium. Background Art
[0002] In a distributed system, a group of independent computers present to users a unified whole. Distributed systems have a variety of common physical and logical resources, can dynamically allocate tasks, and dispersed physical and logical resources can exchange information through computer networks.
[0003] In a distributed system, business access is mostly done in a load-balancing manner, but the system management software generally uses a master-slave approach, that is, only one node provides access services at the same time, and the other nodes serve as slave nodes. When the master node fails, a slave node is selected to switch to become the new master node and continue to provide services. This is a cluster-level master-slave solution.
[0004] As the business continues to expand, it is often necessary to introduce components with built-in master-slave architecture, including but not limited to some relational databases (such as postgresql), some time series databases (such as influxdb), RabbitMQ, etc. For the cluster-level master-slave solution, there is also a set of its own master-slave solution. When a node fails over, access exceptions often occur.
[0005] In summary, how to effectively solve the problems such as master-slave switching of distributed systems is a technical problem that technical personnel in this field urgently need to solve. Summary of the invention
[0006] The purpose of the present application is to provide a master-slave switching method, device, equipment and readable storage medium, which can perform reliable master-slave switching, that is, normal access can be achieved after the master-slave switching.
[0007] In order to solve the above technical problems, this application provides the following technical solutions.
[0008] A master-slave switching method comprises: after a switching mechanism component detects a master node failure, calculating a weighted value of a local node; sending the weighted value to other nodes in a distributed system through a multicast message; receiving weighted values sent by other nodes through a multicast message; determining the local node as a new master node when the weighted value of the local node is the highest; notifying the nodes in the distributed system to perform component switching through a multicast message; if a slave component exists in the local node, upgrading the slave component to a master; after the nodes in the distributed system and the components in the nodes complete the master-slave switching operation, switching the virtual address to the new master node.
[0009] Preferably, when the weighted value of the local node is not the highest, the method includes: receiving a component switching notification sent by a new master node; and if a master component exists in the local node, downgrading the master component to a slave.
[0010] Preferably, calculating the weighted value of the local node includes: obtaining a weighted fixed value of the local node; and determining the weighted fixed value as the weighted value of the local node.
[0011] Preferably, calculating the weighted value of a local node includes: obtaining a multi-branch tree model corresponding to a node component; wherein the multi-branch tree model is a multi-branch tree structure obtained by abstracting the node component; based on the multi-branch tree model, determining the current depth of the local node; and using the current depth to offset the weighted constant of the local node to obtain the weighted value of the local node.
[0012] Preferably, based on the multi-branch tree model, determining the current depth of the local node includes: based on the multi-branch tree model, traversing each component of the local node; when traversing to an abnormal component, stopping the traversal and obtaining the traversal depth; determining the traversal depth as the current depth.
[0013] Preferably, the weighted constant of the local node is offset using the current depth to obtain the weighted value of the local node, including: obtaining the calibrated depth of the multi-branch tree model; calculating the depth difference between the calibrated depth and the current depth; subtracting the depth difference from the weighted constant to obtain the weighted value of the local node.
[0014] Preferably, obtaining the multi-branch tree model corresponding to the node component includes: abstracting the components in the node, taking the interactive interface as the root node and other components as leaf nodes, and connecting the nodes from the top layer to the bottom layer to obtain the multi-branch tree model.
[0015] Preferably, sending the weighted value to other nodes in the distributed system via a multicast message includes: generating an interaction message carrying the weighted value based on a virtual routing redundancy protocol; sending the interaction message to a multicast group; the multicast group includes nodes in the distributed system.
[0016] Preferably, notifying the nodes in the distributed system to perform component switching via multicast messages includes: generating a component switching notification message based on a virtual routing redundancy protocol; sending the component switching notification message to a multicast group; the multicast group includes the nodes in the distributed system.
[0017] Preferably, detecting a master node failure includes: determining that the master node is normal when a notification message sent by the master node is received; determining that the master node is faulty when no notification message sent by the master node is received for more than a preset time; accordingly, after switching the virtual address to a new master node, including: periodically generating notification messages based on a virtual routing redundancy protocol; sending the notification message to a multicast group; the multicast group includes nodes in the distributed system.
[0018] Preferably, it includes: adding the local node to the multicast group and saving the key; generating an encrypted message based on the virtual routing redundancy protocol and in combination with a symmetric encryption algorithm; accordingly, after receiving the message, decrypting the received message using the key; if the decryption is successful, determining that the received message is legal and performing response processing on the message; if the decryption fails, determining that the received message is illegal and discarding the received message.
[0019] A switching mechanism component comprises: a weighted value determination unit, used to calculate the weighted value of a local node after detecting a master node failure; a weighted value interaction unit, used to send the weighted value to other nodes in a distributed system through multicast messages; and receive weighted values sent by other nodes through multicast messages; a node master-slave determination unit, used to determine that the local node is a new master node when the weighted value of the local node is the highest; a component switching notification unit, used to notify the nodes in the distributed system to perform component switching through multicast messages; a component master-slave switching unit, used to upgrade the slave component to a master if there is a slave component in the local node; and an address switching unit, used to switch the virtual address to the new master node after the nodes in the distributed system and the components in the nodes complete the master-slave switching operation.
[0020] An electronic device comprises: a memory for storing a computer program; and a processor for implementing the steps of the master-slave switching method when executing the computer program.
[0021] A readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the master-slave switching method are implemented.
[0022] A computer program product includes a computer program / instruction, and when the computer program / instruction is executed by a processor, the steps of the master-slave switching method are implemented.
[0023] By applying the method provided in the embodiment of the present application, after the switching mechanism component detects a failure of the master node, it calculates the weighted value of the local node; sends the weighted value to other nodes in the distributed system through multicast messages; receives the weighted values sent by other nodes through multicast messages; when the weighted value of the local node is the highest, determines that the local node is the new master node; notifies the nodes in the distributed system to switch components through multicast messages; if there is a slave component in the local node, the slave component is promoted to the master; after the nodes in the distributed system and the components in the nodes complete the master-slave switching operation, the virtual address is switched to the new master node.
[0024] Considering that under the master-slave scheme at the cluster level, there is also a distributed system with its own master-slave scheme, and the access is abnormal due to the mismatch between the master-slave roles of the node and the component. To solve this problem, in the present application, when the exchange mechanism component detects the failure of the master node, the weighted value of the local node is first determined, and then the weighted value is sent to other nodes in the distributed system by means of multicast messages. At the same time, the weighted values sent by other nodes can also be received. By comparing the weighted values of each node, it can be clear whether the weight of the local node is the highest. If so, the local node is determined to be the new master node. After determining that the local node is the new master node, the nodes in the distributed system can be notified to switch components by means of multicast messages. The nodes that receive the multicast message will switch the master-slave roles of their own components. For the local node, since it is upgraded to the master node, it is necessary to upgrade the slave components in it. After the nodes in the distributed system and the components in the nodes have completed the master-slave switching operation, the virtual address can be switched to the new master node. In this way, the new master node can provide services to the outside based on the components that have completed the master-slave role switching.
[0025] Technical effect: In this application, while switching between master and slave nodes, the master and slave roles of components inside each node are switched through multicast information, thereby ensuring that the master and slave roles of the node and its internal components are consistent. In this way, after switching the virtual address, the new master node can be accessed normally, thereby ensuring that the service is not interrupted for a long time.
[0026] Correspondingly, the embodiments of the present application also provide a master-slave switching device, equipment, readable storage medium and computer program product corresponding to the above-mentioned master-slave switching method, which have the above-mentioned technical effects and are not repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are 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 creative work.
[0028] Figure 1 This is a flowchart of an implementation of a master-slave switching method in an embodiment of the present application;
[0029] Figure 2 This is a schematic diagram of a multi-branch tree model in an embodiment of the present application;
[0030] Figure 3 for Figure 2 A schematic diagram of a node with an abnormal component in the multi-branch tree model shown;
[0031] Figure 4 for Figure 2 A schematic diagram of a node with another abnormal component in the multi-branch tree model shown;
[0032] Figure 5 A schematic diagram of a master-slave mode switching process of a component in an embodiment of the present application;
[0033] Figure 6 A schematic diagram of a master-slave node switching process in an embodiment of the present application;
[0034] Figure 7 A schematic diagram of a master-slave node switching process in a related master-slave solution;
[0035] Figure 8 This is a schematic diagram of the structure of a master-slave switching device in an embodiment of the present application;
[0036] Fig. 9 This is a schematic diagram of the structure of an electronic device in an embodiment of the present application;
[0037] Fig.10 This is a schematic diagram of the specific structure of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION
[0038] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.
[0039] To facilitate understanding of the technical solutions provided in the embodiments of the present application, the technical terms involved in this document are first explained.
[0040] Timing DB, timing database; Kernel, kernel; Deploy, deployment; Rest, architecture for organizing web services; Serial DB, serial database; Keepalived, a software similar to layer3, 4 & 5 exchange mechanism, responsible for automatic failover; Postgresql, an open source relational database; Influxdb, a simple and easy-to-use time series database; RabbitMQ, a high-usability component for storing and forwarding messages in distributed systems; AES, a general symmetric encryption algorithm; SSD Predictor, SSD (solid state drive) life prediction engine; HDD Predictor, HDD (hard disk) failure prediction engine; Nginx, an HTTP (hypertext transfer protocol) and reverse proxy web server; CLI, command line interface; Version, protocol version number; Type, message type; Virtual Rtr ID, virtual router ID; Priority, node weight value, used for subsequent node optimization; Count IPv4 Addrs, the number of virtual IPv4 addresses in the backup group; Auth Type, authentication type; Adver Int, the time interval for sending VRRP announcement messages; Checksum, checksum, to ensure the integrity of the message; IPv4 Address, the virtual IPv4 address in the backup group; Authentication Data, the authentication word of the message.
[0041] Please refer to the following Figure 1 , Figure 1 The flowchart of a master-slave switching method in an embodiment of the present application is applicable to a switching mechanism component, namely a keepalived component. Keepalived is a software similar to a layer 3, layer 4, and layer 5 switching mechanism. Keepalived can be completed automatically without manual intervention. In this embodiment, a keepalived component can be set on each node in the distributed system, and the steps of the master-slave switching method can be executed on each keepalived component. Specifically, the method includes the following steps.
[0042] S101. After a master node failure is detected, a weighted value of a local node is calculated.
[0043] In a distributed system, when the keepalived component is located on the master node, it can periodically send notification messages to other nodes in the distributed system so that other nodes can clearly understand the running status of the master node.
[0044] Specifically, when the master node fails, the keepalived component will stop sending notification messages to the outside. Therefore, if other nodes time out and do not receive the notification message sent by the master node, it can be determined that the master node has failed.
[0045] After a master node failure is detected, a new master node needs to be determined in order for the entire distributed system to continue to provide corresponding services.
[0046] In order to enable the new master node to provide reliable services to the outside world, when selecting a new master node, the most reliable node can be selected based on the weighted values of each node.
[0047] Therefore, after determining that the master node fails, the keepalived component can calculate the weighted value of the local node.
[0048] A fixed weighted value or a real-time weighted value may be used. Accordingly, the method for calculating the weighted value of the local node includes but is not limited to the following methods.
[0049] Method 1: Calculating the weighted value of the local node, including: obtaining the weighted fixed value of the local node; and determining the weighted fixed value as the weighted value of the local node.
[0050] For ease of description, the above steps are combined for explanation below.
[0051] In this embodiment, a weighted value can be set for the node in advance based on information such as the software and hardware performance of the node. In this way, after the master node fails, the keepalived component located in other slave nodes can obtain the weighted value of the local node. Then, the weighted value is directly determined as the weighted value of the local node.
[0052] Method 2: Calculate the weighted value of the local node, including: obtaining a multi-branch tree model corresponding to the node component; wherein the multi-branch tree model is a multi-branch tree structure obtained by abstracting the node component; based on the multi-branch tree model, determine the current depth of the local node; use the current depth to offset the weighted constant of the local node to obtain the weighted value of the local node.
[0053] For ease of description, the above steps are combined for explanation below.
[0054] In actual applications, after a master node fails or other slave nodes become abnormal, in order to avoid being unable to select a new master node, the weighted constant can be offset by the functional status of the original slave node to obtain the weighted value of the local node.
[0055] Specifically, in order to clarify the degree of deviation of the weighted fixed value, the current depth of the local node can be determined by the multi-branch tree model corresponding to the node component. Among them, the node component can be submitted from top to bottom with the interactive interface as the root node to construct a multi-branch tree model. In this way, the deeper the depth, the more reliable the function in the node, and the smaller the scope of the abnormal impact. Based on the current depth, the weighted fixed value of the local node is offset to obtain the weighted value of the local node. That is, the weighted value can not only realize dynamic adjustment, but also effectively characterize the functional status of the node.
[0056] In one embodiment of the present application, obtaining a multi-branch tree model corresponding to a node component includes:
[0057] The components in the nodes are abstracted, with the interactive interface as the root node and other components as leaf nodes. The nodes are connected from the top layer to the bottom layer to obtain a multi-branch tree model.
[0058] For ease of description, the above steps are combined for explanation below.
[0059] That is, each component is regarded as a node in the multi-branch tree model. Specifically, the components in the node are abstracted as nodes in the multi-branch tree model, and the interactive interface (such as the UI interface) is taken as the root node, and other components are leaf nodes. Then, the nodes are connected from the top to the bottom, and then the multi-branch tree model is obtained.
[0060] The multi-tree model can be fixed before the cluster is officially put into operation based on its actual business scenarios. Specifically, the model is established based on the front-end page access as the root node, and then continuously extends to the lower layer according to the business call until all business modules of the management software are included. The selection of business modules not only involves the components of the master-slave architecture, but also includes all business modules, so that the weighted value calculated in this way is more in line with the actual business scenario.
[0061] The purpose of introducing and establishing a multi-branch tree model is to dynamically calculate the weighted value of each node based on the maximum depth value of the multi-branch tree when all nodes are abnormal. This value is reflected in the protocol message as the Priority field. Based on this, a node is preferred to be assigned a virtual IP, rather than not being assigned a virtual IP on any node.
[0062] For example, all components of the management software can be abstracted into a multi-branch tree model, with the top-level UI access as the root node and all components that provide services as leaf nodes. The depth value is also calculated starting from the root node until the last leaf node. It is used to select the most reasonable node to bind the virtual IP when all nodes are not completely healthy. Although some services may not be available at this time, it is better than not binding the virtual IP directly.
[0063] According to the actual business and components used, generate Figure 2 The multi-tree structure shown.
[0064] In a specific implementation of the present application, the current depth of the local node is determined based on a multi-branch tree model, including: traversing each component of the local node based on the multi-branch tree model; when an abnormal component is traversed, stopping the traversal and obtaining the traversal depth; and determining the traversal depth as the current depth.
[0065] For ease of description, the above steps are combined for explanation below.
[0066] In this embodiment, the current depth of the local node can be determined directly based on the multi-tree model by traversing the various components of the local node. That is, the order of traversing the various components is based on the order in the multi-tree model, that is, first traversing the surface nodes (such as the UI interface) and then gradually traversing to the bottom nodes.
[0067] When an abnormal component is traversed, the traversal can be stopped directly to obtain the traversal depth, which can be regarded as the current depth of the local node.
[0068] In one embodiment of the present application, the weighted constant of the local node is offset using the current depth to obtain the weighted value of the local node, including: obtaining the calibrated depth of the multi-branch tree model; calculating the depth difference between the calibrated depth and the current depth; subtracting the depth difference from the weighted constant to obtain the weighted value of the local node.
[0069] For ease of description, the above steps are combined for explanation below.
[0070] In this embodiment, the calibrated depth of the multi-branch tree model is first obtained. The calibrated depth is the maximum depth value corresponding to the node under normal conditions. Then, the depth difference between the calibrated depth and the current depth is calculated. The depth difference can indicate the degree of influence of the abnormal situation of the node on the normal function. The weighted fixed value is subtracted from the depth difference, and the difference obtained can be used as the weighted value of the local node.
[0071] In other words, based on the depth-first principle, the depth value (i.e., current depth) of each node can be calculated when all nodes have different anomalies, and then the corresponding offset can be made based on the weighted value of the original keepalived component. That is, the larger the depth value of a node, the higher the weighted value of its keepalived component, but it cannot be higher than the weighted value of a completely healthy node. At this time, when all nodes have anomalies, a node with the optimal solution under the above rules will be selected to bind the virtual IP. The master node selected based on this rule has a higher probability of providing partially complete functions or part of the functions.
[0072] For example: Based on the abstract model of the multi-branch tree model, the calibrated depth of the tree under normal circumstances, that is, the maximum depth value (Depthmax), can be obtained first. When the node is in a faulty state, the current depth value (Depthcurrent) of the multi-branch tree model can be obtained based on the faulty component.
[0073] The weighted value of the keepalived component when the node is normal is the weighted constant value (Prioritynormal).
[0074] Based on the above parameters, the weighted value calculation formula for each node in normal and abnormal conditions is: Prioritycurrent = Prioritynormal – (Depthmax – Depthcurrent).
[0075] like Figures 2 to 4 As shown, with the interactive interface as the root node, the second-layer nodes include deployment, a hypertext transfer protocol and a reverse proxy web server; the third-layer nodes include an architecture for organizing web services, and the architecture for organizing web services is a sub-node of a hypertext transfer protocol and a reverse proxy web server; the fourth-layer nodes include a database, a solid-state drive life prediction engine, and a hard disk failure prediction engine, all of which are sub-nodes of the architecture for organizing web services; the fifth-layer nodes include: a command line interface and a timing database, wherein the command line interface is a sub-node of the database, and the timing database is a sub-node of the hard disk failure prediction engine; the sixth-layer nodes include a kernel and a serial database, both of which are sub-nodes of the command line interface. Figure 2 is a schematic diagram of a normal node. Figure 3 Corresponding to node A, Figure 4 Corresponding to Node B. Figure 2 It can be seen that the maximum depth value of the node under normal circumstances is 6, and the current depth value of node A is 5 ( Figure 3 The components in the bold box correspond to abnormal components, that is, the command line interface of node A is abnormal). The current depth value of node B is 2 ( Figure 4The components in the bold box correspond to abnormal components, that is, the architecture of the organization web service of node B is abnormal). Assuming that the priority value is 100 under normal circumstances, the current weighted value of node A is: 100 - (6 - 5) = 99; the current weighted value of node B is: 100 - (6 - 2) = 96; therefore, in the current state, node A is better than node B and should become the master node and bind the virtual IP.
[0076] S102: Send the weighted value to other nodes in the distributed system via a multicast message.
[0077] Among them, the characteristics of multicast transmission are single-point sending and multi-point receiving. That is, in this embodiment, the weighted value of the local node is determined, in order to select the best new master node through the weighted value, and then the weighted value is sent to other nodes in the distributed system through a multicast message.
[0078] S103: Receive weighted values sent by other nodes via multicast messages.
[0079] Due to the keepalived component in each node, after detecting the failure of the master node, the weighted value of the local node can be determined and broadcast to other nodes.
[0080] Therefore, the keepalived component of each node in the distributed system can receive the weighted value of the keepalived component multicast on other nodes.
[0081] S104: When the weighted value of the local node is the highest, determine the local node as the new master node.
[0082] After receiving the weighted values multicasted by other nodes, the weighted value of the local node can be compared with the weighted values of other nodes received to determine whether the weighted value of the local node is the highest. If the weighted value of the local node is the highest, then the local node can be determined as the new master node; conversely, if the weighted value of the local node is not the highest, then the node with the highest weighted value will become the new master node.
[0083] S105: Notify the nodes in the distributed system to switch components through multicast messages.
[0084] Once the local node is determined as the new master node, it can notify other nodes in the distributed system to switch components through multicast messages.
[0085] It should be noted that the local node can also receive this multicast information.
[0086] S106: If there is a slave component in the local node, the slave component is upgraded to a master component.
[0087] After the local node becomes the new master node, when it receives a multicast message for component switching, it can determine whether there is a slave component in the local node. If so, since the local node has been promoted to the master node, the slave component in the local node needs to be promoted to the master; for the master component in the local node, the master role of the component can be directly retained. In this way, it can be ensured that the new master node and its internal components are not master roles.
[0088] In one embodiment of the present application, in S108, when the weighted value of the local node is not the highest, the local node is determined to be a slave node, and the following steps are performed.
[0089] Step S109: Receive a component switching notification sent by the new master node.
[0090] Step S110: If there is a master component in the local node, the master component is downgraded to a slave component.
[0091] For ease of description, the above steps are combined for explanation below.
[0092] When the weighted value of the local node is not the highest, it is clear that there will be other nodes as the new master node. Therefore, the local node can directly wait to receive the component switching notification sent by the new master node, and then judge the role of the component in the local node. If there is a master component in the local node, the master component can be directly downgraded to a slave component, thereby keeping the node and its internal components in the same slave role.
[0093] Specifically, Figure 5 As shown in the figure, the process of switching the master-slave mode of the components inside the node is as follows:
[0094] The slave node receives the heartbeat message from the master node, which indicates that the master node is in normal status. Check the master-slave status of all components in this node. If it is a master node, check whether there is a component in slave node mode. If so, switch the component to master node mode. If it is a slave node, check whether there is a component in master node mode. If so, switch the component to slave node mode. The above process is checked in each heartbeat process, but the process needs to be locked to prevent multiple heartbeat processes from affecting each other.
[0095] S107: After the nodes in the distributed system and the components in the nodes complete the master-slave switching operation, the virtual address is switched to the new master node.
[0096] After the nodes and components in the distributed system complete the master-slave switching operation, the virtual address can be switched to the new master node. The virtual address can be specifically a virtual IP corresponding to the management function. After the virtual IP is switched to the new master node, the new master node can implement the management or service function of the master node in the distributed system.
[0097] In one embodiment of the present application, when the new master node is switched and in normal status, multicast heartbeat messages are continuously sent to notify all nodes that the current master node is in normal status; accordingly, all components on the slave node are given the opportunity to perform master-slave switching again to prevent a node from restarting after a long period of downtime.
[0098] That is to say, in this embodiment, the switching of the master-slave roles of the components within the node can be performed in two links. First, during the master-slave switching process, after receiving the component switching notification message, the roles of the components in the local node can be immediately switched and adjusted, that is, the components in the master node are adjusted to master components, and the components in the slave node are adjusted to slave components; second, after the master-slave switching is completed, the new master node normally sends a heartbeat message, that is, a notification message, to the outside. When the slave node receives the notification message, it can still switch the master-slave roles of its own components, thereby avoiding the long-term downtime of the slave node resulting in the failure to switch the master-slave roles of its components in time, avoiding confusion, and effectively ensuring the normal operation of the business.
[0099] By applying the method provided in the embodiment of the present application, after the switching mechanism component detects a failure of the master node, it calculates the weighted value of the local node; sends the weighted value to other nodes in the distributed system through multicast messages; receives the weighted values sent by other nodes through multicast messages; when the weighted value of the local node is the highest, determines that the local node is the new master node; notifies the nodes in the distributed system to switch components through multicast messages; if there is a slave component in the local node, the slave component is promoted to the master; after the nodes in the distributed system and the components in the nodes complete the master-slave switching operation, the virtual address is switched to the new master node.
[0100] Considering that under the master-slave scheme at the cluster level, there is also a distributed system with its own master-slave scheme, and the access is abnormal due to the mismatch between the master-slave roles of the node and the component. To solve this problem, in the present application, when the exchange mechanism component detects the failure of the master node, the weighted value of the local node is first determined, and then the weighted value is sent to other nodes in the distributed system by means of multicast messages. At the same time, the weighted values sent by other nodes can also be received. By comparing the weighted values of each node, it can be clear whether the weight of the local node is the highest. If so, the local node is determined to be the new master node. After determining that the local node is the new master node, the nodes in the distributed system can be notified to switch components by means of multicast messages. The nodes that receive the multicast message will switch the master-slave roles of their own components. For the local node, since it is upgraded to the master node, it is necessary to upgrade the slave components in it. After the nodes in the distributed system and the components in the nodes have completed the master-slave switching operation, the virtual address can be switched to the new master node. In this way, the new master node can provide services to the outside based on the components that have completed the master-slave role switching.
[0101] Technical effect: In this application, while switching between master and slave nodes, the master and slave roles of components inside each node are switched through multicast information, thereby ensuring that the master and slave roles of the node and its internal components are consistent. In this way, after switching the virtual address, the new master node can be accessed normally, thereby ensuring that the service is not interrupted for a long time.
[0102] It should be noted that, based on the above embodiments, the embodiments of the present application also provide corresponding improved solutions. In the preferred / improved embodiments, the same steps or corresponding steps as those in the above embodiments can be referenced to each other, and the corresponding beneficial effects can also be referenced to each other, which will not be described one by one in the preferred / improved embodiments of this article.
[0103] In one embodiment of the present application, nodes in a distributed system are notified to perform component switching via multicast messages, including: generating a component switching notification message based on a virtual routing redundancy protocol; sending a component switching notification message to a multicast group; and the multicast group includes nodes in the distributed system.
[0104] In one embodiment of the present application, a master node failure is detected, including: when a notification message sent by the master node is received, it is determined that the master node is normal; when a notification message sent by the master node is not received for more than a preset time, it is determined that the master node is faulty; accordingly, after the virtual address is switched to a new master node, it includes: based on a virtual routing redundancy protocol, regularly generating notification messages; sending notification messages to a multicast group; the multicast group includes nodes in a distributed system.
[0105] In one embodiment of the present application, it includes: adding a local node to a multicast group and saving a key; generating an encrypted message based on a virtual routing redundancy protocol and in combination with a symmetric encryption algorithm; accordingly, after receiving the message, decrypting the received message using the key; if the decryption is successful, determining that the received message is legal, and performing response processing on the message; if the decryption fails, determining that the received message is illegal, and discarding the received message.
[0106] Since the above embodiments all involve message adjustment of the virtual routing redundancy protocol, the improved contents of several of the above embodiments are combined for description below.
[0107] That is, in the present application, the message format of the virtual routing redundancy protocol can also be optimized to better notify the node to perform master-slave switching, notify the node's components to perform master-slave switching, and intercommunication weighted values.
[0108] Specifically, the virtual router redundancy protocol is VRRP (Virtual Router Redundancy Protocol). Generally, the VRRP message is shown in Table 1:
[0109] Table 1, Table 1 is a VRRP message format
[0110]
[0111] In the message format shown in Table 1, the message type is only Adventisemengt (i.e., notification message); Priority is a fixed weighted value. Secondly, the message content shown in Table 1 is plain text.
[0112] The optimized VRRP message format proposed in this application is shown in Table 2:
[0113] Table 2. Table 2 is a VRRP message optimization format
[0114]
[0115] In the message format shown in Table 2, the message types include Adventisemengt (i.e., notification message) and switchElement (component switch notification message); the Priority is determined according to the node situation. For example, the weight value of a completely normal node is 100, and the weight value of a partially abnormal node is 100-n (n is the offset calculated based on the multi-branch tree model). Secondly, the message content shown in Table 2 is AES 256 ciphertext.
[0116] By comparing Table 1 and Table 2, the following differences can be found: Regarding the message type (Type), the message format shown in Table 1 only supports 1, that is, the notification message. When the slave node receives the message, it considers that the master node is in normal state and no switching operation is required. On this basis, a new type 2 is added to Table 2, that is, the component switching notification message. When the slave node receives the component switching notification message, it checks the master-slave status of all its components. If there is a master component, it switches to a slave component; when the master node receives the message, if it detects that a component is not a master component, it switches to a master component. The scope of the component can be determined according to the actual business to improve scalability.
[0117] Regarding the weighted value (Priority), the original value is only based on keepalived's own logical definition, and is either fixed or changes only according to its own status. In this application, the status of each component in the node is also reflected in the weighted value. For nodes where each component is normal, the weighted value uses the maximum value; for nodes where individual components are abnormal, the weighted value is offset to the left based on the maximum depth value of the multi-branch tree. The larger the depth value of the multi-branch tree, the smaller the weighted value offset, that is, the larger the value, and thus has a higher priority. As a result, when there are no abnormalities or both have abnormalities, the node with the smallest abnormal impact is selected to become the new primary node.
[0118] Regarding the authentication type (AuthType), VRRP defines three authentication types in RFC2338: 0-no authentication, 1-plain text authentication, and 2-MD5 authentication. In practice, it is found that these methods cannot provide effective security, so 1 and 2 are currently abandoned. Based on this situation, this application abandons this field and uses AES 256 (a symmetric encryption algorithm) to encrypt the entire protocol message. When all nodes join the multicast network, the secret key is saved. When each VRRP message (such as notification message, component switching notification message) arrives, it attempts to decrypt it. If the decryption is successful, it is considered to be a legitimate message; otherwise, the VRRP message is illegal.
[0119] To help those skilled in the art better understand the master-slave switching method and its technical effects provided in the embodiments of the present application, the following takes the application of the master-slave switching method to a distributed storage system as an example, and compares and explains the master-slave switching method in combination with relevant technical solutions.
[0120] A distributed storage system refers to a storage system that stores data in a dispersed manner on multiple independent devices. Compared with a centralized storage system that uses a centralized storage server to store all data, a distributed storage system undoubtedly increases the reliability and security of the system. It adopts a scalable system structure and uses multiple storage servers to share the load, which not only improves the reliability, availability and access efficiency of the system, but also makes it easy to expand.
[0121] In distributed storage systems, business access mostly adopts load balancing, but the system management software generally adopts a master-slave approach. At the same time, only one node provides access services to the outside world, and other nodes serve as slave nodes. When the master node fails, it switches to become the new master node and continues to provide services. This is a cluster-level master-slave solution.
[0122] However, as the business continues to expand, it is often necessary to introduce components with built-in master-slave architecture, including but not limited to some relational databases (such as postgresql), some time series databases (such as influxdb), RabbitMQ, etc. These components have their own master-slave solution under the cluster-level master-slave solution. When a node fails and switches, other components often fail to switch, resulting in actual access exceptions. For example, when keepalived detects an abnormality in the master node and switches the virtual IP to another node, the database component itself runs normally and no switch occurs, resulting in the master node and the database master library not being on the same node, which in turn makes the function unusable.
[0123] The master-slave switching scheme at the cluster level is generally implemented by the keepalived component, which uses the VRRP protocol at the bottom layer. However, keepalived cannot adapt well to the above scenarios. Although there are call scripts such as notify_master / notify_backup, they are not efficient to use. In addition, the detection scripts of other components of keepalived are not flexible and only exist in two states: available and unavailable. When all nodes are not 100% normal, the virtual IP cannot be assigned to any node. In addition, the VRRP protocol only supports simple character authentication, which has security issues.
[0124] In summary, from the above, it can be seen that this application proposes a method for the collaboration of multiple master-slave components in a distributed cluster, and expands and enhances the keepalived component and the VRRP protocol it uses to adapt to the above scenarios. When a failover occurs in keepalived, all components under all nodes are notified to switch through VRRP protocol messages, which is more efficient and reliable;
[0125] For details, please refer to Figure 6 After applying the master-slave switching method provided in the embodiment of the present application, the switching of the master and slave nodes is as follows:
[0126] The master node continuously sends multicast messages (i.e., notification messages) to inform all nodes that its status is normal. When a fault occurs, it will no longer send this message. At this time, a master-slave switch is required:
[0127] Node 1 is the primary node and fails at a certain point in time.
[0128] Node 1 no longer sends multicast messages, i.e., notification messages, about its own healthy status, and other nodes can then detect the anomaly.
[0129] All nodes calculate their own weighted values. Specifically, when all components are completely normal, the weighted value is the highest. When some components are abnormal, the current weighted value is calculated based on the maximum depth value of the multi-branch tree model and dynamically updated to the keepalived interaction message.
[0130] Keepalived selects the node with the highest weighted value as the new primary node.
[0131] Node 2 sends a VRRP multicast message (i.e., a component switching notification message) to notify all nodes to switch all components, including itself.
[0132] Node 2 upgrades all components to master. The upgrade process for each component is different.
[0133] Other nodes receive the component master-slave switching operation and downgrade all nodes to slaves.
[0134] The master-slave switching of the cluster and all components is completed, and the virtual IP switching process is completed.
[0135] Please refer to Figure 7 , Figure 7 The master-slave switching process of the related solution is compared with the switching process in this application. The switching process in this application has the following differences:
[0136] The election logic of the master node is different, that is, the calculation method of the weighted value is different. In the relevant switching process, the weighted value is fixed; the new process can dynamically calculate the weighted value according to the depth value of the multi-branch tree model, and select a node as the new master node.
[0137] The component switching method is different. The relevant switching process adopts the shell script call method. Each component to be switched needs to implement the script and add it to it. The switching process in this application can be achieved by using the protocol message method, and the multicast message is sent to each node. Each component of each node can respond to the message and process it autonomously if switching is required.
[0138] It should be noted that when all nodes are not 100% normal and there are various anomalies, the present application can calculate the maximum depth value of each node based on the multi-branch tree depth-first idea, thereby calculating the weighted value of each node, and selecting an optimal solution node based on the high and low sorting of the weighted values, rather than just the two states of available and unavailable; in addition, the VRRP protocol is optimized, the simple character authentication method is replaced by the AES 256 encryption algorithm, and the message format is refreshed to improve the security of communication.
[0139] Corresponding to the above method embodiment, the embodiment of the present application further provides a master-slave switching device. The master-slave switching device described below and the master-slave switching method described above can refer to each other.
[0140] See also Figure 8 As shown, the device includes the following modules:
[0141] The weighted value determination unit 101 is used to calculate the weighted value of the local node after detecting a failure of the master node;
[0142] The weighted value interaction unit 102 is used to send weighted values to other nodes in the distributed system through multicast messages; receive weighted values sent by other nodes through multicast messages;
[0143] A node master-slave determination unit 103, configured to determine the local node as a new master node when the weighted value of the local node is the highest;
[0144] The component switching notification unit 104 is used to notify the nodes in the distributed system to perform component switching through a multicast message;
[0145] A component master-slave switching unit 105 is used to upgrade the slave component to a master component if there is a slave component in the local node;
[0146] The address switching unit 106 is used to switch the virtual address to a new master node after the nodes and components in the nodes in the distributed system complete the master-slave switching operation.
[0147] Using the device provided in the embodiment of the present application, after the switching mechanism component detects a failure of the master node, it calculates the weighted value of the local node; sends the weighted value to other nodes in the distributed system through multicast messages; receives the weighted values sent by other nodes through multicast messages; when the weighted value of the local node is the highest, determines that the local node is the new master node; notifies the nodes in the distributed system to switch components through multicast messages; if there is a slave component in the local node, the slave component is promoted to the master; after the nodes in the distributed system and the components in the nodes complete the master-slave switching operation, the virtual address is switched to the new master node.
[0148] Considering that under the master-slave scheme at the cluster level, there is also a distributed system with its own master-slave scheme, and the access is abnormal due to the mismatch between the master-slave roles of the node and the component. To solve this problem, in the present application, when the exchange mechanism component detects the failure of the master node, the weighted value of the local node is first determined, and then the weighted value is sent to other nodes in the distributed system by means of multicast messages. At the same time, the weighted values sent by other nodes can also be received. By comparing the weighted values of each node, it can be clear whether the weight of the local node is the highest. If so, the local node is determined to be the new master node. After determining that the local node is the new master node, the nodes in the distributed system can be notified to switch components by means of multicast messages. The nodes that receive the multicast message will switch the master-slave roles of their own components. For the local node, since it is upgraded to the master node, it is necessary to upgrade the slave components in it. After the nodes in the distributed system and the components in the nodes have completed the master-slave switching operation, the virtual address can be switched to the new master node. In this way, the new master node can provide services to the outside based on the components that have completed the master-slave role switching.
[0149] Technical effect: In this application, while switching between master and slave nodes, the master and slave roles of components inside each node are switched through multicast information, thereby ensuring that the master and slave roles of the node and its internal components are consistent. In this way, after switching the virtual address, the new master node can be accessed normally, thereby ensuring that the service is not interrupted for a long time.
[0150] In a specific implementation of the present application, the node master-slave determination unit is specifically configured to receive a component switching notification sent by a new master node when the weighted value of the local node is not the highest;
[0151] If there is a master component in the local node, the master component will be downgraded to a slave.
[0152] In a specific implementation of the present application, the weighted value determination unit is specifically used to obtain a weighted fixed value of a local node; and determine the weighted fixed value as the weighted value of the local node.
[0153] In a specific implementation of the present application, the weighted value determination unit is specifically used to obtain a multi-branch tree model corresponding to a node component; wherein the multi-branch tree model is a multi-branch tree structure obtained by abstracting the node component; based on the multi-branch tree model, the current depth of the local node is determined; and the weighted constant of the local node is offset using the current depth to obtain the weighted value of the local node.
[0154] In a specific implementation of the present application, the weighted value determination unit is specifically used to traverse each component of the local node based on a multi-branch tree model; when an abnormal component is traversed, the traversal is stopped to obtain the traversal depth; and the traversal depth is determined as the current depth.
[0155] In a specific implementation of the present application, the weighted value determination unit is specifically used to obtain the calibrated depth of the multi-branch tree model; calculate the depth difference between the calibrated depth and the current depth; subtract the depth difference from the weighted value to obtain the weighted value of the local node.
[0156] In a specific implementation of the present application, the weighted value determination unit is specifically used to abstract the components in the node, with the interactive interface as the root node and other components as leaf nodes, and the nodes are connected from the top layer to the bottom layer to obtain a multi-branch tree model.
[0157] In a specific implementation of the present application, the weighted value interaction unit is specifically used to generate an interaction message carrying a weighted value based on a virtual routing redundancy protocol; send the interaction message to a multicast group; the multicast group includes nodes in a distributed system.
[0158] In a specific implementation of the present application, the component switching notification unit is specifically used to generate a component switching notification message based on a virtual routing redundancy protocol; send the component switching notification message to a multicast group; the multicast group includes nodes in a distributed system.
[0159] In a specific embodiment of the present application, the fault detection unit is used to detect the failure of the master node, specifically including: when a notification message sent by the master node is received, determining that the master node is normal; when a notification message sent by the master node is not received for more than a preset time, determining that the master node is faulty; accordingly, after switching the virtual address to the new master node, including: based on the virtual routing redundancy protocol, periodically generating notification messages; sending notification messages to the multicast group; the multicast group includes nodes in the distributed system.
[0160] In a specific implementation of the present application, it includes: a message encryption and decryption unit, which is used to add a local node to a multicast group and save a key; based on a virtual routing redundancy protocol, an encrypted message is generated in combination with a symmetric encryption algorithm; accordingly, after receiving the message, the received message is decrypted using the key; if the decryption is successful, the received message is determined to be legal, and a response processing is performed on the message; if the decryption fails, the received message is determined to be illegal, and the received message is discarded.
[0161] Corresponding to the above method embodiment, an embodiment of the present application further provides an electronic device, and the electronic device described below and the master-slave switching method described above can refer to each other.
[0162] See also Fig. 9 As shown, the electronic device includes:
[0163] A memory 332, for storing computer programs;
[0164] The processor 322 is configured to implement the steps of the master-slave switching method of the above method embodiment when executing a computer program.
[0165] For details, please refer to Fig.10 , Fig.10 A schematic diagram of the specific structure of an electronic device provided for this embodiment, which may have relatively large differences due to different configurations or performances, may include one or more processors (central processing units, CPU) (for example, one or more processors) and a memory 332, and the memory 332 stores one or more computer programs 342 or data 344. Among them, the memory 332 can be a temporary storage or a permanent storage. The program stored in the memory 332 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the data processing device. Furthermore, the processor 322 can be configured to communicate with the memory 332 to execute a series of instruction operations in the memory 332 on the electronic device 301.
[0166] The electronic device 301 may further include one or more power supplies 326 , one or more wired or wireless network interfaces 350 , one or more input and output interfaces 358 , and / or one or more operating systems 341 .
[0167] The steps in the master-slave switching method described above can be implemented by the structure of an electronic device.
[0168] Corresponding to the above method embodiment, the embodiment of the present application further provides a readable storage medium. The readable storage medium described below and the master-slave switching method described above can refer to each other.
[0169] A readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the master-slave switching method of the above method embodiment are implemented.
[0170] The readable storage medium may specifically be a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, or other readable storage medium that can store program codes.
[0171] Corresponding to the above method embodiment, the embodiment of the present application further provides a computer program product. The computer program product described below and the master-slave switching method described above can refer to each other.
[0172] A computer program product includes a computer program / instruction. When the computer program / instruction is executed by a processor, the steps of the master-slave switching method are implemented.
[0173] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0174] Those skilled in the art may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented with electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0175] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0176] Finally, it should be noted that, in this article, relationships such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms include, include or any other variations are intended to cover non-exclusive inclusion, so that a process, method, article or device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.
[0177] Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for those skilled in the art, according to the idea of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A master-slave switching method, characterized in that: include: After the exchange mechanism component detects the failure of the master node, it calculates the weighted value of the local node; Sending the weighted value to other nodes in the distributed system via a multicast message; Receive weighted values sent by other nodes via multicast messages; When the weighted value of the local node is the highest, the local node is determined as the new master node; Notifying nodes in the distributed system to perform component switching via multicast messages; If there is a slave component in the local node, the slave component is upgraded to a master component; After the nodes in the distributed system and the components in the nodes complete the master-slave switching operation, the virtual address is switched to a new master node; The calculation of the weighted value of the local node includes: Obtaining a multi-branch tree model corresponding to the node component; wherein the multi-branch tree model is a multi-branch tree structure obtained by abstracting the node component; Based on the multi-tree model, determining the current depth of the local node; The weighted fixed value of the local node is offset by using the current depth to obtain a weighted value of the local node; the deeper the depth of the node, the more reliable the function in the corresponding node, and the smaller the impact range of the generated abnormality; the weighted value represents the functional status of the node; The weighted fixed value of the local node is offset by using the current depth to obtain the weighted value of the local node, including: Obtaining a calibrated depth of the multi-branch tree model; Calculating a depth difference between the calibrated depth and the current depth; The depth difference is subtracted from the weighted fixed value to obtain a weighted value of the local node.
2. The method according to claim 1, characterized in that When the weighted value of the local node is not the highest, it includes: Receive component switching notifications sent by the new master node; If a master component exists in the local node, the master component is downgraded to a slave component.
3. The method according to claim 1, characterized in that Calculate the weighted value of the local node, including: Get the weighted constant value of the local node; The weighted value is determined as the weighted value of the local node.
4. The method according to claim 1, characterized in that: Based on the multi-tree model, determining the current depth of the local node includes: Based on the multi-branch tree model, traverse each component of the local node; When an abnormal component is traversed, stop traversal and obtain the traversal depth; The traversal depth is determined as the current depth.
5. The method according to claim 1, characterized in that Get the multi-branch tree model corresponding to the node component, including: The components in the nodes are abstractly processed, with the interactive interface as the root node and other components as leaf nodes, and the nodes are connected from the top layer to the bottom layer to obtain the multi-branch tree model.
6. The method according to claim 1, characterized in that Sending the weighted value to other nodes in the distributed system through a multicast message includes: Based on the virtual routing redundancy protocol, generating an interaction message carrying the weighted value; The interaction message is sent to a multicast group; the multicast group includes nodes in the distributed system.
7. The method according to claim 1, characterized in that Notifying nodes in the distributed system to switch components by multicasting messages includes: Generate component switching notification message based on virtual routing redundancy protocol; The component switching notification message is sent to a multicast group; the multicast group includes nodes in the distributed system.
8. The method according to claim 1, characterized in that A master node failure is detected, including: When receiving the notification message sent by the master node, it is determined that the master node is normal; If the notification message sent by the master node is not received after the preset time, it is determined that the master node is faulty; Accordingly, after switching the virtual address to the new primary node, it includes: Generate notification messages regularly based on the virtual routing redundancy protocol; The notification message is sent to a multicast group; the multicast group includes nodes in the distributed system.
9. The method according to any one of claims 6 to 8, characterized in that: include: Add the local node to the multicast group and save the key; Based on the virtual routing redundancy protocol, an encrypted message is generated in combination with a symmetric encryption algorithm; Accordingly, after receiving the message, the received message is decrypted using the key; If the decryption is successful, the received message is determined to be legal and a response is processed for the message; If the decryption fails, the received message is determined to be illegal and the received message is discarded.
10. An exchange mechanism component, characterized in that include: A weighted value determination unit, used to calculate the weighted value of the local node after detecting a failure of the master node; A weighted value interaction unit, configured to send the weighted value to other nodes in the distributed system via a multicast message; Receive weighted values sent by other nodes via multicast messages; A node master-slave determination unit, used to determine the local node as the new master node when the weighted value of the local node is the highest; A component switching notification unit, used to notify nodes in the distributed system to perform component switching through a multicast message; A component master-slave switching unit, used for upgrading a slave component to a master if there is a slave component in the local node; An address switching unit, configured to switch the virtual address to a new master node after the nodes and components in the nodes in the distributed system complete the master-slave switching operation; The calculation of the weighted value of the local node includes: Obtaining a multi-branch tree model corresponding to the node component; wherein the multi-branch tree model is a multi-branch tree structure obtained by abstracting the node component; Based on the multi-tree model, determining the current depth of the local node; The weighted fixed value of the local node is offset by using the current depth to obtain a weighted value of the local node; the deeper the depth of the node, the more reliable the function in the corresponding node, and the smaller the impact range of the generated abnormality; the weighted value represents the functional status of the node; The weighted fixed value of the local node is offset by using the current depth to obtain the weighted value of the local node, including: Obtaining a calibrated depth of the multi-branch tree model; Calculating a depth difference between the calibrated depth and the current depth; The depth difference is subtracted from the weighted fixed value to obtain a weighted value of the local node.
11. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the master-slave switching method as claimed in any one of claims 1 to 9 when executing the computer program.
12. A readable storage medium, characterized in that: The readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the master-slave switching method according to any one of claims 1 to 9 are implemented.
13. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instruction is executed by a processor, the steps of the master-slave switching method described in any one of claims 1 to 9 are implemented.
Citation Information
Patent Citations
Database high availability method, system and device and storage medium
CN117093425A