A data distribution method, system, computer program product, device and medium
By performing fine-grained division of logical unit numbers and consistent hash operations in the distributed storage system, the problem of high pressure on the metadata server is solved, the reliability and stability of the system are improved, and the calculation of automatic data distribution is realized.
Patent Information
- Application Number
- CN202410882267.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-03
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2044-07-03
AI Technical Summary
When data is distributed in the existing distributed storage system, the storage and access pressure of the metadata server is high, and the operation and maintenance is complex, resulting in poor system reliability and stability.
By determining the logical unit number in distributed storage, selecting cluster nodes, dividing them into logical data blocks and generating virtual nodes, performing consistent hash operations and automatically calculating data distribution, reducing dependence on metadata servers and improving system reliability. and stability.
It achieves fine-grained data distribution in a distributed storage system, reduces the impact of failures, reduces the amount of data migration and recovery, improves the reliability and stability of the system, and avoids the need to build an independent metadata server.
Smart Images

Figure CN118409717B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of distributed storage technology, and more specifically, to a data distribution method, system, computer program product, device and medium. Background Art
[0002] Currently, when distributing data in a distributed storage system, a metadata server can be established to record the location of the replica data. However, this method increases the storage and access pressure of metadata, and the metadata server operation and maintenance is relatively complex. Once the metadata server fails, the entire distributed storage system will not work properly, resulting in poor reliability and stability of distributed storage.
[0003] In summary, how to improve the reliability and stability of distributed storage is an urgent problem to be solved by those skilled in the art. Summary of the invention
[0004] The purpose of the present invention is to provide a data distribution method, which can solve the technical problem of how to improve the reliability and stability of distributed storage to a certain extent. The present invention also provides a data distribution system, a computer program product, an electronic device and a computer readable storage medium.
[0005] In order to achieve the above object, the present invention provides the following technical solutions:
[0006] In a first aspect, a data distribution method is provided, comprising:
[0007] In the distributed storage, determining the logical unit number to be deployed;
[0008] In the distributed storage, selecting a first cluster node for deploying the logical unit number;
[0009] Dividing the logical unit number into logical data blocks;
[0010] generating a first virtual node in the first cluster node;
[0011] Performing a consistent hash operation on the logical data block and the first virtual node to obtain a first operation result;
[0012] A first distribution result of the logic data block on the first cluster node is determined according to the first operation result.
[0013] On the other hand, in the distributed storage, selecting a first cluster node for deploying the logical unit number includes:
[0014] Obtaining capacity constraints of cluster nodes in the distributed storage;
[0015] Obtaining a selection strategy for selecting the first cluster node for deploying the logical unit number;
[0016] In the distributed storage, the first cluster node is selected according to the capacity restriction condition and the selection strategy.
[0017] On the other hand, the capacity constraint condition includes a first constraint condition and a second constraint condition, and the selection strategy includes a first strategy, a second strategy and a third strategy;
[0018] The first restriction condition includes that the total capacity usage rate of all cluster nodes in the distributed storage does not exceed a first preset value;
[0019] The second restriction condition includes that the capacity utilization rate of a single cluster node does not exceed a second preset value;
[0020] The first strategy includes selecting the number of cluster nodes as the sum of the number of copies of the logical unit number and 1, and the capacity usage rate of the selected cluster nodes after the logical unit number is allocated is lower than a third preset value;
[0021] The second strategy includes that when the first strategy cannot be satisfied, the capacity usage rate of the selected cluster node after the logical unit number is allocated is lower than a fourth preset value, and the fourth preset value is greater than the third preset value;
[0022] The third strategy includes selecting all cluster nodes that meet the second restriction condition when the first strategy and the second strategy cannot be met, and the capacity utilization rate of the selected cluster nodes after allocating logical unit numbers is lower than a fifth preset value, and the fifth preset value is greater than the fourth preset value.
[0023] On the other hand, selecting the first cluster node according to the capacity restriction condition and the selection strategy includes:
[0024] Calculating a first capacity usage rate after the distributed storage allocates space for the logical unit number;
[0025] If the first capacity usage rate exceeds the first preset value, an error message indicating that the cluster capacity is insufficient is returned.
[0026] On the other hand, after calculating the first capacity usage rate after the distributed storage allocates space for the logical unit number, the method further includes:
[0027] If the first capacity utilization rate does not exceed the first preset value, determining, in the distributed storage, a second cluster node whose capacity utilization rate is lower than the second preset value;
[0028] Sorting the second cluster nodes in descending order of priority of the cluster nodes to obtain a third cluster node;
[0029] Selecting a first number of first candidate cluster nodes from the third cluster nodes, where the first number is a sum of the number of replicas and 1;
[0030] Calculating a second capacity usage rate after the first candidate cluster node allocates space for the logical unit number;
[0031] If the second capacity usage rate is lower than the third preset value, using the first candidate cluster node as the first cluster node;
[0032] The higher the available capacity of a cluster node is, the higher the priority of the cluster node is.
[0033] On the other hand, after calculating the second capacity usage rate after the first candidate cluster node allocates space for the logical unit number, the method further includes:
[0034] If the second capacity usage rate is greater than or equal to the third preset value, selecting a cluster node that has not been selected from the third cluster nodes and adding it to the first candidate cluster nodes to obtain a second candidate cluster node;
[0035] Calculating a third capacity usage rate after the second candidate cluster node allocates space for the logical unit number;
[0036] If the third capacity usage rate is lower than the fourth preset value, the second candidate cluster node is used as the first cluster node.
[0037] On the other hand, after calculating the third capacity usage rate after the second candidate cluster node allocates space for the logical unit number, the method further includes:
[0038] If the third capacity usage rate is greater than or equal to the fourth preset value, selecting a second number of third candidate cluster nodes from the third cluster nodes;
[0039] Calculating a fourth capacity usage rate after the third candidate cluster node allocates space for the logical unit number;
[0040] Repeat the steps of: if the fourth capacity usage rate is lower than the fourth preset value, then dividing the cluster node into two within the range of (C+1, S) and the third candidate cluster node to form a fourth candidate cluster node; if the fourth capacity usage rate is greater than or equal to the fourth preset value, then dividing the cluster node into two within the range of (S, N) and the third candidate cluster node to form a fourth candidate cluster node, until the fourth candidate cluster node satisfies the second strategy, and the fourth candidate cluster node is used as the first cluster node;
[0041] The process of determining the second number includes: S=C+1+((NC-1)) / 2, where S represents the second number, C represents the number of copies, and N represents the total number of cluster nodes.
[0042] On the other hand, after determining the first distribution result of the logic data block on the first cluster node according to the first operation result, the method further includes:
[0043] Determining an expansion strategy for expanding the logical unit number;
[0044] According to the capacity restriction condition and the capacity expansion strategy, the first cluster node is adjusted to obtain a fourth cluster node, and the first distribution result is adjusted.
[0045] On the other hand, the capacity expansion strategy includes not adjusting the first distribution result if the capacity usage rate of the cluster node where the logical unit number is located after the expansion is less than a sixth preset value, otherwise adjusting the first distribution result.
[0046] On the other hand, according to the capacity restriction condition and the capacity expansion strategy, the first cluster node is adjusted to obtain a fourth cluster node, including:
[0047] After the logical unit number is expanded, it is detected whether the remaining capacity of the distributed storage meets the first restriction condition. If not, an error message indicating that the cluster capacity is insufficient is returned.
[0048] On the other hand, after detecting whether the remaining capacity of the distributed storage meets the first restriction condition after the logical unit number is expanded, the method further includes:
[0049] If satisfied, analyzing the type of the logical unit number;
[0050] If the logical unit number is a non-localized logical unit number, calculating a first ideal value of the capacity utilization rate of the first cluster node after the logical unit number is expanded, and if the first ideal value is greater than or equal to the sixth preset value, adjusting the first cluster node according to the second cluster node to obtain the fourth cluster node;
[0051] If the logical unit number is a localized logical unit number, the remaining logical data blocks that cannot be placed in the localized cluster node are determined, and a second ideal value corresponding to the remaining logical data blocks and the non-localized cluster nodes in the first cluster node is calculated; if the second ideal value is greater than or equal to the sixth preset value, the first cluster node is adjusted according to the second cluster node to obtain the fourth cluster node.
[0052] On the other hand, adjusting the first cluster node according to the second cluster node to obtain the fourth cluster node includes:
[0053] Determining, among the second cluster nodes, a fifth cluster node that does not belong to the first cluster node;
[0054] Sorting the fifth cluster nodes in descending order of priority of the cluster nodes to obtain a sixth cluster node;
[0055] Calculate the pre-occupancy value of each cluster node in the first cluster node, and if there is a pre-occupancy value that is greater than the expansion value of the logical unit number, select a cluster node from the sixth cluster node and combine it with the first cluster node to obtain the fourth cluster node;
[0056] The pre-occupied value includes a value obtained by multiplying the ideal value by the cluster node capacity minus the cluster node's used capacity.
[0057] On the other hand, after determining the first distribution result of the logic data block on the first cluster node according to the first operation result, the method further includes:
[0058] In the distributed storage, all seventh cluster nodes that do not have a complete copy of the localized logical unit number are determined,
[0059] Determine, among the seventh cluster nodes, a first target cluster node having the largest capacity utilization rate;
[0060] Determining whether the capacity usage rate of the first target cluster node is greater than a seventh preset value;
[0061] If it is greater than, calculating a first difference between the highest capacity utilization rate and the lowest capacity utilization rate of the seventh cluster node;
[0062] In response to the first difference exceeding a first threshold, reducing the number of virtual nodes on the first target cluster node, increasing the number of virtual nodes on other cluster nodes, and obtaining a second virtual node, wherein the other cluster nodes include cluster nodes in the first cluster node other than the first target cluster node;
[0063] The first distribution result is adjusted according to the second virtual node, and corresponding data migration is performed on the first cluster node.
[0064] On the other hand, after determining the first distribution result of the logic data block on the first cluster node according to the first operation result, the method further includes:
[0065] Determining a capacity utilization rate of each cluster node in the first cluster node;
[0066] Determining a second difference between the highest capacity utilization and the lowest capacity utilization of the first cluster node;
[0067] In response to the second difference exceeding the second threshold, the number of the first virtual nodes is adjusted, and the first distribution result is adjusted, and the step of determining the capacity utilization rate of each cluster node in the first cluster node is returned to execute until the second difference does not exceed the second threshold.
[0068] On the other hand, after determining the first distribution result of the logic data block on the first cluster node according to the first operation result, the method further includes:
[0069] Obtaining information on changes in the number of cluster nodes in the distributed storage;
[0070] The number of the first virtual nodes is adjusted according to the number change information, and the first distribution result is adjusted.
[0071] On the other hand, after determining the first distribution result of the logic data block on the first cluster node according to the first operation result, the method further includes:
[0072] Obtaining disk change information of cluster nodes in the first cluster node;
[0073] The number of the first virtual nodes is adjusted according to the disk change information, and the first distribution result is adjusted.
[0074] On the other hand, after determining the first distribution result of the logic data block on the first cluster node according to the first operation result, the method further includes:
[0075] Record the number of the first cluster nodes and the first virtual nodes corresponding to the logical unit number.
[0076] In a second aspect, a data distribution system is provided, comprising:
[0077] A first determination module is used to determine the logical unit number to be deployed in the distributed storage;
[0078] A first selection module, configured to select a first cluster node for deploying the logical unit number in the distributed storage;
[0079] A first segmentation module, used for segmenting the logical unit number into logical data blocks;
[0080] A first generating module, configured to generate a first virtual node in the first cluster node;
[0081] A first operation module, configured to perform a consistent hash operation on the logical data block and the first virtual node to obtain a first operation result;
[0082] The second determining module is used to determine a first distribution result of the logic data block on the first cluster node according to the first operation result.
[0083] According to a third aspect, a computer program product is provided, comprising a computer program / instruction, which implements the steps of any of the above-mentioned data distribution methods when executed by a processor.
[0084] In a fourth aspect, an electronic device is provided, including:
[0085] Memory for storing computer programs;
[0086] A processor is used to implement the steps of any of the above data distribution methods when executing the computer program.
[0087] According to a fifth aspect, a computer-readable storage medium is provided, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the steps of any of the above data distribution methods are implemented.
[0088] The present invention provides a data distribution method, which determines a logical unit number to be deployed in distributed storage; selects a first cluster node for deploying the logical unit number in the distributed storage; divides the logical unit number into logical data blocks; generates a first virtual node in the first cluster node; performs a consistent hash operation on the logical data block and the first virtual node to obtain a first operation result; and determines a first distribution result of the logical data block on the first cluster node according to the first operation result. The beneficial effects of the present invention are as follows: the selected first cluster node is used to deploy the logical unit number, and then the logical unit number is divided into logical data blocks, and the first cluster node is divided into the first virtual node to perform fine-grained division of the logical unit number and the first cluster node, and finally the first distribution result of the logical data block on the first cluster node is determined by consistent hashing operation, so that the logical data block is distributed to the first cluster node according to the first virtual node, so that when the distributed storage is operated or failed, only the data of the logical data block will be affected, and the global logical unit number will not be affected, reducing the amount of data to be migrated and recovered. In addition, the present invention does not need to build an independent metadata server to record the data distribution, but automatically calculates the distribution of data in the cluster node through consistent hashing operation, so that the data distribution can be clarified only through operation, which improves the reliability and stability of the distributed storage system. A data distribution system, computer program product, electronic device and computer-readable storage medium provided by the present invention also solve the corresponding technical problems. BRIEF DESCRIPTION OF THE DRAWINGS
[0089] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0090] Figure 1 A flow chart of a data distribution method provided by an embodiment of the present invention;
[0091] Figure 2 A schematic diagram of the structure of a data distribution system provided by an embodiment of the present invention;
[0092] Figure 3 It is a schematic diagram of the data distribution system in practical applications;
[0093] Figure 4 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention;
[0094] Figure 5 Another structural schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0095] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0096] See also Figure 1 , Figure 1 A flow chart of a data distribution method provided by an embodiment of the present invention.
[0097] A data distribution method provided by an embodiment of the present invention may include the following steps:
[0098] Step S101: In the distributed storage, determine the logical unit number to be deployed.
[0099] In practical applications, the present invention distributes data in distributed storage using a logical unit number (LUN) as the granularity, so the logical unit number to be deployed needs to be determined, and the size of the logical unit number can be flexibly determined as needed.
[0100] Step S102: In the distributed storage, a first cluster node for deploying the logical unit number is selected.
[0101] In actual applications, after the logical unit number to be deployed is determined, the first cluster node for deploying the logical unit number can be selected, and the number and type of the first cluster node can be flexibly determined according to the application scenario.
[0102] In a specific application scenario, considering that the capacity of distributed storage will change after the corresponding data of the logical unit number is deployed in the distributed storage, in the distributed storage, in the process of selecting the first cluster node for deploying the logical unit number, the capacity restriction condition of the cluster node in the distributed storage can be obtained; the selection strategy for selecting the first cluster node for deploying the logical unit number can be obtained; in the distributed storage, the first cluster node is selected according to the capacity restriction condition and the selection strategy. In this way, the capacity of the cluster node in the distributed storage can be controlled with the help of the capacity restriction condition, and the selection process of the cluster node can also be controlled according to the selection strategy, so that the selection of the first cluster node can meet the user's corresponding settings for the distributed storage and improve the user experience.
[0103] In specific application scenarios, the content of capacity restriction conditions and selection strategies can be flexibly determined according to user needs. For example, the capacity restriction conditions may include a first restriction condition and a second restriction condition, and the selection strategies include a first strategy, a second strategy and a third strategy; the first restriction condition may include that the total capacity utilization rate of all cluster nodes in the distributed storage does not exceed a first preset value; the second restriction condition may include that the capacity utilization rate of a single cluster node does not exceed a second preset value; the first strategy may include that the number of selected cluster nodes is the sum of the number of copies of the logical unit number and 1, and the capacity utilization rate of the selected cluster nodes after the logical unit number is assigned is lower than the third preset value; the second strategy may include that when the first strategy cannot be met, the capacity utilization rate of the selected cluster nodes after the logical unit number is assigned is lower than a fourth preset value, and the fourth preset value is greater than the third preset value; the third strategy may include that when the first strategy and the second strategy cannot be met, all cluster nodes that meet the second restriction condition are selected, and the capacity utilization rate of the selected cluster nodes after the logical unit number is assigned is lower than a fifth preset value, and the fifth preset value is greater than the fourth preset value. Among them, the specific values of the first preset value to the fifth preset value can be determined according to actual needs, for example, the first preset value can be 90%, the second preset value can be 95%, the third preset value can be 60%, the fourth preset value can be 80%, the fifth preset value can be 95%, etc.
[0104] In a specific application scenario, after determining the capacity restriction condition and the selection strategy, in the process of selecting the first cluster node according to the capacity restriction condition and the selection strategy, the first capacity usage rate after the distributed storage allocates space for the logical unit number can be calculated, for example, by To calculate the first capacity utilization rate, where Indicates the current used capacity of the cluster. Indicates the capacity of the created LUN, C indicates the number of copies of the LUN, Indicates the total capacity of the cluster. represents the first capacity utilization rate; if the first capacity utilization rate exceeds the first preset value, the first restriction condition is not met, an error message indicating insufficient cluster capacity is returned, and the task of creating the logical unit number fails; if the first capacity utilization rate does not exceed the first preset value, that is, the first restriction condition is met, a cluster node is selected according to the second restriction condition, and in the distributed storage, a second cluster node whose capacity utilization rate is lower than the second preset value is determined; the second cluster nodes are sorted in descending order of priority of the cluster nodes to obtain a third cluster node; a first number of first candidate cluster nodes are selected from the third cluster nodes, and the first number is the sum of the number of replicas and 1. In this process, when the logical unit number is localized, the first C nodes and the localized nodes are selected. If the localized nodes are included in the first C nodes, the first C+1 nodes are selected. When the logical unit number is non-localized, the first C+1 nodes are selected, and the number S of the selected nodes is C+1 at this time; the second capacity utilization rate after the first candidate cluster node allocates space for the logical unit number is calculated, and the calculation formula can be: , represents the second capacity utilization rate, represents the used capacity of the i-th cluster node, and represents the total capacity of the i-th cluster node; if the second capacity utilization rate is lower than the third preset value, the first strategy is satisfied, and the first candidate cluster node is used as the first cluster node; wherein, the higher the available capacity of the cluster node, the higher the priority of the cluster node. At this time, the cluster node priority can be calculated according to PRI=(Node cur +LUN size ))⁄Node ALL The formula is used to calculate the priority, PRI represents the priority, Nodecur represents the used capacity of the cluster node, and Node ALL Indicates the total capacity of cluster nodes. The smaller the PRI value, the higher the priority of the cluster node.
[0105] In a specific application scenario, after calculating the second capacity utilization rate of the first candidate cluster node after allocating space for the logical unit number, if the second capacity utilization rate is greater than or equal to the third preset value, the first strategy is not satisfied, and the cluster node continues to be selected according to the second strategy, that is, a cluster node that has not been selected is selected from the third cluster node and added to the first candidate cluster node to obtain the second candidate cluster node; the third capacity utilization rate of the second candidate cluster node is calculated after allocating space for the logical unit number, and the calculation formula of the third capacity utilization rate is the same as the calculation formula of the second capacity utilization rate; if the third capacity utilization rate is lower than the fourth preset value, the second strategy is satisfied, and the second candidate cluster node is used as the first cluster node. If the third capacity utilization rate is greater than or equal to the fourth preset value, the second strategy is not satisfied, and the cluster nodes are continuously selected according to the third strategy, that is, the third candidate cluster nodes of the first second quantity are selected from the third cluster nodes; the fourth capacity utilization rate of the third candidate cluster node after allocating space for the logical unit number is calculated; the steps of if the fourth capacity utilization rate is lower than the fourth preset value, then the cluster nodes and the third candidate cluster node are divided into two within the range of (C+1, S) to form the fourth candidate cluster node, and if the fourth capacity utilization rate is greater than or equal to the fourth preset value, then the cluster nodes and the third candidate cluster node are divided into two within the range of (S, N) to form the fourth candidate cluster node, are repeatedly executed, until the fourth candidate cluster node satisfies the second strategy, and the fourth candidate cluster node is used as the first cluster node; and the second quantity determination process includes: S=C+1+((NC-1)) / 2, S represents the second quantity, C represents the number of replicas, and N represents the total number of cluster nodes.
[0106] It should be noted that after the third capacity utilization rate is greater than or equal to the fourth preset value, before continuing to select cluster nodes according to the third strategy, all cluster nodes in the third cluster node can also be selected to calculate the corresponding capacity utilization rate to determine whether the capacity utilization rate is lower than the fourth preset value. If it is not lower, it is determined that the second strategy cannot be met and the cluster node is selected according to the third strategy.
[0107] Step S103: Divide the logical unit number into logical data blocks.
[0108] Step S104: Generate a first virtual node in the first cluster node.
[0109] Step S105: performing a consistent hash operation on the logical data block and the first virtual node to obtain a first operation result.
[0110] Step S106: determining a first distribution result of the logic data block on the first cluster node according to the first operation result.
[0111] In practical applications, after selecting the first cluster node, the data distribution result can be determined according to the logical unit number and the first cluster node. Specifically, the logical unit number can be divided into logical data blocks (Objects), and the number of logical data blocks can be flexibly determined as needed. Then, the first virtual node is generated in the first cluster node, and the number of the first virtual nodes can be flexibly determined as needed. For example, the number of virtual nodes can be determined by the formula Determine, among which, represents the number of virtual nodes of the jth cluster node, 𝑉𝑁𝑜d𝑒 𝐴𝐿𝐿 Indicates the total number of virtual nodes. represents the capacity utilization rate of the jth cluster node, represents the total capacity of the jth cluster node; then a consistent hash operation is performed on the logical data block and the first virtual node to obtain a first operation result, and a first distribution result of the logical data block on the first cluster node is determined according to the first operation result. For example, all virtual nodes and logical data blocks are mapped to the same hash ring according to a hash function, and then the cluster node to which each logical data block copy belongs is searched on the hash ring to form a DHT (Distributed Hash Table) hash table. The steps may be as follows: first, the node where the first copy of the logical data block is located is allocated, and the nearest virtual node is searched clockwise on the hash ring. The cluster node to which the virtual node belongs allocates a position for the first copy of the logical data block. Then, for other copies allocated, the next nearest virtual node is searched on the hash ring to determine whether the cluster node to which it belongs is the same cluster node as the previous copy. If it is the same cluster node, the next virtual node is searched clockwise for determination. If it is not the same cluster node, the cluster node to which the virtual node belongs allocates positions for other copies of the logical data block. This step is repeated until all copies of the logical data block are queried to the cluster node to which they belong. At this time, the first distribution result is the cluster node to which each logical data block is distributed.
[0112] In actual applications, in the application process of distributed storage, as time goes by, there may be a situation where the logical unit number is insufficient. At this time, the logical unit number needs to be expanded. That is, after determining the first distribution result of the logical data block on the first cluster node according to the first operation result, an expansion strategy for expanding the logical unit number can also be determined; according to the capacity limitation condition and the expansion strategy, the first cluster node is adjusted to obtain the fourth cluster node, and the first distribution result is adjusted so that the fourth cluster node can meet the data distribution requirements of the expanded logical unit number.
[0113] In a specific application scenario, after the logical unit number is expanded, data distribution can be performed again according to the method of the present invention, or the existing first distribution result can be adjusted according to the expansion strategy. For example, the expansion strategy may include that if the capacity utilization rate of the cluster node where the logical unit number after expansion is located is less than the sixth preset value, the first distribution result is not adjusted, otherwise the first distribution result is adjusted, and the sixth preset value can be determined as needed, for example, the sixth preset value can be 90%, etc. Correspondingly, in the process of adjusting the first cluster node according to the capacity restriction condition and the expansion strategy to obtain the fourth cluster node, it can be detected whether the remaining capacity of the distributed storage meets the first restriction condition after the logical unit number is expanded. If not, an error message of insufficient cluster capacity is returned.
[0114] Correspondingly, if it is satisfied, the adjustment is continued according to the expansion strategy, that is, the type of the logical unit number is analyzed; if the logical unit number is a non-localized logical unit number, the first ideal value of the capacity utilization rate of the first cluster node after the logical unit number is expanded is calculated. If the first ideal value is less than the sixth preset value, it meets the expansion strategy and there is no need to adjust the first distribution result. If the first ideal value is greater than or equal to the sixth preset value, the first cluster node needs to be adjusted according to the second cluster node to obtain the fourth cluster node; if the logical unit number is a localized logical unit number, since a complete logical unit number copy is placed in the localized cluster node, it is only necessary to ensure that the capacity utilization rate of the localized cluster node after placement is less than 95%, so it is necessary to determine the remaining logical data blocks that cannot be placed in the localized cluster node, and the remaining logical data blocks of the copy participate in the distribution method of the DHT hash table together with other copies, that is, it is necessary to calculate the second ideal value corresponding to the remaining logical data blocks and the non-localized cluster nodes in the first cluster node. If the second ideal value is greater than or equal to the sixth preset value, the first cluster node is adjusted according to the second cluster node to obtain the fourth cluster node.
[0115] It should be noted that the first ideal value and the second ideal value can be obtained by the formula To confirm, represents the ideal value, Indicates the size of the LUN after expansion. Correspondingly, in the process of adjusting the first cluster node according to the second cluster node to obtain the fourth cluster node, a fifth cluster node that does not belong to the first cluster node can be determined in the second cluster node; the fifth cluster node is sorted in descending order of priority of the cluster nodes to obtain the sixth cluster node. At this time, the cluster priority can be calculated by the formula Determine; calculate the pre-occupancy value of each cluster node in the first cluster node. If there is a pre-occupancy value that is greater than the expansion value of the logical unit number, select a cluster node from the sixth cluster node and combine it with the first cluster node to obtain a fourth cluster node; wherein the pre-occupancy value includes the value obtained by multiplying the ideal value by the cluster node capacity minus the used capacity of the cluster node.
[0116] In practical applications, after determining the first distribution result of the logical data block on the first cluster node according to the first operation result, after the first cluster node carries the corresponding data of the logical data block, the capacity utilization rate of the first cluster node will increase, while the capacity utilization rates of other cluster nodes that do not carry the corresponding data of the logical data block will not increase, thereby causing a difference in capacity utilization rates between cluster nodes of distributed storage. In order to avoid this difference being too large, all seventh cluster nodes that do not place a complete copy of the localized logical unit number can be determined in the distributed storage, and among the seventh cluster nodes, the first target cluster node with the largest capacity utilization rate is determined; it is determined whether the capacity utilization rate of the first target cluster node is greater than the seventh preset value, and the seventh preset value can be It can be determined as needed, for example, it can be 80%; if it is greater than, then calculate the first difference between the highest capacity utilization rate and the lowest capacity utilization rate of the seventh cluster node; in response to the first difference exceeding the first threshold, the first threshold can be determined as needed, for example, it can be 5%, then reduce the number of virtual nodes on the first target cluster node, increase the number of virtual nodes on other cluster nodes, and obtain a second virtual node, and the other cluster nodes include the cluster nodes in the first cluster node except the first target cluster node; adjust the first distribution result according to the second virtual node, and perform corresponding data migration on the first cluster node, so as to migrate a small part of the logical data block copies on the first target cluster node to other cluster nodes.
[0117] In a practical application, after determining the first distribution result of the logical data block on the first cluster node according to the first operation result, after distributing the data corresponding to the logical unit number on each first cluster node, considering that the amount of data carried by each first cluster node is different, resulting in differences between the first cluster nodes, in order to avoid excessive differences between the first cluster nodes, the capacity utilization rate of each cluster node in the first cluster node can be determined; the second difference between the highest capacity utilization rate and the lowest capacity utilization rate of the first cluster node is determined; in response to the second difference exceeding the second threshold, the number of first virtual nodes is adjusted, and the adjustment method can be: , The number of virtual nodes after adjustment for the j-th selected cluster node is adjusted, and the first distribution result is adjusted. During this process, only the logical data blocks affected by the added or reduced virtual nodes on the hash ring can be adjusted. After the affected logical data blocks are redistributed on the cluster nodes, return to the step of determining the capacity utilization rate of each cluster node in the first cluster node until the second difference does not exceed the second threshold.
[0118] In practical applications, after determining the first distribution result of the logical data block on the first cluster node according to the first operation result, the number change information of the cluster nodes in the distributed storage can also be obtained; the number of the first virtual node is adjusted according to the number change information, and the first distribution result is adjusted. For example, when adding and deleting cluster nodes and other operation and maintenance operations are performed in the distributed storage, the partial logical data block data of a small part of the logical unit number is migrated between cluster nodes as needed, so that the distribution of the logical data block copy data on each cluster node remains balanced to a certain extent; for example, when adding a new node Node to the cluster, the original first cluster node in the cluster can be traversed to determine whether there is a cluster node with a capacity utilization rate exceeding 80%. If not, there is no need to adjust the first cluster node and end the task. If so, the non-localized and later created logical unit number in the first cluster node is adjusted first, and the new node Node is added to the cluster node selected by the logical unit number, and then the logical unit number is redistributed through the consistent hash operation until the capacity utilization rate of the cluster node is lower than 80% or the included logical unit numbers are adjusted. In addition, when a cluster node is deleted in distributed storage, all logical unit numbers contained in the deleted cluster node can be queried, and these logical unit numbers can be sorted by priority for data recovery. The ones with higher priority are restored first, and the priority can be defined as: the localized logical unit number is higher than the non-localized logical unit number, and the earlier created logical unit number is higher than the later created logical unit number. These logical unit numbers can be re-determined according to the method of the present invention to determine the distribution results. It should be noted that when unpredictable failures such as node power failure and network disconnection occur in the distributed storage environment, the logical data block copies lost by the failed cluster node need to be restored to ensure the integrity and consistency of the logical data block copy data of the LUN. The recovery steps are consistent with the operation of deleting the cluster node, and the process only needs to restore the data of a small part of the LUN without affecting the global LUN.
[0119] In this way, even if the number of cluster nodes of the distributed storage changes, the present invention can adjust the number of the first virtual nodes in real time according to the change information of the number of cluster nodes. When the number of the first virtual nodes is adjusted, even if the number of logical data blocks remains unchanged, the result of the consistent hash operation will also change. Therefore, after adjusting the number of the first virtual nodes according to the change information of the number of cluster nodes, the first distribution result can continue to be adjusted through the consistent hash operation, so that the distribution of the logical data blocks in the distributed storage matches the cluster nodes of the distributed storage, thereby ensuring the stability of the data distribution.
[0120] In actual applications, after determining the first distribution result of the logical data block on the first cluster node according to the first operation result, the disk change information of the cluster nodes in the first cluster node can also be obtained; the number of the first virtual nodes is adjusted according to the disk change information, and the first distribution result is adjusted to make the data distribution result compatible with the disk change of the cluster node.
[0121] In a specific application scenario, when a cluster node in a distributed storage mounts a disk, it can be determined whether data migration is required based on the capacity usage of other cluster nodes. Assuming that the target cluster node A newly mounts a disk, if there is another cluster node X whose capacity exceeds the third threshold, such as more than 90%, the number of virtual nodes of the logical unit number is adjusted, such as preferentially adjusting the non-localized logical unit number contained on other cluster nodes X, reducing the number of virtual nodes corresponding to the non-localized logical unit number, and preferentially adjusting the localized logical unit number on the target cluster node A, increasing the number of virtual nodes corresponding to the localized logical unit number, so that data copies are evenly distributed among cluster nodes, and the distribution of logical unit numbers on cluster nodes is determined according to the consistent hash operation. Correspondingly, when a cluster node in the cluster unmounts a disk, assuming that the target cluster node A unmounts a disk, the capacity usage rate of the target cluster node A after data recovery is calculated. If it is greater than the third threshold, data balancing among cluster nodes is performed, the logical unit number contained in the target cluster node A is found, the number of virtual nodes corresponding to the found logical unit number on the target cluster node A is reduced, and the number of virtual nodes corresponding to other cluster nodes is increased.
[0122] From this process, it can be seen that when a new disk is added to the target cluster node and the capacity of other cluster nodes exceeds the third threshold, the present invention reduces the number of virtual nodes corresponding to the non-localized logical unit number on other cluster nodes and increases the number of virtual nodes corresponding to the localized logical unit number on the target cluster node, so that after the cluster node adds a new disk, the data copies between cluster nodes are relatively balanced; and when a disk is unloaded from the target cluster node and the capacity usage rate of the target cluster node after data recovery is greater than the third threshold, the number of virtual nodes corresponding to the logical unit number of the target cluster node on the target cluster node is reduced, and the number of virtual nodes corresponding to the logical unit number on other cluster nodes is increased, so that after the consistent hash operation, some logical data block copies in the target cluster node will be migrated to other cluster nodes, thereby achieving a relative balance in data distribution between cluster nodes. That is, whether a new disk is added to a cluster node or a disk is unloaded, the present invention can ensure a relative balance in data distribution between cluster nodes.
[0123] In practical applications, after determining the first distribution result of the logical data block on the first cluster node according to the first operation result, the number of the first cluster node corresponding to the logical unit number and the first virtual node corresponding to the first cluster node can also be recorded. In this way, only a small amount of data needs to be recorded, and the number of the first cluster node and the corresponding first virtual node corresponding to the logical unit number can be processed by consistent hashing operation later, and the first distribution result can be restored for data processing, such as data reading, writing, and recovery, which avoids the additional performance overhead caused by the distributed storage due to the storage of the distribution result, and the distribution result can be quickly restored for data processing. In addition, in the present invention, whenever the cluster node is adjusted to generate a new distribution result, the number of cluster nodes and the corresponding virtual nodes corresponding to the latest logical unit number can be recorded. For example, when performing read and write operations on IO (Input / Output) under LUN, the logical data block in LUN can be found first, and the DHT hash table can be constructed according to the consistent hashing operation based on the recorded information, so as to quickly find the cluster node location where the logical data block copy is located for read and write operations, etc.
[0124] The present invention provides a data distribution method, which determines a logical unit number to be deployed in distributed storage; selects a first cluster node for deploying the logical unit number in the distributed storage; divides the logical unit number into logical data blocks; generates a first virtual node in the first cluster node; performs a consistent hash operation on the logical data block and the first virtual node to obtain a first operation result; and determines a first distribution result of the logical data block on the first cluster node according to the first operation result. The beneficial effects of the present invention are as follows: the selected first cluster node is used to deploy the logical unit number, and then the logical unit number is divided into logical data blocks, and the first cluster node is divided into a first virtual node to perform fine-grained division of the logical unit number and the first cluster node, and finally the first distribution result of the logical data block on the first cluster node is determined by a consistent hash operation, thereby realizing the distribution of the logical data block to the first cluster node according to the first virtual node, so that when the distributed storage is operated or fails, only the data of the logical data block will be affected, and the global logical unit number will not be affected, thereby reducing the amount of data to be migrated and recovered. In addition, the present invention does not need to build an independent metadata server to record the data distribution, but automatically calculates the distribution of the data in the cluster node through a consistent hash operation. In this way, the data distribution can be clarified only through calculation, thereby improving the reliability and stability of the distributed storage system.
[0125] See also Figure 2 , Figure 2 A structural diagram of a data distribution system provided by an embodiment of the present invention.
[0126] A data distribution system provided by an embodiment of the present invention may include:
[0127] A first determination module 101 is used to determine a logical unit number to be deployed in a distributed storage;
[0128] A first selection module 102 is used to select a first cluster node for deploying a logical unit number in a distributed storage;
[0129] The first segmentation module 103 is used to segment the logical unit number into logical data blocks;
[0130] A first generating module 104, configured to generate a first virtual node in a first cluster node;
[0131] A first operation module 105, configured to perform a consistent hash operation on the logical data block and the first virtual node to obtain a first operation result;
[0132] The second determining module 106 is configured to determine a first distribution result of the logic data block on the first cluster node according to the first operation result.
[0133] In a data distribution system provided by an embodiment of the present invention, the first selection module may include:
[0134] A first acquisition unit, used to acquire a capacity restriction condition of a cluster node in the distributed storage;
[0135] A second acquisition unit, used for acquiring a selection strategy for selecting the first cluster node for deploying the logical unit number;
[0136] The first selection unit is used to select the first cluster node in the distributed storage according to the capacity restriction condition and the selection strategy.
[0137] An embodiment of the present invention provides a data distribution system, wherein the capacity restriction condition includes a first restriction condition and a second restriction condition, and the selection strategy includes a first strategy, a second strategy and a third strategy;
[0138] The first restriction condition includes that the total capacity usage rate of all cluster nodes in the distributed storage does not exceed a first preset value;
[0139] The second restriction condition includes that the capacity utilization rate of a single cluster node does not exceed a second preset value;
[0140] The first strategy includes selecting the number of cluster nodes as the sum of the number of copies of the logical unit number and 1, and the capacity usage rate of the selected cluster nodes after the logical unit number is allocated is lower than a third preset value;
[0141] The second strategy includes that when the first strategy cannot be satisfied, the capacity usage rate of the selected cluster node after the logical unit number is allocated is lower than a fourth preset value, and the fourth preset value is greater than the third preset value;
[0142] The third strategy includes selecting all cluster nodes that meet the second restriction condition when the first strategy and the second strategy cannot be met, and the capacity utilization rate of the selected cluster nodes after allocating logical unit numbers is lower than a fifth preset value, and the fifth preset value is greater than the fourth preset value.
[0143] In a data distribution system provided by an embodiment of the present invention, a first selection unit can be used to: calculate a first capacity usage rate of the distributed storage after allocating space for the logical unit number; if the first capacity usage rate exceeds the first preset value, return an error message indicating insufficient cluster capacity.
[0144] In a data distribution system provided by an embodiment of the present invention, a first selection unit can be used to: after calculating the first capacity utilization rate of the distributed storage after allocating space for the logical unit number, if the first capacity utilization rate does not exceed the first preset value, then in the distributed storage, determine a second cluster node whose capacity utilization rate is lower than the second preset value; sort the second cluster nodes in order of priority of the cluster nodes from high to low to obtain a third cluster node; select a first number of first candidate cluster nodes from the third cluster nodes, the first number being the sum of the number of replicas and 1; calculate the second capacity utilization rate of the first candidate cluster node after allocating space for the logical unit number; if the second capacity utilization rate is lower than the third preset value, use the first candidate cluster node as the first cluster node; wherein, the higher the available capacity of the cluster node, the higher the priority of the cluster node.
[0145] In a data distribution system provided by an embodiment of the present invention, a first selection unit can be used to: after calculating the second capacity utilization rate of the first candidate cluster node after allocating space for the logical unit number, if the second capacity utilization rate is greater than or equal to the third preset value, select a cluster node that has not been selected from the third cluster node and add it to the first candidate cluster node to obtain a second candidate cluster node; calculate the third capacity utilization rate of the second candidate cluster node after allocating space for the logical unit number; if the third capacity utilization rate is lower than the fourth preset value, use the second candidate cluster node as the first cluster node.
[0146] In a data distribution system provided by an embodiment of the present invention, a first selection unit may be used to: after calculating a third capacity usage rate of the second candidate cluster node after allocating space for the logical unit number, if the third capacity usage rate is greater than or equal to the fourth preset value, select the first second number of third candidate cluster nodes from the third cluster nodes; calculate a fourth capacity usage rate of the third candidate cluster node after allocating space for the logical unit number; repeatedly perform the steps of if the fourth capacity usage rate is lower than the fourth preset value, then divide the cluster node into two within the range of (C+1, S) and the third candidate cluster node to form a fourth candidate cluster node, if the fourth capacity usage rate is greater than or equal to the fourth preset value, then divide the cluster node into two within the range of (S, N) and the third candidate cluster node to form a fourth candidate cluster node, until the fourth candidate cluster node satisfies the second strategy, and the fourth candidate cluster node is used as the first cluster node; wherein the second number determination process includes: S=C+1+((NC-1)) / 2, S represents the second number, C represents the number of replicas, and N represents the total number of cluster nodes.
[0147] A data distribution system provided by an embodiment of the present invention may further include:
[0148] The first adjustment module is used to determine the expansion strategy for expanding the logical unit number after the second determination module determines the first distribution result of the logical data block on the first cluster node according to the first calculation result; according to the capacity limitation condition and the expansion strategy, the first cluster node is adjusted to obtain the fourth cluster node, and the first distribution result is adjusted.
[0149] An embodiment of the present invention provides a data distribution system, wherein the capacity expansion strategy includes not adjusting the first distribution result if the capacity utilization rate of the cluster node where the logical unit number is located after expansion is less than a sixth preset value, otherwise adjusting the first distribution result.
[0150] In a data distribution system provided by an embodiment of the present invention, the first adjustment module may include:
[0151] The first adjustment unit is used to detect whether the remaining capacity of the distributed storage meets the first restriction condition after the logical unit number is expanded. If not, an error message indicating that the cluster capacity is insufficient is returned.
[0152] In a data distribution system provided by an embodiment of the present invention, a first adjustment unit can be used to: detect whether the remaining capacity of the distributed storage meets the first restriction condition after the logical unit number is expanded, and if so, analyze the type of the logical unit number; if the logical unit number is a non-localized logical unit number, calculate a first ideal value of the capacity utilization rate of the first cluster node after the logical unit number is expanded, and if the first ideal value is greater than or equal to the sixth preset value, adjust the first cluster node according to the second cluster node to obtain the fourth cluster node; if the logical unit number is a localized logical unit number, determine the remaining logical data blocks that cannot be placed by the localized cluster node, calculate the second ideal value corresponding to the remaining logical data blocks and the non-localized cluster nodes in the first cluster node, and if the second ideal value is greater than or equal to the sixth preset value, adjust the first cluster node according to the second cluster node to obtain the fourth cluster node.
[0153] In a data distribution system provided by an embodiment of the present invention, a first adjustment unit can be used to: determine a fifth cluster node that does not belong to the first cluster node in the second cluster node; sort the fifth cluster node in descending order of priority of the cluster nodes to obtain a sixth cluster node; calculate the pre-occupancy value of each cluster node in the first cluster node, and if there is a pre-occupancy value that is greater than the expansion value of the logical unit number, select a cluster node from the sixth cluster node to combine with the first cluster node to obtain the fourth cluster node; wherein the pre-occupancy value includes a value obtained by multiplying the ideal value by the cluster node capacity minus the used capacity of the cluster node.
[0154] A data distribution system provided by an embodiment of the present invention may further include:
[0155] A second adjustment module is used for, after the second determination module determines the first distribution result of the logical data block on the first cluster node according to the first calculation result, in the distributed storage, determining all seventh cluster nodes that do not place a complete copy of the localized logical unit number, and among the seventh cluster nodes, determining the first target cluster node with the largest capacity utilization rate; judging whether the capacity utilization rate of the first target cluster node is greater than the seventh preset value; if greater, calculating the first difference between the highest capacity utilization rate and the lowest capacity utilization rate of the seventh cluster node; in response to the first difference exceeding the first threshold, reducing the number of virtual nodes on the first target cluster node, increasing the number of virtual nodes on other cluster nodes, and obtaining a second virtual node, wherein the other cluster nodes include cluster nodes in the first cluster node except the first target cluster node; adjusting the first distribution result according to the second virtual node, and performing corresponding data migration on the first cluster node.
[0156] A data distribution system provided by an embodiment of the present invention may further include:
[0157] A third adjustment module is used to determine the capacity utilization rate of each cluster node in the first cluster node after the second determination module determines the first distribution result of the logical data block on the first cluster node according to the first calculation result; determine the second difference between the highest capacity utilization rate and the lowest capacity utilization rate of the first cluster node; in response to the second difference exceeding the second threshold, adjust the number of the first virtual nodes and the first distribution result, and return to execute the step of determining the capacity utilization rate of each cluster node in the first cluster node until the second difference does not exceed the second threshold.
[0158] A data distribution system provided by an embodiment of the present invention may further include:
[0159] A fourth adjustment module is used to obtain the quantity change information of the cluster nodes in the distributed storage after the second determination module determines the first distribution result of the logical data block on the first cluster node according to the first calculation result; adjust the quantity of the first virtual nodes according to the quantity change information, and adjust the first distribution result.
[0160] A data distribution system provided by an embodiment of the present invention may further include:
[0161] A fifth adjustment module is used to obtain disk change information of cluster nodes in the first cluster node after the second determination module determines the first distribution result of the logical data block on the first cluster node according to the first calculation result; adjust the number of the first virtual nodes according to the disk change information, and adjust the first distribution result.
[0162] A data distribution system provided by an embodiment of the present invention may further include:
[0163] The first recording module is used to record the number of the first cluster nodes and the first virtual nodes corresponding to the logical unit number after the second determining module determines the first distribution result of the logical data block on the first cluster node according to the first calculation result.
[0164] It should be noted that the structure of the data distribution system in the present invention can be flexibly adjusted as needed. For example, the data distribution system can be Figure 3As shown, it includes a fault domain node selection device, a hash table construction device, a data distribution automatic balancing device, a capacity expansion device, an operation and maintenance automatic migration device, a fault automatic recovery device and a read-write device. When a user creates a LUN through the operation interface, he first enters the fault domain node selection device, selects a node from the distributed storage cluster, and determines on which nodes the data corresponding to the LUN is distributed; then enters the hash table construction device, divides the LUN into multiple logical data blocks OBJ according to a fixed size, maps the selected cluster node and OBJ to the same hash ring, selects the corresponding cluster node for each OBJ copy on the hash ring according to the rules, thereby constructing a DHT hash table from the OBJ copy to the cluster node, and determines the specific data distribution of the LUN in the selected cluster node; after the DHT hash table is constructed, enter the data distribution automatic balancing device The OBJ copy data of the LUN on the selected node is further adjusted and balanced; then the expansion device is entered to expand the LUN and perform corresponding processing; when the user adds or deletes nodes in the distributed storage system for operation and maintenance, the operation and maintenance automatic migration device will automatically migrate data at the bottom layer to keep the distribution of OBJ copy data on each node balanced to a certain extent; when unpredictable failures such as node power failure and network disconnection occur in the distributed storage environment, the fault automatic recovery device will automatically restore the lost OBJ copy at the bottom layer; the read-write device can ensure that the LUN can quickly find the cluster node location where the corresponding OBJ copy is located when downloading IO.
[0165] The present invention also provides an electronic device, a computer-readable storage medium, and a computer program product, all of which have the corresponding effects of the data distribution method provided in the embodiment of the present invention. Figure 4 , Figure 4 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention.
[0166] An electronic device provided by an embodiment of the present invention includes a memory 201 and a processor 202. The memory 201 stores a computer program. When the processor 202 executes the computer program, the steps of the data distribution method described in any of the above embodiments are implemented.
[0167] See also Figure 5Another electronic device provided in an embodiment of the present invention may also include: an input port 203 connected to the processor 202, used to transmit commands input from the outside to the processor 202; a display unit 204 connected to the processor 202, used to display the processing results of the processor 202 to the outside; a communication module 205 connected to the processor 202, used to realize communication between the electronic device and the outside. The display unit 204 can be a display panel, a laser scanning display, etc.; the communication method adopted by the communication module 205 includes but is not limited to mobile high-definition link technology (Mobile High-Definition Link, MHL), Universal Serial Bus (Universal Serial Bus, USB), High-Definition Multimedia Interface (High-Definition Multimedia Interface, HDMI), wireless connection: wireless fidelity technology (WIreless Fidelity, WiFi), Bluetooth communication technology, low-power Bluetooth communication technology, and communication technology based on IEEE802.11s.
[0168] An embodiment of the present invention provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the steps of the data distribution method described in any of the above embodiments are implemented.
[0169] The computer-readable storage medium involved in the present invention includes random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, register, hard disk, removable disk, CD-ROM (Compact Disc Read-Only Memory), or any other form of storage medium known in the technical field.
[0170] A computer program product provided by an embodiment of the present invention includes a computer program / instruction, and when the computer program / instruction is executed by a processor, the steps of the data distribution method described in any of the above embodiments are implemented.
[0171] For the description of the relevant parts of a data distribution system, an electronic device, a computer program product, and a computer-readable storage medium provided by an embodiment of the present invention, please refer to the detailed description of the corresponding parts in a data distribution method provided by an embodiment of the present invention, which will not be repeated here. In addition, the parts of the above technical solutions provided by the embodiments of the present invention that are consistent with the implementation principles of the corresponding technical solutions in the prior art are not described in detail to avoid excessive elaboration.
[0172] It should also be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0173] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A data distribution method, characterized in that: include: In the distributed storage, determining the logical unit number to be deployed; In the distributed storage, selecting a first cluster node for deploying the logical unit number; dividing the logical unit number into logical data blocks; generating a first virtual node in the first cluster node; Performing a consistent hash operation on the logical data block and the first virtual node to obtain a first operation result; Determine a first distribution result of the logic data block on the first cluster node according to the first operation result; In the distributed storage, all seventh cluster nodes that do not have a complete copy of the localized logical unit number are determined, Determine, among the seventh cluster nodes, a first target cluster node having the largest capacity utilization rate; Determining whether the capacity usage rate of the first target cluster node is greater than a seventh preset value; If it is greater than, calculating a first difference between the highest capacity utilization rate and the lowest capacity utilization rate of the seventh cluster node; In response to the first difference exceeding a first threshold, reducing the number of virtual nodes on the first target cluster node, increasing the number of virtual nodes on other cluster nodes, and obtaining a second virtual node, wherein the other cluster nodes include cluster nodes in the first cluster node other than the first target cluster node; The first distribution result is adjusted according to the second virtual node, and corresponding data migration is performed on the first cluster node.
2. The data distribution method according to claim 1, characterized in that: In the distributed storage, selecting a first cluster node for deploying the logical unit number includes: Obtaining capacity constraints of cluster nodes in the distributed storage; Obtaining a selection strategy for selecting the first cluster node for deploying the logical unit number; In the distributed storage, the first cluster node is selected according to the capacity restriction condition and the selection strategy.
3. The data distribution method according to claim 2, characterized in that: The capacity constraint condition includes a first constraint condition and a second constraint condition, and the selection strategy includes a first strategy, a second strategy and a third strategy; The first restriction condition includes that the total capacity usage rate of all cluster nodes in the distributed storage does not exceed a first preset value; The second restriction condition includes that the capacity utilization rate of a single cluster node does not exceed a second preset value; The first strategy includes selecting the number of cluster nodes as the sum of the number of copies of the logical unit number and 1, and the capacity usage rate of the selected cluster nodes after the logical unit number is allocated is lower than a third preset value; The second strategy includes that when the first strategy cannot be satisfied, the capacity usage rate of the selected cluster node after the logical unit number is allocated is lower than a fourth preset value, and the fourth preset value is greater than the third preset value; The third strategy includes selecting all cluster nodes that meet the second restriction condition when the first strategy and the second strategy cannot be met, and the capacity utilization rate of the selected cluster nodes after allocating logical unit numbers is lower than a fifth preset value, and the fifth preset value is greater than the fourth preset value.
4. The data distribution method according to claim 3, characterized in that: Selecting the first cluster node according to the capacity restriction condition and the selection strategy includes: Calculating a first capacity usage rate after the distributed storage allocates space for the logical unit number; If the first capacity usage rate exceeds the first preset value, an error message indicating that the cluster capacity is insufficient is returned.
5. The data distribution method according to claim 4, characterized in that: After calculating the first capacity usage rate after the distributed storage allocates space for the logical unit number, the method further includes: If the first capacity utilization rate does not exceed the first preset value, determining, in the distributed storage, a second cluster node whose capacity utilization rate is lower than the second preset value; Sorting the second cluster nodes in descending order of priority of the cluster nodes to obtain a third cluster node; Selecting a first number of first candidate cluster nodes from the third cluster nodes, where the first number is a sum of the number of replicas and 1; Calculating a second capacity usage rate after the first candidate cluster node allocates space for the logical unit number; If the second capacity usage rate is lower than the third preset value, using the first candidate cluster node as the first cluster node; The higher the available capacity of a cluster node is, the higher the priority of the cluster node is.
6. The data distribution method according to claim 5, characterized in that: After calculating the second capacity usage rate after the first candidate cluster node allocates space for the logical unit number, the method further includes: If the second capacity usage rate is greater than or equal to the third preset value, selecting a cluster node that has not been selected from the third cluster nodes and adding it to the first candidate cluster nodes to obtain a second candidate cluster node; Calculating a third capacity usage rate after the second candidate cluster node allocates space for the logical unit number; If the third capacity usage rate is lower than the fourth preset value, the second candidate cluster node is used as the first cluster node.
7. The data distribution method according to claim 6, characterized in that: After calculating the third capacity usage rate after the second candidate cluster node allocates space for the logical unit number, the method further includes: If the third capacity usage rate is greater than or equal to the fourth preset value, selecting a second number of third candidate cluster nodes from the third cluster nodes; Calculating a fourth capacity usage rate after the third candidate cluster node allocates space for the logical unit number; Repeat the steps of: if the fourth capacity usage rate is lower than the fourth preset value, then dividing the cluster node into two within the range of (C+1, S) and the third candidate cluster node to form a fourth candidate cluster node; if the fourth capacity usage rate is greater than or equal to the fourth preset value, then dividing the cluster node into two within the range of (S, N) and the third candidate cluster node to form a fourth candidate cluster node, until the fourth candidate cluster node satisfies the second strategy, and the fourth candidate cluster node is used as the first cluster node; The process of determining the second number includes: S=C+1+((NC-1)) / 2, where S represents the second number, C represents the number of copies, and N represents the total number of cluster nodes.
8. The data distribution method according to claim 7, characterized in that: After determining the first distribution result of the logic data block on the first cluster node according to the first operation result, the method further includes: Determining an expansion strategy for expanding the logical unit number; According to the capacity restriction condition and the capacity expansion strategy, the first cluster node is adjusted to obtain a fourth cluster node, and the first distribution result is adjusted.
9. The data distribution method according to claim 8, characterized in that: The capacity expansion strategy includes not adjusting the first distribution result if the capacity usage rate of the cluster node where the logical unit number is located after the expansion is less than a sixth preset value, otherwise adjusting the first distribution result.
10. The data distribution method according to claim 9, characterized in that: According to the capacity restriction condition and the capacity expansion strategy, the first cluster node is adjusted to obtain a fourth cluster node, including: After the logical unit number is expanded, it is detected whether the remaining capacity of the distributed storage meets the first restriction condition. If not, an error message indicating that the cluster capacity is insufficient is returned.
11. The data distribution method according to claim 10, characterized in that: After detecting whether the remaining capacity of the distributed storage meets the first restriction condition after the logical unit number is expanded, the method further includes: If satisfied, analyzing the type of the logical unit number; If the logical unit number is a non-localized logical unit number, calculating a first ideal value of the capacity utilization rate of the first cluster node after the logical unit number is expanded, and if the first ideal value is greater than or equal to the sixth preset value, adjusting the first cluster node according to the second cluster node to obtain the fourth cluster node; If the logical unit number is a localized logical unit number, the remaining logical data blocks that cannot be placed in the localized cluster node are determined, and a second ideal value corresponding to the remaining logical data blocks and the non-localized cluster nodes in the first cluster node is calculated; if the second ideal value is greater than or equal to the sixth preset value, the first cluster node is adjusted according to the second cluster node to obtain the fourth cluster node.
12. The data distribution method according to claim 11, characterized in that: The step of adjusting the first cluster node according to the second cluster node to obtain the fourth cluster node includes: Determining, among the second cluster nodes, a fifth cluster node that does not belong to the first cluster node; Sorting the fifth cluster nodes in descending order of priority of the cluster nodes to obtain a sixth cluster node; Calculate the pre-occupancy value of each cluster node in the first cluster node, and if there is a pre-occupancy value that is greater than the expansion value of the logical unit number, select a cluster node from the sixth cluster node and combine it with the first cluster node to obtain the fourth cluster node; The pre-occupied value includes a value obtained by multiplying the ideal value by the cluster node capacity minus the cluster node's used capacity.
13. The data distribution method according to claim 1, characterized in that: After determining the first distribution result of the logic data block on the first cluster node according to the first operation result, the method further includes: Determining a capacity utilization rate of each cluster node in the first cluster node; Determining a second difference between the highest capacity utilization and the lowest capacity utilization of the first cluster node; In response to the second difference exceeding the second threshold, the number of the first virtual nodes is adjusted, and the first distribution result is adjusted, and the step of determining the capacity utilization rate of each cluster node in the first cluster node is returned to execute until the second difference does not exceed the second threshold.
14. The data distribution method according to claim 1, characterized in that: After determining the first distribution result of the logic data block on the first cluster node according to the first operation result, the method further includes: Obtaining information on changes in the number of cluster nodes in the distributed storage; The number of the first virtual nodes is adjusted according to the number change information, and the first distribution result is adjusted.
15. The data distribution method according to claim 1, characterized in that: After determining the first distribution result of the logic data block on the first cluster node according to the first operation result, the method further includes: Obtaining disk change information of cluster nodes in the first cluster node; The number of the first virtual nodes is adjusted according to the disk change information, and the first distribution result is adjusted.
16. The data distribution method according to claim 1, characterized in that: After determining the first distribution result of the logic data block on the first cluster node according to the first operation result, the method further includes: Record the number of the first cluster nodes and the first virtual nodes corresponding to the logical unit number.
17. A data distribution system, characterized in that: include: A first determination module is used to determine the logical unit number to be deployed in the distributed storage; A first selection module, configured to select a first cluster node for deploying the logical unit number in the distributed storage; A first segmentation module, used for segmenting the logical unit number into logical data blocks; A first generating module, configured to generate a first virtual node in the first cluster node; A first operation module, configured to perform a consistent hash operation on the logical data block and the first virtual node to obtain a first operation result; A second determining module, configured to determine a first distribution result of the logic data block on the first cluster node according to the first operation result; A second adjustment module is used to determine, in the distributed storage, all seventh cluster nodes where no complete copy of the localized logical unit number is placed, and determine, among the seventh cluster nodes, a first target cluster node with the largest capacity usage rate; Determining whether the capacity usage rate of the first target cluster node is greater than a seventh preset value; If it is greater than, calculating a first difference between the highest capacity utilization rate and the lowest capacity utilization rate of the seventh cluster node; In response to the first difference exceeding a first threshold, reducing the number of virtual nodes on the first target cluster node, increasing the number of virtual nodes on other cluster nodes, and obtaining a second virtual node, wherein the other cluster nodes include cluster nodes in the first cluster node other than the first target cluster node; The first distribution result is adjusted according to the second virtual node, and corresponding data migration is performed on the first cluster node.
18. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the data distribution method according to any one of claims 1 to 16 are implemented.
19. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the data distribution method according to any one of claims 1 to 16 when executing the computer program.
20. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the data distribution method according to any one of claims 1 to 16 are implemented.
