Data balancing method and device, storage medium and electronic equipment

By obtaining the storage expected value and current storage amount of storage devices in the Ceph distributed storage system, filtering and adjusting the weight of storage devices, the problem of unbalanced data distribution is solved, and the efficient data balance and performance improvement of the system is achieved.

CN119902698APending Publication Date: 2025-04-29TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311426620.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-10-27
Publication Date
2025-04-29

AI Technical Summary

Technical Problem

In Ceph distributed storage systems, data is unbalanced on disks managed by OSD, resulting in excessive usage of some OSDs, affecting system performance and availability.

Method used

By obtaining the storage expected value of each storage device, calculating the ratio between its current storage amount and the expected value, filtering out the storage devices with a ratio greater than the preset value, and adjusting the weights of adjacent storage devices according to their weights to achieve a balanced distribution of data.

Benefits of technology

This method realizes data equalization of the distributed storage system through offline calculation of expected values, equal weight adjustment and online one-time injection migration, avoids cluster failures caused by online weight adjustment, reduces the impact of balanced data on performance, and thus improves the overall performance of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119902698A_ABST
    Figure CN119902698A_ABST
Patent Text Reader

Abstract

The invention discloses a data balancing method and device, a storage medium and electronic equipment. The method comprises the following steps: acquiring a storage expected value corresponding to each storage device in the distributed storage system; determining a first ratio between the current storage capacity of the storage device and the storage expected value; determining a first storage device of which the first ratio is greater than a preset value; adjusting the weights of the first storage device and the second storage device at least according to the current weight, the current storage amount and the storage expected value of the first storage device; and migrating the data of the corresponding data volume in the first storage device to the second storage device based on the adjusted weight. According to the scheme, system data balance is achieved through an expected value calculation algorithm, an equal weight adjustment algorithm and online one-time injection migration in an offline mode, the cluster fault problem caused by online weight adjustment is avoided, meanwhile, the performance influence caused by data balance is reduced through one-time injection migration, and the overall performance of the distributed storage system is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer vision technology, and in particular to a data equalization method, device, storage medium and electronic device. Background Art

[0002] Ceph is an open source distributed storage system that can provide object, file, and block storage services at the same time. The underlying layer of Ceph is an object storage. User data will be divided into objects of fixed size and stored on the disk managed by the Object Storage Device (OSD). For the convenience of management, placement groups (PG) are used to manage objects. At the same time, Ceph uses the Crush algorithm (a pseudo-random algorithm) to distribute data so that the PG containing the object is distributed to the OSD. In theory, the Crush pseudo-random algorithm can evenly distribute data on the disk managed by the OSD when the cluster size is large and the amount of data is large.

[0003] However, large scale and large amount of data are general terms, and there is no accurate data indicator. In the actual Ceph cluster, data distribution is uneven. For example, the data utilization rate of the disk managed by an OSD reaches 80%, while there may be OSDs in the cluster with a utilization rate of only 50%. This data imbalance will affect the availability of the Ceph cluster. Due to the high OSD disk utilization rate, the Pool logical pool where this OSD is located may not be able to perform read and write operations, which will cause user requests to be stuck, reducing the overall performance of the distributed storage system. Summary of the invention

[0004] The embodiments of the present application provide a data balancing method, device, storage medium and electronic device, which improve the performance of a distributed storage system.

[0005] A data balancing method, comprising:

[0006] Obtaining the storage expected value corresponding to each storage device in the distributed storage system;

[0007] Determining a first ratio between a current storage capacity of the storage device and the storage expectation value;

[0008] Determine a first storage device where the first ratio is greater than a preset value, wherein the preset value is greater than 1;

[0009] adjusting the weights of the first storage device and the second storage device at least according to the current weight of the first storage device, the current storage capacity and the storage expected value, wherein the second storage device is a storage device in the distributed storage system whose current storage capacity is lower than the storage expected value;

[0010] Based on the adjusted weight, data of a corresponding amount in the first storage device is migrated to the second storage device.

[0011] Accordingly, the embodiment of the present application further provides a data balancing device, including:

[0012] An acquisition unit, used to acquire a storage expected value corresponding to each storage device in the distributed storage system;

[0013] A first determining unit, configured to determine a first ratio between a current storage capacity of the storage device and the storage expected value;

[0014] A second determining unit, configured to determine a first storage device for which the first ratio is greater than a preset value, wherein the preset value is greater than 1;

[0015] an adjusting unit, configured to adjust the weights of the first storage device and the second storage device according to at least a current weight of the first storage device, the current storage amount, and the storage expected value, wherein the second storage device is a storage device in the distributed storage system in which the current storage amount is lower than the storage expected value;

[0016] A migration unit is used to migrate the data of the corresponding amount in the first storage device to the second storage device based on the adjusted weight.

[0017] In one embodiment, the adjustment unit is used to:

[0018] Determining a first target weight to which the first storage device needs to be adjusted according to the current weight of the first storage device, the current storage amount, and the storage expected value;

[0019] Obtaining a cumulative value of a difference between the first target weight and a current weight of the first storage device to obtain a first weight difference;

[0020] The weight of the second storage device is adjusted based on the first weight difference.

[0021] In one embodiment, when determining the first target weight to which the first storage device needs to be adjusted according to the current weight of the first storage device, the current storage amount, and the storage expected value, the adjustment unit is specifically configured to:

[0022] Acquire a second ratio between the expected storage value and the current storage capacity of the first storage device;

[0023] The current weight of the first storage device is weighted according to the second ratio to obtain the first target weight.

[0024] In one implementation, when adjusting the weight of the second storage device based on the weight difference, the adjusting unit is specifically configured to:

[0025] A second target weight to which the second storage device needs to be adjusted is determined according to the current weight of the second storage device, the current storage amount, the storage expected value, and the first weight difference.

[0026] In one embodiment, when determining the second target weight to which the second storage device needs to be adjusted according to the current weight of the second storage device, the current storage amount, the storage expected value, and the first weight difference, the adjustment unit is specifically configured to:

[0027] Acquire a third ratio between the expected storage value and the current storage capacity of the second storage device;

[0028] Performing weighted processing on the current weight of the second storage device according to the third ratio to obtain a processed weight;

