CN118151864B - Main selection method and device of distributed system, program product and distributed system - Google Patents
Main selection method and device of distributed system, program product and distributed system Download PDFInfo
- Publication number
- CN118151864B CN118151864B CN202410564489.9A CN202410564489A CN118151864B CN 118151864 B CN118151864 B CN 118151864B CN 202410564489 A CN202410564489 A CN 202410564489A CN 118151864 B CN118151864 B CN 118151864B
- Authority
- CN
- China
- Prior art keywords
- node
- nodes
- target
- distributed system
- master
- 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.)
- Active
Links
- 238000010187 selection method Methods 0.000 title abstract description 3
- 238000000034 method Methods 0.000 claims abstract description 45
- 238000004590 computer program Methods 0.000 claims description 13
- 230000015556 catabolic process Effects 0.000 claims description 10
- 238000006731 degradation reaction Methods 0.000 claims description 10
- 230000008859 change Effects 0.000 claims description 9
- 238000004891 communication Methods 0.000 description 8
- 238000012545 processing Methods 0.000 description 6
- 238000010586 diagram Methods 0.000 description 5
- 238000005192 partition Methods 0.000 description 5
- 230000005540 biological transmission Effects 0.000 description 3
- 230000003287 optical effect Effects 0.000 description 3
- 230000007423 decrease Effects 0.000 description 2
- 230000006870 function Effects 0.000 description 2
- 230000003993 interaction Effects 0.000 description 2
- 230000008569 process Effects 0.000 description 2
- 230000007704 transition Effects 0.000 description 2
- 238000003491 array Methods 0.000 description 1
- 238000013473 artificial intelligence Methods 0.000 description 1
- 230000001413 cellular effect Effects 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 238000010801 machine learning Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 230000001953 sensory effect Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 230000001360 synchronised effect Effects 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
- 230000000007 visual effect Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0668—Interfaces specially adapted for storage systems adopting a particular infrastructure
- G06F3/067—Distributed or networked storage systems, e.g. storage area networks [SAN], network attached storage [NAS]
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/23—Updating
- G06F16/2365—Ensuring data consistency and integrity
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/27—Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5083—Techniques for rebalancing the load in a distributed system
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Databases & Information Systems (AREA)
- Data Mining & Analysis (AREA)
- Software Systems (AREA)
- Computing Systems (AREA)
- Computer Security & Cryptography (AREA)
- Human Computer Interaction (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The present disclosure provides a method for selecting a distributed system, a device, a program product, and a distributed system, and relates to the field of distributed systems, where the method includes: if the target node is a candidate node in a stable state and the number of main nodes in the stable state in the target data center is smaller than the upper limit of the number of nodes, the target node generates an upgrade random seed, the value of the upgrade random seed changes with time, the distributed system comprises the target data center, and the target node is a node in the target data center; if the value of the updated random seed is changed into a first preset value, the target node changes the stable state of the target node into a changeable state; if the sum of the number of the main nodes and the number of the nodes in the variable state in the target data center is smaller than the upper limit of the number of the nodes, and the target nodes are in the variable state, the target nodes upgrade the target nodes from the candidate nodes to the main nodes. The main selection method of the present disclosure has high availability.
Description
Technical Field
The present disclosure relates to the field of distributed systems, and in particular, to a method, apparatus, program product, and distributed system for selecting a distributed system.
Background
In a distributed system, in order to ensure data consistency, a master node needs to be selected from a plurality of nodes, and a slave node is commanded by the master node, so that the data consistency of the distributed system is ensured. The related art proposes itself to be a master node by one node to other nodes when electing the master node. If the other node accepts the proposal, an acknowledgement message is sent to the proposed node, and if not, no acknowledgement message is sent. When a node receives a certain number of acknowledgement messages, the node becomes itself the master node and broadcasts itself the message to other nodes. However, the related art has a certain requirement on the inventory quantity of the nodes, and assuming that there are N nodes, at least 2N/3+1 nodes are required to survive to complete the complete process of the related art, so that the availability of the distributed system is poor.
Disclosure of Invention
The present disclosure provides a method, apparatus, program product, and distributed system for selecting a distributed system, so as to at least solve the above technical problems in the prior art.
According to a first aspect of the present disclosure, a method of selecting a distributed system is provided. The method comprises the following steps:
If the target node is a candidate node in a stable state and the number of main nodes in the stable state in a target data center is smaller than the upper limit of the number of nodes, generating an upgrade random seed by the target node, wherein the value of the upgrade random seed changes with time, and the distributed system comprises the target data center, and the target node is a node in the target data center;
if the value of the upgrading random seed is changed into a first preset value, the target node changes the stable state of the target node into a variable state;
If the sum of the number of the main nodes and the number of the nodes in the variable state in the target data center is smaller than the upper limit of the number of the nodes, and the target node is in the variable state, the target node upgrades the candidate node to the main node.
In an embodiment, the stable state is used for indicating that the type of the node is forbidden to change within a preset time period; the volatile state is used for indicating that the type of the node is allowed to change within the preset time period.
In one embodiment, the distributed system provides query services to each node in the distributed system, the query services being used to register the type and status of each node in the distributed system.
In an embodiment, if the number of the master nodes in the stable state in the target data center is not less than the upper limit of the number of nodes, the target candidate node determines a target master node according to the number of slave nodes of each master node in the target data center; and updating the target candidate node as a slave node of the target master node.
In an embodiment, if the target node is a master node in the stable state, and the number of master nodes in the stable state in the target data center is greater than the upper limit of the number of nodes, the target node generates a degradation random seed, and the value of the degradation random seed changes with time; if the value of the degradation random seed is changed to a second preset value, the target node changes the target node from the stable state to the variable state; if the number of the main nodes in the stable state in the target data center is greater than the upper limit of the number of the nodes and the target node has no slave nodes, the target node downgrades the target node from the main nodes to candidate nodes.
In an embodiment, when a first master node obtains first data and the first master node determines that a second master node obtains the first data, the first master node sends a data writing request to a management node; the management node sends a write permission notification to the first master node and sends a write prohibition notification to the second master node; the first master node writes the first data according to the write permission notification; the second master node does not write the first data according to the write-inhibit notification; after the first master node completes writing of the first data, the first master node synchronizes the first data into other master nodes in the distributed system.
In an embodiment, in a case where a first master node obtains second data and the second data is not present in other master nodes in the distributed system, the first master node writes the second data to the first master node or a slave node of the first master node.
According to a second aspect of the present disclosure, there is provided a distributed system comprising a target data center; the target node is a node in the target data center;
If the target node is a candidate node in a stable state, and the number of main nodes in the stable state in the target data center is smaller than the upper limit of the number of nodes, generating an upgrade random seed by the target node, wherein the value of the upgrade random seed changes with time;
if the value of the upgrading random seed is changed into a first preset value, the target node changes the stable state of the target node into a variable state;
If the sum of the number of the main nodes and the number of the nodes in the variable state in the target data center is smaller than the upper limit of the number of the nodes, and the target node is in the variable state, the target node upgrades the candidate node to the main node.
According to a third aspect of the present disclosure, there is provided an electronic device comprising:
At least one processor; and
A memory communicatively coupled to the at least one processor; wherein,
The memory stores instructions executable by the at least one processor to enable the at least one processor to perform the methods described in the present disclosure.
According to a fourth aspect of the present disclosure, there is provided a computer program product comprising computer programs/instructions which, when executed by a processor, implement the method described in the present disclosure.
If the target node is a candidate node in a stable state and the number of the main nodes in the stable state in the target data center is smaller than the upper limit of the number of the nodes, the target node generates an upgrade random seed, the value of the upgrade random seed changes with time, and the distributed system comprises the target data center, wherein the target node is a node in the target data center; if the value of the updated random seed is changed into a first preset value, the target node changes the stable state of the target node into a changeable state; if the sum of the number of the main nodes and the number of the nodes in the variable state in the target data center is smaller than the upper limit of the number of the nodes, and the target nodes are in the variable state, the target nodes upgrade the target nodes from the candidate nodes to the main nodes. When judging whether the target node can become the master node or not, the method and the system judge through the number and the states of various nodes in the distributed system, and do not need the target node and other nodes to conduct multiple message transmission, so that the delay of the whole scheme is lower and the availability is high under the condition that the scheme accords with CAP. Moreover, the present disclosure has low demands on the inventory quantity of nodes, and can cope with various emergency situations.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the disclosure, nor is it intended to be used to limit the scope of the disclosure. Other features of the present disclosure will become apparent from the following specification.
Drawings
The above, as well as additional purposes, features, and advantages of exemplary embodiments of the present disclosure will become readily apparent from the following detailed description when read in conjunction with the accompanying drawings. Several embodiments of the present disclosure are illustrated by way of example, and not by way of limitation, in the figures of the accompanying drawings, in which:
In the drawings, the same or corresponding reference numerals indicate the same or corresponding parts.
FIG. 1 illustrates a node type transition schematic provided by an embodiment of the present disclosure;
FIG. 2 is a flow diagram of a method for selecting a distributed system according to an embodiment of the present disclosure;
FIG. 3 illustrates a schematic diagram of a distributed system provided by an embodiment of the present disclosure;
FIG. 4 is a flow chart illustrating a method for node degradation of a distributed system according to an embodiment of the present disclosure;
FIG. 5 is a flow chart illustrating a method for writing data in a distributed system according to an embodiment of the present disclosure;
fig. 6 shows a schematic diagram of a composition structure of an electronic device according to an embodiment of the present disclosure.
Detailed Description
In order to make the objects, features and advantages of the present disclosure more comprehensible, the technical solutions in the embodiments of the present disclosure will be clearly described in conjunction with the accompanying drawings in the embodiments of the present disclosure, and it is apparent that the described embodiments are only some embodiments of the present disclosure, but not all embodiments. Based on the embodiments in this disclosure, all other embodiments that a person skilled in the art would obtain without making any inventive effort are within the scope of protection of this disclosure.
To facilitate an understanding of the present disclosure, basic concepts to which the present disclosure relates are explained below:
CAP (Consistency, availability, partition tolerance), in order, represents consistency, availability, partition fault tolerance): is a measure of the three aspects of a distributed system. Where consistency means that copies of data of multiple nodes in a distributed system need to be kept consistent, i.e., modification operations of one node must be able to take effect synchronously on other nodes. Availability means that the distributed system must remain available for user requests, i.e. the distributed system needs to be able to respond to user requests in time at any moment. Partition fault tolerance refers to that a distributed system can still operate normally when encountering a network partition, i.e., the distributed system can tolerate faults such as network partition or node downtime.
In this disclosure, there are three types of nodes: (1) a master node: and synchronizing data to other master nodes in the distributed system, wherein the synchronizing data is delay synchronization. (2) slave nodes: and pushing data to the master node in a synchronous writing mode. (3) management node: is responsible for solving the contention problem when data is written simultaneously. The management nodes are designated by the external through configuration, and there is one and only one management node in the whole distributed system. The management node, after being designated, does not change its type.
In this disclosure, there are three states for a node: (1) steady state: and when the node is in a stable state, the type of the node is forbidden to change in a preset time period. (2) volatile state: when the node is in a changeable state, the type of the node is allowed to be changed in a preset time period, and the preset time period can be adjusted according to actual requirements. (3) unchanged state: when the node is in the unchanged state, the type of the node is not changed all the time.
Illustratively, fig. 1 shows a node type transition schematic provided by an embodiment of the present disclosure. The state of the slave node can be switched between a stable state and a flexible state according to whether the slave node needs to be upgraded to the master node. If the slave node needs to be upgraded to the master node, the slave node can enter a changeable state and be upgraded to the master node; if the slave node does not need to be upgraded to the master node, the slave node can maintain a stable state. The state of the master node may be switched between a steady state and a flexible state depending on whether the master node needs to be downgraded to the slave node. If the master node needs to be downgraded to the slave node, the master node enters a changeable state and is downgraded to the slave node; if the master node does not need to be downgraded to the slave node, the master node will remain in a steady state.
Fig. 2 is a schematic flow chart of a method for selecting a distributed system according to an embodiment of the disclosure, where the method includes:
Step S201: if the target node is a candidate node in a stable state and the number of the main nodes in the stable state in the target data center is smaller than the upper limit of the number of the nodes, the target node generates an upgrade random seed, the value of the upgrade random seed changes with time, the distributed system comprises the target data center, and the target node is a node in the target data center.
Alternatively, in this embodiment, the candidate node refers to a node whose node type is not determined, and in some embodiments, the candidate node is a node that has just been started, or is initialized, or is a newly added node in the distributed system.
Optionally, the distributed system includes at least two data centers, and the target data center is any data center in the distributed system. The number of nodes in each data center may be the same or different.
For example, referring to fig. 3, the distributed system includes 4 data centers, data center 31 includes 2 nodes, data center 32 includes 2 nodes, data center 33 includes 3 nodes, and data center 34 includes 5 nodes.
Optionally, in the present disclosure, the distributed system further includes a management node, which is one and only one in the distributed system, and may be disposed in any one of the data centers. The management node is used to handle competing writes of data. And the management node is not changed in type after being appointed, and the management node is in a constant state. Illustratively, in FIG. 3, management node 301 is located within data center 32.
Optionally, the distributed system provides a query service to each node in the distributed system, and the query service is used for registering the type and the state of each node in the distributed system. Thus, each node in the distributed system can obtain the type and state of the respective node through the query service. In some embodiments, the target node obtains the number of home nodes in a stable state in the target data center through a query service. In some embodiments, each node in the distributed system reports its respective type and status to the query service.
Optionally, the value of the updated random seed is randomly generated, and the value belongs to a preset interval. In some embodiments, the value of the upgraded random seed is uniformly reduced over time, e.g., the value of the upgraded random seed is reduced by 1 per second.
Optionally, the upper limit of the number of nodes is the maximum of the number of master nodes in the data center. The upper limit of the number of the nodes can be adjusted according to actual requirements.
Step S202: if the value of the upgrade random seed is changed to the first preset value, the target node changes the target node from a stable state to a variable state.
For example, if the data of the upgrade random seed becomes 0, the state of the target node changes, and the target node changes the state of itself from a stable state to a volatile state. The first preset value can be adjusted according to actual requirements.
In some other embodiments, to have a greater probability of different partial nodes becoming master, the rate of change of the value of the upgrade random seed of different nodes is different, e.g., the value of the upgrade random seed of node a decreases by 4 per second and the value of the upgrade random seed of node B decreases by 1 per second.
Step S203: if the sum of the number of the main nodes and the number of the nodes in the variable state in the target data center is smaller than the upper limit of the number of the nodes, and the target nodes are in the variable state, the target nodes upgrade the target nodes from the candidate nodes to the main nodes.
In some other embodiments, there are other candidate nodes in the target data center that cannot be converted to a master node, but rather to a slave node, when the number of master nodes in the target data center reaches an upper limit. If the number of the main nodes in the stable state in the target data center is not less than the upper limit of the number of the nodes, the target candidate nodes determine target main nodes according to the number of the slave nodes of each main node in the target data center; the target candidate node is updated as a slave node of the target master node.
In summary, when determining whether the target node can become the master node, the embodiment determines the number and states of various nodes in the distributed system, and does not need to perform multiple message transmission between the target node and other nodes, so that the delay of the whole scheme is low and the availability is high under the condition that the scheme accords with the CAP. Moreover, the present disclosure has low demands on the inventory quantity of nodes, and can cope with various emergency situations.
Fig. 4 is a flow chart illustrating a node degradation method of a distributed system according to an embodiment of the disclosure, where the method includes:
step S401: if the target node is a main node in a stable state, and the number of the main nodes in the stable state in the target data center is larger than the upper limit of the number of the nodes, the target node generates a degradation random seed, and the value of the degradation random seed changes with time.
Optionally, the upper limit of the number of nodes is the maximum of the number of master nodes in the data center. The upper limit of the number of the nodes can be adjusted according to actual requirements.
Optionally, the distributed system provides a query service to each node in the distributed system, and the query service is used for registering the type and the state of each node in the distributed system. Thus, each node in the distributed system can obtain the type and state of the respective node through the query service. In some embodiments, the target node obtains the number of home nodes in a stable state in the target data center through a query service. In some embodiments, each node in the distributed system reports its respective type and status to the query service.
Optionally, in the present disclosure, the distributed system further includes a management node, which is one and only one in the distributed system, and may be disposed in any one of the data centers. The management node is used to handle competing writes of data. And the management node is not changed in type after being appointed, and the management node is in a constant state.
Step S402: if the value of the degraded random seed is changed to the second preset value, the target node changes the target node from the stable state to the changeable state.
Illustratively, if the data of the degraded random seed becomes 0, the state of the target node changes, and the target node changes its own state from a stable state to a volatile state. The second preset value can be adjusted according to actual requirements.
Step S403: if the number of the main nodes in the stable state in the target data center is larger than the upper limit of the number of the nodes and the target nodes have no slave nodes, the target nodes downgrade the target nodes from the main nodes to candidate nodes.
Optionally, if the number of the master nodes in the target data center in a stable state is less than the upper limit of the number of nodes, or if the target node has a slave node, the target node remains as the master node.
In summary, when determining whether the target node can be degraded, the present embodiment determines the number and states of various nodes in the distributed system, and does not need to perform multiple message transfer between the target node and other nodes, so that the delay of the scheme is low and the availability is high.
Fig. 5 shows a flowchart of a data writing method of a distributed system according to an embodiment of the disclosure, where the method includes:
Step S501: and under the condition that the first master node acquires the first data and the first master node determines that the second master node acquires the first data, the first master node sends a data writing request to the management node.
Optionally, after the first master node obtains the first data, the first master node locks the first data, so as to prevent other nodes in the distributed system from writing the first data.
Optionally, after the first master node obtains the first data, the first master node searches the local storage space for whether the first data exists; if the first data exists, stopping writing the first data; if the first data does not exist, judging whether the second master node exists or not, and acquiring the first data.
Optionally, the first master node determines whether the second master node also obtains the first data through a query service, where the query service is used to register the type and state of each node in the distributed system.
Step S502: the management node sends a write-enable notification to the first master node and sends a write-disable notification to the second master node.
It should be noted that, there is and only one first master node will receive the write permission notification.
Optionally, the management node determines which host node writes the first data according to at least one of load information, stored space and memory space of the first host node and the second host node.
Step S503: the first master node writes the first data according to the write-allowed notification.
Step S504: the second master node does not write the first data according to the write-inhibit notification.
Step S505: after the first master node completes writing of the first data, the first master node synchronizes the first data into other master nodes in the distributed system.
In some other embodiments, the first master node writes the second data to the first master node or a slave node of the first master node in the event that the first master node obtains the second data and no second data is present by other master nodes in the distributed system. Optionally, the first master node synchronizes the second data delay to other master nodes in the distributed system. In some embodiments, the first master node determines whether to write the second data to the master node or the slave node according to a load balancing policy.
In summary, when data arrives at two different master nodes at the same time, the management node may decide which node can write the data and inform the corresponding node to write the data. And the plurality of master nodes are prevented from simultaneously writing the same data, and the data in the distributed system is ensured not to be disordered.
The present disclosure also provides a distributed system including a target data center; the target node is a node in the target data center;
If the target node is a candidate node in a stable state and the number of the main nodes in the stable state in the target data center is smaller than the upper limit of the number of the nodes, generating an upgrade random seed by the target node, wherein the value of the upgrade random seed changes with time;
If the value of the updated random seed is changed into a first preset value, the target node changes the stable state of the target node into a changeable state;
If the sum of the number of the main nodes and the number of the nodes in the variable state in the target data center is smaller than the upper limit of the number of the nodes, and the target nodes are in the variable state, the target nodes upgrade the target nodes from the candidate nodes to the main nodes.
In summary, when determining whether the target node can become the master node, the distributed system of the embodiment determines through the number and states of various nodes in the distributed system, and does not need to perform multiple message transmission between the target node and other nodes, so that the delay of the whole scheme is low and the availability is high under the condition that the scheme accords with the CAP. Moreover, the present disclosure has low demands on the inventory quantity of nodes, and can cope with various emergency situations.
According to embodiments of the present disclosure, the present disclosure also provides an electronic device and a readable storage medium.
Fig. 6 illustrates a schematic block diagram of an example electronic device 600 that may be used to implement embodiments of the present disclosure. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the disclosure described and/or claimed herein.
As shown in fig. 6, the electronic device 600 includes a computing unit 601 that can perform various appropriate actions and processes according to a computer program stored in a Read Only Memory (ROM) 602 or a computer program loaded from a storage unit 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic device 600 can also be stored. The computing unit 601, ROM 602, and RAM 603 are connected to each other by a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
A number of components in the electronic device 600 are connected to the I/O interface 605, including: an input unit 606 such as a keyboard, mouse, etc.; an output unit 607 such as various types of displays, speakers, and the like; a storage unit 608, such as a magnetic disk, optical disk, or the like; and a communication unit 609 such as a network card, modem, wireless communication transceiver, etc. The communication unit 609 allows the electronic device 600 to exchange information/data with other devices through a computer network, such as the internet, and/or various telecommunication networks.
The computing unit 601 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of computing unit 601 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various computing units running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 601 performs the various methods and processes described above, such as the master method of a distributed system. For example, in some embodiments, the optional method of the distributed system may be implemented as a computer software program tangibly embodied on a machine-readable medium, such as storage unit 608. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 600 via the ROM 602 and/or the communication unit 609. When the computer program is loaded into RAM 603 and executed by computing unit 601, one or more steps of the above-described method of selecting a distributed system may be performed. Alternatively, in other embodiments, the computing unit 601 may be configured to perform the principal method of the distributed system by any other suitable means (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
Program code for carrying out methods of the present disclosure may be written in any combination of one or more programming languages. These program code may be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus such that the program code, when executed by the processor or controller, causes the functions/operations specified in the flowchart and/or block diagram to be implemented. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and pointing device (e.g., a mouse or trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), and the internet.
The computer system may include a client and a server. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server may be a cloud server, a server of a distributed system, or a server incorporating a blockchain.
The present disclosure also provides an electronic device including: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-7.
The present disclosure also provides a computer program product comprising computer programs/instructions which, when executed by a processor, implement the method of any one of claims 1-7.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps recited in the present disclosure may be performed in parallel or sequentially or in a different order, provided that the desired results of the technical solutions of the present disclosure are achieved, and are not limited herein.
Furthermore, the terms "first," "second," and the like, are used for descriptive purposes only and are not to be construed as indicating or implying a relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defining "a first" or "a second" may explicitly or implicitly include at least one such feature. In the description of the present disclosure, the meaning of "a plurality" is two or more, unless explicitly defined otherwise.
The foregoing is merely specific embodiments of the disclosure, but the protection scope of the disclosure is not limited thereto, and any person skilled in the art can easily think about changes or substitutions within the technical scope of the disclosure, and it is intended to cover the scope of the disclosure. Therefore, the protection scope of the present disclosure shall be subject to the protection scope of the claims.
Claims (9)
1. A method of hosting a distributed system, the method comprising:
If the target node is a candidate node in a stable state and the number of main nodes in the stable state in a target data center is smaller than the upper limit of the number of nodes, generating an upgrade random seed by the target node, wherein the value of the upgrade random seed changes with time, and the distributed system comprises the target data center, and the target node is a node in the target data center;
If the value of the upgrading random seed is changed into a first preset value, the target node changes the stable state of the target node into a variable state; the steady state is used for indicating that the type of the node is forbidden to change in a preset time period; the variable state is used for indicating that the type of the node is allowed to change within the preset time period;
If the sum of the number of the main nodes and the number of the nodes in the variable state in the target data center is smaller than the upper limit of the number of the nodes, and the target node is in the variable state, the target node upgrades the candidate node to the main node.
2. The method of claim 1, wherein the distributed system provides query services to each node in the distributed system, the query services being used to register the type and status of each node in the distributed system.
3. The method according to claim 1 or 2, characterized in that the method further comprises:
if the number of the main nodes in the stable state in the target data center is not less than the upper limit of the number of the nodes, the target candidate nodes determine target main nodes according to the number of the slave nodes of each main node in the target data center;
and updating the target candidate node as a slave node of the target master node.
4. The method according to claim 1 or 2, characterized in that the method further comprises:
If the target node is a master node in the stable state and the number of the master nodes in the stable state in the target data center is greater than the upper limit of the number of nodes, the target node generates a degradation random seed, and the value of the degradation random seed changes with time;
If the value of the degradation random seed is changed to a second preset value, the target node changes the target node from the stable state to the variable state;
if the number of the main nodes in the stable state in the target data center is greater than the upper limit of the number of the nodes and the target node has no slave nodes, the target node downgrades the target node from the main nodes to candidate nodes.
5. The method according to claim 1 or 2, characterized in that the method further comprises:
when a first master node acquires first data and a second master node acquires the first data, the first master node sends a data writing request to a management node;
the management node sends a write permission notification to the first master node and sends a write prohibition notification to the second master node;
The first master node writes the first data according to the write permission notification; the second master node does not write the first data according to the write-inhibit notification;
After the first master node completes writing of the first data, the first master node synchronizes the first data into other master nodes in the distributed system.
6. The method according to claim 1 or 2, characterized in that the method further comprises:
In the case where a first master node obtains second data and the second data is not present by other master nodes in the distributed system, the first master node writes the second data to the first master node or a slave node of the first master node.
7. A distributed system, the distributed system comprising a target data center; the target node is a node in the target data center;
If the target node is a candidate node in a stable state, and the number of main nodes in the stable state in the target data center is smaller than the upper limit of the number of nodes, generating an upgrade random seed by the target node, wherein the value of the upgrade random seed changes with time;
If the value of the upgrading random seed is changed into a first preset value, the target node changes the stable state of the target node into a variable state; the steady state is used for indicating that the type of the node is forbidden to change in a preset time period; the variable state is used for indicating that the type of the node is allowed to change within the preset time period;
If the sum of the number of the main nodes and the number of the nodes in the variable state in the target data center is smaller than the upper limit of the number of the nodes, and the target node is in the variable state, the target node upgrades the candidate node to the main node.
8. An electronic device, comprising:
At least one processor; and
A memory communicatively coupled to the at least one processor; wherein,
The memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-6.
9. A computer program product comprising computer programs/instructions which, when executed by a processor, implement the method of any of claims 1-6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410564489.9A CN118151864B (en) | 2024-05-08 | 2024-05-08 | Main selection method and device of distributed system, program product and distributed system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410564489.9A CN118151864B (en) | 2024-05-08 | 2024-05-08 | Main selection method and device of distributed system, program product and distributed system |
Publications (2)
Publication Number | Publication Date |
---|---|
CN118151864A CN118151864A (en) | 2024-06-07 |
CN118151864B true CN118151864B (en) | 2024-07-26 |
Family
ID=91286999
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202410564489.9A Active CN118151864B (en) | 2024-05-08 | 2024-05-08 | Main selection method and device of distributed system, program product and distributed system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN118151864B (en) |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114189495A (en) * | 2021-12-16 | 2022-03-15 | 平安壹账通云科技(深圳)有限公司 | Domain name based node scheduling method, system, terminal and storage medium |
CN115811520A (en) * | 2023-02-08 | 2023-03-17 | 天翼云科技有限公司 | Method and device for electing master node in distributed system and electronic equipment |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110674215A (en) * | 2019-09-17 | 2020-01-10 | 郑州阿帕斯科技有限公司 | Master selection method and device for distributed system and distributed system |
CN111124289B (en) * | 2019-12-06 | 2022-02-18 | 浪潮电子信息产业股份有限公司 | Method, device and medium for selecting homing group members of distributed storage system |
CN116170289A (en) * | 2022-08-01 | 2023-05-26 | 北京奥星贝斯科技有限公司 | Node election method and device, storage medium and electronic equipment |
-
2024
- 2024-05-08 CN CN202410564489.9A patent/CN118151864B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114189495A (en) * | 2021-12-16 | 2022-03-15 | 平安壹账通云科技(深圳)有限公司 | Domain name based node scheduling method, system, terminal and storage medium |
CN115811520A (en) * | 2023-02-08 | 2023-03-17 | 天翼云科技有限公司 | Method and device for electing master node in distributed system and electronic equipment |
Also Published As
Publication number | Publication date |
---|---|
CN118151864A (en) | 2024-06-07 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN113590329B (en) | Resource processing method and device | |
CN112650576A (en) | Resource scheduling method, device, equipment, storage medium and computer program product | |
CN114385353B (en) | Resource scheduling method and device, electronic equipment and storage medium | |
EP3817338B1 (en) | Method and apparatus for acquiring rpc member information, electronic device and storage medium | |
CN111324471B (en) | Service adjustment method, device, equipment and storage medium | |
CN109783151B (en) | Method and device for rule change | |
CN112860343B (en) | Configuration changing method, system, device, electronic equipment and storage medium | |
CN108011949B (en) | Method and apparatus for acquiring data | |
CN113364877B (en) | Data processing method, device, electronic equipment and medium | |
CN113193947B (en) | Method, apparatus, medium, and program product for implementing distributed global ordering | |
CN111190719B (en) | Method, device, medium and electronic equipment for optimizing cluster resource allocation | |
CN110069265B (en) | Service cluster upgrading method and device and storage medium | |
CN117725115A (en) | Database sequence processing method, device, equipment and storage medium | |
CN118540171B (en) | Control method and system for providing power for powered equipment and POE equipment | |
CN118151864B (en) | Main selection method and device of distributed system, program product and distributed system | |
CN114143196B (en) | Instance configuration updating method, device, equipment, storage medium and program product | |
CN114051029B (en) | Authorization method, authorization device, electronic equipment and storage medium | |
CN115665263B (en) | Flow allocation method, device, server and storage medium | |
CN113641688B (en) | Node updating method, related device and computer program product | |
CN114070889B (en) | Configuration method, traffic forwarding device, storage medium, and program product | |
CN112965836B (en) | Service control method, device, electronic equipment and readable storage medium | |
CN117749594A (en) | Service distribution method and device, electronic equipment and computer readable storage medium | |
CN115437709A (en) | Method and device for loading application home page splash screen resources | |
CN112818060B (en) | Data synchronization method, device, electronic equipment and readable storage medium | |
CN118467637B (en) | Database synchronization system, method, device, electronic device and medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
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 |