Storage pool capacity determination method and device, equipment and medium
By traversing the crush rules in the Ceph cluster, determining the weight ratio of each OSD, and calculating the storage pool capacity based on these weight ratios, the problem of inaccurate storage pool capacity in the prior art is solved, and the accuracy and consistency of capacity calculation are achieved.
Patent Information
- Application Number
- CN202411826901.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-11
- Publication Date
- 2025-04-01
- Estimated Expiration
- 2044-12-11
AI Technical Summary
In the prior art, the calculation of storage pool capacity is inaccurate, and the calculation results of storage pool capacity under different crush rules are inconsistent.
By obtaining the crush rule of the target storage pool, iterate over the crush rule to determine the take steps and project topics, determine the weight ratio of each Osd according to the choice step corresponding to each Osd in the project topic, and determine the capacity of the target storage pool based on the weight ratio of each Osd in the crush rule.
Improve the accuracy of storage pool capacity, ensure that the calculation results of storage pool capacity under different crush rules are consistent, and meet the actual capacity requirements.
Smart Images

Figure CN119739334A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of cluster technology, and in particular to a method, device, equipment and medium for determining storage pool capacity. Background Art
[0002] Crush is a distributed selection algorithm for Ceph data storage and the core of Ceph storage engine. Each osd has a weight, and a crush rule is specified when creating a storage pool.
[0003] In the prior art, the weight of each OSD and the total weight of all OSDs are obtained by traversing the crush rules, and then the weight ratio of each OSD is obtained according to the weight of each OSD and the total weight of all OSDs, and then the capacity of the storage pool is obtained according to the weight ratio. However, there is a problem that the calculated capacity is inaccurate. Summary of the invention
[0004] The present application provides a storage pool capacity determination method, apparatus, device and medium to solve the problem of inaccurate calculated capacity existing in the prior art.
[0005] In a first aspect, the present application provides a method for determining storage pool capacity, comprising:
[0006] Get the crush rule of the target storage pool, which is the storage pool in the Ceph cluster;
[0007] Traverse the crush rules, determine the take steps in the crush rules, and the project topics in the take steps;
[0008] Determine the weight ratio of each osd according to the select step corresponding to each osd in the project theme;
[0009] Determine the capacity of the target storage pool based on the weight ratio of each OSD in the crush rule.
[0010] In this application, the weight ratio of each osd is determined according to the select step corresponding to each osd in the project theme, including:
[0011] For each osd, obtain the choose step corresponding to the osd and the parameter value in the choose step. The types of the choose step include chooseleaf indep type, chooseleaf firstn type, choose indep type and choose firstn type. The parameter value is greater than zero, equal to zero or less than zero.
[0012] According to the parameter value, determine the number of osds selected in the choose step;
[0013] According to the number of selections corresponding to each osd, the weight ratio of each osd is determined.
[0014] In this application, the number of choices for selecting osd in the choose step is determined according to the parameter value, including:
[0015] If the parameter value is greater than zero, the selected quantity is the smaller value of the parameter value and the redundancy of the target storage pool;
[0016] If the parameter value is equal to zero, the selected quantity is the redundancy of the target storage pool;
[0017] If the parameter value is less than zero, the selected quantity is the difference between the parameter value and the redundancy of the target storage pool.
[0018] In this application, the weight ratio of each osd is determined according to the number of selections corresponding to each osd, including:
[0019] For each osd, obtain the select step corresponding to the osd and the total weight of all osds in the select step;
[0020] According to the weight of each osd, the total weight and the number of selections corresponding to each osd, and the number of partitions in the target storage pool, the weight ratio of each osd is obtained.
[0021] In this application, according to the weight of each osd, the total weight and the number of selections corresponding to each osd, and the number of partitions of the target storage pool, the weight ratio of each osd is obtained, which satisfies:
[0022] ;
[0023] in, For the The weight ratio of each osd, For the The weight of each osd, For the The number of choices corresponding to each osd, For the The total weight corresponding to the osd, is the number of partitions.
[0024] In this application, the capacity of the target storage pool is determined according to the weight ratio of each osd in the crush rule, including:
[0025] Store the weight ratio of each osd in the data container;
[0026] When traversing to the last item step in the crush rule, obtain the weight ratio of all osds in the crush rule according to the data container;
[0027] According to the ratio of the capacity of each osd and the weight ratio of each osd, the effective capacity corresponding to each osd is obtained;
[0028] According to the capacity of each effective capacity, a target effective capacity with the smallest capacity is selected from all effective capacities;
[0029] The capacity of the target storage pool is obtained according to the target effective capacity and the number of partitions of the target storage pool.
[0030] In this application, the weight ratio of each osd is stored in a data container, including:
[0031] For each osd, determine whether the data container already contains the weight ratio of the osd;
[0032] If the data container already contains the weight ratio of osd, and the weight ratio to be stored of osd is less than the stored weight ratio, the stored weight ratio is updated according to the weight ratio to be stored;
[0033] If the data container does not contain the weight ratio of the osd, the weight ratio of the osd is stored in the data container.
[0034] In a second aspect, the present application provides a storage pool capacity determination device, comprising:
[0035] The acquisition module is used to obtain the crush rule of the target storage pool, which is a storage pool in the Ceph cluster;
[0036] The traversal module is used to traverse the crush rules, determine the take steps in the crush rules, and the project topics in the take steps;
[0037] The weight ratio module is used to determine the weight ratio of each osd according to the weight of each osd in the project theme and the choose step corresponding to each osd;
[0038] The capacity module is used to determine the capacity of the target storage pool according to the weight ratio of each OSD in the crush rule.
[0039] In a third aspect, the present application provides an electronic device, comprising: a processor, and a memory communicatively connected to the processor;
[0040] Memory stores computer-executable instructions;
[0041] The processor executes the computer-executable instructions stored in the memory to implement the method in the first aspect.
[0042] In a fourth aspect, the present application provides a computer-readable storage medium, characterized in that the computer-readable storage medium stores computer execution instructions, and the computer execution instructions are used to implement the method in the first aspect when executed by a processor.
[0043] The storage pool capacity determination method, device, equipment and medium provided in the present application obtain crush rules and traverse the crush rules to determine the take steps in the crush rules and the project topics in the take steps, and then determine the weight ratio of each OSD according to the choose step corresponding to each OSD in the project topic, and finally determine the capacity of the target storage pool according to the weight ratio of each OSD in the crush rules, so that the capacity of the target storage pool is more accurate and reasonable. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0045] Figure 1 A schematic diagram of a scenario for determining storage pool capacity provided in an embodiment of the present application;
[0046] Figure 2 A schematic diagram of a flow chart of a method for determining storage pool capacity provided in an embodiment of the present application;
[0047] Figure 3 A schematic diagram of a cluster storage space tree provided in an embodiment of the present application;
[0048] Figure 4 A schematic diagram of the structure of a storage pool capacity determination device provided in an embodiment of the present application;
[0049] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0050] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0051] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0052] In order to clearly understand the technical solution of the present application, the solution of the prior art is first introduced in detail.
[0053] Crush is a distributed selection algorithm for Ceph data storage and the core of the Ceph storage engine. A crush rule is specified when creating a storage pool.
[0054] In a Ceph cluster, all devices are considered a bucket, such as osd, host, root, etc., forming a hierarchical bucket tree. Each osd has a weight, and a crush rule is specified when creating a storage pool. The crush rule specifies which root to select and on which hosts and osds to create the storage pool.
[0055] For example, the crush rule is:
[0056] rule ecrule2
[0057] {
[0058] id 2
[0059] type erasurestep set chooseleaf tries 5
[0060] step set choose tries 100
[0061] step take default
[0062] step take host1
[0063] step chooseleaf index 1 type osd
[0064] step emit
[0065] step take host2
[0066] step chooseleaf index 1 type osd
[0067] step emit
[0068] step take host3
[0069] step chooseleaf index 1 type osd
[0070] step emit
[0071] step emit
[0072] }
[0073] The current Ceph algorithm for calculating storage pool capacity is: set up a map to record the weight ratio of each osd, map<int, float> m.
[0074] 1. Traverse each step of this rule: When encountering a take type step, traverse all osds under the item (such as default) of the step, count the total weight sum of all osds, and then calculate the weight ratio Wi / sum of each osd (Wi is the weight of the i-th osd).
[0075] 2. Traverse each osd in m, find the capacity of each osd, calculate the effective capacity (osd capacity / osd weight ratio) through each osd, and then find the smallest effective capacity avail.
[0076] 3. Calculate the number of partitions (rate) of the storage pool according to the storage pool type: When the storage pool type is a replica type, the rate is the number of replicas (such as 3 for 3 replicas); when the storage pool type is an ec type, the rate is (m+k) / k (m check blocks, k data blocks).
[0077] 4. The capacity of the storage pool is equal to avail / rate.
[0078] The weight ratio refers to the ratio of the capacity of the OSD to the effective capacity of the storage pool, which is used to determine how the data is distributed on each OSD in the cluster. An OSD with a higher weight ratio is more likely to be selected as the storage location for the data.
[0079] With the existing technology, the calculated capacity is smaller than the actual storage pool capacity. At the same time, the storage pool capacities calculated by the existing technology for two crush rules with the same effect are different. Therefore, the existing technology has the problem of inaccurate calculated capacity.
[0080] In response to the problem of inaccurate calculated capacity in the above-mentioned prior art, the inventors discovered in their research that it is possible to traverse the crush rules, determine the take steps in the crush rules, and the project themes in the take steps, and then group them according to the project themes. According to the choose steps corresponding to each OSD in the project themes, determine the weight ratio of each OSD, and determine the capacity of the target storage pool according to the weight ratio of each OSD in the crush rules.
[0081] The following introduces the application scenarios of the storage pool capacity determination method provided in the embodiments of the present application.
[0082] Figure 1 A schematic diagram of a scenario for determining storage pool capacity provided in an embodiment of the present application, such as Figure 1 As shown, the scenario includes a target storage pool, a crush rule corresponding to the target storage pool, and a server. The server is used to obtain the crush rule, traverse the crush rule, determine the take step in the crush rule, and the project subject in the take step, and then determine the weight ratio of each OSD according to the choose step corresponding to each OSD in the project subject. Finally, according to the weight ratio of each OSD in the crush rule, the capacity of the target storage pool is determined.
[0083] Figure 2 A flow chart of a method for determining storage pool capacity provided in an embodiment of the present application is shown as follows: Figure 2 As shown, the method includes:
[0084] S201. Obtain a crush rule of a target storage pool, where the target storage pool is a storage pool in a Ceph cluster.
[0085] Among them, Ceph cluster can refer to an open source distributed storage that supports object storage, block devices, and file systems. Ceph clusters are usually composed of multiple storage nodes, which can be deployed in different data centers or racks to meet different capacity and performance requirements.
[0086] Crush rules can be obtained through the crush (Controlled Replication Under ScalableHashing) algorithm and are used to build the target storage pool. It is a core algorithm in the Ceph distributed storage system. It is mainly used to calculate the storage location of data objects, ensure the balanced distribution of data in the cluster, and support high availability and flexible cluster scalability.
[0087] S202, traverse the crush rules, determine the take steps in the crush rules, and the project topics in the take steps.
[0088] The traversal may refer to reading line by line according to the crush rule until all the data are read.
[0089] The take step can refer to the item selected in the crush rule to determine the starting point of the algorithm. For example, in step take default, the item is default, and in step take host1, the item is host1. The take step and the emit step appear in pairs, and each take step has a corresponding emit step.
[0090] In this application, the project theme is determined through the take step, and then all osds under the project theme are counted to classify the osds according to different project themes, which is convenient for subsequent weight ratio calculation.
[0091] S203. Determine the weight ratio of each osd according to the select step corresponding to each osd in the project theme.
[0092] Among them, osd can refer to Object Storage Device, which is a basic storage unit responsible for the storage, retrieval and management of data copies of objects.
[0093] The types of the choose step can include chooseleaf indep type, chooseleaf firstn type, choose indep type and choose firstn type, where chooseleaf indep may refer to independently selecting an OSD from the candidate OSDs to store data in the current step. chooseleaf first may refer to selecting the first N OSDs from the candidate OSDs to store data. choose indep may refer to independently selecting a node from the candidate nodes (which can be any type of node) in the current step. choose firstn means selecting the first N nodes from the candidate nodes.
[0094] For example, in step chooseleaf indep 1 type osd, chooseleaf means that in the current step, one OSD will be selected from the candidate OSD list as the storage location for the data. The chooseleaf operation is usually used at the end of the rule to ensure that a leaf node (that is, the actual OSD) is finally selected. indep means that when selecting an OSD, an independent selection strategy will be used instead of relying on the selection results of the previous step. This means that the selection of the current step will not be affected by the selection of the previous step. 1 means that in the current step, an OSD will be selected. If the number is greater than 1, the corresponding number of OSDs will be selected to store multiple copies of the data. type osd specifies that the node type to be selected is OSD. In a Ceph cluster, OSD is a daemon responsible for storing data.
[0095] In this application, each project theme includes multiple osds, and each osd is selected through the choose step. Therefore, each osd has a corresponding choose step, and the weight ratio of the osd can be obtained through the choose step.
[0096] In some implementations, determining the weight ratio of each osd according to the select step corresponding to each osd in the project theme may include:
[0097] For each osd, obtain the choose step corresponding to the osd and the parameter value in the choose step. The types of the choose step include chooseleaf indep type, chooseleaf firstn type, choose indep type and choose firstn type. The parameter value is greater than zero, equal to zero or less than zero.
[0098] According to the parameter value, determine the number of osds selected in the choose step;
[0099] According to the number of selections corresponding to each osd, the weight ratio of each osd is determined.
[0100] The parameter value can refer to the value after the choose keyword in the choose step. For example, the parameter value in stepchooseleaf indep 1 type osd is 1.
[0101] The selection quantity may refer to the number of osds that need to be selected in this choose step.
[0102] In this application, for each osd selected in the project theme, each osd corresponds to a choose step. The parameter value in this choose step can determine the number of osds selected in this step, and the weight ratio of the osd can be obtained through the number of osds selected in this step.
[0103] For example, the project theme host1 includes osd1, osd2 and osd3. If the choose step is chooseleaf findep 1 type osd, it means to select any 1 osd from osd1, osd2 and osd3 for data storage. At this time, the probability of each osd being selected is 1 / 3. If the choose step is chooseleaf indep 3 type osd, it means to select any 3 osds from osd1, osd2 and osd3 for data storage. At this time, the probability of each osd being selected is 1. It can be seen that different numbers of selections correspond to the probability of each osd being selected, and the probability of each osd being selected is different, so that the obtained weight ratio is also different. The higher the probability of a certain osd being selected, the higher the weight ratio of the osd in the target storage pool. Therefore, this application fully considers the probability of each osd being selected according to the parameter value in the choose step, so that the weight ratio of each osd can be determined more accurately.
[0104] Furthermore, the parameter value may be greater than zero, equal to zero, or less than zero. According to the parameter value, determining the number of choices for selecting osd in the choose step may include:
[0105] If the parameter value is greater than zero, the selected quantity is the smaller value of the parameter value and the redundancy of the target storage pool;
[0106] If the parameter value is equal to zero, the selected quantity is the redundancy of the target storage pool;
[0107] If the parameter value is less than zero, the selected quantity is the difference between the parameter value and the redundancy of the target storage pool.
[0108] Redundancy refers to the duplication or backup degree of data storage in the system. Specifically, in order to ensure high reliability and fault tolerance of data, Ceph automatically stores multiple copies of each data in the background. In this way, in abnormal situations such as hard disk damage, server failure, or cabinet power outage, data will not be lost and can remain online. The redundancy design enables Ceph to restore complete data through the remaining data copies when some components fail, thereby ensuring the stability of the entire storage system and data security.
[0109] Specifically, the redundancy mode may include EC type and replica type. For EC type, the redundancy is the ratio of the sum of the number of data blocks and the number of check blocks to the number of data blocks. For replica type, the redundancy is the number of replicas.
[0110] In some implementations, determining the weight ratio of each osd according to the number of selections corresponding to each osd may include:
[0111] For each osd, obtain the select step corresponding to the osd and the total weight of all osds in the select step;
[0112] According to the weight of each osd, the total weight and the number of selections corresponding to each osd, and the number of partitions in the target storage pool, the weight ratio of each osd is obtained.
[0113] The weight of an osd may be associated with the storage capacity, performance, or other factors of the OSD and is set by the Ceph administrator during configuration.
[0114] The total weight (sum) can refer to adding the weights of all osds under the project topic to obtain the total weight.
[0115] The number of partitions of the target storage pool may refer to the size of the target storage pool. For EC type, the number of partitions of the target storage pool is the sum of the number of data blocks and the number of check blocks. For copy type, the number of partitions of the target storage pool is the number of copies.
[0116] Specifically, according to the weight of each osd, the total weight and the number of selections corresponding to each osd, and the number of partitions in the target storage pool, the formula for obtaining the weight ratio of each osd can be:
[0117] ;
[0118] in, For the The weight ratio of each osd, For the The weight of each osd, For the The number of choices corresponding to each osd, For the The total weight corresponding to the osd, is the number of partitions.
[0119] In the present application, the weight ratio of the OSD is adjusted by selecting the quantity, and the probability of the OSD being selected in actual use is fully considered. Compared with the prior art in which the ratio of the OSD weight to the total weight is directly used as the OSD weight ratio, the OSD weight ratio obtained in the embodiment of the present application is more accurate and reasonable.
[0120] S204. Determine the capacity of the target storage pool according to the weight ratio of each osd in the crush rule.
[0121] In the present application, after obtaining the weight ratio of each osd, the capacity of the target storage pool can be obtained through the weight ratio of the osd and the capacity of the osd.
[0122] Specifically, since there are multiple osds, the capacities of the target storage pool are also multiple. In order to further screen, the capacity of the target storage pool is determined according to the weight ratio of each osd in the crush rule, which may include:
[0123] Store the weight ratio of each osd in the data container;
[0124] When traversing to the last item step in the crush rule, obtain the weight ratio of all osds in the crush rule according to the data container;
[0125] According to the ratio of the capacity of each osd and the weight ratio of each osd, the effective capacity corresponding to each osd is obtained;
[0126] According to the capacity of each effective capacity, a target effective capacity with the smallest capacity is selected from all effective capacities;
[0127] The capacity of the target storage pool is obtained according to the target effective capacity and the number of partitions of the target storage pool.
[0128] The data container may refer to a container used to count the weight ratio of osd. For example, the weight ratio of each osd may be recorded by a map tool.<int, float> In om, the data container is om.
[0129] The capacity of osd can refer to the size of osd storage capacity, which is set by the Ceph administrator during configuration.
[0130] The effective capacity can be the size of the storage capability of the target memory.
[0131] In the present application, after traversing the crush rules, it means that the weight ratio of each osd is recorded in the data container. According to the capacity and weight ratio of the osd, the effective capacity of the target storage pool can be obtained. Each osd corresponds to an effective capacity. In order to make the calculated capacity of the target storage pool meet the actual capacity of the target storage pool, the effective capacity with the smallest capacity is selected from each effective capacity as the target effective capacity, and then the ratio of the effective capacity to the number of partitions is used as the capacity of the target storage pool, thereby obtaining the capacity that the target storage pool can provide except for the backup capacity.
[0132] In some implementations, storing the weight ratio of each osd in a data container may include:
[0133] For each osd, determine whether the data container already contains the weight ratio of the osd;
[0134] If the data container already contains the weight ratio of osd, and the weight ratio to be stored of osd is less than the stored weight ratio, the stored weight ratio is updated according to the weight ratio to be stored;
[0135] If the data container does not contain the weight ratio of the osd, the weight ratio of the osd is stored in the data container.
[0136] In this application, since the project topics in the take step may include the same osd, for example, please refer to Figure 3 In the cluster storage space tree diagram provided in the embodiment of the present application, osd1 is included in both default and host1, so different values may be obtained when calculating the weight ratio of osd. In order to minimize the target effective capacity, the weight ratio with a larger value is stored in the data container as the weight ratio of osd, so that the capacity of the target storage pool is more accurate and reasonable.
[0137] For example, assuming that the target storage pool is an EC storage pool with k=2 and m=1, k is the number of data blocks, m is the number of check blocks, and the crush rule used is:
[0138] rule ecrule2
[0139] {
[0140] id 2
[0141] type erasurestep set chooseleaf tries 5
[0142] step set choose tries 100
[0143] step take default
[0144] step take host1
[0145] step chooseleaf indep 1 type osd
[0146] step emit
[0147] step take host2
[0148] step chooseleaf index 1 type osd
[0149] step emit
[0150] step take host3
[0151] step chooseleaf index 1 type osd
[0152] step emit
[0153] step emit
[0154] }
[0155] First, a map is used to record the weight ratio of each osd.<int,float> Om.
[0156] Step 1: Traverse each step of this rule (the step types are take, choose and emit)
[0157] When the step type is take, the item of this step is recorded to obtain take_item (project subject).
[0158] When the step type is choose (including chooseleaf indep, chooseleaf firstn, chooseindep, and choose firstn), choose_val (number of selections) is calculated based on choose's val (parameter value). When choose's val is equal to 0, choose_val is pool size (number of partitions in the target storage pool); when choose's val is less than 0, choose_val is choose's val + pool size; when choose's val is greater than 0, choose_val is the minimum value between choose's val and pool size.
[0159] When the step type is emit, get all osds under take_item of take corresponding to emit, and record the weight Wi of each osd according to the total weight sum of all osds in choose where each osd is located. Then check whether the osd is in om. If not, the weight ratio of osd is m[id]=Wi*choose_val / (sum*pool size) (id is the id of osd), otherwise, m[id] is the maximum value of m[id] and Wi*choose_val / (sum*pool size).
[0160] Take and emit appear in pairs. This step is used to calculate the weight ratio of all osds under each pair of take / emit.
[0161] Step 2:
[0162] Traverse each OSD in the OM calculated in step 1, find the capacity of this OSD, calculate the effective capacity (OSD capacity / OSD weight ratio) through this OSD, and find the smallest effective capacity avail.
[0163] Step 3:
[0164] The rate (redundancy) of the storage pool is calculated based on the storage pool type: for replicas, it is the number of replicas (such as 3 for 3 replicas); for ec, it is (m+k) / k (m check blocks, k data blocks).
[0165] Step 4:
[0166] Calculate storage pool capacity: avail / rate.
[0167] The storage pool capacity determination method provided in the embodiment of the present application obtains the crush rule and traverses the crush rule to determine the take step in the crush rule and the project theme in the take step, and then determines the weight ratio of each OSD according to the choose step corresponding to each OSD in the project theme, and finally determines the capacity of the target storage pool according to the weight ratio of each OSD in the crush rule, so that the capacity of the target storage pool is more accurate and reasonable.
[0168] Figure 4 A schematic diagram of a storage pool capacity determination device provided in an embodiment of the present application is shown in FIG. Figure 4 As shown, the device 40 includes:
[0169] The acquisition module 401 is used to acquire the crush rule of the target storage pool, where the target storage pool is a storage pool in the Ceph cluster;
[0170] A traversal module 402 is used to traverse the crush rules and determine the take steps in the crush rules and the project topics in the take steps;
[0171] The weight ratio module 403 is used to determine the weight ratio of each osd according to the weight of each osd in the project theme and the select step corresponding to each osd;
[0172] The capacity module 404 is used to determine the capacity of the target storage pool according to the weight ratio of each OSD in the crush rule.
[0173] In some implementations, the weight ratio module 403 is further used to:
[0174] For each osd, obtain the choose step corresponding to the osd and the parameter value in the choose step. The types of the choose step include chooseleaf indep type, chooseleaf firstn type, choose indep type and choose firstn type. The parameter value is greater than zero, equal to zero or less than zero.
[0175] According to the parameter value, determine the number of osds selected in the choose step;
[0176] According to the number of selections corresponding to each osd, the weight ratio of each osd is determined.
[0177] In some implementations, the weight ratio module 403 is further used to:
[0178] If the parameter value is greater than zero, the selected quantity is the smaller value of the parameter value and the redundancy of the target storage pool;
[0179] If the parameter value is equal to zero, the selected quantity is the redundancy of the target storage pool;
[0180] If the parameter value is less than zero, the selected quantity is the difference between the parameter value and the redundancy of the target storage pool.
[0181] In some implementations, the weight ratio module 403 is further used to:
[0182] For each osd, obtain the select step corresponding to the osd and the total weight of all osds in the select step;
[0183] According to the weight of each osd, the total weight and the number of selections corresponding to each osd, and the number of partitions in the target storage pool, the weight ratio of each osd is obtained.
[0184] In some implementations, the weight ratio module 403 is further used to satisfy:
[0185] ;
[0186] in, For the The weight ratio of each osd, For the The weight of each osd, For the The number of choices corresponding to each osd, For the The total weight corresponding to the osd, is the number of partitions.
[0187] In some implementations, the capacity module 404 is further used to:
[0188] Store the weight ratio of each osd in the data container;
[0189] When traversing to the last item step in the crush rule, obtain the weight ratio of all osds in the crush rule according to the data container;
[0190] According to the ratio of the capacity of each osd and the weight ratio of each osd, the effective capacity corresponding to each osd is obtained;
[0191] According to the capacity of each effective capacity, a target effective capacity with the smallest capacity is selected from all effective capacities;
[0192] The capacity of the target storage pool is obtained according to the target effective capacity and the number of partitions of the target storage pool.
[0193] In some implementations, the capacity module 404 is further used to:
[0194] For each osd, determine whether the data container already contains the weight ratio of the osd;
[0195] If the data container already contains the weight ratio of osd, and the weight ratio to be stored of osd is less than the stored weight ratio, the stored weight ratio is updated according to the weight ratio to be stored;
[0196] If the data container does not contain the weight ratio of the osd, the weight ratio of the osd is stored in the data container.
[0197] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 5 As shown, the electronic device 50 includes:
[0198] The electronic device 50 may include a processor 501 with one or more processing cores, a memory 502 with one or more computer-readable storage media, a communication component 503 and other components. The processor 501 , the memory 502 and the communication component 503 are connected via a bus 504 .
[0199] In a specific implementation process, at least one processor 501 executes the computer-executable instructions stored in the memory 502, so that at least one processor 501 executes the above method.
[0200] The specific implementation process of the processor 501 can be found in the above method embodiment, and its implementation principle and technical effect are similar, so this embodiment will not be repeated here.
[0201] In the above Figure 5 In the illustrated embodiment, it should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the method disclosed in the invention may be directly implemented as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor.
[0202] The memory may include a high-speed memory (Random Access Memory, RAM), and may also include a non-volatile memory (NVM), such as at least one disk storage.
[0203] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of this application is not limited to only one bus or one type of bus.
[0204] In some embodiments, a computer program product is also proposed, including a computer program or instructions, which implement the steps in any of the above methods when executed by a processor.
[0205] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0206] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0207] To this end, an embodiment of the present application provides a computer-readable storage medium, in which multiple instructions are stored, and the instructions can be loaded by a processor to execute the steps in any method provided in the embodiment of the present application.
[0208] The storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0209] According to one aspect of the present application, a computer program product or a computer program is provided. The computer program product or the computer program comprises computer instructions stored in a computer-readable storage medium.
[0210] Since the instructions stored in the storage medium can execute the steps in any method provided in the embodiments of the present application, the beneficial effects that can be achieved by any method provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0211] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.
[0212] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A method for determining storage pool capacity, characterized in that: include: Obtain a crush rule for a target storage pool, where the target storage pool is a storage pool in a Ceph cluster; Traversing the crush rules, determining the take steps in the crush rules, and the project topics in the take steps; Determine the weight ratio of each osd according to the select step corresponding to each osd in the project theme; The capacity of the target storage pool is determined according to the weight ratio of each osd in the crush rule.
2. The method according to claim 1, characterized in that: The step of determining the weight ratio of each osd according to the select step corresponding to each osd in the project theme includes: For each osd, obtain the choose step corresponding to the osd and the parameter value in the choose step, the type of the choose step includes chooseleaf indep type, chooseleaf firstn type, choose indep type and choose firstn type, and the parameter value is greater than zero, equal to zero or less than zero; According to the parameter value, determining the number of osds selected in the choose step; According to the number of selections corresponding to each osd, the weight ratio of each osd is determined.
3. The method according to claim 2, characterized in that Determining the number of osds selected in the choose step according to the parameter value includes: If the parameter value is greater than zero, the selected quantity is the smaller value of the parameter value and the redundancy of the target storage pool; If the parameter value is equal to zero, the selected quantity is the redundancy of the target storage pool; If the parameter value is less than zero, the selection quantity is the difference between the parameter value and the redundancy of the target storage pool.
4. The method according to claim 2, characterized in that: Determining the weight ratio of each osd according to the number of selections corresponding to each osd includes: For each osd, obtain the select step corresponding to the osd and the total weight of all osds in the select step; The weight ratio of each osd is obtained according to the weight of each osd, the total weight and the number of selections corresponding to each osd, and the number of partitions of the target storage pool.
5. The method according to claim 4, characterized in that According to the weight of each osd, the total weight and the number of selections corresponding to each osd, and the number of partitions of the target storage pool, the weight ratio of each osd is obtained, which satisfies: ; in, For the The weight ratio of each osd, For the The weight of each osd, For the The number of choices corresponding to each osd, For the The total weight corresponding to the osd, is the number of partitions.
6. The method according to any one of claims 1 to 5, characterized in that: Determining the capacity of the target storage pool according to the weight ratio of each osd in the crush rule includes: Store the weight ratio of each osd in the data container; When traversing to the last item step in the crush rule, the weight ratio of all osds in the crush rule is obtained according to the data container; According to the ratio of the capacity of each osd and the weight ratio of each osd, the effective capacity corresponding to each osd is obtained; According to the capacity of each effective capacity, a target effective capacity with the smallest capacity is selected from all effective capacities; The capacity of the target storage pool is obtained according to the target effective capacity and the number of partitions of the target storage pool.
7. The method according to claim 6, characterized in that The step of storing the weight ratio of each osd in the data container includes: For each osd, determining whether the data container already contains the weight ratio of the osd; If the data container already contains the weight ratio of the osd, and the weight ratio to be stored of the osd is less than the stored weight ratio, updating the stored weight ratio according to the weight ratio to be stored; If the data container does not contain the weight ratio of the osd, the weight ratio of the osd is stored in the data container.
8. A storage pool capacity determination device, characterized in that: include: An acquisition module, used to acquire a crush rule of a target storage pool, where the target storage pool is a storage pool in a Ceph cluster; A traversal module, used for traversing the crush rule, determining the take step in the crush rule, and the project theme in the take step; A weight ratio module, used for determining the weight ratio of each osd according to the weight of each osd in the project theme and the select step corresponding to each osd; The capacity module is used to determine the capacity of the target storage pool according to the weight ratio of each osd in the crush rule.
9. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 7 when executed by a processor.
Citation Information
Patent Citations
Arrangement group allocation method and device and distributed storage system
CN112817535A
Distributed storage capacity balancing optimization method, system, equipment and medium
CN114647381A
Distributed storage collocation group PG balancing method and device, equipment and medium
CN117389465A
Distributed storage balancing method, device and equipment
CN117950594A
Data-driven CEPH performance optimizations
US20160349993A1