Database cluster service providing method, program product and readable storage medium

The majority partition of the database cluster is determined by arbitration nodes and provided services by them, which solves the problem that if there are less than half of the surviving nodes in the prior art, and improves the availability and recovery capabilities of the database.

CN119025591APending Publication Date: 2024-11-26CETC JINCANG (BEIJING) TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410362018.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-03-27
Publication Date
2024-11-26

AI Technical Summary

Technical Problem

The majority principle of existing database clusters leads to the inability to provide external services when there are more cluster nodes and less than half of the surviving nodes, resulting in reduced availability.

Method used

Introduce arbitration nodes, determine the node partition based on the communication status between cluster nodes, and send preset information to the cluster nodes in the majority partition to determine whether it is located in the majority partition, thereby deciding whether to provide external services.

Benefits of technology

Even if there are less than half of the surviving nodes, the arbitration node can determine and serve the majority partition, improve database availability, improve recovery time goals and recovery point goals.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119025591A_ABST
    Figure CN119025591A_ABST
Patent Text Reader

Abstract

The invention provides a service providing method for a database cluster, a program product and a readable storage medium. The database cluster is provided with a plurality of cluster nodes and arbitration nodes in communication connection with the cluster nodes. The method comprises the following steps: the arbitration node determines node partitions of the database cluster according to communication states among the cluster nodes, then identifies a majority partition from the node partitions, and sends preset information to the cluster nodes in the majority partition; and if the cluster node receives the preset information, determining that the cluster node is located in the majority partition, and determining that the cluster node has the capability of providing external services. According to the technical scheme, even if the number of the cluster nodes surviving in the database cluster is less than half, external services can be provided by the cluster nodes in the majority partition, so that the purpose of improving the availability of the database is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of database technology, and in particular to a method, a program product and a readable storage medium for providing services by a database cluster. Background Art

[0002] The majority principle of a database cluster means that when a database cluster is making a resolution, more than half of the cluster nodes need to vote in favor of the proposal before it can be passed. The majority principle can ensure the data consistency of the database cluster and prevent the problem of split-brain in the database cluster due to network partitioning. However, the majority principle of a database cluster in the prior art requires that more than half of the cluster nodes in the database cluster survive in order to ensure that the database provides external services. In the case of a large number of cluster nodes in the database cluster, if the number of surviving cluster nodes is less than half of the total number of cluster nodes, then even if there are cluster nodes that survive, the database cluster cannot provide external services, which will reduce the availability of the database cluster. Summary of the invention

[0003] The object of the present invention is to provide a method, a program product and a readable storage medium for providing services by a database cluster, so as to solve the problem of low availability of the database cluster caused by the majority principle in the prior art.

[0004] Specifically, in a first aspect, the present invention provides a method for providing services by a database cluster, wherein the database cluster has a plurality of cluster nodes and an arbitration node that is communicatively connected to each of the cluster nodes; the method comprises:

[0005] The arbitration node determines the node partition of the database cluster according to the communication status between each of the cluster nodes, then identifies the majority partition from each of the node partitions, and sends preset information to the cluster nodes in the majority partition;

[0006] If the cluster node receives the preset information, it determines that the cluster node is located in the majority partition and determines that the cluster node has the ability to provide external services.

[0007] Furthermore, the sending of preset information to the cluster nodes in the majority partition includes:

[0008] Voting to each cluster node in the majority partition;

[0009] If the cluster node receives the preset information, determining whether the cluster node is located in the majority partition includes:

[0010] Determine whether the cluster node has received the vote of the arbitration node;

[0011] If so, it is determined that the cluster node has received the preset information, and that the cluster node is located in the majority partition.

[0012] Further, the number of votes of the arbitration node is a first set number, and the determining whether the cluster node has received the vote of the arbitration node includes:

[0013] If the total number of votes received by the cluster node is greater than the second set number, it is determined that the cluster node has received the vote of the arbitration node.

[0014] Furthermore, the first set number is at least the total number of cluster nodes minus one, and the second set number is half of the total number of cluster nodes plus one and rounded down.

[0015] Further, after determining that the cluster node is located in the majority partition, the method further includes:

[0016] If the communication connection between the cluster node and other cluster nodes or the arbitration node is disconnected, the total number of votes of the cluster node is recalculated, and voting is re-initiated when the total number of votes of the cluster node is less than the second set number.

