Cloud native distributed database uniform scheduling method and device, equipment and storage medium
By determining the maximum allowable difference of the scheduling resource pool in the cloud native database and filtering appropriate nodes when expanding or shrinking capacity, the node failure problem caused by centralized scheduling of components is solved, and uniform scheduling of distributed database nodes and system High availability.
Patent Information
- Application Number
- CN202411436941.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-15
- Publication Date
- 2025-02-14
AI Technical Summary
In the existing cloud-native database technology, when components are randomly scheduled on the cloud platform, it is easy to cause the same component to be centrally scheduled to the same node, resulting in the failure of nodes, and the main and replicas of the component cannot provide services, affecting the smooth operation of the distributed system.
By determining the maximum allowable difference between the number of storage nodes in the target machine in the scheduling resource pool and the global minimum value, the scheduling requirements of the distributed database are received, and when expanding or reducing capacity, the difference value meets the requirements. It can scale or delete nodes to achieve uniform scheduling of distributed database nodes.
It realizes dynamic and uniform distribution of distributed database nodes, avoids node failures affecting the smooth operation of the entire system, and has the ability to maintain independently, ensuring the high availability and stability of the distributed system.
Smart Images

Figure CN119440752A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of database technology, and in particular to a cloud-native distributed database uniform scheduling method, device, equipment and storage medium. Background Art
[0002] Cloud-native technology is developing rapidly, and more and more enterprises and organizations are choosing to build and manage applications in public clouds to adapt to rapidly changing business needs and digital transformation trends. Cloud-native software is designed to predict failures and automatically operate and maintain, so that it can maintain stable operation even when the infrastructure it relies on fails or other changes occur. Compared with traditional databases, distributed databases introduce consistency consensus algorithms into database technology to achieve consistency of multiple copies of data. The cloudification of distributed databases can realize automatic operation and recovery of multiple copies of databases, and operate stably in a constantly changing environment.
[0003] In existing cloud-native database technologies, when a database is deployed on a cloud platform, dependent components are randomly scheduled to nodes, which leads to the problem of the same components being centrally scheduled to the same node. When a node fails, the primary copy of the component cannot provide services, which affects the smooth operation of the entire distributed system and does not meet the high availability principle. Summary of the invention
[0004] The technical problem to be solved by the present invention is to overcome the shortcomings of the prior art and provide a cloud-native distributed database uniform scheduling method, device, equipment and storage medium.
[0005] In order to solve the above technical problems, the technical solution of the present invention is as follows: A cloud native distributed database uniform scheduling method includes the following steps: Step S101: determining a maximum allowable difference between the number of storage nodes in a target machine in a scheduling resource pool and a global minimum value; Step S102: receiving a scheduling requirement of a distributed database, and executing step S103 when the distributed database needs to be expanded, and executing step S104 when the distributed database needs to be reduced; Step S103: for any machine in the scheduling resource pool, calculate the difference between the number of storage nodes after the storage nodes are expanded and the global minimum, and select the expandable machines whose difference between the number of storage nodes after the storage nodes are expanded and the global minimum is less than or equal to the maximum allowable difference; Step S104: Determine the schedulable nodes, and for any schedulable node, calculate the difference between the number of storage nodes in any machine after deletion and the global minimum, and filter out the deletable storage nodes whose difference between the number of storage nodes in any machine after deletion and the global minimum is less than or equal to the maximum allowed difference.
[0006] As a preferred solution of the cloud native distributed database uniform scheduling method of the present invention, after screening out the schedulable machine in which the difference between the number of storage nodes in the expanded storage node and the global minimum is less than or equal to the maximum allowable difference, it also includes: It is determined whether the number of expandable machines is greater than or equal to two. If so, the scheduling priorities of all the expandable machines are determined, and a target expansion machine is determined based on the scheduling priorities.
[0007] As a preferred solution of the cloud native distributed database uniform scheduling method of the present invention, the step of determining the scheduling priority of the expandable machine and determining the target expansion machine based on the scheduling priority includes: Determining a resource priority sequence of the scalable machine; For any of the scalable machines, calculating a score for each resource in the resource priority sequence; Based on the resource priority sequence, the resource scores of all the scalable machines are compared in turn to determine a target expansion machine.
[0008] As a preferred solution of the cloud-native distributed database uniform scheduling method described in the present invention, the resource priority sequence of the scalable machine includes CPU, memory, and network bandwidth in descending order of priority.
[0009] As a preferred solution of the cloud native distributed database uniform scheduling method of the present invention, the determining of the schedulable nodes includes: Exclude the master node from the scheduling resource pool; The remaining secondary nodes are regarded as schedulable nodes.
[0010] As a preferred solution of the cloud native distributed database uniform scheduling method of the present invention, before excluding the master node in the scheduling resource pool, it also includes: Delete abnormal storage nodes in the scheduling resource pool.
[0011] As a preferred solution of the cloud-native distributed database uniform scheduling method described in the present invention, when the distributed database needs to be scaled down, the maximum allowable difference between the number of storage nodes in the target machine in the scheduling resource pool and the global minimum is 1.
[0012] The present invention also provides a cloud native distributed database uniform scheduling device, comprising: A determination module, used for determining a maximum allowable difference between the number of storage nodes in the target machine in the scheduling resource pool and a global minimum value; A judgment module is used to receive the scheduling requirements of the distributed database and judge whether the distributed database needs to be expanded or locked; Expansion module: used for calculating the difference between the number of storage nodes after the expansion of storage nodes in any machine in the scheduling resource pool and the global minimum value, and screening out the expandable machines whose difference between the number of storage nodes after the expansion of storage nodes and the global minimum value is less than or equal to the maximum allowable difference; The shrinking module is used to determine the schedulable nodes. For any schedulable node, the difference between the number of storage nodes in any machine after its deletion and the global minimum is calculated, and the deletable storage nodes whose difference between the number of storage nodes in any machine after its deletion and the global minimum is less than or equal to the maximum allowed difference are screened out.
[0013] The present invention also provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method described in any of the above-mentioned cloud-native distributed database uniform scheduling methods is implemented.
[0014] The present invention also provides a computer-readable storage medium having a computer program stored thereon, and when the program is executed by a processor, the method described in any of the above-mentioned cloud-native distributed database uniform scheduling methods is implemented.
[0015] The beneficial effects of the present invention are: The present invention enables distributed database nodes to be dynamically and evenly distributed on the nodes on the cloud platform. When a host fails, it will not affect the smooth operation of the entire distributed database system, and has the ability of autonomous maintenance. On the one hand, the method supports components at different levels to achieve uniform scheduling. On the other hand, it takes into account the scenarios of distributed database expansion, reduction, and abnormal reconstruction, and achieves uniform scheduling under different actions, ensuring the high availability and stability of the distributed system. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0017] Figure 1This is a diagram of the deployment of distributed database components in the k8s environment; Figure 2 A schematic diagram of the process of the cloud native distributed database uniform scheduling method provided by the present invention; Figure 3 A schematic diagram of capacity expansion processing for the cloud native distributed database uniform scheduling method provided by the present invention; Figure 4 Another schematic diagram of capacity expansion processing by the cloud native distributed database uniform scheduling method provided by the present invention; Figure 5 A schematic diagram of lock capacity processing by the cloud native distributed database uniform scheduling method provided by the present invention; Figure 6 A schematic diagram of a cloud-native distributed database uniform scheduling device provided by the present invention; Figure 7 A schematic diagram of a computer device provided by the present invention. DETAILED DESCRIPTION
[0018] In order to make the content of the present invention more clearly understood, the present invention is further described in detail below according to specific implementation modes and in combination with the accompanying drawings.
[0019] In the k8s environment, the distributed database component deployment diagram of the present application embodiment is as follows: Figure 1 As shown in the figure, database components (data computing node components, storage node components, distributed transaction identification management components, etc.) will be deployed in the k8s environment in the form of containers. Among them, the component storage node (DN) and distributed transaction identification management component (GTM) are deployed in a master-slave mode in the dimension of the team, and the computing node (CN) is deployed in a multi-copy mode in the dimension of the computer room.
[0020] Figure 2 A flow chart of a method for uniformly scheduling a cloud-native distributed database provided in an embodiment of the present application. The method specifically includes the following steps: Step S101: determining a maximum allowable difference between the number of storage nodes in a target machine in a scheduling resource pool and a global minimum value.
[0021] Specifically, the uniform scheduling method designed in this embodiment is divided according to the component function level, such as Figure 1 The storage component in the system uses the team-level machine cluster as the scheduling resource pool, while the computing component uses the computer room-level machine cluster as the scheduling resource pool.
[0022] When performing database scheduling, the cloud-native distributed database uniform scheduling method provided in this embodiment maintains the degree of uneven distribution (maxDiff), that is, the maximum allowable difference between the number of storage nodes in the target machine in the scheduling resource pool and the global minimum.
[0023] Step S102: receiving a scheduling requirement of a distributed database, and executing step S103 when the distributed database needs to be expanded, and executing step S104 when the distributed database needs to be reduced.
[0024] Specifically, the scheduling of the distributed database includes the expansion of the distributed database and the reduction of the distributed database. In the expansion and reduction scenarios, the actions to achieve uniform scheduling are also different. Specifically: when the distributed database is expanded, the operation of step S103 is performed, and when the distributed database is reduced, the operation of step S104 is performed.
[0025] Step S103: for any machine in the scheduling resource pool, calculate the difference between the number of storage nodes after the storage nodes are expanded and the global minimum, and select expandable machines whose difference between the number of storage nodes after the storage nodes are expanded and the global minimum is less than or equal to the maximum allowed difference.
[0026] Specifically, when expanding the capacity of a distributed database, Figure 3 As shown in the figure, we set maxDiff to M=1. The current resource pool consists of three machines, and a storage node has been distributed on each of machine 1 and machine 2. When expanding a new storage node: if it continues to be distributed on machine 1, the nodes in the machine are distributed as 2, 1, 0. In this way, the actual maxDiff is 2, which does not meet the set value M, and scheduling is not allowed; if it continues to be distributed on machine 3, the nodes in the machine are distributed as 1, 1, 1. In this way, the actual maxDiff is 0, which is less than the set value M, and scheduling is allowed.
[0027] From the above analysis, we can know that the machine that can be expanded is machine 3. Therefore, when expanding, the storage node will be deployed on machine 3.
[0028] It should be noted that after selecting the expandable machines, it is still necessary to determine whether the number of expandable machines is greater than or equal to two. If not, Figure 3 As shown, the storage node is directly deployed on the selected expandable machine. If yes, it indicates that there are multiple expandable machines that meet the requirements. At this time, it is necessary to determine the scheduling priorities of all the expandable machines, and determine the target expansion machine based on the scheduling priorities.
[0029] like Figure 4As shown, we set maxDiff to M=1. The current resource pool consists of three machines. Machine 1 has already allocated a storage node, and machines 2 and 3 are idle. When expanding a new storage node, both machines 2 and 3 can meet the requirements. At this time, it is necessary to determine the scheduling priority of all expandable machines, and determine the target expansion machine based on the scheduling priority. The specific operation process is as follows: Step S201: Determine the resource priority sequence of the scalable machine.
[0030] Specifically, in this embodiment, the resource priority sequence of the expandable machine includes CPU, memory, and network bandwidth in descending order of priority.
[0031] Step S202: For any of the scalable machines, calculate the score of each resource in the resource priority sequence.
[0032] Specifically, according to the above resource priority sequence, the CPU resource score, memory resource score and network bandwidth resource score of each scalable machine are calculated.
[0033] Step S203: Based on the resource priority sequence, the resource scores of all the scalable machines are compared in turn to determine a target expansion machine.
[0034] Specifically, based on the resource priority sequence, the CPU resource scores of all expandable machines are first compared. If the CPU resource scores of the expandable machines are all different, the machine with the highest CPU resource score is the target expansion machine.
[0035] If there are two or more scalable machines with the same CPU resource score, the next resource score is compared, that is, the memory resource scores of these scalable machines. If the memory resource scores of the scalable machines are different, the machine with the highest memory resource score is the target expansion machine.
[0036] If there are still two or more scalable machines with the same memory resource score, the next resource score is compared, that is, the network bandwidth resource scores of these scalable machines are compared, and the machine with the highest network bandwidth resource score is selected as the target expansion machine.
[0037] Step S104: Determine the schedulable nodes, and for any schedulable node, calculate the difference between the number of storage nodes in any machine after deletion and the global minimum, and filter out the deletable storage nodes whose difference between the number of storage nodes in any machine after deletion and the global minimum is less than or equal to the maximum allowed difference.
[0038] Specifically, when scaling down a distributed database, first, delete the abnormal storage nodes in the scheduling resource pool, that is, recycle the pods on the abnormal storage nodes. Then, exclude the master node in the cluster, and then use the remaining slave nodes as schedulable nodes to perform evenly scheduled deletion logic: first delete the nodes on the machine with the largest number of value nodes to ensure that the difference in the number of components between nodes is within a fixed value range.
[0039] like Figure 5 As shown in the figure, there are seven nodes scattered on four machines. When trying to shrink the team of this storage node by one node, the abnormal storage node G is deleted first, and storage node B is the main node of the team and cannot be deleted. Then storage nodes A, C, D, and E are all schedulable nodes.
[0040] When storage node E is deleted, the number of nodes on machine 3 is 0, and the maximum number of nodes on the machines in the cluster is 2. The calculated maxDiff value is 2, so the requirement of M=1 is not met. When storage nodes A, C, or D are deleted, the maxDiff value can be calculated to be 1, which meets the requirement of M=1. Therefore, when shrinking a storage node, the order of nodes that can be deleted is: abnormal node G is deleted first, and A, C, and D can be deleted.
[0041] It should be noted that when scaling down a distributed database, the default setting of maxDiff is M=1.
[0042] It is understandable that excluding the master node in the cluster is to ensure the stability of the distributed database service.
[0043] Therefore, the above-mentioned cloud-native distributed database uniform scheduling method can make the distributed database nodes dynamically and evenly distributed on the nodes on the cloud platform. When a host fails, it will not affect the smooth operation of the entire distributed database system, and it has the ability to maintain itself. On the one hand, this method supports components at different levels to achieve uniform scheduling. On the other hand, it takes into account the scenarios of distributed database expansion, reduction, and abnormal reconstruction, and achieves uniform scheduling under different actions, ensuring the high availability and stability of the distributed system.
[0044] Figure 6 A schematic diagram of a cloud native distributed database uniform scheduling device provided in an embodiment of the present application. The device includes a determination module, a judgment module, a capacity expansion module and a capacity reduction module.
[0045] The determination module is used to determine the maximum allowable difference between the number of storage nodes in the target machine in the scheduling resource pool and the global minimum value.
[0046] The judgment module is used to receive the scheduling requirements of the distributed database and judge whether the distributed database needs to be expanded or locked.
[0047] The expansion module is used to perform expansion processing, specifically, for any machine in the scheduling resource pool, calculate the difference between the number of storage nodes after the storage nodes are expanded and the global minimum, and screen out expandable machines whose difference between the number of storage nodes after the storage nodes are expanded and the global minimum is less than or equal to the maximum allowed difference.
[0048] It should be noted that the expansion module is also used to determine whether the number of expandable machines is greater than or equal to two after the expandable machines are screened out. If not, the storage node is directly deployed on the screened expandable machines. If so, the scheduling priorities of all the expandable machines are determined, and the target expansion machine is determined based on the scheduling priorities.
[0049] The shrinking module is used to perform shrinking processing, specifically to determine the schedulable nodes, and for any schedulable node, calculate the difference between the number of storage nodes in any machine after its deletion and the global minimum, and filter out the deletable storage nodes whose difference between the number of storage nodes in any machine after its deletion and the global minimum is less than or equal to the maximum allowed difference.
[0050] See also Figure 7 This embodiment also provides a computer device, and the components of the computer device may include but are not limited to: one or more processors or processing units, a system memory, and a bus connecting different system components (including the system memory and the processing unit).
[0051] The term "bus" refers to one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus architectures. For example, these architectures include, but are not limited to, the Industry Standard Architecture (ISA) bus, the Micro Channel Architecture (MAC) bus, the Enhanced ISA bus, the Video Electronics Standards Association (VESA) local bus, and the Peripheral Component Interconnect (PCI) bus.
[0052] The computer system / server typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the computer system / server, including volatile and non-volatile media, removable and non-removable media.
[0053] The system memory may include computer system readable media in the form of volatile memory, such as random access memory (RAM) and / or cache memory. The computer device may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system may be used to read and write non-removable, non-volatile magnetic media. A disk drive for reading and writing removable non-volatile disks (such as "floppy disks") and an optical disk drive for reading and writing removable non-volatile optical disks (such as CD-ROMs, DVD-ROMs or other optical media) may be provided. In these cases, each drive may be connected to the bus via one or more data medium interfaces. The memory may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present invention.
[0054] A program / utility having a set (at least one) of program modules may be stored, for example, in a memory, such program modules including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. The program modules generally perform the functions and / or methods of the embodiments described herein.
[0055] The computer device may also communicate with one or more external devices such as a keyboard, a pointing device, a display, etc. Such communication may be performed through an input / output (I / O) interface. Furthermore, the computer device may also communicate with one or more networks (such as a local area network (LAN), a wide area network (WAN) and / or a public network, such as the Internet) through a network adapter.
[0056] The processing unit executes the functions and / or methods described in the embodiments of the present invention by running the programs stored in the system memory.
[0057] The above-mentioned computer program can be set in a computer storage medium, that is, the computer storage medium is encoded with a computer program, and when the program is executed by one or more computers, it enables one or more computers to execute the method flow and / or device operation shown in the above-mentioned embodiments of the present invention.
[0058] With the development of time and technology, the meaning of medium is becoming more and more extensive, and the propagation path of computer programs is no longer limited to tangible media, but can also be downloaded directly from the network, etc. Any combination of one or more computer-readable media can be used. Computer-readable media can be computer-readable signal media or computer-readable storage media. Computer-readable storage media can be, for example, - but not limited to - electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or devices, or any combination of the above. More specific examples of computer-readable storage media (non-exhaustive list) include: electrical connections with one or more wires, portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), optical fibers, portable compact disk read-only memories (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the above. In this document, computer-readable storage media can be any tangible medium containing or storing programs, which can be used by or in combination with instruction execution systems, devices or devices.
[0059] Computer-readable signal media may include a data signal propagated in baseband or as part of a carrier wave, which carries a computer-readable program code. Such propagated data signals may take a variety of forms, including, but not limited to, electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0060] Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0061] Computer program code for performing the operations of the present invention may be written in one or more programming languages or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through 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., via the Internet using an Internet service provider).
[0062] In addition to the above embodiments, the present invention may also have other implementation modes; any technical solutions formed by equivalent replacement or equivalent transformation shall fall within the protection scope required by the present invention.
Claims
1. A cloud-native distributed database uniform scheduling method, characterized by: The following steps are involved: Step S101: determining a maximum allowable difference between the number of storage nodes in a target machine in a scheduling resource pool and a global minimum value; Step S102: receiving a scheduling requirement of a distributed database, and executing step S103 when the distributed database needs to be expanded, and executing step S104 when the distributed database needs to be reduced; Step S103: for any machine in the scheduling resource pool, calculate the difference between the number of storage nodes after the storage nodes are expanded and the global minimum, and select the expandable machines whose difference between the number of storage nodes after the storage nodes are expanded and the global minimum is less than or equal to the maximum allowable difference; Step S104: Determine the schedulable nodes, and for any schedulable node, calculate the difference between the number of storage nodes in any machine after deletion and the global minimum, and filter out the deletable storage nodes whose difference between the number of storage nodes in any machine after deletion and the global minimum is less than or equal to the maximum allowed difference.
2. The cloud native distributed database uniform scheduling method according to claim 1 is characterized in that: After the schedulable machine whose difference between the number of storage nodes in the expanded storage node and the global minimum is less than or equal to the maximum allowed difference is selected, the method further includes: It is determined whether the number of expandable machines is greater than or equal to two. If so, the scheduling priorities of all the expandable machines are determined, and a target expansion machine is determined based on the scheduling priorities.
3. The cloud native distributed database uniform scheduling method according to claim 2 is characterized in that: Determining the scheduling priority of the expandable machine and determining the target expansion machine based on the scheduling priority includes: Determining a resource priority sequence of the scalable machine; For any of the scalable machines, calculating a score for each resource in the resource priority sequence; Based on the resource priority sequence, the resource scores of all the scalable machines are compared in turn to determine a target expansion machine.
4. The cloud native distributed database uniform scheduling method according to claim 3 is characterized by: The resource priority sequence of the scalable machine includes CPU, memory, and network bandwidth in descending order of priority.
5. The cloud-native distributed database uniform scheduling method according to claim 1, characterized in that: The determining of the schedulable nodes comprises: Exclude the master node from the scheduling resource pool; The remaining secondary nodes are regarded as schedulable nodes.
6. The cloud native distributed database uniform scheduling method according to claim 5 is characterized in that: Before excluding the master node in the scheduling resource pool, the method further includes: Delete abnormal storage nodes in the scheduling resource pool.
7. The cloud native distributed database uniform scheduling method according to claim 1, characterized in that: When the distributed database needs to be scaled down, the maximum allowed difference between the number of storage nodes in the target machine in the scheduling resource pool and the global minimum is 1.
8. A cloud native distributed database uniform scheduling device, characterized by: include: A determination module, used for determining a maximum allowable difference between the number of storage nodes in the target machine in the scheduling resource pool and a global minimum value; A judgment module is used to receive the scheduling requirements of the distributed database and judge whether the distributed database needs to be expanded or locked; Expansion module; For any machine in the scheduling resource pool, it is used to calculate the difference between the number of storage nodes after the storage nodes are expanded and the global minimum value, and to select the expandable machines whose difference between the number of storage nodes after the storage nodes are expanded and the global minimum value is less than or equal to the maximum allowed difference; The shrinking module is used to determine the schedulable nodes. For any schedulable node, the difference between the number of storage nodes in any machine after its deletion and the global minimum is calculated, and the deletable storage nodes whose difference between the number of storage nodes in any machine after its deletion and the global minimum is less than or equal to the maximum allowed difference are screened out.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.