[0029] Adjusting the processed weight and the current weight of the second storage device based on a preset adjustment coefficient, and summing the adjusted processed weight and the adjusted current weight to obtain an adjusted weight;

[0030] Obtaining a cumulative value of a difference between the adjusted weight and a current weight of the second storage device to obtain a second weight difference;

[0031] The adjusted weight is iterated until the second weight difference is the same as the first weight difference, and the adjusted weight obtained in the last iteration is determined as the second target weight.

[0032] In one embodiment, the migration unit is used to:

[0033] Based on the adjusted weights, determining a first amount of data to be migrated out of the first storage device and a second amount of data to be migrated into the second storage device;

[0034] Based on the first data amount and the second data amount, data in the first storage device is migrated to the corresponding second storage device.

[0035] In one embodiment, the acquisition unit is used to:

[0036] Get the current cluster topology information corresponding to the distributed storage system;

[0037] Determining a basic weight of each storage device in the distributed storage system according to the current cluster topology information;

[0038] Obtaining the total amount of data stored in the distributed system;

[0039] The storage expected value corresponding to each storage device is determined according to the basic weight and the total amount of data storage.

[0040] In addition, an embodiment of the present application further provides an electronic device, including a processor and a memory, wherein the memory stores an application program, and the processor is used to run the application program in the memory to implement the steps in the data balancing method provided in the embodiment of the present application.

[0041] In addition, an embodiment of the present application further provides a computer-readable storage medium, which stores a plurality of instructions, and the instructions are suitable for a processor to load to execute the steps in the data balancing method provided in the embodiment of the present application.

[0042] In addition, an embodiment of the present application also provides a computer program product, including a computer program or instructions, which, when executed by a processor, implements the steps in the data balancing method provided in the embodiment of the present application.

[0043] In the embodiment of the present application, the storage expectation value corresponding to each storage device in the distributed storage system is obtained, and the first ratio between the current storage capacity of each storage device and the storage expectation value is determined; then, the first storage device whose first ratio is greater than the preset value is screened out, and the weights of the first storage device and the second storage device are adjusted according to the current weight, current storage capacity and storage expectation value of the first storage device; finally, based on the adjusted weight, the data of the corresponding amount in the first storage device is migrated to the second storage device to balance the data distribution in the distributed storage system. This solution realizes system data balance through the calculation expectation value algorithm, equal weight adjustment algorithm and online one-time injection migration in an offline manner, avoiding the cluster failure problem caused by online weight adjustment. At the same time, the one-time injection migration reduces the performance impact caused by balanced data and improves the overall performance of the distributed storage system. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0045] Figure 1 It is a scenario diagram of the data balancing method provided in an embodiment of the present application;

[0046] Figure 2 It is a flowchart of a data balancing method provided in an embodiment of the present application;

[0047] Figure 3 It is a schematic diagram of the architecture of the offline data balancing system provided in an embodiment of the present application;

[0048] Figure 4 It is a flowchart of the expected value algorithm provided in the embodiment of the present application;

[0049] Figure 5 It is a schematic diagram of the structure of the cluster topology diagram provided in the embodiment of the present application;

[0050] Figure 6 It is a flowchart of equal weight adjustment provided in an embodiment of the present application;

[0051] Figure 7 This is a schematic diagram of a scenario of injection migration provided in an embodiment of the present application;

[0052] Figure 8 is a structural diagram of a data equalization device provided in an embodiment of the present application;

[0053] Fig. 9 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0054] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.

[0055] In a Ceph cluster, objects are divided into 4M and stored on disks managed by OSDs. Since 4M objects are large in size, the capacity of each PG is relatively balanced. The imbalance in OSD usage is mainly caused by the difference in the number of PGs carried by each OSD. In related technologies, OSD weights can be adjusted online time and time again based on experience, reducing the number of PGs in OSDs with high usage and increasing the number of PGs in OSDs with low usage.

[0056] However, the adjustment range of this adjustment method is uncertain (it needs to be based on experience), and since the weight adjustment is performed online, if the adjustment attempt fails, it may cause Ceph cluster failure, thus affecting user services. In addition, since each weight adjustment will cause data migration, multiple weight adjustments will cause multiple data migrations, and data migration will affect the performance of the entire Ceph cluster to a certain extent.

[0057] Based on this, the embodiments of the present application provide a data balancing method, device, storage medium and electronic device, which can improve the performance of a distributed storage system. The data balancing device can be integrated in an electronic device, which can be a server or a terminal.

[0058] Among them, the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, network acceleration services, and big data and artificial intelligence platforms. The terminal can be a smart phone, tablet computer, laptop computer, desktop computer, smart speaker, smart watch, etc., but is not limited to this. The terminal and the server can be directly or indirectly connected via wired or wireless communication, and this application does not limit this.

[0059] For example, see Figure 1 Taking the data balancing device integrated in an electronic device as an example, the electronic device obtains the storage expectation value corresponding to each storage device in the distributed storage system; determines a first ratio between the current storage capacity of the storage device and the storage expectation value; determines a first storage device whose first ratio is greater than a preset value, wherein the preset value is greater than 1; adjusts the weights of the first storage device and the second storage device based on at least the current weight of the first storage device, the current storage capacity and the storage expectation value, wherein the second storage device is a storage device in the distributed storage system whose current storage capacity is lower than the storage expectation value; based on the adjusted weight, migrates the data of the corresponding data volume in the first storage device to the second storage device.

[0060] It can be understood that in the specific implementation of this application, related data such as attribute data, attribute sets and attribute subsets are involved. When the following embodiments of this application are applied to specific products or technologies, permission or consent is required, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.

[0061] It should be noted that the description order of the following embodiments is not intended to limit the preferred order of the embodiments.

[0062] This embodiment will be described from the perspective of a data balancing device, which can be specifically integrated in an electronic device, which can be a server or a terminal. The terminal can include a tablet computer, a laptop computer, a personal computer (PC) or other smart devices capable of data processing.