[0017] Further, the step of identifying a majority partition from each of the node partitions includes:

[0018] If the number of the node partitions is one, the node partition is used as the majority partition;

[0019] If there are multiple node partitions, the node partition with the latest data location among the node partitions is used as the majority partition.

[0020] Further, the step of identifying a majority partition from each of the node partitions includes:

[0021] If there are multiple node partitions with the latest and identical data locations, the node partition with the latest data location and the largest number of cluster nodes among the node partitions will be used as the majority partition.

[0022] Further, the step of identifying a majority partition from each of the node partitions includes:

[0023] If there are multiple node partitions with the latest and same data locations and the same number of cluster nodes, the node partition with the latest data location, the largest number of cluster nodes and the smallest partition ID among the node partitions will be used as the majority partition.

[0024] In a second aspect, the present invention further provides a computer program product, including a computer program, characterized in that when the computer program is executed by a processor, the steps of the method for providing services by a database cluster as described in any one of the above are implemented.

[0025] In a third aspect, the present invention further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the method for providing services by a database cluster as described in any one of the above are implemented.

[0026] The technical solution provided by the present invention is that there are an arbitration node and multiple cluster nodes in the database cluster. The arbitration node can determine the node partition of the database cluster according to the communication status between the cluster nodes, and send preset information to the majority partition therein; each cluster node can determine whether it is located in the majority partition according to whether it can receive the preset information of the arbitration node, and provide external services when it is determined that it is located in the majority partition. In the technical solution of the present invention, even if the number of cluster nodes surviving in the database cluster is less than half, the arbitration node can determine the cluster node in the database cluster that is located in the majority partition, and the cluster node in the majority partition provides external services, thereby achieving the purpose of improving the availability of the database.

[0027] Based on the following detailed description of specific embodiments of the present invention in conjunction with the accompanying drawings, those skilled in the art will become more aware of the above and other objects, advantages and features of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] Hereinafter, some specific embodiments of the present invention will be described in detail in an exemplary and non-limiting manner with reference to the accompanying drawings. The same reference numerals in the accompanying drawings indicate the same or similar components or parts. It should be understood by those skilled in the art that these drawings are not necessarily drawn to scale. In the accompanying drawings:

[0029] Figure 1 is a schematic flow chart of a method for processing arbitration nodes in a method for providing services by a database cluster according to an embodiment of the present invention;

[0030] Figure 2 is a schematic flow chart of a cluster node processing method in a method for providing services by a database cluster according to an embodiment of the present invention;

[0031] Figure 3 is a schematic flow chart of a method for determining whether a cluster node has received a vote from an arbitration node according to an embodiment of the present invention;

[0032] Figure 4 is a schematic flow chart of a method for identifying a majority partition of a database cluster from each node partition according to an embodiment of the present invention;

[0033] Figure 5 is a schematic flow chart of a method for processing arbitration nodes in a method for providing services by a database cluster according to another embodiment of the present invention;

[0034] Figure 6 is a schematic flow chart of a cluster node processing method in a method for providing services by a database cluster according to another embodiment of the present invention;

[0035] Figure 7 is a schematic diagram of a computer program product according to an embodiment of the present invention;

[0036] Figure 8 is a schematic diagram of a computer-readable storage medium according to an embodiment of the present invention. DETAILED DESCRIPTION

[0037] Refer to the following Figures 1 to 8 To describe the method, program product and readable storage medium for providing services by a database cluster of an embodiment of the present invention. In the description of this embodiment, it should be understood that the terms "first" and "second" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features, that is, include one or more of the features. In the description of the present invention, the meaning of "multiple" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined. When a feature "includes or contains" one or some of the features it covers, unless otherwise specifically described, this indicates that other features are not excluded and may further include other features.

[0038] The present invention provides a method for providing services by a database cluster, wherein the applicable database cluster has an arbitration node and multiple cluster nodes, wherein the arbitration node is connected to each cluster node through network communication. Each cluster node can send a heartbeat message, node data and other information to the arbitration node through the communication connection with the arbitration node, wherein the heartbeat message sent by each cluster node to the arbitration node includes: a list of node IDs of cluster nodes that maintain heartbeat connections with the cluster node, the data location of the cluster node, the node ID of the cluster node, and the name of the database cluster where the cluster node is located.

