Static partition data migration method and system for distributed storage system
By dividing the migration and migration of disks in a distributed storage system and determining the data volume threshold based on the capacity threshold and water level line, the data migration problem caused by uneven disk capacity is solved, and the load balancing of disks and space utilization optimization is achieved.
Patent Information
- Application Number
- CN202411979811.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-04-01
- Estimated Expiration
- 2044-12-30
AI Technical Summary
Existing distributed storage systems are difficult to effectively determine disk data migration in scenarios with uneven disk capacity, resulting in the problem of insufficient disk space.
By dividing the disks of the storage node into a set of migrated disks and a set of migrated disks, the data volume threshold is determined based on the disk capacity threshold and the current water level line, and then the migration plan for the distributed storage system is generated.
In scenarios with uneven disk capacity, better plan the distribution of disk data, avoid insufficient disk space in actual migration, and realize load balancing of disks.
Smart Images

Figure CN119376655B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of distributed storage systems, and in particular to a static partition data migration method for a distributed storage system and a distributed storage system. Background Art
[0002] A distributed storage system is a storage system that stores data in multiple independent computers (nodes). These nodes are connected through a network and work together to provide data storage and access services. In a distributed storage system, physical storage space is generally allocated to the data generated by the applications / virtual machines installed on the nodes according to the principle of load balancing. In related technologies, load balancing strategies usually use the average data load of the disk to measure the migration of data in and out, but this method may cause some boundary conditions to be unable to be handled. For example, when the capacity of the disk is less than the average data load, continuing to migrate subsequent data may cause the disk to overflow. Summary of the invention
[0003] The purpose of this application is to provide a static partition data migration method for a distributed storage system, which is conducive to better determining disk data migration in scenarios with uneven disk capacity and avoiding insufficient disk space during actual migration.
[0004] Based on the above purpose, the present application provides a static partition data migration method for a distributed storage system, the distributed storage system includes multiple storage nodes, and the method includes:
[0005] The disks of each storage node are divided into an incoming disk set and an outgoing disk set, and the disk division method includes: for at least one disk, determining the data volume threshold of the disk based on the capacity threshold of the disk and the current watermark, determining whether the disk is an incoming disk or an outgoing disk according to the data volume threshold and the current load of the disk, and then obtaining the incoming disk set and the outgoing disk set, wherein the current watermark is determined based on the current load of the disk participating in the watermark update this time;
[0006] Based on the set of disks to be migrated in and the set of disks to be migrated out, a migration plan for the distributed storage system is determined.
[0007] Furthermore, each storage node includes at least one solid-state hard disk and at least one mechanical hard disk, at least one solid-state hard disk of the multiple storage nodes is defined as a disk of a primary partition, and at least one mechanical hard disk of the multiple storage nodes is defined as a disk of a replica partition, and the method further includes:
[0008] In response to the current disk information and the target disk information of each storage node, determining the type of task to be performed, wherein the task type is at least one of the following: load balancing, capacity expansion, and capacity reduction;
[0009] In response to the task type being load balancing or capacity expansion, the disks of the primary partition are divided into a first migration-in disk set and a first migration-out disk set based on the disk partitioning method, and the disks of the replica partition are divided into a second migration-in disk set and a second migration-out disk set;
[0010] In response to the task type being shrinkage, adding the shrunken disk of the primary partition to the first evacuated disk set, and adding the shrunken disk of the replica partition to the second evacuated disk set;
[0011] For any first migration-out disk in the first migration-out disk set, based on the current load and data volume threshold of the first migration-out disk and based on the current load and data volume threshold of the first migration-in disk to be migrated, a migration plan of the first migration-out disk is determined, thereby obtaining a migration plan of the primary partition;
[0012] For any second-migrated disk in the second-migrated disk set, based on the current load and data volume threshold of the second-migrated disk and based on the current load and data volume threshold of the migrated second disk, a migration plan of the second-migrated disk is determined, thereby obtaining a migration plan for the replica partition;
[0013] Based on the migration plan of the primary partition and the migration plan of the replica partition, a migration plan of each storage node is determined to generate a migration plan for the distributed storage system.
[0014] Further, each storage node includes at least one solid-state hard disk and at least one mechanical hard disk, and at least one solid-state hard disk of the multiple storage nodes is defined as a disk of the primary partition, wherein a data volume threshold of the disk is determined based on a capacity threshold of the disk and a current watermark, and whether the disk is a migration-in disk or a migration-out disk is determined according to the data volume threshold and a current load of the disk, including:
[0015] The average current load of all disks in the primary partition is used as the initial watermark;
[0016] If the capacity threshold of any disk of the primary partition is greater than or equal to the initial watermark, the initial watermark is used as the data volume threshold of the disk, wherein the capacity threshold of the disk is determined based on the total capacity of the disk;
[0017] If there is at least one disk whose capacity threshold is smaller than the initial watermark, multiple rounds of iterative updates are performed on the initial watermark, including: if the capacity threshold of the disk is greater than or equal to the current watermark, the capacity threshold of the disk is used as the data volume threshold of the disk, and the disk is determined not to participate in the next round of watermark update, and the quotient of the difference between the current load of all disks minus the capacity threshold of the disk and the number of remaining disks is used as the watermark for the next round, until the capacity thresholds of all disks participating in the watermark update are greater than or equal to the watermark of this round, then the iterative update is stopped, and the watermark of this round is used as the data volume threshold of all disks participating in the watermark update;
[0018] If the data volume threshold of the disk is greater than the current load volume of the disk, the disk is determined to be a migration-in disk; otherwise, the disk is determined to be a migration-out disk.
[0019] Further, for any first-migrated disk in the first-migrated disk set, determining the first-migrated disk to be migrated, and determining a migration plan for the first-migrated disk based on the current load and data volume threshold of the first-migrated disk and the current load and data volume threshold of the first-migrated disk, including:
[0020] Sort the first-migrated disks in the first-migrated disk set from large to small according to the current load of the disk, with the shrunk disk being prioritized at the front, to obtain a sorted first-migrated disk set;
[0021] Sorting the first migration disks in the first migration disk set from small to large according to the current load of the disk, to obtain a sorted first migration disk set;
[0022] Based on the sorted first migration-out disk set, migration calculations are performed on the first migration-out disks in turn. For the currently selected first migration-out disk, a first migration-in disk to be migrated is selected from the sorted first migration-in disk set, and a current migration plan for the first migration-out disk is determined. The current migration plan includes:
[0023] The data quota for this migration is determined based on the data volume threshold of the first migration-out disk and the current load, and the data quota for this migration-in is determined based on the data volume threshold of the first migration-in disk and the current load, and the minimum value of the data quota for this migration-out and the data quota for this migration-in is selected as the total data quota for this migration;
[0024] Based on the total amount of data for this migration and the backpack algorithm, the optimal number of migration partitions is determined, and the optimal number of migration partitions is backtracked to determine the migration partitions for this migration of the first migration disk;
[0025] A migration plan of the first migrated-out disk is determined based on each migrated-out partition of each migration of the first migrated-out disk and the first migrated-in disk to be migrated.
[0026] Further, for any first-migrated disk in the first-migrated disk set, determining the first-migrated disk to be migrated, and determining a migration plan for the first-migrated disk based on the current load and data volume threshold of the first-migrated disk and the current load and data volume threshold of the first-migrated disk, including:
[0027] If the first disk to be migrated out is a reduced disk, and the amount of data to be migrated out of the reduced disk is less than the amount of data to be migrated into the first disk to be migrated into, the step of determining the optimal number of partitions to be migrated out is not performed, and all the data of all partitions of the first disk to be migrated out are directly migrated out to the first disk to be migrated into;
[0028] and / or,
[0029] If the first migration disk is a reduced capacity disk, after all the migration partitions of the first migration disk are determined, it is determined whether the first migration disk has residual partitions. If there are residual partitions, a migration plan for each residual partition is determined based on a greedy migration strategy.
[0030] Furthermore, the migration plan for each residual partition is determined based on the greedy migration strategy, including:
[0031] The first migration disk is determined by adopting the principle of migrating the residual partitions to the first migration disk with the smallest current load first;
[0032] Based on the data volume of the residual partition and the current load volume of the selected first migration disk, determine the total load volume of the selected first migration disk after adding the residual partition, if the total load volume is less than the capacity threshold of the selected first migration disk, determine to migrate the residual partition to the first migration disk, and update the current load volume of the first migration disk;
[0033] After each residual partition is migrated, the first migrated disks are reordered from small to large according to the current load of the disks.
[0034] Further, based on the total amount of data for this migration and the backpack algorithm, the optimal number of migration partitions is determined, and the optimal number of migration partitions is backtracked to determine each migration partition of the first migration disk for this migration, including:
[0035] Set the total amount of data for this migration to q, define a two-dimensional array dp[i][j], which represents the maximum value of the first i partitions under the data amount j, and the state transfer equation is:
[0036] dp[i][j]= Max(dp[i - 1][j], dp[i - 1][j - v[i]]+ w[i]);
[0037] Where v[i] represents the data volume of the i-th partition, and w[i] represents the value of the i-th partition;
[0038] Poll all partitions of the first migrated disk to obtain an optimal solution dp[n][q] that indicates that the sum of the data amounts of n partitions is closest to the total data amount q;
[0039] Starting from the optimal solution dp[n][q], we trace back step by step and store dp[n][q] in a variable totalValue. For each iteration: we compare dp[i][j] and dp[i - 1][j]. If they are equal, the i-th partition is not determined as the migration partition. If they are not equal, the i-th partition is determined as the migration partition. We add the i-th partition to the list of selected migration partitions and update the variables totalValue and value to determine the state before putting it into the i-th partition:
[0040] totalValue = totalValue-v [i - 1];
[0041] j = j - w[i - 1];
[0042] Continue to execute the next round of iteration until totalValue = 0, then stop the iteration and determine the partitions to be migrated in the first migration disk;
[0043] The actual data volume of this migration is determined based on the sum of the data volumes of all the partitions to be migrated out of this migration;
[0044] The current load of the first migration-out disk is updated based on the actual data volume of the current migration, and the current load of the first migration-in disk is updated.
[0045] Furthermore, the storage nodes allocated to each primary partition are different from the storage nodes of the replica partitions corresponding to the same primary partition, and the storage nodes allocated to the replica partitions corresponding to the same primary partition are different; the number of backup copies is less than the number of storage nodes, wherein before determining the migration plan of the replica partition, the steps include:
[0046] If the first migrated-out disk is migrated to the storage node where the first migrated-in disk is located, and the storage node has a replica partition ID that is the same as the partition ID of the first migrated-out disk, the replica partition is determined as a conflicting replica partition;
[0047] Based on the migration plan of the primary partition, all the conflicting replica partitions determined are defined as the conflicting replica partition set;
[0048] For any conflict replica partition in the conflict replica partition set, the second migration disk to which the conflict replica partition is to be migrated is determined based on the principle that the conflict replica partition is preferentially migrated to the second migration disk with the smallest current load, the disk where the conflict replica partition is located is taken as the source disk of the conflict replica partition, the second disk to which the conflict replica partition is to be migrated is taken as the installation disk of the conflict replica partition, conflict replica migration records of each conflict replica partition are generated, and the current load of each second migration disk after migration is updated, wherein each record in the conflict replica migration record includes at least: the conflict replica partition ID, the source disk of the conflict replica partition, the installation disk of the conflict replica partition, and the amount of data migrated.
[0049] Further, for any second migration-out disk in the second migration-out disk set, a second migration-in disk to be migrated is determined, and a migration plan of the second migration-out disk is determined based on a current load and a data volume threshold of the second migration-out disk and a current load and a data volume threshold of the second migration-in disk, thereby obtaining a migration plan of the replica partition, including:
[0050] For the currently selected second migration-out disk, select the second migration-in disk to be migrated, define all partitions of the second migration-out disk as a first partition set, define partitions of all disks of the primary partition of the storage node where the second migration-in disk is located and partitions of all disks of the replica partition as a second partition set, and define the intersection of the first partition set and the second partition set as a candidate partition set of the second migration-out disk;
[0051] Based on the total amount of data migrated each time by the second migration disk and the backpack algorithm, determine each migration partition of each migration of the second migration disk from the candidate partition set, and then determine the migration plan of the second migration disk;
[0052] Traverse each record in the conflict replica migration record, obtain the conflict replica partition ID, the source disk of the conflict replica partition and the placement disk of the conflict replica partition of the record; if the placement disk of the conflict replica partition is not in the migration plan of the second migration-out disk, use the source disk of the conflict replica partition as the migration-out disk, and use the placement disk of the conflict replica partition as the migration-in disk to determine the migration plan of the conflict replica partition of the record, and then determine the migration plan of the conflict replica partition; if the placement disk of the conflict replica partition is in the migration plan of the second migration-out disk, use the source disk of the conflict replica partition as the migration-out disk, and use the second disk to be migrated in the migration plan of the second migration-out disk as the migration-in disk, so as to update the migration plan of the second migration-out disk;
[0053] Based on the migration plan of the conflicting replica partition and the migration plans of each second migration-out disk, a migration plan of the replica partition is determined.
[0054] Furthermore, the method also includes:
[0055] If the second migration disk is a reduced capacity disk, after all the migration partitions of the second migration disk are determined, the remaining partitions of the second migration disk are determined, and for each remaining partition, a migration plan for the remaining partition is determined based on a greedy migration strategy, including:
[0056] Determine the partition ID of the replica partition where the second migration-out disk is located, traverse each second migration-in disk in the second migration-in disk set, determine the storage node where the second migration-in disk is located for each second migration-in disk, and determine the partition ID set of all primary partitions and all replica partitions under the storage node. If the partition ID exists in the partition ID set, do not select the second migration-in disk;
[0057] Among the selected second migration disks, the principle of preferentially migrating the residual partition to the second migration disk with the smallest current load is adopted to determine the selected second migration disk;
[0058] Based on the data volume of the residual partition and the current load volume of the selected second migration disk, determine the total load volume of the selected second migration disk after adding the residual partition, and if the total load volume is less than the capacity threshold of the second migration disk, determine to migrate the residual partition to the second migration disk;
[0059] After each residual partition is migrated, the second migration disks in the second migration disk set are re-sorted from small to large according to the current load of the disk.
[0060] Based on the above purpose, the present application provides a distributed storage system, which includes multiple storage nodes, each storage node includes at least a processor,
[0061] A processor is used to divide the disks of a storage node into an incoming disk set and an outgoing disk set, wherein the disk division method includes: for at least one disk, determining a data volume threshold of the disk based on the capacity threshold of the disk and a current watermark, determining whether the disk is an incoming disk or an outgoing disk based on the data volume threshold and the current load of the disk, thereby obtaining an incoming disk set and an outgoing disk set, and determining a migration plan of a distributed storage system based on the incoming disk set and the outgoing disk set, wherein the current watermark is determined based on the current load of the disk participating in the watermark update this time.
[0062] Based on the above purpose, the present application provides a computer device, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the steps of the static partition data migration method of the distributed storage system as described above are implemented.
[0063] This application determines the data volume threshold of each disk through disk capacity limitation and watermark algorithm. This data volume threshold is used as the maximum threshold of the data volume migrated into or out of the disk, which is conducive to better planning the distribution of disk data in the scenario of uneven disk capacity, realizing the migration of disk data, avoiding the situation of insufficient disk space in actual migration, and avoiding a series of boundary problems caused by insufficient disk space to achieve disk load balancing. This application implements disk-level load balancing, allowing data migration between disks of the same node or across nodes. The granularity of load balancing is finer, which is more suitable for distributed storage systems with separated storage and computing. BRIEF DESCRIPTION OF THE DRAWINGS
[0064] Figure 1 It is a first flow chart of a static partition data migration method of a distributed storage system provided in an embodiment of the present application;
[0065] Figure 2 It is a second flow diagram of the static partition data migration method of the distributed storage system provided in an embodiment of the present application;
[0066] Figure 3 It is a third flow chart of the static partition data migration method of the distributed storage system provided in accordance with an embodiment of the present application;
[0067] Figure 4 It is a schematic diagram of water level update provided according to an embodiment of the present application;
[0068] Figure 5 It is a fourth flow diagram of a static partition data migration method of a distributed storage system provided in an embodiment of the present application;
[0069] Figure 6 It is a schematic diagram of an iteration of a migration plan for migrating a disk according to an embodiment of the present application;
[0070] Figure 7 is a fifth flow chart of a static partition data migration method for a distributed storage system provided in an embodiment of the present application;
[0071] Figure 8 is a sixth flow chart of a static partition data migration method for a distributed storage system provided in an embodiment of the present application;
[0072] Fig. 9 is a seventh flow chart of a static partition data migration method for a distributed storage system provided in accordance with an embodiment of the present application;
[0073] Fig.10 is an eighth flow chart of a static partition data migration method for a distributed storage system provided in accordance with an embodiment of the present application;
[0074] Fig.11 is a schematic diagram of the structure of a distributed storage system provided according to an embodiment of the present application;
[0075] Fig.12 It is a schematic diagram of the structure of a computer device provided according to an embodiment of the present application. DETAILED DESCRIPTION
[0076] The present application will be described in detail below in conjunction with the specific implementation modes shown in the accompanying drawings, but these implementation modes do not limit the present application. Structural, methodological, or functional changes made by ordinary technicians in the field based on these implementation modes are included in the protection scope of the present application.
[0077] The load balancing strategy of a distributed storage system usually uses the average data load to measure the migration of data in and out. If the disk load is less than the average data load, the disk migrates data in. If the disk load is greater than the average data load, the disk migrates data out. However, this method may cause some boundary conditions to be unable to be handled. For example, if the disk load is less than the average data load, the disk should migrate data in according to the above method. However, if the capacity of the disk is less than the average data load, the average data load threshold will not play a constraining role. If the subsequent data migration continues, it may cause the disk to overflow. Therefore, the present application proposes a static partition data migration method for a distributed storage system, which can avoid the situation of insufficient disk space in actual migration to achieve disk load balancing.
[0078] See also Figure 1 , Figure 1 A schematic flow chart of a static partition data migration method for a distributed storage system provided in one embodiment of the present application is shown. The method includes steps S101 and S102.
[0079] A distributed storage system is a storage system that stores data in a dispersed manner on multiple independent computers (nodes). Static partitioning means that the number of partitions in the logical partitioning stage is fixed. Regardless of whether the partition records increase or decrease, partition splitting and merging are not allowed. This fixed number of partitions is easier to implement and maintain. Static partitioning is usually implemented by performing a modulo operation on the total number of partitions after hashing the partition key. A distributed storage system includes multiple storage nodes, each of which can be set up separately. Each storage node is used to store data. Multiple storage nodes can be connected to each other through the network to form a complete, logically centralized, and physically distributed distributed storage system.
[0080] Exemplarily, each storage node includes at least one solid-state hard disk and at least one mechanical hard disk, at least one solid-state hard disk of multiple storage nodes is defined as a disk of a primary partition, and at least one mechanical hard disk of multiple storage nodes is defined as a disk of a replica partition. The storage node assigned to each primary partition is different from the storage node of the replica partition corresponding to the same primary partition, and the storage nodes assigned to the replica partitions corresponding to the same primary partition are different. In order to ensure that data is not lost, when partitions are assigned in multiple storage nodes of a distributed storage system, there will be multiple primary partitions and replica partitions. The primary partition is used to provide data reading and writing, and the replica partition is used to back up the data of the primary partition. When the storage node where the primary partition is located fails, since the data of the replica partition is complete, a new primary partition can be elected. Therefore, the same node does not allow primary partitions and replica partitions with the same partition ID. In order to improve the efficiency of data reading and writing, all primary partitions are assigned to solid-state hard disks, and all replica partitions are assigned to mechanical hard disks. For example, a storage node is mounted with multiple solid-state hard disks and multiple mechanical hard disks. In the embodiment of the present application, the migration plan of the main partition occurs in the mechanical hard disk of each node in the cluster, and will not affect the copy in the mechanical hard disk. The migration plan of the replica partition occurs in the mechanical disk of each node in the cluster, and will not affect the data of the solid-state hard disk.
[0081] Exemplarily, the number of replicas is less than the number of nodes in the system. For example, if the number of nodes is 2, each partition is allowed to have at most 1 replica. The replica and the primary partition are stored on different disks.
[0082] Step S101, divide the disks of each storage node into an incoming disk set and an outgoing disk set, and the disk division method includes: for at least one disk, determine the data volume threshold of the disk based on the capacity threshold of the disk and the current watermark, determine whether the disk is an incoming disk or an outgoing disk based on the data volume threshold and the current load of the disk, and then obtain an incoming disk set and an outgoing disk set, wherein the current watermark is determined based on the current load of the disk participating in the watermark update this time.
[0083] The data volume threshold of the disk is determined by the watermark algorithm. In the watermark algorithm, the data volume threshold of the disk is determined based on the capacity threshold of the disk and the current watermark. The current watermark is determined based on the current load of the disk participating in the watermark update. That is, the watermark is updated after multiple iterations, and the data volume threshold of the disk is determined based on the watermark after each round of update and the capacity threshold of the disk. Exemplarily, the capacity threshold of the disk can be set to 85% of the total capacity of the disk. According to the data volume threshold and the current load of the disk, it is determined whether the disk is a migration disk or a migration disk, and then the migration disk set and the migration disk set of the distributed storage system are obtained.
[0084] Step S102: determining a migration plan of the distributed storage system based on the migration-in disk set and the migration-out disk set.
[0085] According to the migration-in disk set and the migration-out disk set of the distributed storage system, the migration plan of the distributed storage system can be further determined.
[0086] In this implementation, the data volume threshold of each disk is determined by the watermark algorithm. For the incoming disk, the data volume threshold indicates the maximum threshold of the incoming data volume, and for the outgoing disk, the data volume threshold indicates the maximum threshold of the outgoing data volume. When the partition migration algorithm is subsequently calculated, it will not exceed the range specified by the threshold, and a series of boundary problems caused by insufficient disk space can be avoided. This solution is adjusted according to the disk capacity limit, which is conducive to better determining data migration in scenarios with uneven disk capacity and avoiding the situation of insufficient disk space in actual migration. This implementation implements disk-level load balancing, allowing data migration between disks of the same node or across nodes. Compared with the node-level granularity, its granularity is finer and more suitable for distributed storage systems with separated storage and computing.
[0087] In some embodiments, Figure 2 As shown, the method also includes:
[0088] Step S201, in response to the current disk information and the target disk information of each storage node, determining the type of task to be executed, wherein the task type is at least one of the following: load balancing, capacity expansion, and capacity reduction.
[0089] Get the current disk information and target disk information of each storage node, determine the disk change information based on the current disk information and target disk information, and then determine the type of task to be performed. The target disk information can be understood as the disk information of each storage node in the distributed storage system after load balancing / expansion / reduction.
[0090] Exemplarily, the current disk information includes the information of each disk under the storage node and the partition information under each disk. <String, Map<String, DiskInfo> >Struct encapsulation, where the first generic String is the node ID, the second String is the disk ID, and DiskInfo is a class that encapsulates disk space information, including attributes such as remaining disk space, total disk capacity, disk type (SSD or HDD), and disk partition load. The target disk information can be obtained using a Map <String, List <string>>Type structure encapsulation, the generic Key is the node ID, and the Value is a list of disk paths mounted under the node, which is used to indicate the various disks under the node.
[0091] Exemplarily, the type of task to be performed can be determined by determining the disk change information based on the current disk information and the target disk information. If the node and the disk have not changed, the task type is load balancing. If there is an increase in nodes / disks, the task type is capacity expansion; if there is a decrease in nodes / disks, the task type is capacity reduction. Since capacity expansion is essentially load balancing for empty nodes newly added to the system, this application treats load balancing and capacity expansion as the same type of task processing.
[0092] For the task type of load balancing / capacity expansion, a parameter of a load balancing coefficient is obtained. The load balancing coefficient is used to indicate the degree of balance that the user expects the system to achieve. If the system reaches this degree of balance in advance when iteratively calculating the migration plan, a migration plan is generated. In the embodiment of the present application, the degree of load balancing of the system disk is measured based on information entropy. The calculation formula of information entropy H(X) is as follows:
[0093] ;
[0094] in, It is expressed as the load level of the i-th disk. It represents the ratio of the load of the i-th disk to the load of all disks, that is:
[0095] ;
[0096] The higher the entropy value of information entropy, the more balanced the system load is. The load balancing coefficient is an evaluation coefficient of the standardized entropy value. The standardized entropy value is the information entropy value normalized to the range of [0,1]. If the number of disks currently participating in the information entropy calculation is n, the standardized entropy value is:
[0097] ;
[0098] In the subsequent iteration process, if the normalized entropy value calculated in the current iteration is greater than or equal to the load balancing coefficient, it means that the balance degree of the disks in the system meets the user's expectations, the iteration process ends, and a disk migration plan can be generated.
[0099] Step S202, in response to the task type being load balancing or capacity expansion, the disks of the primary partition are divided into a first migration-in disk set and a first migration-out disk set based on the disk partitioning method, and the disks of the replica partition are divided into a second migration-in disk set and a second migration-out disk set.
[0100] If the task type is load balancing or capacity expansion, each disk of the primary partition is divided into a first migration-in disk set and a first migration-out disk set. If the primary partition has a corresponding replica partition, the disk of the replica partition is divided into a second migration-in disk set and a second migration-out disk set.
[0101] Step S203 , in response to the task type being shrinking, adding the shrinking disk of the primary partition to the first migration-out disk set, and adding the shrinking disk of the replica partition to the second migration-out disk set.
[0102] In response to the task type being shrinkage, the shrunk disk of the primary partition is determined as the first emigrated disk and added to the first emigrated disk set, and the shrunk disk of the replica partition is determined as the second emigrated disk and added to the second emigrated disk set.
[0103] Step S204, for any first-migrated disk in the first-migrated disk set, based on the current load and data volume threshold of the first-migrated disk and the current load and data volume threshold of the first-migrated disk to be migrated, determine the migration plan of the first-migrated disk, and then obtain the migration plan of the primary partition.
[0104] Based on the first set of disks to be migrated out and the first set of disks to be migrated in of the primary partition, determine the migration plan of the primary partition. If the task type is load balancing / capacity expansion, calculate the standardized entropy value of the disk load of the current primary partition. If the standardized entropy value is less than the load balancing coefficient, it is necessary to iterate the disk migration of the primary partition, that is, to generate subsequent migration plans for the primary partition. It should be noted that after the migration plan for each disk to be migrated out is generated, the standardized entropy value of the disk load of the current primary partition will be calculated. If the task type is capacity reduction, the load balancing coefficient is meaningless, because the purpose of capacity reduction is to transfer all partitions in the reduced disk to the remaining disks. If this coefficient is used, the cluster will become more unbalanced during the iteration process. Therefore, capacity reduction will only calculate the standardized entropy value of one remaining disk after the iteration.
[0105] For any first-migrated disk in the first-migrated disk set, the amount of data to be migrated of the first-migrated disk and the first-migrated disk to be migrated are determined based on the current load and data volume threshold of the first-migrated disk. For the currently selected first-migrated disk, iterative calculation is performed with each first-migrated disk in the first-migrated disk set, and the partition to be migrated in the first-migrated disk is selected. After multiple iterations, the first-migrated disk iteratively completes the migration into the first-migrated disk set, thereby determining the migration plan of the first-migrated disk, and iterative migration calculation is performed on each first-migrated disk in turn. When the iterative calculation of all disks in the first-migrated disk set is completed, the migration plan of the primary partition is obtained, and the standardized entropy value of the disk load of the system primary partition is updated, but the shrunken disk is not included.
[0106] Step S205, for any second migrated disk in the second migrated disk set, based on the current load and data volume threshold of the second migrated disk, and based on the current load and data volume threshold of the migrated second disk, determine the migration plan of the second migrated disk, and then obtain the migration plan of the replica partition.
[0107] Distributed storage systems will consider using tiered storage to ensure high availability of the system while reducing costs. Tiered storage means that in a distributed storage system, data is stored on storage media with different performance and costs based on data access frequency, importance, and other characteristics. As mentioned earlier, tiered storage usually assigns all primary partitions to solid-state drives and all replica partitions to mechanical hard disks. Therefore, this embodiment proposes a migration plan for replica partitions to implement a plan for simultaneous migration of primary and replica partitions. Based on the second set of outbound disks and the second set of inbound disks for the replica partition, a migration plan for the replica partition is determined. The implementation method of the migration plan for the replica partition is similar to that of the primary partition migration, and will not be repeated here.
[0108] Step S206: Determine the migration plan of each storage node based on the migration plan of the primary partition and the migration plan of the replica partition to generate a migration plan for the distributed storage system.
[0109] According to the migration plan of the primary partition and the migration plan of the replica partition, the migration path of each disk of the primary partition is determined, that is, the migration path of the disk to be migrated out of the primary partition and the corresponding migration path of the disk to be migrated in, and the migration path of each disk of the replica partition is determined, that is, the migration path of the disk to be migrated out of the replica partition and the corresponding migration path of the disk to be migrated in, and then the migration path of each migrated disk and the migrated disk under each storage node can be determined, that is, the migration plan of each storage node is determined, so as to generate the migration plan of the distributed storage system. The migration plan is returned to the load balancer of the distributed storage system for actual data migration, and the standardized entropy value of the primary partition disk and the standardized entropy value of the replica partition disk in the final state of the system are output to provide users with evaluation of whether the load balancing has achieved the expected effect.
[0110] The load balancing strategy in this embodiment supports hierarchical storage and can generate a migration plan that supports load balancing of both the primary partition and the replica partition. In the load balancing strategy, the migration plan of the primary partition occurs in the mechanical hard disk of each node in the system and will not affect the replica in the mechanical hard disk. The migration plan of the replica partition occurs in the mechanical disk of each node in the system and will not affect the data of the solid-state hard disk.
[0111] In one embodiment, the determination of the migration disk and the migration disk is described by taking the disk of the primary partition as an example. The implementation method of the disk of the replica partition is similar to that of the disk of the primary partition, and will not be described in detail here. Figure 3 As shown, the data volume threshold of the disk is determined based on the capacity threshold of the disk and the current watermark, and the disk is determined to be a migration-in disk or a migration-out disk according to the data volume threshold and the current load of the disk, including:
[0112] Step S301, taking the current load average of all disks of the primary partition as the initial watermark;
[0113] Step S302, if the capacity threshold of any disk of the primary partition is greater than or equal to the initial watermark, the initial watermark is used as the data volume threshold of the disk, wherein the capacity threshold of the disk is determined based on the total capacity of the disk;
[0114] Step S303, if there is at least one disk whose capacity threshold is smaller than the initial water level, perform multiple rounds of iterative updates on the initial water level, and for each round of iterative updates of the water level, include: if the capacity threshold of the disk is greater than or equal to the current water level, use the capacity threshold of the disk as the data volume threshold of the disk, determine that the disk does not participate in the next round of water level updates, and use the quotient of the difference between the current load of all disks and the capacity threshold of the disk and the number of remaining disks as the water level of the next round, until the capacity thresholds of all disks participating in the water level update are greater than or equal to the water level of this round, stop the iterative updates, and use the water level of this round as the data volume threshold of all disks participating in the water level update;
[0115] Step S304: if the data volume threshold of the disk is greater than the current load volume of the disk, the disk is determined to be a migration-in disk; otherwise, the disk is determined to be a migration-out disk.
[0116] In this embodiment, the water level is updated through multiple iterations, and the data volume threshold of the disk is determined based on the water level updated each time and the capacity threshold of the disk. The water level is determined based on the current load average of the disk updated based on the parameter water level. Therefore, based on the limitation of the disk capacity and the update of the water level, the situation of insufficient disk space in actual migration is avoided, which is conducive to better planning of data distribution in scenarios with uneven disk capacity.
[0117] by Figure 4 As an example, the updating of the watermark and the determination of the data volume threshold of the disk are described in detail. In this embodiment, three disks are taken as an example for explanation. The current load of the first disk is l1, the current load of the second disk is l2, and the current load of the third disk is l3. The total load of the three disks is t = l1+ l2+ l3. The initial watermark is the average load of all disks t / 3. If the capacity thresholds of the three disks are all equal to the initial watermark t / 3, the initial watermark is used as the data volume threshold of the three disks. If there is at least one disk whose capacity threshold is less than the initial watermark, such as Figure 4 In the state 2 shown, the current load of the first disk, l1, is less than the initial watermark t / 3, indicating that the capacity of the first disk has been submerged by the initial watermark. Therefore, the data volume threshold of the first disk is set to the capacity threshold d1 to ensure that the disk still has space for data writing after load balancing. d1 can be set to 85% of the disk capacity of the first disk. After determining the data volume threshold of the first disk, the first disk no longer parameters the subsequent watermark update, the updated current watermark is (l1+ l2+ l3–d1) / 2, as shown in Figure 4 State 3 shown. Based on the current water level (l1+ l2+l3–d1) / 2, the judgment is made, such as Figure 4 In the state 4 shown, the current load of the second disk, l2, is less than the current watermark (l1+ l2+ l3–d1) / 2, and the capacity of the second disk is submerged by the updated watermark. Therefore, the data volume threshold of the second disk is set to the capacity threshold d2, which can be set to 85% of the disk capacity of the second disk. The second disk no longer participates in the subsequent watermark update, and the updated watermark is (l1+ l2+l3–d1–d2), and further judgment is made. If the updated watermark is higher than the capacity threshold d3 of the third disk, it means that this migration may cause data overflow, and the program returns an abnormal exit. If the updated watermark is not higher than the capacity threshold d3 of the third disk, the data volume threshold of the third disk is set to the updated watermark (l1+ l2+l3–d1–d2). Determine the data volume threshold of all disks, and judge whether the disk is a migration-in disk or a migration-out disk based on the data volume threshold, that is, the disk whose data volume threshold is greater than the current load of the disk is a migration-out disk, and the disk whose data volume threshold is less than or equal to the current load of the disk is a migration-in disk. In the above use case, the first and second disks are added to the migration disk set, and the third disk is added to the migration disk set. When the task type is shrinking, the data volume threshold of the disk to be shrunk is set to 0, and it does not participate in the watermark update, and is added to the migration disk set.
[0118] In some embodiments, Figure 5 As shown, for any first-migrated disk in the first-migrated disk set, determining the first-migrated disk to be migrated, and determining the migration plan of the first-migrated disk based on the current load and data volume threshold of the first-migrated disk and the current load and data volume threshold of the first-migrated disk, including the steps of:
[0119] Step S501, sorting the first migration-out disks in the first migration-out disk set from large to small according to the current load of the disk, with the reduced capacity disk being prioritized at the front, to obtain a sorted first migration-out disk set;
[0120] Step S502, sorting the first migration disks in the first migration disk set from small to large according to the current load of the disk, to obtain a sorted first migration disk set;
[0121] Step S503, based on the sorted first migration-out disk set, migration calculations are performed on the first migration-out disks in sequence, and for the currently selected first migration-out disk, a first migration-in disk to be migrated is selected from the sorted first migration-in disk set, and a current migration plan for the first migration-out disk is determined. The current migration plan includes:
[0122] Step S5031, determining the data quota for this migration out based on the data volume threshold of the first migration-out disk and the current load, determining the data quota for this migration-in based on the data volume threshold of the first migration-in disk and the current load, and selecting the minimum value of the data quota for this migration out and the data quota for this migration-in as the total data quota for this migration;
[0123] Step S5032, based on the total amount of data to be migrated this time and the backpack algorithm, determine the optimal number of migrated partitions, trace back the optimal number of migrated partitions, and determine the various migrated partitions of the first migrated disk for this migration;
[0124] Step S504: determining a migration plan of the first migrated-out disk based on each migrated-out partition of the first migrated-out disk and the first migrated-in disk to be migrated.
[0125] Exemplarily, the data quota for this migration is determined based on the difference between the data volume threshold of the first migration-out disk and the current load volume, and the data quota for this migration-in is determined based on the difference between the data volume threshold of the first migration-in disk and the current load volume. The data quota for this migration is determined based on the data quota for this migration-out and the data quota for this migration-in, that is, the minimum value of the data quota for this migration-out and the data quota for this migration-in is used as the total data quota for this migration.
[0126] In the embodiment of the present application, based on the sorted first migration disk set, each first migration disk is iteratively calculated in turn, and the migration calculation is performed for the currently selected first migration disk and each first migration disk in the sorted first migration disk set. Based on the data quota of the first migration disk this time, based on the data quota of the first migration disk this time, the data quota of this migration is determined, and the number of migration partitions required to be closest to the total data quota of this migration is calculated using the backpack algorithm, and backtracking is performed to determine each migration partition selected by the first migration disk. Based on each migration partition obtained in each migration and the first migration disk to be migrated, the migration plan of the first migration disk is determined, and so on, each migration disk in the first migration disk set is iterated to obtain the migration plan of each first migration disk, that is, to determine the migration plan of the main partition. The migration plan can understand which partitions the first migration disk selects for data migration and the first migration disk to be migrated, that is, the migration path. If the task type is load balancing / capacity expansion, after determining the migration plan of the first migrated disk, calculate the standardized entropy value of the disk load of the current primary partition. If the standardized entropy value is greater than or equal to the load balancing coefficient, it means that the system has reached the expected balance level at this time, and the iterative calculation of the migration plan of the first migrated disk set can be exited in advance, otherwise the migration iterative calculation continues. If the task type is capacity reduction, there is no need to calculate the standardized entropy value. If all disks in the first migrated disk set complete the migration plan, update the standardized entropy value of the primary partition, but do not include the reduced disk.
[0127] Traditional load balancing algorithms usually calculate the amount of data in the load, and ultimately achieve a load balancing state for the cluster by transferring the amount of data between nodes. This load balancing algorithm is not applicable to distributed storage systems that use static partitions. This embodiment uses a partition selection algorithm based on dynamic programming to implement partition migration between disks, thereby achieving load balancing at the partition granularity. In the selection of partitions to be migrated from the disk, the backpack algorithm is used to select the optimal solution for the migrated partition, thereby achieving a load balancing effect. This method is more suitable for scenarios in which static partitioned distributed storage systems have hot data in individual partitions that cause partition data to skew. Traditional load balancing methods do not support shrinking. This embodiment not only supports shrinking, but also supports disk-level shrinking, so as to achieve better load balancing effects.
[0128] A specific embodiment of the present application determines the total amount of data for this migration, and selects the partitions in the first migration-out disk. It is necessary to select appropriate partitions so that the sum of the data volumes of the partitions can meet the total amount of data for this migration to the greatest extent. The partition selection problem can be regarded as a 01 knapsack problem, and dynamic programming is used to solve this problem. Specifically, the total amount of data for this migration is set to q, and a two-dimensional array dp[i][j] is defined to represent the maximum value of the first i partitions under the data transfer amount j. v[i] represents the data volume of the i-th partition, and w[i] represents the value of the i-th partition. Since the goal of the algorithm is to calculate the sum of the data volumes of the partitions that are closest to the amount q under a given amount q, the value of each partition is equated with the data volume of each partition. The algorithm's solution process is as follows:
[0129] The initial state of the state transfer. The current state depends on the previous state. It can be understood as starting the decision from the initial state dp[0][0] = 0. There are n partitions, the migration amount is q, q is an integer, and n * q decisions are required. Each decision is to update the state of the i-th partition when the amount of transferred data is j.
[0130] The state transfer process is:
[0131] If j < v[i], it means that there is not enough capacity to select the i-th partition, so the optimal solution for the first i partitions is the optimal solution for the first i-1 partitions, that is:
[0132] dp[i][j] = dp[i - 1][j];
[0133] If j ≥ v[i], there is enough capacity to select the i-th partition, so it is necessary to decide whether to select the i-th partition or not. If the i-th partition is selected, the state transition is:
[0134] dp[i][j]= dp[i - 1][j - v[i]]+ w[i];
[0135] If the i-th partition is not selected, the state transition is: dp[i][j] = dp[i - 1][j];
[0136] That is, the state transfer equation is:
[0137] dp[i][j]= Max(dp[i - 1][j], dp[i - 1][j - v[i]]+ w[i]);
[0138] The decision is how to get the maximum value, so it is necessary to take the maximum value of the above two situations.
[0139] Through the above state transfer equation, we can calculate the partition data volume and the amount closest to the amount q under a given total data amount q. Since the partition data volume and disk data volume are usually expressed as floating point types, such as the data volume of a partition is 15.422G, but the algorithm requires the amount of data transferred to be a discrete integer. Therefore, in actual calculations, it is necessary to convert the floating point type into an integer. Usually, the impact of the capacity below the MB level on the overall load balancing can be ignored. The data volume representation can be enlarged. For example, when it is enlarged 1000 times, the data volume of the partition can be expressed as 15422, so that the data accuracy reaches the MB level, which is used to quantify the subscript of each state.
[0140] Poll all partitions of the first disk to be migrated out. After all states are calculated iteratively, obtain an optimal solution dp[n][q] that represents the sum of the data volume of n partitions that is closest to the total data quota q. This is also the optimal solution for the partitions selected to maximize the amount of migration. In order to obtain which partitions are selected, it is necessary to backtrack the dynamically planned dp table. Backtrack from the optimal solution dp[n][q] and gradually backtrack forward. Store dp[n][q] in the variable totalValue to represent the current capacity. For each round of iteration: mark dp[i][j] and dp[i - 1][j]. If the two are equal, it means that the i-th partition is not selected and the i-th partition is not determined as the partition to be migrated out. If the two are not equal, it means that the maximum value is not inherited from the previous round, which means that the i-th partition is selected and the i-th partition is determined to be the partition to be migrated out. Add the i-th partition to the list of selected partitions to be migrated out. Update the variables totalValue and value to determine the state before the i-th partition is placed.
[0141] totalValue = totalValue-v [i - 1];
[0142] j = j - w[i - 1];
[0143] Set i=i-1 for the next iteration until totalValue = 0, then stop the iteration and determine the various outbound partitions of the first outbound disk for this migration. Determine the actual data volume of this migration based on the sum of the data volumes of the various outbound partitions of this migration. Update the current load of the first outbound disk based on the actual data volume of this migration, and update the current load of the first incoming disk, that is, the updated current load of the first outbound disk is the difference between the current load of the first outbound disk and the actual data volume of this migration, and the updated current load of the first incoming disk is the sum of the current load of the first incoming disk and the actual data volume of this migration. After the current load is updated, even if the current migration plan fails to ideally make the loads of the outbound disk and the incoming disk close to the threshold due to the partition granularity, the migration opportunity will be dynamically given to the next migration plan.
[0144] A specific embodiment of the present application is as follows Figure 6 Assume that the first migration disk set includes the first migration disk D o1 and D o2 , D o1 The current load is 120G, the data volume threshold is 50G, D o2 The current load is 90G, and the data volume threshold is 50G. Assume that the first migration disk set includes the first migration disk D i3 , D i4 and D i5 , D i3 The current load is 0G, the data volume threshold is 50G, D i4 The current load is 10G, the data volume threshold is 50G, D i5 The current load is 30G, and the data volume threshold is 50G. o1 The selected migration disk is D i3 , for D o1 and D i3 Calculate the migration amount and get D o1 The first migration quota q=min(70,50)=50G, for D o1 The partitions in are solved based on the backpack algorithm to obtain the partitions {p1, p3, …, Pk} that meet the maximum migration quota as the migration partitions, and D is obtained through the backtracking algorithm o1 The partitions for the first migration are {P3, P6, …, Pj}. The actual amount of data for the first migration is 47G. Update D o1 The current load is updated to 73G, and D i3 The current load is updated to 47G, generating D o1 The first migration plan is to move from D o1 Move to D i3 , D o1 The migration partitions are {P3, P6, …, Pj}, and the actual data volume of the first migration is 47G. o1 Perform the second disk migration calculation, D o1 The selected migration disk is D i4 , calculate D o1 The first migration quota q=min(23,40)=23G, for D o1 The partitions in are solved based on the backpack algorithm to obtain the partitions {p1, p5, ..., Pk} that meet the maximum migration quota as the migration partitions, and D is obtained through the backtracking algorithm. o1 The partitions for the second migration are {P5, P9, …, Pk}. The actual amount of data for the second migration is 22G. o1 The current load of D is updated to 51G. i4 The current load is updated to 32G, confirming that D o1 The second migration plan is to move from D o1 Move to D i4 , D o1 The migration partitions are {P5, P9, …, Pk}, and the actual data volume of the second migration is 22G. o1 With D i5 The migration amount is D o1 The difference between the current load and the threshold is 1G, but due to D o1 The disk no longer has a partition smaller than 1G, so there is no partition to migrate. o1 The migration plan is completed. Calculate the standard entropy value of the remaining disks. If the standard entropy value is less than the preset load balancing coefficient, continue to migrate disk D. o2 Perform migration iteration calculation. Based on the same implementation method, D o2 Three migration plans were generated, namely the first migration plan from D o2 Move to D i3 The partition for the first migration is {p2}. The actual data volume for the first migration is 1G. The second migration plan starts from D o2 Move to D i4 The partitions for the second migration are {p4, p11, …, Pl}. The actual data volume for the second migration is 17G. The third migration starts from D o2 Move to D i5 The partitions for the third migration are {p7, p13, …, Pm}, and the actual data volume for the third migration is 20G. o1 Migration plan and D o2 The migration plan can generate the migration plan of the primary partition disk, that is, D o1 The migration plan is: from D o1 Move to D i3 , the migration partitions are {P3, P6, …, Pj}, and the actual amount of data migrated is 47G; o1 Move to D i4 , the migration partition is {P5, P9, …, Pk}, and the actual amount of data migrated is 22G; D o2 The migration plan is: from D o2 Move to D i3 The migration partition is {P2}, and the actual amount of data migrated is 1G; o2 Move to D i4 , the migration partition is {P4,P11,…,Pl}, and the actual amount of data migrated is 17G; o2 Move to D i5 The migration partitions are {P7, P13, …, Pm}, and the actual amount of data migrated is 20G.
[0145] In some embodiments, for any first-migrated disk in the first-migrated disk set, determining a first-migrated disk to be migrated, and determining a migration plan for the first-migrated disk based on a current load and a data volume threshold of the first-migrated disk and based on a current load and a data volume threshold of the first-migrated disk, include:
[0146] If the first disk to be migrated out is a reduced capacity disk, and the amount of data to be migrated out of the reduced capacity disk is less than the amount of data to be migrated into the first disk to be migrated in, the step of determining the optimal number of partitions to be migrated out is not performed, and the data of all partitions of the first disk to be migrated out is directly migrated out in full to the first disk to be migrated in. If the first disk to be migrated out is a reduced capacity disk, when the amount of data to be migrated out is less than the amount of data to be migrated in, there is no need to perform the partition selection algorithm of the first disk to be migrated out, and it is only necessary to migrate all partitions in the first disk to be migrated out in full to the first disk to be migrated in, update the current load of the first disk to be migrated out and the current load of the first disk to be migrated in, and adopt a direct and clear implementation method of full migration instead of partition selection.
[0147] In some embodiments, for any first migrated disk in the first migrated disk set, the first migrated disk to be migrated is determined, and based on the current load and data volume threshold of the first migrated disk, and based on the current load and data volume threshold of the first migrated disk, a migration plan of the first migrated disk is determined, including: if the first migrated disk is a reduced capacity disk, after all migrated partitions of the first migrated disk are determined, it is determined whether the first migrated disk has residual partitions, and if there are residual partitions, a migration plan for each residual partition is determined based on a greedy migration strategy.
[0148] In a specific embodiment, Figure 7 As shown in the figure, the migration plan for each residual partition is determined based on the greedy migration strategy, including:
[0149] Step S701, adopting the principle of migrating the residual partition to the first migration disk with the smallest current load first, determining the selected first migration disk;
[0150] Step S702, based on the data volume of the residual partition and the current load volume of the selected first migration disk, determining the total load volume of the selected first migration disk after adding the residual partition, if the total load volume is less than the capacity threshold of the selected first migration disk, determining to migrate the residual partition to the first migration disk, and updating the current load volume of the first migration disk;
[0151] Step S703: after each residual partition is migrated, the first migrated disks are reordered from small to large according to the current load of the disks.
[0152] In this embodiment, if the first disk to be migrated is a reduced capacity disk, it is necessary to determine whether the disk still has residual partitions. Due to the characteristics of the partition granularity, after multiple rounds of iterations, the migration quota may not be able to accommodate a small number of partitions. For this small number of partitions, a greedy migration strategy is adopted. During migration, the remaining partitions in the current reduced capacity disk are greedily allocated in turn, and are preferentially placed in the first migration disk with the smallest current load. Each time a residual partition is migrated, the various migration disks in the first migration disk set are reordered. Since the migration disk is not constrained by the data volume threshold when greedily migrating the residual partition, each time it is migrated, it is necessary to determine whether the current load of the migration disk exceeds the capacity threshold of the disk after migrating the residual partition.
[0153] This implementation is more complicated when processing shrinking tasks. The partition selection algorithm in dynamic planning may not be able to migrate all partitions, and a greedy migration strategy is used to process the remaining partitions.
[0154] After determining the migration plan of the primary partition, determine the migration plan for the replica partition corresponding to the primary partition. However, there may be a situation where, after the primary partition is migrated to a storage node, there may be a replica partition ID in the storage node that is the same as the primary partition ID, resulting in a conflict between the primary partition and the corresponding replica partition on the same storage node. Therefore, the conflicting replica partition needs to be migrated out of the storage node. Figure 8 As shown in the figure, before determining the migration plan for the replica partition, include:
[0155] Step S801, if the first migrated-out disk is migrated to the storage node where the first migrated-in disk is located, and the storage node has a replica partition ID that is the same as the partition ID of the first migrated-out disk, the replica partition is determined as a conflicting replica partition;
[0156] Step S802, based on the migration plan of the primary partition, defining all determined conflicting replica partitions as a conflicting replica partition set;
[0157] Step S803, for any conflict replica partition in the conflict replica partition set, based on the principle of migrating the conflict replica partition to the second migration disk with the smallest current load first, determine the second migration disk to which the conflict replica partition is to be migrated, take the disk where the conflict replica partition is located as the source disk of the conflict replica partition, take the second disk to which the conflict replica partition is to be migrated as the installation disk of the conflict replica partition, generate conflict replica migration records for each conflict replica partition, and update the current load of each second migration disk after migration, wherein each record in the conflict replica migration record includes at least: conflict replica partition ID, source disk of the conflict replica partition, installation disk of the conflict replica partition, and amount of data migrated.
[0158] In an embodiment of the present application, a greedy migration strategy is adopted to migrate the conflicting replica partitions out of the storage node, and each conflicting replica partition is traversed. Under the constraint that there is no replica partition with the same ID on the storage node, the replica partition is preferentially migrated to the node with the largest remaining load, and a conflicting replica migration record is generated. Based on the record, the current load of each second migration disk after migration is updated. It should be noted that the conflicting replica migration record is a logical migration plan, not an actual data migration. The migration record and the subsequent second migration-out disk migration plan together determine the migration plan of the replica partition. It should be noted that after determining the conflicting replica migration record, the current load of each second migration-in disk after migration is updated, and the second migration-in disk set and the second migration-out disk set of the replica partition are further determined.
[0159] In some embodiments of the present application, Fig. 9 As shown, for any second migration-out disk in the second migration-out disk set, determining the second migration-in disk to be migrated, and determining the migration plan of the second migration-out disk based on the current load and data volume threshold of the second migration-out disk, and based on the current load and data volume threshold of the second migration-in disk, the step of determining the migration plan of the replica partition includes:
[0160] Step S901, sorting the second migration-out disks in the second migration-out disk set from large to small according to the current load of the disk, with the reduced capacity disk being prioritized at the front, to obtain a sorted second migration-out disk set;
[0161] Step S902, sorting the second migration disks in the second migration disk set from small to large according to the current load of the disk, to obtain a sorted second migration disk set;
[0162] Step S903, based on the sorted second migration-out disk set, migration calculations are performed on the second migration-out disks in sequence, and for the currently selected second migration-out disk, a second migration-in disk to be migrated is selected from the sorted second migration-in disk set, and a current migration plan for the second migration-out disk is determined. The current migration plan includes:
[0163] Step S9031, defining all partitions of the second migrated-out disk as a first partition set, defining partitions of all disks of the primary partition of the storage node where the second migrated-in disk is located and partitions of all disks of the replica partition as a second partition set, and defining the intersection of the first partition set and the second partition set as a candidate partition set of the second migrated-out disk;
[0164] Step S9032, determining the data quota for this migration out based on the data volume threshold of the second migration-out disk and the current load, determining the data quota for this migration in based on the data volume threshold of the second migration-in disk and the current load, and selecting the minimum value of the data quota for this migration out and the data quota for this migration in as the total data quota for this migration;
[0165] Step S9033, based on the total amount of data for this migration and the backpack algorithm, determine the optimal number of migration-out partitions from the candidate partition set, backtrack the optimal number of migration-out partitions, and determine the migration-out partitions for this migration of the second migration disk;
[0166] Step S904, determining a migration plan of the second migration-out disk based on each migration of the second migration-out disk and the second migration-in disk to be migrated;
[0167] Step S905, traverse each record in the conflict replica migration record, obtain the conflict replica partition ID, the source disk of the conflict replica partition and the placement disk of the conflict replica partition of the record, if the placement disk of the conflict replica partition is not in the migration plan of the second migration-out disk, use the source disk of the conflict replica partition as the migration-out disk, use the placement disk of the conflict replica partition as the migration-in disk, determine the migration plan of the conflict replica partition of the record, and then determine the migration plan of the conflict replica partition; if the placement disk of the conflict replica partition is in the migration plan of the second migration-out disk, use the source disk of the conflict replica partition as the migration-out disk, and use the second disk to be migrated in the migration plan of the second migration-out disk as the migration-in disk, so as to update the migration plan of the second migration-out disk;
[0168] Step S906: Determine a migration plan for the replica partition based on the migration plan for the conflicting replica partition and the migration plans for each second migration-out disk.
[0169] The implementation method of the migration plan for the second migration disk is basically similar to that of the migration plan for the first migration disk, and will not be repeated here. The difference is that in order to ensure the principle that the same storage node does not allow primary partitions and replica partitions with the same partition ID, the candidate partitions of the currently selected second migration disk are restricted. Assuming that the partition set in the second migration disk is A, and the set of all partitions under the node where the second migration disk is located (including the partitions of all disks of the primary partition under the node and the partitions of all disks of the replica partition) is B, then the candidate partition set of the second migration disk is the difference between A and B. When performing partition selection based on dynamic planning, v[i] represents the data volume of the i-th candidate partition, w[i] represents the value of the i-th candidate partition, and other algorithms are consistent with the algorithms for the primary partition, and will not be repeated here. It should be noted that if the second migration disk is a reduced capacity disk, when the amount of data to be migrated is less than the amount of data to be migrated, it is not effective to migrate all the data of the second migration disk.
[0170] When determining the migration of the replica partition, it is necessary to include the conflict replica migration record in the migration plan, traverse each record in the conflict replica migration record, obtain the conflict replica partition ID, the source disk of the conflict replica partition, and the placement disk of the conflict replica partition of the record, if the placement disk of the conflict replica partition is not in the migration plan of the second migration disk, the source disk of the conflict replica partition is actually to be migrated to the placement disk of the conflict replica partition, and the data to be migrated is the data of the conflict replica partition, the source disk of the conflict replica partition is used as the migration disk, and the placement disk of the conflict replica partition is used as the migration disk, and the migration plan of the conflict replica partition of the record is determined, and then the migration plan of the conflict replica partition is determined. If the placement disk of the conflict replica partition is in the migration plan of the second migration disk, that is, the second migration disk contains the placement disk, the source disk of the conflict replica partition is used as the migration disk, and the second disk to be migrated in the migration plan of the second migration disk is used as the migration disk, that is, the disk to which the conflict replica partition is actually to be migrated, and the data to be migrated is the data of the conflict replica partition, so as to update the actual migration path of the conflict replica, and update the migration plan of the second migration disk.
[0171] In a specific embodiment of the present application, it is assumed that the second migration disk set includes the second migration disk F o1 and F o2 , the second migration disk set includes the second migration disk F i3 、F i4 and F i5 , F o1 、F o2 、F i3 、F i4 、F i5 There is only one copy on 5 different storage nodes. o1 The current load is 84G, the data volume threshold is 50G, and F o2 The current load is 76G, the data volume threshold is 50G, and F i3 The current load is 0G, the data volume threshold is 50G, and F i4 The current load is 42G, the data volume threshold is 50G, and F i5 The current load is 48G, and the data volume threshold is 50G. i4 and F i5 If there is a conflict between the replica partition and the primary partition, the conflicting partition is migrated to the remaining placement disks based on the greedy strategy. The conflicting replica migration record is: F i4 Move to F i3 , the migration partition is {p11,p16}, the amount of data to be migrated is 3G, F i5 Move to F i3 , the migration partition is {p8,p24,…,pt}, and the amount of data to be migrated is 8G. Update the current load of the disk, F o1 The current load is 84G, F o2 The current load is 76G, F i3 The current load is 11G, F i4 The current load is 39G, F i5 The current load is 40G. o1 The selected migration disk is F i3 , the candidate partition set is disk F o1 The replica partition is F i3 The difference between the primary partition and the replica partition. o1 and F i3 Calculate the migration quota and get F o1 The first migration quota is 34G. o1 The partitions in are solved based on the backpack algorithm to obtain the partitions {p2, p4, ..., Pk} that meet the maximum migration quota as the migration partitions, and F is obtained through the backtracking algorithm. o1 The partitions to be migrated for the first time are {P2, P7, …, Pl}, and the actual amount of data to be migrated for the first time is 30G. Update the current load of the disk, F o1 The current load is 54G, F i3 The current load is 41G, F o1 The first migration plan is: from F o1 Move to F i3 , the partitions for the first migration are {P2, P7, …, Pl}, and the actual data volume for the first migration is 30G. Based on the same method, we get F o1 The second migration plan and the third migration plan are as follows: o1 Move to F i4 The partition for the second migration is {P10}. The actual data volume for the second migration is 1G. The third migration plan is: o1 Move to F i5 , the partition for the third migration is {P18}, and the actual data volume for the third migration is 1G. Calculate the standard entropy value of the remaining disks. Assuming that the standard entropy value is less than the preset load balancing coefficient, continue to migrate disk F. o2 Perform migration iteration calculation, disk F o2 Generate three migration plans, F o2 The first migration plan is: from F o2 Move to F i3 The partitions for the first migration are {P1, P9, …, Pn}. The actual amount of data for the first migration is 6G. Disk F o2 The second migration plan is: from F o2 Move to F i4 The partitions for the second migration are {P5, P12, …, Ps}. The actual amount of data for the second migration is 8G. Disk F o2 The third migration plan is: from F o2 Move to F i5 , the partitions for the third migration are {P6, P10, …, Pr}, the actual data volume of the first migration is 8G, and the current load of each disk is updated. Combined with the conflict replica migration records, F o1 The relocation plan and F o2 The migration plan of the replica partition is generated by the migration plan of F o1 The migration plan is: from F o1 Move to F i3 The migration partitions are {P2, P7, …, Pl}, and the actual amount of data migrated is 30G. o1 Move to F i4 The migration partition is {P10}, the actual amount of data to be migrated is 1G, and the migration partition is {P10}. o1 Move to F i5 , the migration partition is {P18}, and the actual amount of data migrated is 1G; F o2 The migration plan is: from F o2 Move to F i3 The migration partitions are {P1, P9, ..., Pn}, and the actual amount of data migrated is 6G. o2 Move to F i4 The migration partitions are {P5, P12, …, Ps}, and the actual amount of data migrated is 8G. o2 Move to F i5 , the migration partition is {P6,P10,…,Pr}, and the actual amount of data migrated is 8G; F i4 The migration plan is: i4 Move to F i3 , the migration partition is {p11,p16}, and the amount of data to be migrated is 3G; F i5 The migration plan is: i5 Move to F i3 The migration partition is {p8, p24, …, pt}, and the amount of data to be migrated is 8G.
[0172] In some embodiments of the present application, Fig.10 As shown, the method also includes the steps of:
[0173] Step S1001, determine the partition ID of the replica partition where the second migration-out disk is located, traverse each second migration-in disk in the second migration-in disk set, determine the storage node where the second migration-in disk is located for each second migration-in disk, determine the partition ID set of all primary partitions and all replica partitions under the storage node, if the partition ID exists in the partition ID set, then do not select the second migration-in disk;
[0174] Step S1002, among the selected second migration disks, the principle of preferentially migrating the residual partition to the second migration disk with the smallest current load is adopted to determine the selected second migration disk;
[0175] Step S1003, based on the data volume of the residual partition and the current load volume of the selected second migration disk, determining the total load volume of the selected second migration disk after adding the residual partition, and if the total load volume is less than the capacity threshold of the second migration disk, determining to migrate the residual partition to the second migration disk;
[0176] Step S1004: after each residual partition is migrated, the second migration disks in the second migration disk set are re-sorted from small to large according to the current load of the disk.
[0177] In this embodiment, if the second disk to be migrated is a reduced disk, it is necessary to determine whether the disk still has residual partitions. Compared with the primary partition migration, the replica partition migration may have more residual disk partitions due to the limitation of high availability characteristics, and a greedy migration strategy is used.
[0178] like Fig.11 As shown, a distributed storage system provided by an embodiment of the present application includes multiple storage nodes 11, each storage node includes at least a processor 1101, which is used to divide the disks of the storage node into an incoming disk set and an outgoing disk set, and the disk division method includes: for at least one disk, determining the data volume threshold of the disk based on the capacity threshold of the disk and the current watermark, determining whether the disk is an incoming disk or an outgoing disk according to the data volume threshold and the current load of the disk, and then obtaining an incoming disk set and an outgoing disk set, and based on the incoming disk set and the outgoing disk set, determining the migration plan of the distributed storage system, wherein the current watermark is determined based on the current load of the disk participating in the watermark update this time.
[0179] In this implementation, the data volume threshold of each disk of the primary partition is determined by the watermark algorithm. For the migration disk, the data volume threshold indicates the maximum threshold of the migration data volume, and for the migration disk, the data volume threshold indicates the maximum threshold of the migration data volume. This solution is adjusted according to the disk capacity limit, which is conducive to better planning of data distribution in the scenario of uneven disk capacity and avoiding the situation of insufficient disk space in actual migration.
[0180] Further, each storage node includes at least one solid-state hard disk and at least one mechanical hard disk, at least one solid-state hard disk of the multiple storage nodes is defined as a disk of the primary partition, and at least one mechanical hard disk of the multiple storage nodes is defined as a disk of the replica partition, and the processor 1101 is specifically used to:
[0181] In response to the current disk information and the target disk information of each storage node, determining the type of task to be performed, wherein the task type is at least one of the following: load balancing, capacity expansion, and capacity reduction;
[0182] In response to the task type being load balancing or capacity expansion, the disks of the primary partition are divided into a first migration-in disk set and a first migration-out disk set based on the disk partitioning method, and the disks of the replica partition are divided into a second migration-in disk set and a second migration-out disk set;
[0183] In response to the task type being shrinkage, adding the shrunken disk of the primary partition to the first evacuated disk set, and adding the shrunken disk of the replica partition to the second evacuated disk set;
[0184] For any first migration-out disk in the first migration-out disk set, based on the current load and data volume threshold of the first migration-out disk and based on the current load and data volume threshold of the first migration-in disk to be migrated, a migration plan of the first migration-out disk is determined, thereby obtaining a migration plan of the primary partition;
[0185] For any second-migrated disk in the second-migrated disk set, based on the current load and data volume threshold of the second-migrated disk and based on the current load and data volume threshold of the migrated second disk, a migration plan of the second-migrated disk is determined, thereby obtaining a migration plan for the replica partition;
[0186] Based on the migration plan of the primary partition and the migration plan of the replica partition, a migration plan of each storage node is determined to generate a migration plan for the distributed storage system.
[0187] Furthermore, the processor 1101 is specifically configured to:
[0188] The average current load of all disks in the primary partition is used as the initial watermark;
[0189] If the capacity threshold of any disk of the primary partition is greater than or equal to the initial watermark, the initial watermark is used as the data volume threshold of the disk, wherein the capacity threshold of the disk is determined based on the total capacity of the disk;
[0190] If there is at least one disk whose capacity threshold is smaller than the initial watermark, multiple rounds of iterative updates are performed on the initial watermark, including: if the capacity threshold of the disk is greater than or equal to the current watermark, the capacity threshold of the disk is used as the data volume threshold of the disk, and the disk is determined not to participate in the next round of watermark update, and the quotient of the difference between the current load of all disks minus the capacity threshold of the disk and the number of remaining disks is used as the watermark for the next round, until the capacity thresholds of all disks participating in the watermark update are greater than or equal to the watermark of this round, then the iterative update is stopped, and the watermark of this round is used as the data volume threshold of all disks participating in the watermark update;
[0191] If the data volume threshold of the disk is greater than the current load volume of the disk, the disk is determined to be a migration-in disk; otherwise, the disk is determined to be a migration-out disk.
[0192] Furthermore, the processor 1101 is specifically configured to:
[0193] Sort the first-migrated disks in the first-migrated disk set from large to small according to the current load of the disk, with the shrunk disk being prioritized at the front, to obtain a sorted first-migrated disk set;
[0194] Sorting the first migration disks in the first migration disk set from small to large according to the current load of the disk, to obtain a sorted first migration disk set;
[0195] Based on the sorted first migration-out disk set, migration calculations are performed on the first migration-out disks in turn. For the currently selected first migration-out disk, a first migration-in disk to be migrated is selected from the sorted first migration-in disk set, and a current migration plan for the first migration-out disk is determined. The current migration plan includes:
[0196] The data quota for this migration is determined based on the data volume threshold of the first migration-out disk and the current load, and the data quota for this migration-in is determined based on the data volume threshold of the first migration-in disk and the current load, and the minimum value of the data quota for this migration-out and the data quota for this migration-in is selected as the total data quota for this migration;
[0197] Based on the total amount of data for this migration and the backpack algorithm, the optimal number of migration partitions is determined, and the optimal number of migration partitions is backtracked to determine the migration partitions for this migration of the first migration disk;
[0198] A migration plan of the first migrated-out disk is determined based on each migrated-out partition of each migration of the first migrated-out disk and the first migrated-in disk to be migrated.
[0199] Furthermore, the processor 1101 is specifically configured to:
[0200] If the first disk to be migrated out is a reduced disk, and the amount of data to be migrated out of the reduced disk is less than the amount of data to be migrated into the first disk to be migrated into, the step of determining the optimal number of partitions to be migrated out is not performed, and all the data of all partitions of the first disk to be migrated out are directly migrated out to the first disk to be migrated into;
[0201] and / or,
[0202] If the first migration disk is a reduced capacity disk, after all the migration partitions of the first migration disk are determined, it is determined whether the first migration disk has residual partitions. If there are residual partitions, a migration plan for each residual partition is determined based on a greedy migration strategy.
[0203] Furthermore, the processor 1101 is specifically configured to:
[0204] The first migration disk is determined by adopting the principle of migrating the residual partitions to the first migration disk with the smallest current load first;
[0205] Based on the data volume of the residual partition and the current load volume of the selected first migration disk, determine the total load volume of the selected first migration disk after adding the residual partition, if the total load volume is less than the capacity threshold of the selected first migration disk, determine to migrate the residual partition to the first migration disk, and update the current load volume of the first migration disk;
[0206] After each residual partition is migrated, the first migrated disks are reordered from small to large according to the current load of the disks.
[0207] Furthermore, the processor 1101 is specifically configured to:
[0208] Set the total amount of data for this migration to q, define a two-dimensional array dp[i][j], which represents the maximum value of the first i partitions under the j-th amount of data transferred. The state transfer equation is:
[0209] dp[i][j]= Max(dp[i - 1][j], dp[i - 1][j - v[i]]+ w[i]);
[0210] Where v[i] represents the data volume of the i-th partition, and w[i] represents the value of the i-th partition;
[0211] Poll all partitions of the first migrated disk to obtain an optimal solution dp[n][q] that indicates that the sum of the data amounts of n partitions is closest to the total data amount q;
[0212] Starting from the optimal solution dp[n][q], we trace back step by step and store dp[n][q] in a variable totalValue. For each iteration: we compare dp[i][j] and dp[i - 1][j]. If they are equal, the i-th partition is not determined as the migration partition. If they are not equal, the i-th partition is determined as the migration partition. We add the i-th partition to the list of selected migration partitions and update the variables totalValue and value to determine the state before putting it into the i-th partition:
[0213] totalValue = totalValue-v [i - 1];
[0214] j = j - w[i - 1];
[0215] Continue to execute the next round of iteration until totalValue = 0, then stop the iteration and determine the partitions to be migrated in the first migration disk;
[0216] The actual data volume of this migration is determined based on the sum of the data volumes of all the partitions to be migrated out of this migration;
[0217] The current load of the first migration-out disk is updated based on the actual data volume of the current migration, and the current load of the first migration-in disk is updated.
[0218] Further, the storage node allocated to each primary partition is different from the storage node of the replica partition corresponding to the same primary partition, and the storage nodes allocated to the replica partitions corresponding to the same primary partition are different; the number of backup copies is less than the number of storage nodes, wherein, before determining the migration plan of the replica partition, the processor 1101 is specifically used to:
[0219] If the first migrated-out disk is migrated to the storage node where the first migrated-in disk is located, and the storage node has a replica partition ID that is the same as the partition ID of the first migrated-out disk, the replica partition is determined as a conflicting replica partition;
[0220] Based on the migration plan of the primary partition, all the conflicting replica partitions determined are defined as the conflicting replica partition set;
[0221] For any conflict replica partition in the conflict replica partition set, the second migration disk to which the conflict replica partition is to be migrated is determined based on the principle that the conflict replica partition is preferentially migrated to the second migration disk with the smallest current load, the disk where the conflict replica partition is located is taken as the source disk of the conflict replica partition, the second disk to which the conflict replica partition is to be migrated is taken as the placement disk of the conflict replica partition, conflict replica migration records of each conflict replica partition are generated, and the current load of each second migration disk after migration is updated, wherein each record in the conflict replica migration record includes at least: the conflict replica partition ID, the source disk of the conflict replica partition, and the placement disk of the conflict replica partition.
[0222] Furthermore, the processor 1101 is specifically configured to:
[0223] For the currently selected second migration-out disk, select the second migration-in disk to be migrated, define all partitions of the second migration-out disk as a first partition set, define partitions of all disks of the primary partition of the storage node where the second migration-in disk is located and partitions of all disks of the replica partition as a second partition set, and define the intersection of the first partition set and the second partition set as a candidate partition set of the second migration-out disk;
[0224] Based on the total amount of data migrated each time by the second migration disk and the backpack algorithm, determine each migration partition of each migration of the second migration disk from the candidate partition set, and then determine the migration plan of the second migration disk;
[0225] Traverse each record in the conflict replica migration record, obtain the conflict replica partition ID, the source disk of the conflict replica partition and the placement disk of the conflict replica partition of the record; if the placement disk of the conflict replica partition is not in the migration plan of the second migration-out disk, use the source disk of the conflict replica partition as the migration-out disk, and use the placement disk of the conflict replica partition as the migration-in disk to determine the migration plan of the conflict replica partition of the record, and then determine the migration plan of the conflict replica partition; if the placement disk of the conflict replica partition is in the migration plan of the second migration-out disk, use the source disk of the conflict replica partition as the migration-out disk, and use the second disk to be migrated in the migration plan of the second migration-out disk as the migration-in disk, so as to update the migration plan of the second migration-out disk;
[0226] Based on the migration plan of the conflicting replica partition and the migration plans of each second migration-out disk, a migration plan of the replica partition is determined.
[0227] Furthermore, the processor 1101 is specifically configured to:
[0228] If the second migration disk is a reduced capacity disk, after all the migration partitions of the second migration disk are determined, the remaining partitions of the second migration disk are determined, and for each remaining partition, a migration plan for the remaining partition is determined based on a greedy migration strategy, including:
[0229] Determine the partition ID of the replica partition where the second migration-out disk is located, traverse each second migration-in disk in the second migration-in disk set, determine the storage node where the second migration-in disk is located for each second migration-in disk, and determine the partition ID set of all primary partitions and all replica partitions under the storage node. If the partition ID exists in the partition ID set, do not select the second migration-in disk;
[0230] Among the selected second migration disks, the principle of preferentially migrating the residual partition to the second migration disk with the smallest current load is adopted to determine the selected second migration disk;
[0231] Based on the data volume of the residual partition and the current load volume of the selected second migration disk, determine the total load volume of the selected second migration disk after adding the residual partition, and if the total load volume is less than the capacity threshold of the second migration disk, determine to migrate the residual partition to the second migration disk;
[0232] After each residual partition is migrated, the second migration disks in the second migration disk set are re-sorted from small to large according to the current load of the disk.
[0233] An embodiment of the present application also provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, any of the above-mentioned methods for static partition data migration of a distributed storage system is implemented.
[0234] Fig.12 It is a schematic diagram of the hardware structure of a computer device provided in an embodiment of the present application. Fig.12 The computer device shown includes: a processor 1201, a communication interface 1202, a memory 1203 and a communication bus 1204. The processor 1201, the communication interface 1202 and the memory 1203 communicate with each other via the communication bus 1204. Fig.12 The connection method between the processor 1201, the communication interface 1202, and the memory 1203 shown is merely exemplary. During implementation, the processor 1201, the communication interface 1202, and the memory 1203 may also be connected to each other in communication with each other using other connection methods besides the communication bus 1204.
[0235] The memory 1203 can be used to store a computer program, which may include instructions and data to implement the steps of any of the above static partition data migration methods. In an embodiment of the present application, the memory 1203 may be various types of storage media, such as random access memory (RAM), read only memory (ROM), non-volatile RAM (NVRAM), programmable ROM (PROM), erasable PROM (EPROM), electrically erasable PROM (EEPROM), flash memory, optical storage, and registers. The memory 1203 may include a hard disk and / or a memory.
[0236] The processor 1201 may be a general-purpose processor, which may be a processor that performs specific steps and / or operations by reading and executing a computer program (e.g., a computer program) stored in a memory (e.g., memory 1203). The general-purpose processor may use data stored in the memory (e.g., memory 1203) in the process of performing the steps and / or operations. The general-purpose processor may be, for example, but not limited to, a central processing unit (CPU). In addition, the processor 1201 may also be a special-purpose processor, which may be a processor specially designed to perform specific steps and / or operations. The special-purpose processor may be, for example, but not limited to, an ASIC and an FPGA. In addition, the processor 1201 may also be a combination of multiple processors, such as a multi-core processor.
[0237] The communication interface 1202 may include an input / output (I / O) interface, a physical interface, and a logical interface for interconnecting devices within the network device, as well as an interface for interconnecting the network device with other devices (e.g., network devices). The communication network may be Ethernet, a radio access network (RAN), a wireless local area network (WLAN), etc. The communication interface 1202 may be a module, a circuit, a transceiver, or any device capable of implementing communication.
[0238] In the implementation process, each step of the above method can be completed by an integrated logic circuit of the hardware in the processor 1201 or an instruction in the form of software. The method disclosed in conjunction with the embodiment of the present application can be directly embodied as a hardware processor for execution, or a combination of hardware and software modules in the processor for execution. The software module can be located in a mature storage medium in the art such as a random access memory flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 1203, and the processor 1201 reads the information in the memory 1203 and completes the steps of the above method in conjunction with its hardware. To avoid repetition, it is not described in detail here.
[0239] Although the preferred embodiments of the present application have been disclosed for illustrative purposes, those skilled in the art will appreciate that various modifications, additions and substitutions are possible, without departing from the scope and spirit of the application as disclosed in the accompanying claims.< / string>
Claims
1. A static partition data migration method for a distributed storage system, wherein the distributed storage system comprises a plurality of storage nodes, characterized in that: The method comprises: The disks of each storage node are divided into an incoming disk set and an outgoing disk set, and the disk division method includes: for at least one disk, determining the data volume threshold of the disk based on the capacity threshold of the disk and the current watermark, determining whether the disk is an incoming disk or an outgoing disk according to the data volume threshold and the current load of the disk, and then obtaining an incoming disk set and an outgoing disk set, wherein the current watermark is determined based on the current load of the disk participating in the watermark update this time; Determining a migration plan of the distributed storage system based on the set of disks to be migrated in and the set of disks to be migrated out; Each storage node includes at least one solid-state hard disk and at least one mechanical hard disk, and at least one solid-state hard disk of the plurality of storage nodes is defined as a disk of a primary partition, wherein a data volume threshold of the disk is determined based on a capacity threshold of the disk and a current watermark, and whether the disk is a migration-in disk or a migration-out disk is determined according to the data volume threshold and a current load of the disk, including: The current load average of all disks of the primary partition is used as the initial watermark; If the capacity threshold of any disk of the primary partition is greater than or equal to the initial watermark, the initial watermark is used as the data volume threshold of the disk, wherein the capacity threshold of the disk is determined based on the total capacity of the disk; If there is at least one disk whose capacity threshold is smaller than the initial water level, multiple rounds of iterative updates are performed on the initial water level, and each round of iterative updates of the water level includes: if the capacity threshold of the disk is greater than or equal to the current water level, the capacity threshold of the disk is used as the data volume threshold of the disk, and the disk is determined not to participate in the next round of water level updates, and the quotient of the difference between the current load of all disks minus the capacity threshold of the disk and the number of remaining disks is used as the water level of the next round, until the capacity thresholds of all disks participating in the water level update are greater than or equal to the water level of this round, the iterative update is stopped, and the water level of this round is used as the data volume threshold of all disks participating in the water level update; If the data volume threshold of the disk is greater than the current load volume of the disk, the disk is determined to be a migration-in disk; otherwise, the disk is determined to be a migration-out disk.
2. The static partition data migration method of a distributed storage system according to claim 1, characterized in that: Defining at least one mechanical hard disk of the plurality of storage nodes as a disk of a replica partition, the method further comprising: In response to the current disk information and the target disk information of each storage node, determining the type of task to be performed, wherein the task type is at least one of the following: load balancing, capacity expansion, and capacity reduction; In response to the task type being load balancing or capacity expansion, the disks of the primary partition are divided into a first migration-in disk set and a first migration-out disk set based on the disk division method, and the disks of the replica partition are divided into a second migration-in disk set and a second migration-out disk set; In response to the task type being shrinking, adding the shrunken disk of the primary partition to the first evacuated disk set, and adding the shrunken disk of the replica partition to the second evacuated disk set; For any first migration-out disk in the first migration-out disk set, based on the current load and data volume threshold of the first migration-out disk and based on the current load and data volume threshold of the first migration-in disk to be migrated, a migration plan of the first migration-out disk is determined, thereby obtaining a migration plan of the primary partition; For any second migration-out disk in the second migration-out disk set, based on the current load and data volume threshold of the second migration-out disk and the current load and data volume threshold of the second migration-in disk to be migrated, a migration plan of the second migration-out disk is determined, thereby obtaining a migration plan of the replica partition; Based on the migration plan of the primary partition and the migration plan of the replica partition, a migration plan of each storage node is determined to generate a migration plan for the distributed storage system.
3. The static partition data migration method of a distributed storage system according to claim 2, characterized in that: For any first-migrated disk in the first-migrated disk set, determining a first-migrated disk to be migrated, and determining a migration plan for the first-migrated disk based on a current load and a data volume threshold of the first-migrated disk and a current load and a data volume threshold of the first-migrated disk, including: Sorting the first migration-out disks in the first migration-out disk set from large to small according to the current load of the disk, with the reduced capacity disk being prioritized at the front, to obtain a sorted first migration-out disk set; sorting the first migration disks in the first migration disk set from small to large according to the current load of the disk, to obtain a sorted first migration disk set; Based on the sorted first migration-out disk set, migration calculations are performed on the first migration-out disks in sequence, and for the currently selected first migration-out disk, a first migration-in disk to be migrated is selected from the sorted first migration-in disk set, and a current migration plan of the first migration-out disk is determined, wherein the current migration plan includes: Determine the data quota for this migration out based on the data volume threshold of the first migration-out disk and the current load, determine the data quota for this migration in based on the data volume threshold of the first migration-in disk and the current load, and select the minimum value of the data quota for this migration out and the data quota for this migration in as the total data quota for this migration; Determine the optimal number of migration partitions based on the total amount of data for this migration and the backpack algorithm, trace back the optimal number of migration partitions, and determine the migration partitions for this migration of the first migration disk; A migration plan of the first migrated-out disk is determined based on each migrated-out partition of each migration of the first migrated-out disk and the first migrated-in disk to be migrated.
4. The static partition data migration method of a distributed storage system according to claim 3, characterized in that: For any first-migrated disk in the first-migrated disk set, determining a first-migrated disk to be migrated, and determining a migration plan for the first-migrated disk based on a current load and a data volume threshold of the first-migrated disk and a current load and a data volume threshold of the first-migrated disk, including: If the first migration-out disk is a shrinking disk, and the amount of data to be migrated out of the shrinking disk is less than the amount of data to be migrated into the first migration-in disk, the step of determining the optimal number of migration-out partitions is not performed, and all the data of all partitions of the first migration-out disk are directly migrated out to the first migration-in disk; and / or, If the first migration disk is a reduced capacity disk, after all migration partitions of the first migration disk are determined, it is determined whether the first migration disk has residual partitions. If there are residual partitions, a migration plan for each residual partition is determined based on a greedy migration strategy.
5. The static partition data migration method of a distributed storage system according to claim 4, characterized in that: Determine the migration plan for each residual partition based on the greedy migration strategy, including: The first migration disk is determined by adopting the principle of migrating the residual partitions to the first migration disk with the smallest current load first; Based on the data volume of the residual partition and the current load volume of the selected first migration disk, determine the total load volume of the selected first migration disk after adding the residual partition, if the total load volume is less than the capacity threshold of the selected first migration disk, determine to migrate the residual partition to the first migration disk, and update the current load volume of the first migration disk; After each residual partition is migrated, the first migrated disks are reordered from small to large according to the current load of the disks.
6. The static partition data migration method of a distributed storage system according to claim 3, characterized in that: The optimal number of migrated partitions is determined based on the total amount of data for this migration and the backpack algorithm, and the optimal number of migrated partitions is backtracked to determine each migrated partition for this migration of the first migrated disk, including: Set the total amount of data for this migration to q, define a two-dimensional array dp[i][j], which represents the maximum value of the first i partitions under the j-th amount of data transferred. The state transfer equation is: dp[i][j] = Max(dp[i - 1][j], dp[i - 1][j - v[i]] + w[i]); Where v[i] represents the amount of data in the i-th partition, and w[i] represents the value of the i-th partition; Poll all partitions of the first migrated disk to obtain an optimal solution dp[n][q] indicating that the sum of the data amounts of the n partitions is closest to the total data amount q; Starting from the optimal solution dp[n][q], we trace back step by step and store dp[n][q] in a variable totalValue. For each iteration: we compare dp[i][j] and dp[i - 1][j]. If they are equal, the i-th partition is not determined as the partition to be moved out. If they are not equal, the i-th partition is determined to be the partition to be moved out. We add the i-th partition to the list of partitions to be moved out. We update the variables totalValue and value to determine the state before putting it into the i-th partition: totalValue = totalValue-v [i - 1]; j = j - w[i - 1]; Continue to execute the next round of iteration until totalValue = 0, then stop the iteration and determine each migration partition of the first migration disk for this migration; The actual data volume of this migration is determined based on the sum of the data volumes of all the partitions to be migrated out of this migration; The current load of the first migration-out disk is updated based on the actual data volume of the current migration, and the current load of the first migration-in disk is updated.
7. The static partition data migration method of a distributed storage system according to claim 2, characterized in that: The storage nodes allocated to each primary partition are different from the storage nodes of the replica partitions corresponding to the same primary partition, and the storage nodes allocated to the replica partitions corresponding to the same primary partition are different; The number of replica backups is less than the number of storage nodes. Before determining the migration plan for the replica partition, the following are included: If the first migrated-out disk is migrated to the storage node where the first migrated-in disk is located, and the storage node has a replica partition ID that is the same as the partition ID of the first migrated-out disk, the replica partition is determined as a conflicting replica partition; Based on the migration plan of the primary partition, defining all determined conflicting replica partitions as a conflicting replica partition set; For any conflict replica partition in the conflict replica partition set, the second migration disk to which the conflict replica partition is to be migrated is determined based on the principle that the conflict replica partition is preferentially migrated to the second migration disk with the smallest current load, the disk where the conflict replica partition is located is taken as the source disk of the conflict replica partition, and the second disk to which the conflict replica partition is to be migrated is taken as the installation disk of the conflict replica partition, conflict replica migration records of each conflict replica partition are generated, and the current load of each second migration disk after migration is updated, wherein each record in the conflict replica migration record includes at least: the conflict replica partition ID, the source disk of the conflict replica partition, the installation disk of the conflict replica partition, and the amount of data migrated.
8. The static partition data migration method of a distributed storage system according to claim 7, characterized in that: For any second-migrated disk in the second-migrated disk set, determining the second-migrated disk to be migrated, and determining a migration plan for the second-migrated disk based on the current load and data volume threshold of the second-migrated disk and the current load and data volume threshold of the second-migrated disk, thereby obtaining a migration plan for the replica partition, including: For the currently selected second migration-out disk, select the second migration-in disk to be migrated, define all partitions of the second migration-out disk as a first partition set, define partitions of all disks of the primary partition of the storage node where the second migration-in disk is located and partitions of all disks of the replica partition as a second partition set, and define the intersection of the first partition set and the second partition set as a candidate partition set of the second migration-out disk; Based on the total amount of data migrated each time by the second migration disk and the backpack algorithm, determine each migration partition of each migration of the second migration disk from the candidate partition set, and then determine the migration plan of the second migration disk; Traverse each record in the conflict replica migration record, obtain the conflict replica partition ID, the source disk of the conflict replica partition and the placement disk of the conflict replica partition of the record; if the placement disk of the conflict replica partition is not in the migration plan of the second migration-out disk, use the source disk of the conflict replica partition as the migration-out disk, and use the placement disk of the conflict replica partition as the migration-in disk to determine the migration plan of the conflict replica partition of the record, and then determine the migration plan of the conflict replica partition; if the placement disk of the conflict replica partition is in the migration plan of the second migration-out disk, use the source disk of the conflict replica partition as the migration-out disk, and use the second disk to be migrated in the migration plan of the second migration-out disk as the migration-in disk, so as to update the migration plan of the second migration-out disk; Based on the migration plan of the conflicting replica partition and the migration plans of each second migration-out disk, a migration plan of the replica partition is determined.
9. The static partition data migration method of a distributed storage system according to claim 7, characterized in that: The method further comprises: If the second migration disk is a reduced capacity disk, after all the migration partitions of the second migration disk are determined, the remaining partitions of the second migration disk are determined, and for each remaining partition, a migration plan for the remaining partition is determined based on a greedy migration strategy, including: Determine the partition ID of the replica partition where the second migrated disk is located, traverse each second migrated disk in the second migrated disk set, determine the storage node where the second migrated disk is located for each second migrated disk, determine the partition ID set of all primary partitions and all replica partitions under the storage node, and if the partition ID exists in the partition ID set, do not select the second migrated disk; Among the selected second migration disks, the principle of preferentially migrating the residual partition to the second migration disk with the smallest current load is adopted to determine the selected second migration disk; Based on the data volume of the residual partition and the current load volume of the selected second migration disk, determine the total load volume of the selected second migration disk after adding the residual partition, and if the total load volume is less than the capacity threshold of the second migration disk, determine to migrate the residual partition to the second migration disk; After each residual partition is migrated, the second migration disks in the second migration disk set are re-sorted from small to large according to the current load of the disk.
10. A distributed storage system, comprising a plurality of storage nodes, each storage node comprising at least a processor, characterized in that: The processor is used to divide the disks of the storage node into an incoming disk set and an outgoing disk set, and the disk division method includes: for at least one disk, determining the data volume threshold of the disk based on the capacity threshold of the disk and the current watermark, determining whether the disk is an incoming disk or an outgoing disk according to the data volume threshold and the current load of the disk, and then obtaining an incoming disk set and an outgoing disk set, and determining the migration plan of the distributed storage system based on the incoming disk set and the outgoing disk set, wherein the current watermark is determined based on the current load of the disk participating in the watermark update this time; Each storage node includes at least one solid-state hard disk and at least one mechanical hard disk, and at least one solid-state hard disk of the plurality of storage nodes is defined as a disk of a primary partition, wherein a data volume threshold of the disk is determined based on a capacity threshold of the disk and a current watermark, and whether the disk is a migration-in disk or a migration-out disk is determined according to the data volume threshold and a current load of the disk, including: The current load average of all disks of the primary partition is used as the initial watermark; If the capacity threshold of any disk of the primary partition is greater than or equal to the initial watermark, the initial watermark is used as the data volume threshold of the disk, wherein the capacity threshold of the disk is determined based on the total capacity of the disk; If there is at least one disk whose capacity threshold is smaller than the initial water level, multiple rounds of iterative updates are performed on the initial water level, and each round of iterative updates of the water level includes: if the capacity threshold of the disk is greater than or equal to the current water level, the capacity threshold of the disk is used as the data volume threshold of the disk, and the disk is determined not to participate in the next round of water level updates, and the quotient of the difference between the current load of all disks minus the capacity threshold of the disk and the number of remaining disks is used as the water level of the next round, until the capacity thresholds of all disks participating in the water level update are greater than or equal to the water level of this round, the iterative update is stopped, and the water level of this round is used as the data volume threshold of all disks participating in the water level update; If the data volume threshold of the disk is greater than the current load volume of the disk, the disk is determined to be a migration-in disk; otherwise, the disk is determined to be a migration-out disk.
11. A computer device comprising a memory and a processor, wherein a computer program is stored in the memory, wherein: When the processor executes the computer program, the steps of the static partition data migration method of the distributed storage system as described in claims 1-9 are implemented.
Citation Information
Patent Citations
Data balancing method, system and equipment and readable storage medium
CN117193665A