CN117149534A - Distributed database active master node election method, device, equipment and storage medium - Google Patents

Distributed database active master node election method, device, equipment and storage medium Download PDF

Info

Publication number
CN117149534A
CN117149534A CN202311434340.0A CN202311434340A CN117149534A CN 117149534 A CN117149534 A CN 117149534A CN 202311434340 A CN202311434340 A CN 202311434340A CN 117149534 A CN117149534 A CN 117149534A
Authority
CN
China
Prior art keywords
node
information
competitive
network
master node
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202311434340.0A
Other languages
Chinese (zh)
Other versions
CN117149534B (en
Inventor
杨建平
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Tielishan Technology Co ltd
Original Assignee
Beijing Tielishan Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Tielishan Technology Co ltd filed Critical Beijing Tielishan Technology Co ltd
Priority to CN202311434340.0A priority Critical patent/CN117149534B/en
Publication of CN117149534A publication Critical patent/CN117149534A/en
Application granted granted Critical
Publication of CN117149534B publication Critical patent/CN117149534B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/16Error detection or correction of the data by redundancy in hardware
    • G06F11/20Error detection or correction of the data by redundancy in hardware using active fault-masking, e.g. by switching out faulty elements or by switching in spare elements
    • G06F11/202Error detection or correction of the data by redundancy in hardware using active fault-masking, e.g. by switching out faulty elements or by switching in spare elements where processing functionality is redundant
    • G06F11/2023Failover techniques
    • G06F11/2025Failover techniques using centralised failover control functionality
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2201/00Indexing scheme relating to error detection, to error correction, and to monitoring
    • G06F2201/82Solving problems relating to consistency
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Quality & Reliability (AREA)
  • Computing Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The present invention relates to the field of distributed database technologies, and in particular, to a method, an apparatus, a device, and a storage medium for electing a master node in a distributed database; the method comprises the steps of responding to the fact that an original master node does not send notification information at fixed time, modifying the state of a slave node, and obtaining a candidate state slave node; acquiring the competitive information sent by each candidate state from the node to obtain a competitive information set, and processing the competitive information set to obtain a processing result; determining a network master node of a corresponding node network based on the processing result; acquiring notification information sent by the network master node of each node network to obtain a notification information set; processing the notification information set to obtain a distributed database rendering master node; the invention is convenient for improving the running stability of the distributed database system.

Description

Distributed database active master node election method, device, equipment and storage medium
Technical Field
The present invention relates to the field of distributed database technologies, and in particular, to a method, an apparatus, a device, and a storage medium for electing a master node in a distributed database.
Background
Redis is used as an open source memory database, is widely applied to a distributed database system, and the distributed database system based on the Redis database comprises a master node and slave nodes, wherein the master node can synchronize storage data stored by own data into the slave nodes, so that the consistency of the storage data between the slave nodes and the master node is ensured; in the running process of the master node, the master node needs to be reelected in order to ensure the normal running of the distributed data system under the condition that the equipment fails and is down and offline.
One way to reselect a master node in a distributed database system is currently: when the original slave node does not receive the heartbeat information periodically sent by the master node, adding 1 to the period value of the slave node, and actively sending out a voting message, wherein the voting message comprises the current period value of the corresponding slave node, and each slave node can only cast a vote when voting; after receiving voting information sent by other slave nodes, one slave node judges whether the current period value of the slave node is smaller than the current period value of other nodes, if so, a vote is cast to the corresponding slave node; if the current master node also receives the voting message, judging whether the current period value of the master node is larger than the current period value of the slave node corresponding to the voting message, if not, casting a vote to the corresponding slave node; and then judging whether the number of votes obtained by each slave node is greater than half of the number of voting nodes, and if so, electing the slave node as a new master node.
However, on the one hand, since the number of slave nodes that can be voted is large, and each node participating in voting can cast only one vote, this is liable to result in the fact that eventually no slave node having more than half the number of votes obtained is generated, i.e. eventually a new master node cannot be cast; on the other hand, the distributed database system may include a plurality of networks, if each network selects its own master node, any two networks are combined, and the current period values of the two master nodes are consistent, the two master nodes will collide, so that a new master node cannot be selected in a short time after the combined networks; by combining the two aspects, if the selected main node is not available in the database for a long time, the running stability of the distributed database system can be greatly reduced.
Disclosure of Invention
In order to facilitate the improvement of the running stability of a distributed database system, the embodiment of the invention provides a distributed database active master node election method, a device, equipment and a storage medium.
In a first aspect, an embodiment of the present invention provides a method for electing a distributed database rendering master node, including:
in response to the fact that the original master node does not send notification information regularly, modifying the state of the slave node to obtain candidate slave nodes;
acquiring the competitive information sent by each candidate state from the node to obtain a competitive information set, and processing the competitive information set to obtain a processing result; determining a network master node of the corresponding node network based on the processing result;
acquiring notification information sent by a network master node of each node network to obtain a notification information set;
and processing the notification information set to obtain the distributed database rendering master node.
In a second aspect, an embodiment of the present invention provides a distributed database rendering master node election device, including:
the state modifying module is used for responding to the fact that the original master node does not send the notification information at fixed time, modifying the state of the slave node and obtaining a candidate state slave node;
the network main node generating module is used for acquiring the competitive information sent by each candidate slave node to obtain a competitive information set, and processing the competitive information set to obtain a processing result; determining a network master node of a corresponding node network based on the processing result;
the notice information set generation module is used for acquiring notice information sent by the network master node of each node network to obtain a notice information set;
and the current master node determining module is used for processing the notification information set to obtain the distributed database current master node.
In a third aspect, an embodiment of the present invention provides a computer device, where the computer device includes a memory and a processor, where the memory stores a computer program, and where the processor implements the steps of the method described above when executing the computer program.
In a fourth aspect, embodiments of the present invention provide a computer readable storage medium having stored thereon a computer program which when executed by a processor performs steps in the above-described method.
In a fifth aspect, embodiments of the present invention also provide a computer program product. Computer program product comprising a computer program which, when executed by a processor, implements the steps of any of the method embodiments described above.
According to the embodiment of the method, the device, the equipment and the storage medium for selecting the distributed database active master node, when the original master node of the distributed database does not normally and periodically send out notification information, the system judges that the original master node fails, then the states of other slave nodes in the same node network are modified into candidate states, so that each slave node fairly participates in the election of the new master node, each slave node shares own election information with other slave nodes participating in the election, an election information set can be obtained, and then different election information in the election information set is processed, so that the network master node of the corresponding node network is determined; the corresponding network master node is obtained after the competitive information set is processed, and the situation that in the prior art, the number of slave nodes which can be voted is numerous, each node participating in voting can only cast a vote, and therefore, no slave node with the obtained vote number being more than half of the number of voting nodes is finally generated, namely, a new master node cannot be selected finally; in addition, after the network master node of each node network is selected in an competitive manner, in the process of combining different node networks, acquiring the notification information sent by different network master nodes so as to obtain a notification information set, and then processing the notification information set to obtain the current master node of the whole distributed database; the problem that the two master nodes conflict due to the fact that the current period values of the two master nodes are consistent, and therefore a new master node cannot be selected in a short time after the network is combined is solved.
Drawings
FIG. 1 is a diagram of an application environment for a distributed database rendering master node election method in accordance with one embodiment of the present invention;
FIG. 2 is a flowchart of a method for electing a master node of a distributed database according to one embodiment of the present invention;
FIG. 3 is a schematic structural diagram of a distributed database active master node election device according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of a computer device according to an embodiment of the present invention;
fig. 5 is an internal structural diagram of a computer-readable storage medium provided in one embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present disclosure more apparent, the present disclosure will be further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the present disclosure.
It should be noted that the terms "first," "second," and the like in the description and claims herein and in the foregoing figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments described herein may be capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, apparatus, article, or device that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed or inherent to such process, method, article, or device.
In this document, the term "and/or" is merely one association relationship describing the associated object, meaning that three relationships may exist. For example, a and/or B may represent: a exists alone, A and B exist together, and B exists alone. In addition, the character "/" herein generally indicates that the front and rear associated objects are an "or" relationship.
In order to solve the above-mentioned problems, an embodiment of the present disclosure provides a distributed database active master node election method, which can be applied to an application environment as shown in fig. 1. Wherein the terminal 102 communicates with the server 104 via a network. The data storage system may store data that the server 104 needs to process. The data storage system may be integrated on the server 104 or may be located on a cloud or other network server. The terminal 102 may be, but not limited to, various personal computers, notebook computers, smart phones, tablet computers, internet of things devices, and portable wearable devices, where the internet of things devices may be smart speakers, smart televisions, smart air conditioners, smart vehicle devices, and the like. The portable wearable device may be a smart watch, smart bracelet, headset, or the like. The server 104 may be implemented as a stand-alone server or as a server cluster of multiple servers.
Fig. 2 is a flowchart of a method for electing a master node in a distributed database according to an embodiment of the present invention, and referring to fig. 2, the method may be performed by an apparatus for performing the method, where the apparatus may be implemented by software and/or hardware, and the method includes:
and S100, responding to the fact that the original master node does not send notification information at fixed time, modifying the state of the slave node, and obtaining the candidate state slave node.
It should be noted that, the distributed database system includes at least one node network, the whole distributed database system has a master node, the rest of distributed computing nodes are slave nodes, the master node is used for synchronizing the storage data stored by the self data to each slave node, thereby ensuring the consistency of the storage data between the slave nodes and the master node; if different node networks are in an uncombined state, each data network needs to have a corresponding network master node for synchronizing the stored data stored in the data network to each slave node in the same node network. In the normal operation state, the master node regularly broadcasts notification information to the subordinate slave nodes so as to facilitate the slave node to know that the master node is in the normal operation state.
Taking one node network as an example, in the implementation, the distributed database system regularly detects whether a network master node corresponding to the node network regularly sends notification information to a corresponding slave node; if not, the corresponding network master node is indicated to possibly fail, and the network master node which does not send out the notification information at fixed time is recorded as the original master node; in order to ensure the normal operation of the data synchronization of the subsequent node network, the corresponding node network needs to select a new network master node from a plurality of slave nodes of the node network; at this time, the node network modifies the state of the corresponding slave node first, and modifies the state of the corresponding slave node from the original following state to a candidate state, that is, converts the corresponding following state slave node to the candidate state slave node; wherein the candidate slave node qualifies to participate in the election of the new network master node.
In one embodiment, the notification information sent by the master node includes one or more of database version information corresponding to the master node, a node ID number, and the number of slave nodes in the same network following state.
It should be noted that, the database version information is used to characterize the number of times the database of the corresponding node is operated, the more the number of times the database is operated, the newer the database version information, the more the corresponding node has the potential to become the master node; the node ID number in this embodiment may be specifically an MAC address of the corresponding node hardware device, where the smaller the node ID number, the longer the time that the corresponding node hardware device is used is represented, and the higher the stability of the corresponding node hardware device is represented, and the higher the possibility of storing the latest version of data is, which indicates that the corresponding node has the potential of becoming a master node; in a normal operation state, a node network is provided with a network master node, other nodes except the network master node are follower state slave nodes, and the notification information comprises the number of the follower state slave nodes.
S200, acquiring the competitive information sent by each candidate state from the node to obtain a competitive information set, and processing the competitive information set to obtain a processing result; and determining a network master node of the corresponding node network based on the processing result.
It should be noted that after candidate slave nodes are generated in the node network, each candidate slave node shares its own election information to other candidate slave nodes, and in one embodiment, the election information includes one or more of database version information and node ID number corresponding to the candidate slave node, where the description of the database version information and the node ID number is omitted here; the distributed database system synthesizes the competitive information sent by the nodes in each candidate state, thereby obtaining the competitive information set.
In one embodiment, processing the set of auction information to obtain a processing result includes: selecting two pieces of competitive information from the competitive information set as first competitive information and second competitive information respectively; priority comparison is carried out on the first competitive information and the second competitive information to obtain comparison information, and whether other competitive information exists in the competitive information set or not is judged; if yes, generating new first competitive information based on the comparison information, selecting one competitive information from other competitive information in the competitive information set as new second competitive information, and comparing the priority of the new first competitive information with the priority of the new second competitive information until the other competitive information is not available in the competitive information set; otherwise, processing results are obtained based on the comparison information.
Specifically, the competitive information set contains at least two competitive information, the distributed database system selects two competitive information from the competitive information set, the two competitive information are respectively marked as first competitive information and second competitive information, then the corresponding elements in the first competitive information and the second competitive information are sequentially compared, namely, priority comparison is carried out, so that comparison information is obtained, and the comparison information is used for representing which of the first competitive information and the second competitive information is better; wherein the element is database version information or node ID number; and then the distributed database system also judges whether other competitive information exists in the competitive information set except the first competitive information and the second competitive information, if so, the better competitive information in the first competitive information and the second competitive information is used as new first competitive information, then one of the other competitive information is selected as new second competitive information, then the priority comparison is continued until the competitive information set does not have other competitive information which is not subjected to the priority comparison any more, the comparison information obtained by the last priority comparison is used as a processing result, namely, the better competitive information in the last group of first competitive information and the second competitive information which are subjected to the priority comparison is used as a processing result.
In one embodiment, comparing the priority of the first competitive information with the second competitive information to obtain comparison information includes: preferentially judging whether the database version information in the first competitive information is newer than the database version information in the second competitive information or not, and obtaining a first comparison result; judging whether the node ID number in the first competitive information is smaller than the node ID number in the second competitive information or not, and obtaining a second comparison result; and obtaining comparison information based on the first comparison result and the second comparison result.
It should be noted that, in this embodiment, the priorities of the two elements in the election information are different, and in this embodiment, the priority of the database version information is greater than the priority of the node ID number.
In implementation, after the distributed database system acquires a group of first competitive information and second competitive information, the distributed database system preferentially acquires the database version information in the first competitive information and marks the database version information in the second competitive information as first database version information and marks the database version information in the second competitive information as second database version information; then judging whether the first database version information is newer than the second database version information, so as to obtain a corresponding first comparison result; if the first comparison result is that the first database version information is newer than the second database version information, the node database corresponding to the first database version information is indicated to be operated more times than the node database corresponding to the second database version information, that is, the node database corresponding to the first database version information can represent the database of data update, and meanwhile, the node corresponding to the first database version information has greater potential of becoming a new network master node; if the first comparison result is that the second database version information is newer than the first database version information, it is indicated that the node database corresponding to the second database version information is operated more times than the node database corresponding to the first database version information, that is, the node database corresponding to the second database version information can represent the database with the latest data, and at the same time, it is also indicated that the node corresponding to the second database version information has the potential of being more called as a new network master node.
Further, the distributed database system then acquires the node ID number in the first competitive information, marks the node ID number as a first node ID number, acquires the node ID number in the second competitive information, marks the node ID number as a second node ID number, and then judges whether the first node ID number is smaller than the second node ID number, so that a corresponding second comparison result is obtained; if the second comparison result is that the first node ID number is smaller than the second node ID number, the longer the node hardware equipment corresponding to the first node ID number is used, the higher the stability of the corresponding node hardware equipment is, the higher the possibility of storing the latest version of data is, and the greater the potential of becoming a new network master node is; if the second comparison result is that the second node ID number is smaller than the first node ID number, the longer the node hardware equipment corresponding to the second node ID number is used, the higher the stability of the corresponding node hardware equipment is, the higher the possibility of storing the latest version of data is, and the greater potential of becoming a new network master node is provided.
The implementation of the steps can obtain a first comparison result and a second comparison result, and the first comparison result and the second comparison result are synthesized to obtain comparison information; specifically, the comparison information includes the following four cases:
the method comprises the steps that firstly, the version information of a first database is newer than that of a second database, and the ID number of a first node is smaller than that of the second node;
second, the first database version information is newer than the second database version information, and the second node ID number is smaller than the first node ID number;
thirdly, the version information of the second database is newer than that of the first database, and the ID number of the first node is smaller than that of the second node;
fourth, the second database version information is newer than the first database version information, and the second node ID number is smaller than the first node ID number.
It should be noted that the comparison information obtained last time, that is, the processing result, also includes the above four cases.
In implementation, a network master node of the corresponding node network can be determined through the processing result, and the determined network master node is recorded as the network master node.
In one embodiment, determining a network master node of a corresponding node network based on a processing result includes: if the processing result is that the database version information in the first competitive information is newer than the database version information in the second competitive information and/or the node ID number in the first competitive information is smaller than the node ID number in the second competitive information, determining the candidate slave node corresponding to the first competitive information as the network master node of the corresponding node network; otherwise, the candidate slave node corresponding to the second competitive information is determined to be the network master node of the corresponding node network.
Specifically, the known processing result includes the above four cases, in implementation, after the processing result is obtained, the processing result is judged, if the processing result is one of the first case, the second case and the third case, the candidate slave node corresponding to the first election information is determined to be the network master node of the corresponding node network, otherwise, the candidate slave node corresponding to the second election information is determined to be the network master node of the corresponding node network. In this way, it is possible to determine a new network master node of the node network where the original master node that does not regularly transmit the advertisement information is located.
In one embodiment, the step of determining the network master node based on the processing result further comprises: judging whether newly generated competitive information exists or not; if yes, notifying the candidate state slave node corresponding to the newly generated competitive information to withdraw from the network master node competing with the network master node, modifying the state of the corresponding candidate state slave node, and generating the corresponding following state slave node.
It should be noted that, some candidate slave nodes in the node network send the election information to the distributed database system only after the network master node of the corresponding node network has been selected because the election information is not timely sent; if the distributed database system further performs the election of the new network master node between the candidate slave node corresponding to the election information and the selected network master node, the generation time of the process of generating the network master node is increased, so that the data synchronization process of the distributed database system is adversely affected.
In implementation, if a node network generates a network master node that operates normally, the node network generates the election information again, the distributed database system notifies the candidate slave node corresponding to the newly generated election information to exit from the network master node competing with the network master node, and modifies the state of the corresponding candidate slave node to make it a following slave node.
S300, acquiring notification information sent by a network master node of each node network, and obtaining a notification information set.
It should be noted that, the network master node is used for controlling the data synchronization of the node network where the network master node is located, the distributed database system is provided with a plurality of node networks, each node network is provided with a network master node to which the node network belongs, and each network master node sends out notification information to the subordinate following state slave node at regular time when running; it should be noted that, in the end, only one master node capable of operating normally is needed to perform data synchronization for the whole distributed database, so that the master node of the distributed database needs to be continuously selected from the selected network master nodes.
Specifically, in implementation, the distributed database system acquires notification information sent by each network master node, thereby obtaining a notification information set; the notification information comprises one or more of database version information corresponding to a network master node, a node ID number and the number of slave nodes in the same network following state; in this embodiment, the elements in the advertisement information include database version information corresponding to the network master node, a node ID number, and the number of slave nodes following the same network.
S400, processing the notification information set to obtain the distributed database rendering master node.
In the implementation, two pieces of notification information are selected from the notification information set and respectively recorded as first notification information and second notification information, corresponding elements in the first notification information and the second notification information are sequentially compared, and specifically, whether the database version information in the first notification information is newer than the database version information in the second notification information or not is judged; meanwhile, judging whether the node ID number in the first notification information is smaller than the node ID number in the second notification information; meanwhile, whether the number of the slave nodes with the same network following state in the first notification information is larger than that of the slave nodes with the same network following state in the second notification information is judged, and therefore a judging result is obtained.
If the judgment result is that: and the database version information in the first notification information is newer than the database version information in the second notification information, and/or the node ID number in the first notification information is smaller than the node ID number in the second notification information, and/or the number of the same-network following state slave nodes in the first notification information is larger than the number of the same-network following state slave nodes in the second notification information, the first notification information is used as new first notification information, otherwise, the second notification information is used as new first notification information.
Further, whether other notification information which does not participate in comparison exists in the notification information set is judged, if so, one notification information is selected from the other notification information to serve as new second notification information, and then the comparison is sequentially carried out on the corresponding elements in the new first notification information and the new second notification information until it is judged that the other notification information which does not participate in comparison does not exist in the notification information set.
And after the last group of first notification information is compared with the second notification information, generating new first notification information, and taking the network master node corresponding to the newly generated first notification information as a distributed database master node.
FIG. 2 is a flow diagram of a method for electing a master node in a distributed database in one embodiment. It should be understood that, although the steps in the flowchart of fig. 2 are shown in sequence as indicated by the arrows, the steps are not necessarily performed in sequence as indicated by the arrows; the steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders; and at least some of the steps in fig. 2 may include multiple sub-steps or stages that are not necessarily performed at the same time, but may be performed at different times, nor do the order in which the sub-steps or stages are performed necessarily performed in sequence, but may be performed alternately or alternately with at least a portion of the other steps or sub-steps of other steps.
Based on the same inventive concept, the embodiment of the disclosure also provides a distributed database present master node election device for implementing the above related distributed database present master node election method. The implementation of the solution provided by the device is similar to the implementation described in the above method, so the specific limitation in the embodiments of the one or more distributed database active master node election devices provided below may be referred to as the limitation of the distributed database active master node election method hereinabove, and will not be repeated herein.
In one embodiment, as shown in fig. 3, there is provided a distributed database rendering master node election apparatus, including:
the state modifying module is used for responding to the fact that the original master node does not send the notification information at fixed time, modifying the state of the slave node and obtaining a candidate state slave node;
the network main node generating module is used for acquiring the competitive information sent by each candidate slave node to obtain a competitive information set, and processing the competitive information set to obtain a processing result; determining a network master node of the corresponding node network based on the processing result;
the notice information set generation module is used for acquiring notice information sent by a network main node of each node network to obtain a notice information set;
and the current master node determining module is used for processing the notification information set to obtain the distributed database current master node.
The above-mentioned distributed database may be implemented in whole or in part by software, hardware, or a combination thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In one embodiment, a computer device is provided, which may be a server, the internal structure of which may be as shown in fig. 4. The computer device includes a processor, a memory, and a network interface connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database of the computer device is for storing data. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program when executed by a processor implements a distributed database rendering master node election method.
Those skilled in the art will appreciate that the architecture shown in fig. 4 is merely a block diagram of a portion of the architecture in connection with the disclosed aspects and is not limiting of the computer apparatus to which the disclosed aspects apply, and that a particular computer apparatus may include more or less components than those shown, or may combine some of the components, or have a different arrangement of components.
In one embodiment, a computer device is provided, comprising a memory and a processor, the memory having stored therein a computer program, the processor implementing the steps of the method embodiments described above when the computer program is executed.
In one embodiment, a computer readable storage medium is provided, as shown in fig. 5, having a computer program stored thereon, which when executed by a processor, implements the steps of the method embodiments described above.
In an embodiment, a computer program product is provided, comprising a computer program which, when executed by a processor, implements the steps of the method embodiments described above.
It should be noted that, the user information (including, but not limited to, user equipment information, user personal information, etc.) and the data (including, but not limited to, data for analysis, stored data, presented data, etc.) related to the present disclosure are information and data authorized by the user or sufficiently authorized by each party.
Those skilled in the art will appreciate that implementing all or part of the above-described methods in accordance with the embodiments may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed may comprise the steps of the embodiments of the methods described above. Any reference to memory, database, or other medium used in embodiments provided by the present disclosure may include at least one of non-volatile and volatile memory, among others. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, high density embedded nonvolatile Memory, resistive random access Memory (ReRAM), magnetic random access Memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric Memory (Ferroelectric Random Access Memory, FRAM), phase change Memory (Phase Change Memory, PCM), graphene Memory, and the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, and the like. By way of illustration, and not limitation, RAM can be in the form of a variety of forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), and the like. The databases referred to in the various embodiments provided by the present disclosure may include at least one of a relational database and a non-relational database. The non-relational database may include, but is not limited to, a blockchain-based distributed database, and the like. The processors involved in the embodiments provided by the present disclosure may be general-purpose processors, central processing units, graphics processors, digital signal processors, programmable logic, quantum computing-based data processing logic, etc., without limitation thereto.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The foregoing examples merely represent several embodiments of the present disclosure, which are described in more detail and are not to be construed as limiting the scope of the present disclosure. It should be noted that variations and modifications can be made by those skilled in the art without departing from the spirit of the disclosure, which are within the scope of the disclosure. Accordingly, the scope of the present disclosure should be determined from the following claims.