[0039] The method for providing services by a database cluster of the present invention can determine the majority partition of the database cluster through an arbitration node, and the cluster nodes in the majority partition provide external services, thereby achieving the purpose of improving the availability of the database. The method for providing services by a database cluster of the present invention is described in detail below in conjunction with specific application scenarios.

[0040] The method for providing services by a database cluster in this embodiment includes a method for executing on an arbitration node and a method for executing on a cluster node. Figure 1 and Figure 2 The process shown provides a detailed introduction to the method for executing on the arbitration node and the method for executing on the cluster node.

[0041] In this embodiment, the process of the method executed on the arbitration node is as follows: Figure 1 As shown, the following steps are included:

[0042] Step S102: determining the node partition of the database cluster according to the communication status between the cluster nodes;

[0043] Step S104: identifying the majority partition of the database cluster from each node partition;

[0044] Step S106: Sending preset information to each cluster node in the majority partition of the database cluster.

[0045] In this embodiment, each cluster node in the database cluster is connected to the arbitration node in communication, and sends a heartbeat message to the arbitration node. When the database cluster is normal, each cluster node in the database cluster is connected to each other in communication, and sends heartbeat messages to each other; when the database cluster is abnormal, the cluster nodes in the same node partition are connected to each other in communication, and send heartbeat messages to each other.

[0046] The heartbeat message received by the arbitration node from the cluster node includes the name of the database cluster where the cluster node is located, and the node ID list of the cluster nodes to which the cluster node heartbeat is connected. Therefore, in the above step S102, the arbitration node can determine the cluster nodes located in the same database cluster according to the name of the database cluster where each cluster node is located, and determine the cluster nodes in each database cluster that are connected to each other in communication according to the heartbeat message of each cluster node; and then divide the cluster nodes in each database cluster that are connected to each other in communication into the same node partition, thereby determining the node partition of each database cluster.

[0047] After the majority partition of the database cluster is identified in the above step S104, each cluster node cannot determine whether it is located in the majority partition. Therefore, in the above step S106, the arbitration node sends preset information to each cluster node in the majority partition to inform the cluster nodes located in the majority partition.

[0048] In this embodiment, the method for executing on the cluster node is as follows: Figure 2 As shown, the following steps are included:

[0049] Step S202: Determine whether the cluster node has received preset information of the arbitration node;

[0050] If yes, execute step S204;

[0051] Step S204: Determine whether the cluster node is located in the majority partition, and determine whether the cluster node has the ability to provide external services.

[0052] Since the arbitration node sends preset information to the cluster nodes in the majority partition after determining the majority partition of the database cluster, the cluster node in this embodiment can determine whether it is in the majority partition based on whether it can receive the preset information from the arbitration node.

[0053] In the above step S204, it is determined that the cluster node has the ability to provide external services, which means that the cluster node can receive the user's data request instruction and perform operations such as querying, modifying, adding or deleting the stored data according to the user's data request instruction.

[0054] For example, after one of the cluster nodes determines that it is located in the majority partition, it can first elect a master cluster node from the cluster nodes in the majority partition based on the preset master election principle. The master cluster node receives the user's data request instructions and sends data operation commands to the cluster nodes in the majority partition based on the data request instructions to respond to the user's access request and achieve the purpose of providing external services.

[0055] In this embodiment, the method for electing a master cluster node from cluster nodes in the majority partition according to a preset master election rule includes:

[0056] After determining that it is located in the majority partition, this cluster node selects a cluster node that meets the preset master election principle from the majority partition, and sends a master election vote to the selected cluster node; the arbitration node also selects a cluster node that meets the preset selection principle from the majority partition, and sends a master election vote to the selected cluster node. Each cluster node in the majority partition calculates the total number of master election votes it has obtained, and the cluster node with the largest number of total master election votes is used as the master cluster node. The method of providing external services through the master cluster node in this embodiment can improve the reliability and stability of the database cluster.

[0057] According to the above content, in the technical solution of this embodiment, the arbitration node determines the majority partition in the database cluster and informs the corresponding cluster node through preset information; the cluster node determines whether it is located in the majority partition according to whether it can receive the preset information of the arbitration node, and after determining that it is located in the majority partition, it determines that it can provide external services. Therefore, even if the number of cluster nodes surviving in the database cluster is less than half, the arbitration node can determine the cluster node in the database cluster that is located in the majority partition, and the cluster node in the majority partition provides external services, thereby achieving the purpose of improving the availability of the database.

