Method and device for realizing dual-computer-room arbitration system based on distributed key value storage library
By introducing the observer role on the arbitration node of the dual-computer room arbitration system, it only participates in the voting of the master without storing and copying data, the problem of arbitration nodes participating in data replication and updating in the existing technology is solved, and the master selection process is optimized and resources are saved.
Patent Information
- Application Number
- CN202411752569.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-02
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2044-12-02
AI Technical Summary
In arbitration system deployed in dual-computer room, the existing technology requires all nodes to participate in data replication and update, resulting in a complex arbitration process and wasted resources.
By introducing an observer role on the arbitration node, it only participates in the voting master selection without storing and copying data, the master selection process is optimized and resources are saved.
It realizes that the arbitration node only participates in the voting and does not be elected as the main one, does not need to store and copy data, optimizes the master selection process, and saves bandwidth and compute storage resources.
Smart Images

Figure CN119728378A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of network technology, and in particular to a method and device for realizing a dual-computer room arbitration system based on a distributed key-value storage library. Background Art
[0002] In the construction of cloud computer rooms, there is a need to build dual computer rooms. In this way, the virtual network control plane of the IaaS (Infrastructure as a Service) layer has services that need to be arbitrated for the election of the leader. Usually, in the scenario where arbitration is required for the deployment of dual computer rooms, an arbitration node is added in a third suitable site outside the two computer rooms to form a 3-node etcd (Extended Distributed Key Value, a distributed key-value storage library) cluster for arbitration and leader election. These three etcd instances will undertake data replication and update without distinction during operation. The three nodes are equal roles and require the same configuration specifications, such as memory, cpu (Central Processing Unit), disk, and transmission bandwidth. That is to say, the etcd instance deployed on the arbitration node will store all data and participate in data replication and update in the same way as the etcd instances in the two computer rooms. However, the arbitration node does not need to be a leader node, nor does it need to store and replicate data. The current leader election arbitration and leader election process is relatively cumbersome and wastes bandwidth and computing storage resources. Summary of the invention
[0003] In view of the above problems, a method and device for implementing a dual-computer room arbitration system based on a distributed key-value storage library is proposed to overcome the above problems or at least partially solve the above problems, including:
[0004] A method for implementing a dual-computer room arbitration system based on a distributed key-value storage library, the dual-computer room arbitration system comprising an arbitration node, a first node and a second node, the first node and the second node being deployed in different computer rooms, the method comprising:
[0005] In response to the startup of the dual-computer room arbitration system, obtaining configuration parameters and determining role information of the arbitration node;
[0006] Sending the role information of the arbitration node to the first node and the second node by broadcasting, and receiving the role information of the first node and the role information of the second node;
[0007] Selecting a leader node from the first node and the second node according to the role information of the first node and the role information of the second node;
[0008] According to the role information of the arbitration node, a message permission list of the arbitration node is obtained, and the operation instruction message of the leader node is filtered through the message permission list; wherein the operation instruction message includes a data replication operation and a data update operation.
[0009] Optionally,
[0010] The role information includes the node URL and the node role;
[0011] The node role includes one of an observer, a leader, a candidate or a follower, and the node role of the leading node is the leader.
[0012] Optionally, the acquiring configuration parameters and determining the role information of the arbitration node includes:
[0013] Get command line parameters or configuration files;
[0014] By executing the command line parameter or reading the configuration file, the node role of the arbitration node is determined to be the observer.
[0015] Optionally, after obtaining the configuration parameters and determining the role information of the arbitration node, the method further includes:
[0016] Initialize a global read-only role variable, and set the value of the global read-only role variable to the enumeration value corresponding to the observer.
[0017] Optionally, it also includes:
[0018] Process messages or operations related to arbitration nodes through the preset observer state processing function.
[0019] Optionally, selecting a leader node from the first node and the second node according to the role information of the first node and the role information of the second node includes:
[0020] Receiving voting request messages sent by the first node and the second node;
[0021] Sending a voting approval message or a voting rejection message to the first node and the second node;
[0022] A leading node is determined according to the sending status of the approval voting message or the rejection voting message.
[0023] Optionally, determining the leader node according to the sending status of the approval voting message or the rejection voting message includes:
[0024] When the first node receives the voting approval message, the second node receives the voting rejection message and determines that the first node is the leader node and the node role of the second node is the follower;
[0025] In the case where the first node receives the voting rejection message, the second node receives the voting approval message and determines that the second node is the leader node and the node role of the first node is the follower.
[0026] A dual-computer room arbitration system implementation device based on a distributed key-value storage library, the dual-computer room arbitration system comprising an arbitration node, a first node and a second node, the first node and the second node are deployed in different computer rooms, the device comprising:
[0027] A role information determination module, configured to obtain configuration parameters and determine the role information of the arbitration node in response to the startup of the dual-computer room arbitration system;
[0028] A role information sending and receiving module, used to send the role information of the arbitration node to the first node and the second node by broadcasting, and receive the role information of the first node and the role information of the second node;
[0029] An election module, configured to select a leader node from the first node and the second node according to the role information of the first node and the role information of the second node;
[0030] A message filtering module is used to obtain the message permission list of the arbitration node according to the role information of the arbitration node, and filter the operation instruction message of the leader node through the message permission list; wherein the operation instruction message includes data replication operation and data update operation.
[0031] An electronic device comprises a processor, a memory and a computer program stored in the memory and capable of running on the processor, wherein when the computer program is executed by the processor, the method for implementing a dual-computer room arbitration system based on a distributed key-value storage library as described above is implemented.
[0032] A readable storage medium stores a computer program, and when the computer program is executed by a processor, the method for implementing a dual-computer room arbitration system based on a distributed key-value storage library as described above is implemented.
[0033] The embodiments of the present invention have the following advantages:
[0034] In an embodiment of the present invention, by responding to the startup of the dual-computer room arbitration system, obtaining configuration parameters, determining the role information of the arbitration node, sending the role information of the arbitration node to the first node and the second node by broadcasting, receiving the role information of the first node and the role information of the second node, selecting a leader node from the first node and the second node by the role information of the first node and the role information of the second node, obtaining a message allowance list of the arbitration node according to the role information of the arbitration node, and filtering the operation instruction message of the leader node by the message allowance list, wherein the operation instruction message includes a data copy operation and a data update operation, thereby realizing a newly added target role, allowing the arbitration node to only participate in voting for the leader and not be elected as the leader, and not needing to store and copy data, thereby optimizing the leader election process and saving bandwidth and computing storage resources at the same time. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the technical solution of the present invention, the accompanying drawings required for use in the description of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0036] Figure 1 It is a flowchart of the steps of a method for implementing a dual-computer room arbitration system based on a distributed key-value storage library provided by some embodiments of the present invention;
[0037] Figure 2 It is a schematic diagram of a dual-computer room arbitration system architecture provided by some embodiments of the present invention;
[0038] Figure 3 is a flowchart of the steps of election in a dual-computer room arbitration system provided by some embodiments of the present invention;
[0039] Figure 4 It is a schematic diagram of the architecture of a dual-computer room arbitration system after election provided by some embodiments of the present invention;
[0040] Figure 5 It is a structural block diagram of a dual-computer room arbitration system implementation device based on a distributed key-value storage library provided by some embodiments of the present invention. DETAILED DESCRIPTION
[0041] In order to make the above-mentioned purposes, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0042] Etcd is an open source strongly consistent distributed key-value storage library used to store and manage critical information required for distributed systems to keep running.
[0043] Etcd is built on the Raft (Replicated And Fault-Tolerant) consensus algorithm, which ensures data storage consistency across all nodes in the cluster, which is the goal of a fault-tolerant distributed system. Raft achieves this consistency through an elected leader node, which is responsible for managing replication for other nodes in the cluster (called follower nodes). The leader node accepts requests from clients and then forwards them to the follower nodes. Once the leader node determines that a majority of the follower nodes have stored each new request as a log entry, it applies the entry to the local state machine and returns the result of this execution (a "write" operation) to the client. If a follower node crashes or network packets are lost, the leader node will retry until all follower nodes have stored all log entries consistently. If a follower node fails to receive a message from the leader node within a specified time interval, a new leader node will be elected. The follower node will declare itself as a candidate, and other follower nodes will vote for it or any other node based on its availability. Once a new leader node is elected, it will begin managing replication and the process will repeat itself. This process enables all etcd nodes to maintain a highly available and consistent copy of the data store.
[0044] In one embodiment of the present invention, by modifying etcd implementation and adding an observer role, the etcd server instance of the arbitration node only participates in voting for the leader and will not be elected as the leader, and does not need to store and copy data, thereby optimizing the leader election process and saving bandwidth and computing and storage resources. The observer role in the present invention may refer to an etcd server instance started with the observer role.
[0045] Reference Figure 1, shows a flowchart of a method for implementing a dual-computer room arbitration system based on a distributed key-value storage library provided in some embodiments of the present invention, wherein the dual-computer room arbitration system includes an arbitration node, a first node, and a second node, wherein the first node and the second node are deployed in different computer rooms, and specifically may include the following steps:
[0046] Step 101 , in response to the startup of the dual-computer room arbitration system, obtain configuration parameters and determine the role information of the arbitration node.
[0047] like Figure 2 As shown, an architecture diagram of a dual-computer room arbitration system of the present invention is shown, wherein az (Availability Zone) can represent the availability zone where the computer room is located, and the computer room corresponds to the corresponding node, and az1 and az2 can correspond to the first node in computer room 1 and the second node in computer room 2. It should be noted that the arbitration node, the first node and the second node can all be etcd server instances.
[0048] Specifically, in the present invention, a new implementation method is added by modifying etcd, and a new observer role is added. When the dual-computer room arbitration system is started, the etcd server instance of the arbitration node can obtain corresponding configuration parameters to determine the role information of the etcd server instance of the arbitration node itself.
[0049] In some embodiments of the present invention, the role information includes a node website and a node role;
[0050] The node role includes one of an observer, a leader, a candidate or a follower, and the node role of the leading node is the leader.
[0051] The role information may include the URL and node role of the corresponding node. The node role may be one of observer, leader, candidate or follower. For example, the leader node is the first node or the second node whose node role is leader.
[0052] In some embodiments of the present invention, the obtaining of configuration parameters and determining the role information of the arbitration node includes:
[0053] Sub-step 11, obtaining command line parameters or configuration files.
[0054] When the dual-computer room arbitration system is started, command line parameters or configuration files can be obtained.
[0055] Sub-step 12: determining the node role of the arbitration node as the observer by executing the command line parameters or reading the configuration file.
[0056] After obtaining the command line parameters or the configuration file, the node role of the arbitration node may be determined by executing the command line parameters or reading the configuration file.
[0057] Specifically, you can determine that the node role of the etcd server instance of the arbitration node is observer by passing the "--role observer" startup parameter (that is, the command line parameter) or reading the newly added "role: observer" item in the configuration file.
[0058] In some embodiments of the present invention, after obtaining the configuration parameters and determining the role information of the arbitration node, the method further includes:
[0059] Initialize a global read-only role variable, and set the value of the global read-only role variable to the enumeration value corresponding to the observer.
[0060] Specifically, after determining the node role of the etcd server instance of the arbitration node, when the etcd server instance of the arbitration node is initialized, a global read-only role variable can be defined in the following way:
[0061] const role int = OBSERVER (OBSERVER is an enumeration value)
[0062] By defining the enumeration type role and setting the value of the global read-only role variable role to an enumeration value such as OBSERVER, the node role of the etcd server instance of the arbitration node can be clearly defined through the global read-only role variable to ensure that the role information of the node is clear and consistent during system operation.
[0063] It should be noted that in programming, enumeration values are usually used to define a set of fixed values, which can only take one of the predefined values in the program. For example, when defining the week, you can use the enumeration type week, whose values include Monday, Tuesday, Wednesday, etc. In this way, the variable can only take these predefined values, avoiding the use of magic numbers or string constants, making the code clearer and easier to maintain.
[0064] Step 102: Send the role information of the arbitration node to the first node and the second node by broadcasting, and receive the role information of the first node and the role information of the second node.
[0065] After the etcd server instance of the arbitration node determines its own node role, the node role and node URL (i.e., role information) of the etcd server instance of the arbitration node can be sent to the etcd server instances corresponding to the first node and the second node by broadcasting.
[0066] At the same time, the etcd server instances corresponding to the first node and the second node also send the node URLs and node roles (i.e., role information) of the etcd server instances corresponding to the first node and the second node to the etcd server instance of the arbitration node by broadcasting. The etcd server instance of the arbitration node can receive the role information of the etcd server instance of the first node and the role information of the etcd server instance of the second node.
[0067] Specifically, each node's etcd server instance can broadcast its own role information by calling the BroadcastRole() method. It can also start the ReceiveRoleNotification() method to receive role information sent by other nodes' etcd server instances. Each node's etcd instance can also record the mapping relationship between the node URL and node role of other nodes' etcd server instances.
[0068] Step 103: Select a leader node from the first node and the second node according to the role information of the first node and the role information of the second node.
[0069] When the dual-computer room arbitration system is carrying out the election process, the etcd server instance of the arbitration node can obtain the node URL of the first node etcd server instance and the node URL of the second node etcd server instance from the role information of the first node etcd server instance and the role information of the second node etcd server instance, and send a voting message through the node URL of the first node etcd server instance and the node URL of the second node etcd server instance.
[0070] In some embodiments of the present invention, selecting a leader node from the first node and the second node according to the role information of the first node and the role information of the second node includes:
[0071] Sub-step 21: receiving voting request messages sent by the first node and the second node.
[0072] After the election process starts in the dual-computer room arbitration system, the etcd server instance of the arbitration node can receive the voting request message sent by the etcd server instance of the first node and the etcd server instance of the second node. It should be noted that at this time, the node roles of the etcd server instance of the first node and the etcd server instance of the second node are candidates.
[0073] Sub-step 22: Send a voting approval message or a voting rejection message to the first node and the second node.
[0074] After receiving the voting request messages sent by the etcd server instance of the first node and the etcd server instance of the second node, the etcd server instance of the arbitration node can send voting messages to the etcd server instance of the first node and the etcd server instance of the second node respectively.
[0075] The voting message may be an approval voting message or a rejection voting message.
[0076] Sub-step 23, determining the leading node according to the sending status of the approval voting message or the rejection voting message.
[0077] After the etcd server instance of the arbitration node sends the approval voting message or the rejection voting message respectively, the leading node can be determined according to the sending status of the approval voting message or the rejection voting message.
[0078] In some embodiments of the present invention, determining the leader node according to the sending status of the approval voting message or the rejection voting message includes:
[0079] When the etcd server instance of the first node receives the voting approval message, the second node receives the voting rejection message and determines that the first node is the leader node and the node role of the second node is the follower;
[0080] In the case where the first node receives the voting rejection message, the second node receives the voting approval message and determines that the second node is the leader node and the node role of the first node is the follower.
[0081] Specifically, when the etcd server instance of the first node receives a message of approval to vote, the etcd server instance of the second node will receive a message of rejection to vote, that is, the arbitration node casts a vote for the first node. At this time, the first node can be determined as the leader node, and the node role of the second node is a follower, or it can be considered a follower node. At the same time, the node role of the etcd server instance of the first node can be changed from candidate to leader, and the node role of the etcd server instance of the second node can be changed from candidate to follower.
[0082] When the etcd server instance of the first node receives a rejection message, the etcd server instance of the second node will receive a consent message, that is, the arbitration node casts a vote for the second node. At this time, the second node can be determined as the leader node, and the node role of the first node can be determined as a follower. At the same time, the node role of the etcd server instance of the second node can be changed from candidate to leader, and the node role of the etcd server instance of the first node can be changed from candidate to follower.
[0083] It should be noted that the first node and the second node can also participate in the voting, but in general, the first node and the second node can vote for themselves, so the consent vote of the arbitration node can determine the node that will become the leader node. The node role of the etcd server instance of the arbitration node is observer. The node with the observer role only participates in the voting and will not vote to elect itself as the leader node. The vote will only be voted for the non-observer role deployed in the two az (availability zones) (that is, the first node or the second node in the corresponding computer room of the availability zone), which means that the leader node will only appear in the first or second node corresponding to the two computer rooms.
[0084] In some embodiments of the present invention, it further comprises:
[0085] Process messages or operations related to arbitration nodes through the preset observer state processing function.
[0086] An observer state processing function can be preset to handle messages or operations related to the etcd server instance of the arbitration node.
[0087] Specifically, the arbitration node corresponding to the observer role has special behaviors and responsibilities, so an independent state can be defined for it. In Raft, a new state named StateObserver can be added to identify the observer role. That is, a new state can be introduced into the Raft state machine to specifically handle the logic of the observer role. A becomeObserver() processing function can be added to switch the state of the etcd server instance of the arbitration node to StateObserver and perform corresponding initialization operations.
[0088] A global processing function stepObserver() similar to stepCandidate (candidate state processing function) / stepFollower (follower state processing function) / stepLeader (leader state processing function) can be added in Rraft, that is, the preset observer state processing function, which is used to process all observer-related messages and actions, that is, messages or operations related to the etcd server instance of the arbitration node.
[0089] In this way, it can be ensured that the observer node, that is, the etcd server instance of the arbitration node, can correctly process the messages from the leader node and does not participate in the election of the leader node, but only votes.
[0090] Step 104: obtaining a message permission list of the arbitration node according to the role information of the arbitration node, and filtering the operation instruction message of the leader node through the message permission list; wherein the operation instruction message includes a data replication operation and a data update operation.
[0091] After determining the leader node, the message allowance list of the arbitration node can be obtained according to the node role of the etcd server instance of the arbitration node, that is, the list of message types that can be received. This list does not include data replication operations and data update operations, that is, the data replication operations and data update operations of the leader node will not be allowed to be sent to the arbitration node, thereby filtering the data replication operations and data update operations of the leader node through the message allowance list.
[0092] In actual applications, for the etcd server instance of each node, the observer role can be processed in the Transport layer, and the role attribute can be added to the peer (node in the dual-computer room arbitration system) to distinguish between the observer role and the non-observer role.
[0093] If the role of the etcd server instance itself is equal to observer, it means that the node role is leader, follower or candidate. For the message sending of the peer whose role is observer, special processing can be done. Only MsgHup (election trigger message) / MsgVote (voting request message) / MsgVoteResp (response to voting request message) / MsgHeartbeat (heartbeat message) / MsgHeartbeatResp (heartbeat response message) / MsgPreVote (pre-election message) / MsgPreVoteResp (response to pre-voting request message) and other messages (that is, the message permission list of the arbitration node) can be sent to the peer whose node role is observer, that is, Append (log replication message) / Snapshot (acceleration message) and other messages (that is, data replication operation and data update operation of the leader node) can be filtered out.
[0094] At the same time, the arbitration node will not actively initiate data synchronization requests, so data synchronization will only occur between the etcd server instances of the first node and the second node, that is, between the etcd server instances of the leader and follower roles.
[0095] In an embodiment of the present invention, by responding to the startup of the dual-computer room arbitration system, obtaining configuration parameters, determining the role information of the arbitration node, sending the role information of the arbitration node to the first node and the second node by broadcasting, receiving the role information of the first node and the role information of the second node, selecting a leader node from the first node and the second node by the role information of the first node and the role information of the second node, obtaining a message allowance list of the arbitration node according to the role information of the arbitration node, and filtering the operation instruction message of the leader node by the message allowance list, wherein the operation instruction message includes a data copy operation and a data update operation, thereby realizing a newly added target role, allowing the arbitration node to only participate in voting for the leader and not be elected as the leader, and not needing to store and copy data, thereby optimizing the leader election process and saving bandwidth and computing storage resources at the same time.
[0096] Reference Figure 3 , shows a flowchart of the steps of election in a dual-computer room arbitration system provided by some embodiments of the present invention, which may specifically include the following steps:
[0097] 1. The arbitration node confirms its role information and initializes;
[0098] 2. The arbitration node sends its role to AZ1 (the computer room corresponding to available zone 1, i.e., the first node) and AZ2 (the computer room corresponding to available zone 2, i.e., the second node), and receives the returned ack (Acknowledgment) message, i.e., the confirmation message.
[0099] 3. The arbitration node receives the voting request messages from the first node and the second node;
[0100] 4. The arbitration node sends an approval vote message to the first node and a rejection request message to the second node, thereby determining that the node role of the first node is the leader and the node role of the second node is the follower;
[0101] 5. Change the node role of the first node to a leader, i.e., a leading node, and change the node role of the second node to a follower, i.e., a following node;
[0102] 6. The leader node (first node) sends a data update message to the follower node (second node) and receives an ack message returned by the follower node.
[0103] like Figure 4 The above shows a schematic diagram of the architecture of the dual-computer room arbitration system after the election of the leader node is completed.
[0104] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0105] Reference Figure 5 , shows a schematic diagram of the structure of a dual-computer room arbitration system implementation device based on a distributed key-value storage library provided in some embodiments of the present invention, wherein the dual-computer room arbitration system includes an arbitration node, a first node, and a second node, wherein the first node and the second node are deployed in different computer rooms, and specifically may include the following modules:
[0106] The role information determination module 501 is used to obtain configuration parameters and determine the role information of the arbitration node in response to the startup of the dual-computer room arbitration system;
[0107] The role information sending and receiving module 502 is used to send the role information of the arbitration node to the first node and the second node by broadcasting, and receive the role information of the first node and the role information of the second node;
[0108] An election module 503, configured to select a leader node from the first node and the second node according to the role information of the first node and the role information of the second node;
[0109] The message filtering module 504 is used to obtain the message permission list of the arbitration node according to the role information of the arbitration node, and filter the operation instruction message of the leader node through the message permission list; wherein the operation instruction message includes data replication operation and data update operation.
[0110] In one embodiment of the present invention,
[0111] The role information includes the node URL and the node role;
[0112] The node role includes one of an observer, a leader, a candidate or a follower, and the node role of the leading node is the leader.
[0113] In one embodiment of the present invention, the role information determination module 501 includes:
[0114] Configuration parameter acquisition submodule, used to obtain command line parameters or configuration files;
[0115] The role information determination submodule is used to determine the node role of the arbitration node as the observer by executing the command line parameters or reading the configuration file.
[0116] In an embodiment of the present invention, after obtaining the configuration parameters and determining the role information of the arbitration node, the method further includes:
[0117] The initialization module is used to initialize a global read-only role variable and set the value of the global read-only role variable to the enumeration value corresponding to the observer.
[0118] In one embodiment of the present invention, it also includes:
[0119] The message or operation processing module is used to process messages or operations related to the arbitration node through a preset observer state processing function.
[0120] In one embodiment of the present invention, the election module 503 includes:
[0121] A voting request message receiving submodule, configured to receive voting request messages sent by the first node and the second node;
[0122] A voting message sending submodule, used to send a voting approval message or a voting rejection message to the first node and the second node;
[0123] The leader node determination submodule is used to determine the leader node according to the sending status of the approval voting message or the rejection voting message.
[0124] In one embodiment of the present invention, the leader node determination submodule includes:
[0125] When the first node receives the voting approval message, the second node receives the voting rejection message and determines that the first node is the leader node and the node role of the second node is the follower;
[0126] In the case where the first node receives the voting rejection message, the second node receives the voting approval message and determines that the second node is the leader node and the node role of the first node is the follower.
[0127] In an embodiment of the present invention, by responding to the startup of the dual-computer room arbitration system, obtaining configuration parameters, determining the role information of the arbitration node, sending the role information of the arbitration node to the first node and the second node by broadcasting, receiving the role information of the first node and the role information of the second node, selecting a leader node from the first node and the second node by the role information of the first node and the role information of the second node, obtaining a message allowance list of the arbitration node according to the role information of the arbitration node, and filtering the operation instruction message of the leader node by the message allowance list, wherein the operation instruction message includes a data copy operation and a data update operation, thereby realizing a newly added target role, allowing the arbitration node to only participate in voting for the leader and not be elected as the leader, and not needing to store and copy data, thereby optimizing the leader election process and saving bandwidth and computing storage resources at the same time.
[0128] Some embodiments of the present invention further provide an electronic device, comprising a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the above method is implemented when the computer program is executed by the processor.
[0129] Some embodiments of the present invention further provide a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the above method is implemented.
[0130] Some embodiments of the present invention further provide a computer program product, including a computer program, which implements the above method when executed by a processor.
[0131] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0132] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0133] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0134] Those skilled in the art will appreciate that the embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, the embodiments of the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0135] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0136] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0137] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0138] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.
[0139] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used 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", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including 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 terminal device. In the absence of further restrictions, the elements defined by the sentence "including one..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the above elements.
[0140] The above is a detailed introduction to the dual-computer room arbitration system implementation method and device based on the distributed key-value storage library. In this article, specific examples are used to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as limiting the present invention.
Claims
1. A method for implementing a dual-computer room arbitration system based on a distributed key-value storage library, characterized in that: The dual-computer room arbitration system includes an arbitration node, a first node, and a second node, wherein the first node and the second node are deployed in different computer rooms, and the method includes: In response to the startup of the dual-computer room arbitration system, obtaining configuration parameters and determining role information of the arbitration node; Sending the role information of the arbitration node to the first node and the second node by broadcasting, and receiving the role information of the first node and the role information of the second node; Selecting a leader node from the first node and the second node according to the role information of the first node and the role information of the second node; According to the role information of the arbitration node, a message permission list of the arbitration node is obtained, and the operation instruction message of the leader node is filtered through the message permission list; wherein the operation instruction message includes a data replication operation and a data update operation.
2. The method according to claim 1, characterized in that The role information includes the node URL and the node role; The node role includes one of an observer, a leader, a candidate or a follower, and the node role of the leading node is the leader.
3. The method according to claim 2, characterized in that The obtaining of configuration parameters and determining the role information of the arbitration node includes: Get command line parameters or configuration files; By executing the command line parameter or reading the configuration file, the node role of the arbitration node is determined to be the observer.
4. The method according to any one of claims 2 to 3, characterized in that: After obtaining the configuration parameters and determining the role information of the arbitration node, the method further includes: Initialize a global read-only role variable, and set the value of the global read-only role variable to the enumeration value corresponding to the observer.
5. The method according to claim 3, characterized in that: Also includes: Process messages or operations related to arbitration nodes through the preset observer state processing function.
6. The method according to claim 2, characterized in that The selecting a leader node from the first node and the second node according to the role information of the first node and the role information of the second node includes: Receiving voting request messages sent by the first node and the second node; Sending a voting approval message or a voting rejection message to the first node and the second node; A leading node is determined according to the sending status of the approval voting message or the rejection voting message.
7. The method according to claim 6, characterized in that The determining the leading node according to the sending status of the approval voting message or the rejection voting message includes: When the first node receives the voting approval message, the second node receives the voting rejection message and determines that the first node is the leader node and the node role of the second node is the follower; In the case where the first node receives the voting rejection message, the second node receives the voting approval message and determines that the second node is the leader node and the node role of the first node is the follower.
8. A dual-computer room arbitration system implementation device based on a distributed key-value storage library, characterized in that: The dual-computer room arbitration system includes an arbitration node, a first node, and a second node, wherein the first node and the second node are deployed in different computer rooms, and the device includes: A role information determination module, configured to obtain configuration parameters and determine the role information of the arbitration node in response to the startup of the dual-computer room arbitration system; A role information sending and receiving module, used to send the role information of the arbitration node to the first node and the second node by broadcasting, and receive the role information of the first node and the role information of the second node; An election module, configured to select a leader node from the first node and the second node according to the role information of the first node and the role information of the second node; A message filtering module is used to obtain the message permission list of the arbitration node according to the role information of the arbitration node, and filter the operation instruction message of the leader node through the message permission list; wherein the operation instruction message includes data replication operation and data update operation.
9. An electronic device, characterized in that: The invention comprises a processor, a memory and a computer program stored in the memory and capable of running on the processor, wherein when the computer program is executed by the processor, the method for realizing a dual-computer room arbitration system based on a distributed key-value storage library as described in any one of claims 1 to 7 is realized.
10. 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 method for implementing a dual-computer room arbitration system based on a distributed key-value storage library according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Raft distributed system leader election method, related equipment and system
CN108616566A
Method and device for realizing ETCD double-node high availability based on VRRP (Virtual Router Redundancy Protocol)
CN114390052A
Cluster fault processing method, system and device and storage medium
CN115664915A
System and method for determining consensus within a distributed database
US20170270176A1