Claims (10)

1. A distributed database rendering master node election method, comprising:
in response to the fact that the original master node does not send notification information regularly, modifying the state of the slave node to obtain candidate slave nodes;
acquiring the competitive information sent by each candidate state from the node to obtain a competitive information set, and processing the competitive information set to obtain a processing result; determining a network master node of a corresponding node network based on the processing result;
acquiring notification information sent by the network master node of each node network to obtain a notification information set;
and processing the notification information set to obtain the distributed database rendering master node.
2. A method according to claim 1, wherein the notification information includes one or more of database version information corresponding to the master node, a node ID number, and the number of slave nodes following the network; the election information includes one or more of database version information corresponding to the candidate slave node and a node ID number.
3. A method according to claim 1, wherein said processing said set of auction information to obtain a processed result comprises:
selecting two pieces of competitive information from the competitive information set, wherein the two pieces of competitive information are respectively used as first competitive information and second competitive information;
comparing the priority of the first competitive information with the priority of the second competitive information to obtain comparison information, and judging whether other competitive information exists in the competitive information set;
if yes, generating new first competitive information based on the comparison information, selecting one competitive information from other competitive information in the competitive information set as new second competitive information, and comparing the new first competitive information with the new second competitive information in priority level until the competitive information set does not have other competitive information;
otherwise, the processing result is obtained based on the comparison information.
4. A method according to claim 3, wherein said comparing the priority of the first and second arenas to obtain comparison information comprises:
preferentially judging whether the database version information in the first competitive information is newer than the database version information in the second competitive information or not, and obtaining a first comparison result;
judging whether the node ID number in the first competitive information is smaller than the node ID number in the second competitive information or not, and obtaining a second comparison result;
the comparison information is obtained based on the first comparison result and the second comparison result.
5. A method according to claim 3, wherein said determining a network master node of a corresponding node network based on said processing result comprises:
if the processing result is that the database version information in the first competitive information is newer than the database version information in the second competitive information and/or the node ID number in the first competitive information is smaller than the node ID number in the second competitive information, determining the candidate slave node corresponding to the first competitive information as a network master node of a corresponding node network;
otherwise, the candidate slave node corresponding to the second election information is determined to be a network master node of a corresponding node network.
6. A method according to claim 1, wherein said step of determining a network master node based on said processing result further comprises:
judging whether the newly generated competitive information exists or not;
if yes, notifying the candidate state slave node corresponding to the newly generated competitive information to exit the network master node corresponding to the network master node, modifying the state of the corresponding candidate state slave node, and generating the corresponding follow state slave node.
7. A distributed database rendering master election device, the device comprising:
the state modifying module is used for responding to the fact that the original master node does not send the notification information at fixed time, modifying the state of the slave node and obtaining a candidate state slave node;
the network main node generating module is used for acquiring the competitive information sent by each candidate slave node to obtain a competitive information set, and processing the competitive information set to obtain a processing result; determining a network master node of a corresponding node network based on the processing result;
the notice information set generation module is used for acquiring notice information sent by the network master node of each node network to obtain a notice information set;
and the current master node determining module is used for processing the notification information set to obtain the distributed database current master node.
8. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any of claims 1 to 6 when the computer program is executed.
9. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 6.
10. A computer program product comprising a computer program, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 6.
CN202311434340.0A 2023-11-01 2023-11-01 Distributed database active master node election method, device, equipment and storage medium Active CN117149534B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311434340.0A CN117149534B (en) 2023-11-01 2023-11-01 Distributed database active master node election method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311434340.0A CN117149534B (en) 2023-11-01 2023-11-01 Distributed database active master node election method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN117149534A true CN117149534A (en) 2023-12-01
CN117149534B CN117149534B (en) 2024-02-06