[0058] In some embodiments of the present invention, the method of sending preset information to each cluster node in the majority partition of the database cluster in the above step S106 includes:

[0059] The arbiter node votes for each cluster node in the majority partition of the database cluster.

[0060] Accordingly, the determination of whether the preset information of the arbitration node is received in the above step S202 includes:

[0061] Determine whether the cluster node has received the vote from the arbitration node;

[0062] If yes, it is determined that the cluster node has received the preset information of the arbitration node.

[0063] In this embodiment, after the database cluster is started, or after a cluster node is isolated by the network, each cluster node will vote for each other, and the arbitration node will also vote for the cluster node in the majority partition. After receiving the vote, the cluster node can determine whether it has received the vote of the arbitration node based on whether the voting nodes include the arbitration node. Or after the arbitration node votes for the cluster node, it sends a vote confirmation message to the cluster node that obtained the vote of the arbitration node, and sends a no-vote confirmation message to other cluster nodes. Each cluster node determines whether it has received the vote of the arbitration node based on whether it has received the vote confirmation message from the arbitration node.

[0064] Through this embodiment, each cluster node in the database cluster can quickly determine whether the cluster node is located in the majority partition according to whether it receives the vote of the arbitration node, so as to improve the convenience and reliability of implementing the technical solution of the present invention.

[0065] In some embodiments of the present invention, the number of votes of the arbitration node is a first set number, and the number of votes of each cluster node is one. Accordingly, the method for determining whether the cluster node has received the vote of the arbitration node in this embodiment is as follows: Figure 3 As shown, the following steps are included:

[0066] Step S212: Obtain the total number of votes obtained by the cluster node;

[0067] Step S214: determining whether the total number of votes obtained by the cluster node is greater than a second set number;

[0068] If yes, execute step S216;

[0069] Step S216: Determine whether the cluster node has received the vote of the arbitration node.

[0070] In this embodiment, the values ​​of the first set number and the second set number can be determined according to the total number of cluster nodes in the database cluster, so that when the cluster node receives the vote of the arbitration node, the total number of votes obtained is greater than the second set number, but when the cluster node does not receive the vote of the arbitration node, the total number of votes obtained is not greater than the second set number, so that each cluster node can determine whether it is in the majority partition according to the total number of votes it has received.

[0071] According to the technical solution of this embodiment, after receiving the vote, the cluster node does not need to identify the node that issued the vote, nor does it need to receive the voting confirmation message from the arbitration node again. It only needs to determine whether the total number of votes obtained is greater than the second set number to determine whether it is in the majority partition. This improves the convenience and reliability of each cluster node in determining whether it is in the majority partition.

[0072] In some embodiments of the present invention, the first set number is at least the total number of cluster nodes in the database cluster minus one, and the second set number is half of the total number of cluster nodes plus one rounded down.

[0073] In this embodiment, after the cluster node of the database cluster is started, the cluster node initializes its own number of votes to one, and calculates a second set number based on the number of cluster nodes in the database cluster. The arbitration node sets its own number of votes to the total number of cluster nodes minus one based on the number of cluster nodes in the database cluster.

[0074] In this embodiment, assuming that the number of cluster nodes in the database cluster is n, the value of the first set number is n-1, and the value of the second set number is n / 2+1 rounded down. In the above step S214, if the cluster node is located in the majority partition, then the cluster node can receive votes from the arbitration node, and the number of votes obtained must be greater than the second set number. On the contrary, if the cluster node is not located in the majority partition, the number of votes obtained by the cluster node will not receive votes from the arbitration node, and even if all cluster nodes in the same node partition vote for the cluster node, the number of votes obtained by the cluster node will not be greater than the second set number.

[0075] For example, if there are 3 cluster nodes in the database cluster, the number of votes of the arbitration node is 2, and the value of the second set number is 2. Assuming that the 3 cluster nodes are located in different node partitions, in the above step 212, the total number of votes obtained by the cluster nodes located in the majority partition is 3, which is greater than the above second set number; and the total number of votes obtained by the cluster nodes not located in the majority partition is 1, which is not greater than the above second set number.

[0076] Therefore, through the implementation of this embodiment, even if there is only one cluster node in the majority partition of the database cluster, it can be ensured that the cluster node can be located in the majority partition, and the cluster node can be elected as the main cluster node to provide external services, thereby further improving the availability of the database cluster.