[0063] An embodiment of the present application provides a data balancing method, including: obtaining a storage expectation value corresponding to each storage device in a distributed storage system; determining a first ratio between a current storage capacity of the storage device and the storage expectation value; determining a first storage device for which the first ratio is greater than a preset value, wherein the preset value is greater than 1; adjusting the weights of the first storage device and the second storage device based on at least a current weight of the first storage device, the current storage capacity, and the storage expectation value, wherein the second storage device is a storage device in the distributed storage system for which the current storage capacity is lower than the storage expectation value; and migrating a corresponding amount of data in the first storage device to the second storage device based on the adjusted weight.

[0064] like Figure 2 As shown, the specific process of the data balancing method is as follows:

[0065] 101. Obtain a storage expectation value corresponding to each storage device in a distributed storage system.

[0066] In this application, the distributed storage system can store data in multiple independent data nodes, and each data node can be equipped with one or more storage devices, so as to share the storage load using multiple data nodes. In practical applications, the distributed storage system can distribute data to multiple independent storage devices through relevant data distribution algorithms, and can locate storage information using location servers. Each storage device has corresponding storage capacity.

[0067] For example, the distributed storage system can be a Ceph cluster, which provides services to the outside world in units of logical pools (Pool), and can provide object, file, and block storage services at the same time; the storage device can be an OSD, which can provide data storage services and manage the reading and writing of disk data. The Ceph cluster can include multiple data nodes, and each data node can include one or more OSDs. The Ceph cluster can divide each data stream to be managed into one or more object data of a fixed size (such as 4M), and store the divided object data on the disk managed by the OSD through a pseudo-random algorithm (such as the Crush algorithm), and use PG to manage the object data. In addition, the Pool logical pool can be a single copy or multiple copies, each copy will occupy an OSD, and an OSD can be occupied by multiple Pool logical pools.

[0068] Due to the Ceph cluster failure caused by online weight adjustment, in this embodiment, the weight adjustment is performed offline, by analyzing the current cluster topology information of the distributed storage system offline, and calculating the new cluster topology information that can balance the data in the distributed storage system based on the analysis results. In specific implementation, the storage expected value corresponding to each storage device in the distributed storage system can be obtained based on the current cluster topology information of the distributed storage system. That is, in one embodiment, when obtaining the storage expected value corresponding to each storage device in the distributed storage system, the following process can be included:

[0069] Get the current cluster topology information corresponding to the distributed storage system;

[0070] Determine the basic weight of each storage device in the distributed storage system based on the current cluster topology information;

[0071] Get the total amount of data stored in the distributed system;

[0072] Determine the storage expectation value corresponding to each storage device based on the basic weight and the total amount of data storage.

[0073] Among them, the current cluster topology information includes the distributed topology structure of the storage devices in the distributed storage system and the weight of each storage device. Among them, the weight is determined according to the storage capacity of the storage device and the probability that the system selects the storage device to carry data. In the embodiment of the present application, the probability that the system selects each storage device to carry data can be the same or different, which is specifically determined by the data distribution algorithm adopted. For the sake of ease of explanation, the following will further describe this solution based on the assumption that the probability that the system selects each storage device to carry data is the same.

[0074] Specifically, the basic weight of a storage device is determined by the storage capacity of the storage device and the probability that the system selects the storage device to carry data. Since each storage device has the same probability of carrying data, the basic weight is determined by the storage capacity of each storage device. For example, if the distributed storage system includes M storage devices, and the storage capacity of each storage device is 3TB, the basic weight corresponding to each storage device is 3.0.

[0075] Then, the total amount of data storage in the current distributed storage system can be obtained. For example, the distributed storage system includes two logical pools, Pool A and Pool B. Assuming that Pool A includes 2 replicas, each replica consists of 200 PGs, and Pool B includes 3 replicas, each replica consists of 200 PGs, then the total amount of data storage is the sum of the data amounts of Pool A and Pool B, that is, 1000 PGs.

[0076] Finally, the storage expectation value corresponding to each storage device is determined based on the basic weight and total data storage obtained above. In specific implementation, the ratio of the basic weight of each storage device to the overall weight of the system can be obtained, and the storage expectation value corresponding to each storage device can be calculated based on the ratio and the total data storage. For example, assuming there are 5 storage devices, and the basic weight corresponding to each storage device is 3.0, and the total data storage of the system is 1000 PG, the storage expectation value of each storage device can be calculated to be 200 PG.

[0077] 102. Determine a first ratio between a current storage capacity of a storage device and a storage expectation value.

[0078] Specifically, the current storage capacity (ie, the amount of data currently carried) of each storage device may be obtained from the current cluster topology information, and a ratio of the current storage capacity to the storage expected value may be calculated to obtain a first ratio.

[0079] 103. Determine a first storage device whose first ratio is greater than a preset value, where the preset value is greater than 1.

[0080] Specifically, since data is constantly being written in the distributed system, absolute data balance is often not possible. Therefore, the present solution allows data balance to be maintained within a certain range, that is, the preset value is set to be greater than 1. For example, the preset value can be set to 1.05, 1.1, etc., and a storage device whose current storage capacity is greater than 1.05 or 1.1 times the expected storage value is determined as the first storage device. The number of first storage devices can be one or more.

[0081] 104. Adjust the weights of the first storage device and the second storage device at least according to the current weight, current storage capacity and storage expectation value of the first storage device, wherein the second storage device is a storage device in the distributed storage system whose current storage capacity is lower than the storage expectation value.

[0082] The first storage device is a storage device whose current storage capacity exceeds the expected storage value, and the second storage device is a storage device whose current output capacity is lower than the expected storage value. The number of the second storage devices may also be one or more.

[0083] In this embodiment, balancing data means balancing the storage capacity on each storage device, that is, the weight of each storage device needs to be readjusted, and the weight of the first storage device that exceeds the storage expectation value is adjusted to the second storage device that is lower than the storage expectation value, so as to construct new cluster topology information that can balance the data in the distributed storage system. That is, in one embodiment, adjusting the weight of the first storage device and the second storage device based on at least the current weight, current storage capacity and the storage expectation value of the first storage device may include the following process:

[0084] Determining a first target weight to which the first storage device needs to be adjusted according to a current weight, a current storage amount, and an expected storage value of the first storage device;

[0085] Obtaining a cumulative value of a difference between the first target weight and a current weight of the first storage device to obtain a first weight difference;