Family

ID=88912488

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311434340.0A Active CN117149534B (en) 2023-11-01 2023-11-01 Distributed database active master node election method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117149534B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7587465B1 (en) * 2002-04-22 2009-09-08 Cisco Technology, Inc. Method and apparatus for configuring nodes as masters or slaves
CN109964446A (en) * 2018-06-08 2019-07-02 北京大学深圳研究生院 A kind of common recognition method based on ballot
CN114448769A (en) * 2022-04-02 2022-05-06 支付宝(杭州)信息技术有限公司 Node election voting method and device based on consensus system
CN115102839A (en) * 2022-06-17 2022-09-23 济南浪潮数据技术有限公司 Master-slave node election method, device, equipment and medium
CN115208578A (en) * 2022-07-07 2022-10-18 西安电子科技大学 Unmanned aerial vehicle cluster information consistency sharing method based on block chain
WO2023082800A1 (en) * 2021-11-11 2023-05-19 中兴通讯股份有限公司 Main node selection method, distributed database and storage medium

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7587465B1 (en) * 2002-04-22 2009-09-08 Cisco Technology, Inc. Method and apparatus for configuring nodes as masters or slaves
CN109964446A (en) * 2018-06-08 2019-07-02 北京大学深圳研究生院 A kind of common recognition method based on ballot
WO2019232789A1 (en) * 2018-06-08 2019-12-12 北京大学深圳研究生院 Voting-based consensus method
WO2023082800A1 (en) * 2021-11-11 2023-05-19 中兴通讯股份有限公司 Main node selection method, distributed database and storage medium
CN114448769A (en) * 2022-04-02 2022-05-06 支付宝(杭州)信息技术有限公司 Node election voting method and device based on consensus system
WO2023186085A1 (en) * 2022-04-02 2023-10-05 支付宝(杭州)信息技术有限公司 Node election voting method and apparatus based on consensus system
CN115102839A (en) * 2022-06-17 2022-09-23 济南浪潮数据技术有限公司 Master-slave node election method, device, equipment and medium
CN115208578A (en) * 2022-07-07 2022-10-18 西安电子科技大学 Unmanned aerial vehicle cluster information consistency sharing method based on block chain

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
王芬 等: "基于Bully算法的Redis集群选举方案优化", 计算机科学, pages 170 - 175 *
谈兴秋: "增量同步约束条件下的多节点间主节点选举算法", 现代电子技术, pages 51 - 54 *