[0077] In some embodiments of the present invention, the method executed on the cluster node further includes the following steps after determining in the above step S206 that the cluster node is located in the majority partition:

[0078] Determine whether the communication connection between the cluster node and other cluster nodes or arbitration nodes is disconnected;

[0079] If yes, recalculate the total number of votes of the cluster nodes, and determine whether the total number of votes of the cluster nodes is less than the second set number;

[0080] If it is less, the cluster node will re-initiate voting.

[0081] In this embodiment, each cluster node in the database cluster maintains a heartbeat connection, and the arbitration node also maintains a heartbeat connection with each cluster node. When the heartbeat connection between the cluster node and other cluster nodes or arbitration nodes is disconnected, the cluster node will lose the votes of other cluster nodes or arbitration nodes. At this time, the total number of votes for the cluster node needs to be recalculated to obtain the latest total number of votes for the cluster node. If the recalculated total number of votes for the cluster node is less than the second set number, it can be considered that the node partition of the database cluster needs to be re-divided, so the vote is re-initiated.

[0082] In this embodiment, after the cluster node re-initiates voting, the cluster node sends a voting request to other cluster nodes and the arbitration node; after receiving the voting request, the arbitration node again determines the node partition of the database cluster, identifies the majority partition and sends a vote to the cluster nodes in the majority partition; after receiving the voting request, each cluster node votes for each other and determines whether the cluster node is in the majority partition based on the total number of votes received.

[0083] In some embodiments of the present invention, in the method executed on the arbitration node, the method of identifying the majority partition of the database cluster from each node partition in step S104 is as follows: Figure 4 As shown, the following steps are included:

[0084] Step S302: Obtain the number of node partitions in the database cluster;

[0085] Step S304: Determine whether the number of node partitions in the database cluster is one or more.

[0086] If there is one, execute step S306; if there are multiple, execute step S308;

[0087] Step S306: taking the node partition in the database cluster as the majority partition;

[0088] Step S308: determining whether the number of node partitions with the latest and identical data locations is one or more;

[0089] If yes, execute step S310;

[0090] Step S310: The node partition with the latest data location is used as the majority partition.

[0091] In this embodiment, the data location of the node partition refers to the location of the cluster node with the latest data in the node partition. The latest and same data location means that the cluster node with the latest data in the partition node updates the data at the same time.

[0092] In the implementation of this embodiment, when there is only one node partition in the database cluster, the node partition can be used as the majority partition to improve the reliability of the database cluster. When there are multiple node partitions in the database cluster, since the node partition with the latest data location has the largest amount of data, the node partition with the latest data location can be used as the majority partition to ensure that the data on the main cluster node is completed as much as possible, reduce the phenomenon of data loss, and achieve the purpose of ensuring the integrity of the data in the database cluster.

[0093] In some embodiments of the present invention, Figure 4 As shown, after determining whether the number of node partitions with the latest data location is one or more in the above step S308, the method further includes:

[0094] If the number of node partitions with the latest data location is multiple, execute step S312;

[0095] Step S312: Obtain the node partition with the latest data location and the largest number of cluster nodes;

[0096] Step S314: determining whether the number of node partitions with the latest data location and the largest number of cluster nodes is one or more;

[0097] If yes, execute step S316;

[0098] Step S316: The node partition with the latest data location and the largest number of cluster nodes is used as the majority partition.

[0099] In this embodiment, since the node partition with the largest number of cluster nodes has the latest data status of the database cluster, the node partition with the largest number of cluster nodes is selected as the majority partition to ensure the reliability of the database cluster while ensuring the latest data location.

[0100] In some embodiments of the present invention, Figure 4 As shown, after determining in step S314 whether the number of node partitions with the latest data location and the largest number of cluster nodes is one or more, the following further includes:

[0101] If the number of node partitions with the latest data location and the largest number of cluster nodes is multiple, execute step S318;

[0102] Step S318: Obtain the partition ID of each node partition with the latest data location and the largest number of cluster nodes, and use the node partition with the smallest partition ID as the majority partition.

[0103] In this embodiment, after receiving the heartbeat message of each cluster node and partitioning each cluster node according to the heartbeat message, the arbitration node uses the cluster node with the smallest node ID in each node partition as the partition ID of the corresponding node partition. Since the data of the cluster node with the smallest node ID is the latest, the node partition with the smallest partition ID is used as the majority partition, so that the cluster node with the smallest node ID is located in the majority partition, and the data of the majority partition can be guaranteed to be the latest during the data synchronization process, thereby ensuring the integrity of the data in the database cluster.

[0104] In some embodiments of the present invention, the process of the method for executing the method at the arbitration node in the method for providing services by the database cluster is as follows: Figure 5 As shown, the following steps are also included:

[0105] Step S402: After the arbitration node is started, the arbitration node receives the heartbeat message of each cluster node in the database cluster through the communication connection with each cluster node in the database cluster;

[0106] Step S404: acquiring the communication status between each cluster node according to the heartbeat message of each cluster node, and partitioning each cluster node according to the communication status between each cluster node to obtain the node partition of the database cluster;

[0107] Step S406: Obtain the total number n of cluster nodes in the database cluster, and set the number of votes of the arbitration node to n-1;

[0108] Step S408: Identify the majority partition in each node partition according to the data age of each node partition, the number of partition cluster nodes, and the cluster node ID, and vote for the cluster nodes in the majority partition of the database cluster.

[0109] In the above step S408, the method for identifying the majority partition in each node partition according to the data freshness of each node partition, the number of partition cluster nodes, and the cluster node ID includes:

[0110] If the number of node partitions in the database cluster is one, then this node partition serves as the majority partition;

[0111] If there are multiple node partitions in the database cluster, whether the number of node partitions with the latest and identical data locations is one or more;

[0112] If there is one, the node partition with the latest data location is used as the majority partition;

[0113] If there are multiple nodes, obtain the node partition with the latest data location and the largest number of cluster nodes, and determine whether the number of node partitions with the latest data location and the largest number of cluster nodes is one or more;

[0114] When the number of node partitions with the latest data location and the largest number of cluster nodes is one, the node partition with the latest data location and the largest number of cluster nodes is used as the majority partition;

[0115] When there are multiple node partitions with the latest data location and the largest number of cluster nodes, the partition IDs of the node partitions with the latest data location and the largest number of cluster nodes are obtained, and the node partition with the smallest partition ID is used as the majority partition.

[0116] In this embodiment, the process of the method executed on the cluster node is as follows: Figure 6 As shown, the following steps are included:

[0117] Step S502: After the cluster node is started, the number of votes of the cluster node is initialized to 1, and a heartbeat connection is maintained with other cluster nodes and arbitration nodes in the same node partition;

[0118] Step S504: setting the value of the second set number to n / 2+1 and rounding down;

[0119] Step S506: Calculate the total number of votes obtained by the cluster node, and determine whether the total number of votes obtained by the cluster node is greater than a second set number;

[0120] If yes, execute step S508;

[0121] Step S508: Determine whether the cluster node is located in the majority partition, and determine whether the cluster node has the ability to provide external services.

[0122] The technical solution of this embodiment uses arbitration nodes to identify the majority partition in the database cluster, and the cluster nodes of the majority partition provide external services, so that services can still be provided when the number of cluster nodes in the database cluster that survive is less than half, and even when only one cluster node survives. Therefore, the technical solution of this embodiment can improve the availability of the database cluster, and significantly improve the RTO (Recovery Time Objective) and RPO (Recovery Point Objective) of the database cluster.

[0123] The flow chart that each embodiment provides is not intended to indicate that the operation of the method will be performed in any particular order, or all operations of the method are included in all every case. In addition, the method may include additional operations. Within the scope of the technical thinking that the present embodiment method provides, additional changes can be made to the above method.

[0124] It should be understood that in some embodiments, each part can be implemented by hardware, software, firmware or a combination thereof. In the above embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system.

[0125] This embodiment also provides a computer program product 10 and a computer readable storage medium 20 . Figure 7 is a schematic diagram of a computer program product 10 according to an embodiment of the present invention, Figure 8 is a schematic diagram of a computer-readable storage medium 20 according to an embodiment of the present invention. The computer program product 10 includes a computer program 11, which implements the steps of any of the above-mentioned methods for providing services by a database cluster when the computer program 11 is executed by a processor 32. The computer-readable storage medium 20 stores the above-mentioned computer program 11, which implements the steps of any of the above-mentioned methods for providing services by a database cluster when the computer program 11 is executed by a processor 32.

[0126] The computer program 11 for performing the operation of the present invention may be an assembly instruction, an instruction set architecture (ISA) instruction, a machine instruction, a machine-related instruction, a microcode, a firmware instruction, a state setting data, a configuration data of an integrated circuit, or a source code or an object code written in any combination of one or more programming languages ​​and process programming languages. The computer program 11 may be executed entirely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the latter case, the remote computer may be connected to the user's computer via any type of network (including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider via the Internet). In some embodiments, in order to perform various aspects of the present invention, an electronic circuit including, for example, a programmable logic circuit, a field programmable gate array (FPGA) or a programmable logic array (PLA) may execute computer-readable program instructions by utilizing the state information of the computer-readable program instructions to personalize the electronic circuit.

[0127] In the description of this embodiment, the computer program product 10 is a related product including the computer program 11 .

[0128] For the purpose of the description of the present embodiment, the computer readable storage medium 20 is a tangible device capable of retaining and storing the computer program 11, which can be any device that can contain, store, communicate, propagate or transmit the computer program 11 for use with an instruction execution system, device or apparatus or in conjunction with these instruction execution systems, devices or apparatuses. More specific examples (a non-exhaustive list) of the computer readable storage medium 20 include the following: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, and any suitable combination of the above.

[0129] At this point, those skilled in the art should recognize that, although multiple exemplary embodiments of the present invention have been shown and described in detail herein, many other variations or modifications that conform to the principles of the present invention can still be directly determined or derived based on the content disclosed in the present invention without departing from the spirit and scope of the present invention. Therefore, the scope of the present invention should be understood and recognized as covering all these other variations or modifications.

Claims

1. A method for providing services by a database cluster, wherein the database cluster has a plurality of cluster nodes and an arbitration node that is communicatively connected to each of the cluster nodes; characterized in that: The method comprises: The arbitration node determines the node partition of the database cluster according to the communication status between each of the cluster nodes, then identifies the majority partition from each of the node partitions, and sends preset information to the cluster nodes in the majority partition; If the cluster node receives the preset information, it determines that the cluster node is located in the majority partition and determines that the cluster node has the ability to provide external services.

2. The method for providing services by a database cluster according to claim 1, characterized in that: The sending of preset information to the cluster nodes in the majority partition includes: Voting to each cluster node in the majority partition; If the cluster node receives the preset information, determining whether the cluster node is located in the majority partition includes: Determine whether the cluster node has received the vote of the arbitration node; If so, it is determined that the cluster node has received the preset information, and that the cluster node is located in the majority partition.

3. The method for providing services by a database cluster according to claim 2, characterized in that: The number of votes of the arbitration node is a first set number, and the determining whether the cluster node has received the vote of the arbitration node includes: If the total number of votes received by the cluster node is greater than the second set number, it is determined that the cluster node has received the vote of the arbitration node.

4. The method for providing services by a database cluster according to claim 3, characterized in that: The first set number is at least the total number of cluster nodes minus one, and the second set number is half of the total number of cluster nodes plus one and rounded down.

5. The method for providing services by a database cluster according to claim 3, characterized in that: After determining that the cluster node is located in the majority partition, the method further includes: If the communication connection between the cluster node and other cluster nodes or the arbitration node is disconnected, the total number of votes of the cluster node is recalculated, and voting is re-initiated when the total number of votes of the cluster node is less than the second set number.

6. The method for providing services by a database cluster according to claim 1, characterized in that: The step of identifying a majority partition from each of the node partitions comprises: If the number of the node partitions is one, the node partition is used as the majority partition; If there are multiple node partitions, the node partition with the latest data location among the node partitions is used as the majority partition.

7. The method for providing services by a database cluster according to claim 1, characterized in that: The step of identifying a majority partition from each of the node partitions comprises: If there are multiple node partitions with the latest and identical data locations, the node partition with the latest data location and the largest number of cluster nodes among the node partitions will be used as the majority partition.

8. The method for providing services by a database cluster according to claim 1, characterized in that: The step of identifying a majority partition from each of the node partitions comprises: If there are multiple node partitions with the latest and same data locations and the same number of cluster nodes, the node partition with the latest data location, the largest number of cluster nodes and the smallest partition ID among the node partitions will be used as the majority partition.

9. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method for providing services by a database cluster according to any one of claims 1 to 8 are implemented.

10. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed by a processor, the steps of the method for providing services by a database cluster according to any one of claims 1-8 are implemented.

Citation Information

Cited By

  • High-availability database system based on cluster file system and read-write method

    CN121833666A