[0086] The weight of the second storage device is adjusted based on the first weight difference.

[0087] In a specific implementation, the weight of the first storage device whose current storage capacity exceeds the storage expected value may be adjusted first, and the current weight of the first storage device may be lowered. In one embodiment, determining the first target weight to which the first storage device needs to be adjusted based on the current weight, current storage capacity and storage expected value of the first storage device may include the following process:

[0088] Acquire a second ratio between the expected storage value and the current storage capacity of the first storage device;

[0089] The current weight of the first storage device is weighted according to the second ratio to obtain a first target weight.

[0090] The calculation formula of the first target weight is as follows:

[0091] First target weight = (storage expectation value / current storage amount) * current weight

[0092] In the embodiment of the present application, the weight adjustment strategy is to reduce the weight of the storage device that exceeds the storage expectation value, and increase the weight of the storage device that is less than the expected storage value, during which the weight reduction amount must be the same as the weight increase amount. That is, the weight that needs to be adjusted to the second storage device will be affected by the first weight difference. Therefore, when adjusting the weight of the second storage device based on the weight difference, it is necessary to determine the second target weight that the second storage device needs to be adjusted to based on the current weight, current storage capacity, storage expectation value and first weight difference of the second storage device.

[0093] In one embodiment, when determining the second target weight to which the second storage device needs to be adjusted according to the current weight, current storage capacity, storage expectation value and first weight difference of the second storage device, the following process may be specifically included:

[0094] Acquire a third ratio between the expected storage value and the current storage capacity of the second storage device;

[0095] Performing weighted processing on the current weight of the second storage device according to the third ratio to obtain a processed weight;

[0096] Adjusting the processed weight and the current weight of the second storage device based on a preset adjustment coefficient, and summing the adjusted processed weight and the adjusted current weight to obtain an adjusted weight;

[0097] Obtaining a cumulative value of a difference between the adjusted weight and a current weight of the second storage device to obtain a second weight difference;

[0098] The adjusted weight is iterated until the second weight difference is the same as the first weight difference, and the adjusted weight obtained in the last iteration is determined as the second target weight.

[0099] The calculation formula of the processed weight is as follows:

[0100] Processed weight = (storage expected value / current storage amount) * current weight

[0101] In this embodiment, the processed weight is a critical weight that can just make the storage capacity of the second storage device reach the expected storage value. Since the weight adjustment of the second storage device is also limited by the first weight difference, in order to avoid excessive adjustment, an adjustment coefficient can be set in advance, and the weight of the second storage device is determined by combining the current weight of the second storage device and the critical weight (i.e., the processed weight) that can make its storage capacity reach the expected storage value. Among them, the preset adjustment coefficient can be 0.3, 0.5, 0.7, etc., which can be set according to actual conditions. Among them, the calculation formula of the adjusted weight is as follows:

[0102] Adjusted weight = current weight * (1-preset adjustment coefficient) + processed weight * preset adjustment coefficient

[0103] In specific implementation, since the weight reduction and increase must be the same in the end, the difference between the adjusted weight and the current weight of the second storage device can be calculated and deducted from the first weight difference. During this period, the adjusted weight needs to be iterated, and the adjusted weight is updated by repeating the above steps until the first weight difference is completely deducted (that is, the first weight difference is equal to the second weight difference).

[0104] 105. Based on the adjusted weight, migrate a corresponding amount of data in the first storage device to the second storage device.

[0105] Specifically, based on the adjusted weights, new cluster topology information that can balance the data in the distributed storage system can be constructed offline, and the new cluster topology information can be re-injected into the distributed storage system. Based on the new cluster topology information, the corresponding amount of data in the first storage device can be migrated to the second storage device at one time through online data migration, thereby achieving system data balance.

[0106] In one implementation, when migrating a corresponding amount of data in the first storage device to the second storage device based on the adjusted weight, the following process may be specifically included:

[0107] Based on the adjusted weights, determining a first amount of data to be migrated out of the first storage device and a second amount of data to be migrated into the second storage device;

[0108] Based on the first data amount and the second data amount, data in the first storage device is migrated to the corresponding second storage device.

[0109] In this embodiment, there may be one or more first storage devices that need to migrate data out, and there may also be one or more second storage devices that need to migrate data in. During the specific implementation process, all first storage devices and second storage devices need to be weight adjusted and data migrated.

[0110] Specifically, the first data volume to be migrated out can be determined based on the first target weight, current weight and current storage capacity of the first storage device; the second data volume to be migrated in can be determined based on the second target weight, current weight and current storage capacity of the second storage device. Finally, based on the first data volume and the second data volume, the data in the first storage device is migrated to the corresponding second storage device.

[0111] As can be seen from the above, the data balancing method provided by the embodiment of the present application obtains the storage expectation value corresponding to each storage device in the distributed storage system, and determines the first ratio between the current storage capacity of each storage device and the storage expectation value; then, the first storage device whose first ratio is greater than the preset value is screened out, and the weights of the first storage device and the second storage device are adjusted according to the current weight, current storage capacity and storage expectation value of the first storage device; finally, based on the adjusted weight, the data of the corresponding amount of data in the first storage device is migrated to the second storage device to balance the data distribution in the distributed storage system. This solution realizes system data balancing through the calculation expectation value algorithm, equal weight adjustment algorithm and online one-time injection migration in an offline manner, avoiding the cluster failure problem caused by online weight adjustment. At the same time, the one-time injection migration reduces the performance impact caused by balanced data and improves the overall performance of the distributed storage system.

[0112] According to the method described in the above embodiment, the following will be further described in detail with examples. In another embodiment of the present application, another offline data balancing system is also provided. The following will take the distributed storage system as a Ceph cluster and the storage device as an OSD as an example to describe in detail the offline data balancing system provided in this embodiment.

[0113] refer to Figure 3 , Figure 3The schematic diagram of the architecture of the offline data balancing system provided in the embodiment of the present application is shown in FIG. The offline data balancing system includes a client, a Ceph cluster and an offline adjustment program.

[0114] The data requested by the client is distributed in Pool A of the Ceph cluster. Pool A occupies 3 OSDs: OSD.0, OSD.1, and OSD.2. Pool A includes 2 replicas, each with 300 PGs, so the total number of PGs in Pool A is 600. In addition, the disk capacity managed by the three OSDs is 3 TB, and the corresponding weights are all 3.0.

[0115] In specific implementation, the current cluster topology information (crushmap) in the Ceph cluster can be obtained, and the crushmap can be input into the offline adjustment program, and a new crushmap can be output. The input crushmap contains information such as the distribution topology structure of the OSD in the Ceph cluster and the current weight of the OSD; the output crushmap contains the adjusted OSD weight. Subsequently, the new crushmap output by the offline adjustment program is injected into the cluster through the Ceph injection command, and the PG data is migrated according to the OSD weight in the new crushmap. When the data migration is completed, the Ceph cluster can reach a data balance state.

[0116] The offline data balancing system provided by this solution will achieve data balancing by calculating the expected value algorithm, the equal weight adjustment algorithm and one-time injection migration to solve the problem of system performance degradation caused by online weight adjustment.

[0117] 1. Offline Expected Value Algorithm

[0118] Specifically, to make the Ceph cluster data balanced, the number of PGs carried by the OSD must be balanced. The purpose of adjusting the weight is to make the number of PGs carried by the current OSD close to the expected value. Therefore, the expected value of each OSD needs to be calculated offline first. For details, refer to Figure 4 First, you need to obtain all Pool logical pools and related information in the Ceph cluster, such as the ID of the Pool logical pool, the ID of the crush rule used by each Pool logical pool, etc. Then, loop through all Pool logical pools, and perform the following operations for each Pool logical pool:

[0119] (11) Find all OSDs where the Pool logical pool data may be distributed based on the crush rule ID of the Pool logical pool;

[0120] (12) For each OSD, the composite weight value is calculated by multiplying its capacity value and reweight value, where the reweight value represents the probability of the crush algorithm selecting the OSD to carry PG data;

[0121] (13) Add up the composite weights of all OSDs in the Pool logical pool to get the total composite weight of the Pool logical pool;

[0122] (14) Calculate the ratio of the composite weight of each OSD to the total composite weight of the Pool logical pool;

[0123] (15) Based on the number of replicas and PGs of the Pool logical pool and the ratio obtained in step 6, calculate the number of PGs that this Pool logical pool expects to have on this OSD.

[0124] Finally, the expected number of PGs of all Pool logical pools on a certain OSD obtained by the above operation is accumulated to obtain the total expected value of this OSD. The relevant algorithm formula is as follows:

[0125] OSD composite weight value = storage capacity * reweight

[0126]

[0127] The reweight value indicates the probability of the crush algorithm selecting an OSD to carry PG data; n..m indicates the OSDs belonging to this Pool logical pool.

[0128] OSD i Expected weight value = OSD composite weight value / Pool i Composite weight value * (number of replicas * number of pool PGs) where i represents the i-th Pool logical pool;

[0129]

[0130] Among them, 0..n represents all Pool logical pools.

[0131] refer to Figure 5 , Figure 5 A schematic diagram of the cluster topology provided for this embodiment. The Ceph cluster includes three data nodes, each of which includes two OSDs, for a total of six OSDs. The storage capacity of OSD.0 to OSD.3 is 4TB, the storage capacity of OSD.4 and OSD.5 is 2TB, the reweight value is 1, and the six OSDs carry the data of Pool A and Pool B.

[0132] Assume that Pool A includes 2 replicas, each replica includes 200 PGs, then the expected values ​​of PGs carried by OSD.0 to OSD.5 in Pool A are as follows:

[0133] Pool A composite weight value = 1*4TB+1*4TB+1*4TB+1*4TB+1*2TB+1*2TBPool A OSD.0 expected PG value = 2*200*(1*4TB) / (1*4TB+1*4TB+1*4TB+

[0134] 1*4TB+1*2TB+1*2TB)=80

[0135] Among them, the calculation formulas of the expected PG value of OSD.1, the expected PG value of OSD.2 and the expected PG value of OSD.3 are the same as the calculation formula of the expected PG value of OSD.0;

[0136] The expected PG value of OSD.4 in Pool A = 2*200*(1*2TB) / (1*4TB+1*4TB+1*4TB+1*4TB+1*2TB+1*2TB) = 40

[0137] Among them, the calculation formula of the expected PG value of OSD.5 is the same as the calculation formula of the expected PG value of OSD.4.

[0138] Assume that Pool B includes 3 replicas, each replica includes 200 PGs, then the expected values ​​of PGs carried by OSD.0 to OSD.5 in Pool B are as follows:

[0139] Pool B composite weight value = 1*4TB+1*4TB+1*4TB+1*4TB+1*2TB+1*2TB

[0140] Expected PG value of OSD.0 in Pool B = 3*200*(1*4TB) / (1*4TB+1*4TB+1*4TB+1*4TB+1*2TB+1*2TB) = 120

[0141] Among them, the calculation formulas of the expected PG value of OSD.1, the expected PG value of OSD.2 and the expected PG value of OSD.3 are the same as the calculation formula of the expected PG value of OSD.0;

[0142] Expected PG value of OSD.4 in Pool B = 3*200*(1*2TB) / (1*4TB+1*4TB+1*4TB+1*4TB+1*2TB+1*2TB) = 60

[0143] Among them, the calculation formula of the expected PG value of OSD.5 is the same as the calculation formula of the expected PG value of OSD.4.

[0144] Then, the expected value of OSD.0 to OSD.5 carrying the entire cluster is:

[0145] OSD.0 expected value = OSD.1 expected value = OSD.2 expected value = OSD.3 expected value = 80 + 120 = 200

[0146] OSD.4 expected value = OSD.5 expected value = 40 + 60 = 100

[0147] 2. Equal Weight Adjustment Algorithm

[0148] Specifically, to adjust the number of PGs carried by the OSD to near the expected value, the current weight of the OSD needs to be adjusted. At the same time, Ceph cluster data is constantly being written, and absolute data balance is often not achieved. Therefore, the algorithm allows data balance to be maintained within a certain range. For example, the weight of an OSD whose current PG data is not greater than 1.05 times the expected value is not adjusted. Here, the equal weight adjustment algorithm is used, mainly to reduce the weight of OSDs that exceed the expected value and increase the weight of OSDs that are less than the expected value. During this period, it is necessary to ensure that the amount of weight reduction is equal to the amount of weight increase.

[0149] refer to Figure 6 , the following will combine Figure 6 The equal weight adjustment algorithm provided by this solution is described in detail:

[0150] (21) Sort all OSDs in the system in descending order according to the number of PGs currently carried by the OSD;

[0151] (22) Traverse the descending sorted OSD set. For a certain OSD, if the number of PGs is less than 1.05 times the expected value, do not adjust its weight and proceed to the next OSD. Otherwise, execute step (23);

[0152] (23) If the number of PGs is greater than 1.05 times the expected value, the new weight new_weight of the OSD is calculated using the following formula:

[0153] new_weight = round (old_weight * expected number of PGs / current number of PGs)

[0154] Among them, old_weight represents the current weight, and round represents rounding of floating point numbers;

[0155] (24) Calculate the difference between the current weight old_weight and the new weight new_weight in step (23), and accumulate it as the reduction;

[0156] (25) When the descending sorted OSD set traversal is completed, the weights of all OSDs that exceed the expected value have been adjusted. At this time, all OSDs in the system are sorted in ascending order based on the latest PG number of the OSD;

[0157] (26) Traverse the OSD set sorted in ascending order. If the current value of the cumulative reduction is equal to 0, it means that the weights of the OSDs that currently need to be adjusted to be lower than the expected value have all been balanced, and the traversal ends. Otherwise, go to step (27).

[0158] (27) If there is still a remaining reduction, the new weight new_weight is calculated for the currently traversed OSD. The calculation formula is as follows:

[0159] new_weight=old_weight*(1-0.5)+round(old_weight*desired PG number / current PG number)*0.5

[0160] Among them, old_weight represents the current weight, and round represents rounding of floating-point numbers.

[0161] (28) Calculate the difference between the new weight new_weight in step (27) and the current weight old_weight, and make a corresponding deduction from the accumulated reduction.

[0162] The equal weight adjustment uses descending and ascending sorting. By traversing the descending set, the cumulative value that exceeds the expected weight is calculated, and then the cumulative value is used to fill the ascending set, and the weight of the OSD that exceeds the expected value is adjusted to the OSD that is lower than the expected value. After the OSD is adjusted to obtain the new weight, a new crushmap is generated based on the new weight.

[0163] 3. One-time injection migration

[0164] Specifically, after modifying the OSD weight to generate a new crushmap, inject the new crushmap into the Ceph cluster, and perform PG data migration based on the new crushmap. Since the weight in the new crushmap is the weight when the data is finally balanced, only one data migration is required to achieve data balance. Figure 7 By injecting a new crushmap with adjusted weights, OSD.0 migrates 30 PGs to OSD.1, thus achieving data balance in the system.

[0165] The offline data balancing system provided in the embodiment of the present application realizes system data balancing through an offline calculation expectation algorithm, an equal weight adjustment algorithm and an online one-time injection migration, thereby avoiding cluster failure problems caused by online weight adjustment. At the same time, the one-time injection migration reduces the performance impact brought by balanced data and improves the overall performance of the distributed storage system.

[0166] In order to better implement the above method, an embodiment of the present application also provides a data balancing device, which can be integrated in an electronic device, such as a server or a terminal. The terminal may include a tablet computer, a laptop computer and / or a personal computer.

[0167] For example, Figure 8 As shown, the data balancing device may include: an acquisition unit 301, a first determination unit 302, a second determination unit 303, an adjustment unit 304 and a migration unit 305, as follows:

[0168] An acquisition unit 301 is used to acquire a storage expected value corresponding to each storage device in the distributed storage system;

[0169] A first determining unit 302, configured to determine a first ratio between a current storage capacity of the storage device and the storage expected value;

[0170] A second determining unit 303, configured to determine a first storage device where the first ratio is greater than a preset value, wherein the preset value is greater than 1;

[0171] An adjusting unit 304 is configured to adjust the weights of the first storage device and the second storage device at least according to the current weight of the first storage device, the current storage capacity and the storage expected value, wherein the second storage device is a storage device in the distributed storage system whose current storage capacity is lower than the storage expected value;

[0172] The migration unit 305 is used to migrate the data of the corresponding amount in the first storage device to the second storage device based on the adjusted weight.

[0173] In one implementation, the adjustment unit 304 is configured to:

[0174] Determining a first target weight to which the first storage device needs to be adjusted according to the current weight of the first storage device, the current storage amount, and the storage expected value;

[0175] Obtaining a cumulative value of a difference between the first target weight and a current weight of the first storage device to obtain a first weight difference;

[0176] The weight of the second storage device is adjusted based on the first weight difference.

[0177] In one embodiment, when determining the first target weight to which the first storage device needs to be adjusted according to the current weight of the first storage device, the current storage amount, and the storage expected value, the adjustment unit 304 is specifically configured to:

[0178] Acquire a second ratio between the expected storage value and the current storage capacity of the first storage device;

[0179] The current weight of the first storage device is weighted according to the second ratio to obtain the first target weight.

[0180] In one implementation, when adjusting the weight of the second storage device based on the weight difference, the adjusting unit 304 is specifically configured to:

[0181] A second target weight to which the second storage device needs to be adjusted is determined according to the current weight of the second storage device, the current storage amount, the storage expected value, and the first weight difference.

[0182] In one embodiment, when determining the second target weight to which the second storage device needs to be adjusted according to the current weight of the second storage device, the current storage amount, the storage expected value and the first weight difference, the adjustment unit 304 is specifically used to:

[0183] Acquire a third ratio between the storage expected value and the current storage capacity of the second storage device;

[0184] Performing weighted processing on the current weight of the second storage device according to the third ratio to obtain a processed weight;

[0185] Adjusting the processed weight and the current weight of the second storage device based on a preset adjustment coefficient, and summing the adjusted processed weight and the adjusted current weight to obtain an adjusted weight;

[0186] Obtaining a cumulative value of a difference between the adjusted weight and a current weight of the second storage device to obtain a second weight difference;

[0187] The adjusted weight is iterated until the second weight difference is the same as the first weight difference, and the adjusted weight obtained in the last iteration is determined as the second target weight.

[0188] In one embodiment, the migration unit 305 is used to:

[0189] Based on the adjusted weights, determining a first amount of data to be migrated out of the first storage device and a second amount of data to be migrated into the second storage device;

[0190] Based on the first data amount and the second data amount, the data in the first storage device is migrated to the corresponding second storage device.

[0191] In one implementation, the acquisition unit 301 is specifically configured to:

[0192] Get the current cluster topology information corresponding to the distributed storage system;

[0193] Determine the basic weight of each storage device in the distributed storage system according to the current cluster topology information;

[0194] Get the total amount of data storage in the distributed system;

[0195] The storage expected value corresponding to each storage device is determined according to the basic weight and the total amount of data storage.

[0196] As can be seen from the above, the data balancing device provided in the embodiment of the present application obtains the storage expectation value corresponding to each storage device in the distributed storage system, and determines the first ratio between the current storage capacity of each storage device and the storage expectation value; then, the first storage device whose first ratio is greater than the preset value is screened out, and the weights of the first storage device and the second storage device are adjusted according to the current weight, current storage capacity and storage expectation value of the first storage device; finally, based on the adjusted weight, the data of the corresponding amount of data in the first storage device is migrated to the second storage device to balance the data distribution in the distributed storage system. This solution realizes system data balancing through the calculation expectation value algorithm, equal weight adjustment algorithm and online one-time injection migration in an offline manner, avoiding the cluster failure problem caused by the online weight adjustment. At the same time, the one-time injection migration reduces the performance impact caused by balanced data and improves the overall performance of the distributed storage system.

[0197] The present application also provides an electronic device, such as Fig. 9 As shown, it shows a schematic diagram of the structure of the electronic device involved in the embodiment of the present application, specifically:

[0198] The electronic device may include components such as a processor 401 with one or more processing cores, a memory 402 with one or more computer-readable storage media, a power supply 403, and an input unit 404. Those skilled in the art will appreciate that Fig. 9 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0199] The processor 401 is the control center of the electronic device, and uses various interfaces and lines to connect various parts of the entire electronic device. By running or executing software programs and / or modules stored in the memory 402, and calling data stored in the memory 402, the processor 401 performs various functions of the electronic device and processes data. Optionally, the processor 401 may include one or more processing cores; preferably, the processor 401 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 401.

[0200] The memory 402 can be used to store software programs and modules. The processor 401 executes various functional applications and data balancing by running the software programs and modules stored in the memory 402. The memory 402 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 402 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 402 may also include a memory controller to provide the processor 401 with access to the memory 402.

[0201] The electronic device also includes a power supply 403 for supplying power to each component. Preferably, the power supply 403 can be logically connected to the processor 401 through a power management system, so as to manage charging, discharging, power consumption and other functions through the power management system. The power supply 403 can also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators and other arbitrary components.

[0202] The electronic device may further include an input unit 404, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.

[0203] Although not shown, the electronic device may further include a display unit, etc., which will not be described in detail herein. Specifically in this embodiment, the processor 401 in the electronic device will load the executable files corresponding to the processes of one or more application programs into the memory 402 according to the following instructions, and the processor 401 will run the application programs stored in the memory 402, thereby realizing various functions, as follows:

[0204] Obtaining the storage expected value corresponding to each storage device in the distributed storage system;

[0205] Determining a first ratio between a current storage capacity of the storage device and the storage expectation value;

[0206] Determine a first storage device where the first ratio is greater than a preset value, wherein the preset value is greater than 1;

[0207] Adjusting the weights of the first storage device and the second storage device at least according to the current weight of the first storage device, the current storage capacity and the storage expected value, wherein the second storage device is a storage device in the distributed storage system whose current storage capacity is lower than the storage expected value;

[0208] Based on the adjusted weight, data of a corresponding amount in the first storage device is migrated to the second storage device.

[0209] In one embodiment, when adjusting the weights of the first storage device and the second storage device according to at least the current weight of the first storage device, the current storage amount, and the storage expected value, the processor 401 is specifically configured to:

[0210] Determining a first target weight to which the first storage device needs to be adjusted according to the current weight of the first storage device, the current storage amount, and the storage expected value;

[0211] Obtaining a cumulative value of a difference between the first target weight and a current weight of the first storage device to obtain a first weight difference;

[0212] The weight of the second storage device is adjusted based on the first weight difference.

[0213] In one embodiment, when determining the first target weight to which the first storage device needs to be adjusted according to the current weight of the first storage device, the current storage amount, and the storage expected value, the processor 401 is specifically configured to:

[0214] Acquire a second ratio between the expected storage value and the current storage capacity of the first storage device;

[0215] The current weight of the first storage device is weighted according to the second ratio to obtain the first target weight.

[0216] In one implementation, when adjusting the weight of the second storage device based on the weight difference, the processor 401 is specifically configured to:

[0217] A second target weight to which the second storage device needs to be adjusted is determined according to the current weight of the second storage device, the current storage amount, the storage expected value, and the first weight difference.

[0218] In one embodiment, when determining the second target weight to which the second storage device needs to be adjusted according to the current weight of the second storage device, the current storage amount, the storage expected value, and the first weight difference, the processor 401 is specifically configured to:

[0219] Acquire a third ratio between the storage expected value and the current storage capacity of the second storage device;

[0220] Performing weighted processing on the current weight of the second storage device according to the third ratio to obtain a processed weight;

[0221] Adjusting the processed weight and the current weight of the second storage device based on a preset adjustment coefficient, and summing the adjusted processed weight and the adjusted current weight to obtain an adjusted weight;

[0222] Obtaining a cumulative value of a difference between the adjusted weight and a current weight of the second storage device to obtain a second weight difference;

[0223] The adjusted weight is iterated until the second weight difference is the same as the first weight difference, and the adjusted weight obtained in the last iteration is determined as the second target weight.

[0224] In one implementation, when migrating the data of the corresponding amount in the first storage device to the second storage device based on the adjusted weight, the processor 401 is specifically configured to:

[0225] Based on the adjusted weights, determining a first amount of data to be migrated out of the first storage device and a second amount of data to be migrated into the second storage device;

[0226] Based on the first data amount and the second data amount, the data in the first storage device is migrated to the corresponding second storage device.

[0227] In one implementation, when acquiring the storage expected value corresponding to each storage device in the distributed storage system, the processor 401 is specifically configured to:

[0228] Get the current cluster topology information corresponding to the distributed storage system;

[0229] Determine the basic weight of each storage device in the distributed storage system according to the current cluster topology information;

[0230] Get the total amount of data storage in the distributed system;

[0231] The storage expected value corresponding to each storage device is determined according to the basic weight and the total amount of data storage.

[0232] The electronic device provided in the embodiment of the present application obtains the storage expectation value corresponding to each storage device in the distributed storage system, and determines the first ratio between the current storage capacity of each storage device and the storage expectation value; then, screens out the first storage device whose first ratio is greater than the preset value, and adjusts the weights of the first storage device and the second storage device according to the current weight, current storage capacity and storage expectation value of the first storage device; finally, based on the adjusted weight, migrates the corresponding amount of data in the first storage device to the second storage device to balance the data distribution in the distributed storage system. This solution achieves system data balance through the calculation expectation value algorithm, equal weight adjustment algorithm and online one-time injection migration in an offline manner, avoiding the cluster failure problem caused by online weight adjustment. At the same time, the one-time injection migration reduces the performance impact caused by balanced data and improves the overall performance of the distributed storage system.

[0233] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.

[0234] The computer-readable storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0235] Since the instructions stored in the computer-readable storage medium can execute the steps in any data balancing method provided in the embodiments of the present application, the beneficial effects that can be achieved by any data balancing method provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.

[0236] According to one aspect of the present application, a computer program product or a computer program is provided, the computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the method provided in various optional implementations of the above-mentioned data balancing aspect.

[0237] The above is a detailed introduction to a data balancing method, device, storage medium and electronic device provided in an embodiment of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for technical personnel in this field, according to the idea of ​​the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A data balancing method, characterized in that: include: Obtaining the storage expected value corresponding to each storage device in the distributed storage system; Determining a first ratio between a current storage capacity of the storage device and the storage expectation value; Determine a first storage device where the first ratio is greater than a preset value, wherein the preset value is greater than 1; adjusting the weights of the first storage device and the second storage device at least according to the current weight of the first storage device, the current storage capacity and the storage expected value, wherein the second storage device is a storage device in the distributed storage system whose current storage capacity is lower than the storage expected value; Based on the adjusted weight, a corresponding amount of data in the first storage device is migrated to the second storage device.

2. The data equalization method according to claim 1, characterized in that: The step of adjusting the weights of the first storage device and the second storage device at least according to the current weight of the first storage device, the current storage amount, and the storage expected value includes: Determining a first target weight to which the first storage device needs to be adjusted according to the current weight of the first storage device, the current storage amount, and the storage expected value; Obtaining a cumulative value of a difference between the first target weight and a current weight of the first storage device to obtain a first weight difference; The weight of the second storage device is adjusted based on the first weight difference.

3. The data equalization method according to claim 2, characterized in that: Determining a first target weight to which the first storage device needs to be adjusted according to the current weight of the first storage device, the current storage amount, and the storage expected value includes: Acquire a second ratio between the expected storage value and the current storage capacity of the first storage device; The current weight of the first storage device is weighted according to the second ratio to obtain the first target weight.

4. The data equalization method according to claim 2, characterized in that: The adjusting the weight of the second storage device based on the weight difference includes: A second target weight to which the second storage device needs to be adjusted is determined according to the current weight of the second storage device, the current storage amount, the storage expected value, and the first weight difference.

5. The data equalization method according to claim 4, characterized in that: The determining, according to the current weight of the second storage device, the current storage amount, the storage expected value, and the first weight difference, a second target weight to which the second storage device needs to be adjusted includes: Acquire a third ratio between the expected storage value and the current storage capacity of the second storage device; Performing weighted processing on the current weight of the second storage device according to the third ratio to obtain a processed weight; Adjusting the processed weight and the current weight of the second storage device based on a preset adjustment coefficient, and summing the adjusted processed weight and the adjusted current weight to obtain an adjusted weight; Obtaining a cumulative value of a difference between the adjusted weight and a current weight of the second storage device to obtain a second weight difference; The adjusted weight is iterated until the second weight difference is the same as the first weight difference, and the adjusted weight obtained in the last iteration is determined as the second target weight.

6. The data equalization method according to claim 1, characterized in that: The step of migrating a corresponding amount of data in the first storage device to the second storage device based on the adjusted weight includes: Based on the adjusted weights, determining a first amount of data to be migrated out of the first storage device and a second amount of data to be migrated into the second storage device; Based on the first data amount and the second data amount, data in the first storage device is migrated to the corresponding second storage device.

7. The data equalization method according to any one of claims 1 to 6, characterized in that: The obtaining of the storage expected value corresponding to each storage device in the distributed storage system includes: Get the current cluster topology information corresponding to the distributed storage system; Determining a basic weight of each storage device in the distributed storage system according to the current cluster topology information; Obtaining the total amount of data stored in the distributed system; The storage expected value corresponding to each storage device is determined according to the basic weight and the total amount of data storage.

8. A data equalization device, characterized in that: include: An acquisition unit, used to acquire a storage expected value corresponding to each storage device in the distributed storage system; A first determining unit, configured to determine a first ratio between a current storage capacity of the storage device and the storage expected value; A second determining unit, configured to determine a first storage device for which the first ratio is greater than a preset value, wherein the preset value is greater than 1; an adjusting unit, configured to adjust the weights of the first storage device and the second storage device according to at least a current weight of the first storage device, the current storage amount, and the storage expected value, wherein the second storage device is a storage device in the distributed storage system in which the current storage amount is lower than the storage expected value; A migration unit is used to migrate the data of the corresponding amount in the first storage device to the second storage device based on the adjusted weight.

9. An electronic device, characterized in that: It comprises a processor and a memory, wherein the memory stores an application program, and the processor is used to run the application program in the memory to execute the steps in the data balancing method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the steps in the data balancing method according to any one of claims 1 to 7.