Also Published As

Publication number Publication date
CN117149534B (en) 2024-02-06

Similar Documents

Publication Publication Date Title
CN106878382B (en) Method and device for dynamically changing cluster scale in distributed arbitration cluster
CN111880956B (en) Data synchronization method and device
US20210320977A1 (en) Method and apparatus for implementing data consistency, server, and terminal
CN114169536B (en) Data management and control method and related device
US20210160312A1 (en) Service processing methods and systrems based on a consortium blockchain network
CN110941666A (en) Database multi-activity method and device
CN111163148A (en) Synchronization method and related equipment for consensus state of block chain system
CN108875035B (en) Data storage method of distributed file system and related equipment
CN114238495A (en) Method and device for switching main cluster and standby cluster of database, computer equipment and storage medium
Sethi et al. Design and Optimization of a Zookeeper and Kafka-Based Messaging Broker for Asynchronous Processing in High Availability and Low Latency Applications
US11886225B2 (en) Message processing method and apparatus in distributed system
CN117149534B (en) Distributed database active master node election method, device, equipment and storage medium
CN111427689B (en) Cluster keep-alive method and device and storage medium
US11120513B2 (en) Capital chain information traceability method, system, server and readable storage medium
CN110502460B (en) Data processing method and node
CN115730016B (en) Data synchronization method, system, device, computer equipment and storage medium
CN112882839A (en) Message processing method and device based on kafka
CN113792891B (en) Machine learning feature production system and method
US20230252306A1 (en) Asynchronous architecture for evolutionary computation techniques
CN117478299B (en) Block chain consensus algorithm switching method, device and computer equipment
CN115168366B (en) Data processing method, data processing device, electronic equipment and storage medium
CN110457392B (en) Copy reading and writing method and device
CN118069293A (en) Cluster expansion and contraction method, device, equipment, medium and program product
CN116827966B (en) Data processing method and system
CN115604667B (en) Message sending method, device, computer equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant