Capacity reduction method and device of distributed storage system, electronic equipment and medium
By accepting the shrinkage request, obtaining and migrating the full data of the data table, recording the corresponding relationship, and deleting the first shard, the problem of low shrinkage efficiency in the distributed storage system is solved, and efficient data migration and business continuity are achieved.
Patent Information
- Application Number
- CN202410789618.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-18
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2044-06-18
AI Technical Summary
When scaling down a distributed storage system, the existing technology is inefficient and cannot correctly obtain the data storage location, resulting in complicated migration and affecting system performance.
By accepting the capacity reduction request, obtain the full data of the data table to be migrated, migrate it to the second shard, record the corresponding relationship, and delete the first shard to avoid direct data migration with the second shard and reduce business impact. influence.
It improves the flexibility and efficiency of distributed storage system scaling, lifts the restrictions on data migration caused by hash operations, reduces the impact on business, and ensures data consistency.
Smart Images

Figure CN118626563A
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to the field of cloud storage and distributed system management technology. Background Art
[0002] In a distributed storage system, data tables are stored in the form of shards. When data tables stored in a sharded cluster are transferred to other systems, or when a large-capacity sharded cluster established to cope with business peaks needs to reduce capacity after the business peak, there is a need to reduce the number of shards in the distributed storage system. In this case, the distributed storage system needs to be scaled down, that is, some shards in the distributed storage system need to be deleted. Summary of the invention
[0003] The present disclosure provides a capacity reduction method, device, electronic device and medium for a distributed storage system.
[0004] In a first aspect of an embodiment of the present disclosure, a method for reducing capacity of a distributed storage system is provided, wherein the distributed storage system includes a first shard and a second shard, each shard includes a plurality of nodes, and each node included in the same shard stores the same data table, and the method includes:
[0005] receiving a shrink request, the shrink request being used to request migration of the to-be-migrated data table stored in the first shard to the second shard;
[0006] Obtaining the full amount of data of the data table to be migrated stored in a node of the first shard;
[0007] Migrating all the data in the to-be-migrated data table to each node included in the second shard;
[0008] Recording a correspondence between the identifier of the data table to be migrated and the identifier of the second shard, wherein the correspondence indicates that the data table to be migrated is stored in the second shard;
[0009] Delete the first fragment.
[0010] According to a second aspect of an embodiment of the present disclosure, a device for reducing capacity of a distributed storage system is provided, wherein the distributed storage system includes a first shard and a second shard, each shard includes a plurality of nodes, and each node in the same shard stores the same data table, and the device includes:
[0011] A receiving module, configured to receive a shrink request, wherein the shrink request is used to request to migrate the to-be-migrated data table stored in the first shard to the second shard;
[0012] An acquisition module, used to acquire the full amount of data of the data table to be migrated stored in a node of the first shard;
[0013] A migration module, used to migrate all the data of the data table to be migrated to each node included in the second shard;
[0014] A recording module, used for recording a correspondence between the identifier of the data table to be migrated and the identifier of the second shard, wherein the correspondence indicates that the data table to be migrated is stored in the second shard;
[0015] A deletion module is used to delete the first fragment.
[0016] According to a third aspect of the embodiments of the present disclosure, there is provided an electronic device, including:
[0017] at least one processor; and
[0018] a memory communicatively connected to the at least one processor; wherein,
[0019] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform any method according to the first aspect.
[0020] According to a fourth aspect of an embodiment of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause the computer to execute a method according to any one of the first aspects.
[0021] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided, including a computer program, wherein when the computer program is executed by a processor, the method according to any one of the first aspects is implemented.
[0022] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.
[0024] Figure 1 is a flow chart of a method for reducing capacity of a distributed storage system provided by an embodiment of the present disclosure;
[0025] Figure 2 It is a flow chart of a method for synchronizing distributed metadata by a reduced capacity server provided by an embodiment of the present disclosure;
[0026] Figure 3 is an exemplary schematic diagram of a capacity reduction process of a distributed storage system provided by an embodiment of the present disclosure;
[0027] Figure 4 is a signaling diagram of a capacity reduction process of a distributed storage system provided by an embodiment of the present disclosure;
[0028] Figure 5 is an exemplary schematic diagram of another distributed storage system capacity reduction provided by an embodiment of the present disclosure;
[0029] Figure 6 is a structural schematic diagram of a capacity reduction device of a distributed storage system provided by an embodiment of the present disclosure;
[0030] Figure 7 It is a block diagram of an electronic device used to implement the capacity reduction method of the distributed storage system according to the embodiment of the present disclosure. DETAILED DESCRIPTION
[0031] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0032] At present, the shard where a data table stored in a distributed storage system is located is generally determined by the data identifier (Identifier, id) of the data table, that is, a hash operation is performed on the data id of the data table, and the resulting hash value is the shard id of a shard, indicating that the data table is stored in the shard corresponding to the shard id.
[0033] In this case, if you need to migrate the data table stored in shard 1 to shard 2, the data table's ID and the existing hash operation cannot correctly obtain the storage location of the data table. Therefore, you can only modify the data table's ID or hash operation to ensure that the migrated data can be accurately located after the data migration. It can be seen that this method is relatively complicated, resulting in low efficiency in scaling down the distributed storage system.
[0034] In order to solve this problem, an embodiment of the present disclosure provides a method for reducing the capacity of a distributed storage system. Before introducing the method, the terms involved in the embodiment of the present disclosure are first explained:
[0035] A distributed storage system includes multiple shards. In order to distinguish the two shards involved in the scaling process, the embodiment of the present disclosure refers to the shard that needs to be deleted as the first shard, and the shard that needs to store the data table in the first shard as the second shard. The first shard may also be referred to as the shard to be scaled down, and the second shard may also be referred to as the reserved shard.
[0036] A shard includes multiple nodes. Each node in a shard stores the same data table. Each node is software running in a storage server. Each node in a shard can run in the same storage server or different storage servers.
[0037] The master node of the shard is used to perform write operations on the data table, and implement functions such as adding, deleting, and modifying the data table. In cases where the shard does not include slave nodes or the data table is read frequently, the master node can be set to implement the data table reading function.
[0038] The slave node of the shard is used to synchronize the data table stored in the master node and implement the reading function of the data table.
[0039] The backup node of the shard is used to synchronize the data tables stored in the primary node.
[0040] The capacity reduction server is used to execute the capacity reduction method of the distributed storage system provided in the embodiment of the present disclosure, so as to reduce the capacity of the distributed storage system and reduce the number of shards included in the distributed storage system.
[0041] The metadata server is used to store the metadata of each shard in the distributed storage system, as well as the correspondence between each data table and the shard in which it is located. For example, the metadata of the shard includes: the Internet Protocol (IP) address and port number of the storage server where each node included in the shard is located, the master-slave status of each node, and the available storage space and used storage space of the shard, etc. Among them, the master-slave status indicates whether the node is currently a master node, a slave node, or a backup node.
[0042] The proxy server is used to receive the read and write instructions issued by the user, find the shard where the data table is located, and perform the read and write operations on the shard.
[0043] See also Figure 1 The distributed storage system capacity reduction method provided in the embodiment of the present disclosure is applied to the capacity reduction server, and includes the following steps:
[0044] S101. Receive a shrink request, where the shrink request is used to request to migrate a to-be-migrated data table stored in a first shard to a second shard.
[0045] The distributed storage system includes a first shard and a second shard. The first shard and the second shard may be specified by a user, or may be random, or may be preset, and this is not specifically limited in the embodiments of the present disclosure.
[0046] The shrink request may be triggered by a user or automatically. For example, when the monitoring server detects that the ratio between the total amount of data stored in each shard in the distributed storage system and the total capacity of each shard is less than a preset ratio, the monitoring server sends a shrink request to the shrink server.
[0047] S102: Obtain all the data of the data table to be migrated stored in a node of the first shard.
[0048] Since the data stored in each node in the first shard is the same, it is possible to obtain the full data of the data table to be migrated stored in only one node of the first shard.
[0049] S103: Migrate all the data in the data table to be migrated to each node included in the second shard.
[0050] Optionally, before S103, each node included in the second shard may store other data tables, or may not store any data tables. In the case that each node included in the second shard stores other data tables before S103, executing S103 does not affect the data tables stored in each node included in the second shard, that is, during the data migration process, the data tables to be migrated do not cover the data tables stored in each node of the second shard, so that after executing S103, each node of the second shard stores the originally stored data tables and the data tables to be migrated.
[0051] S104: Record the correspondence between the identifier of the data table to be migrated and the identifier of the second shard, where the correspondence indicates that the data table to be migrated is stored in the second shard.
[0052] The identifier of the data table may be a unique identifier such as the name of the data table or the ID of the data table. The identifier of the shard may be a unique identifier such as the name or number of the shard.
[0053] For example, the corresponding relationship is: “123:11111”, where 123 is the identifier of the data table, and 11111 is the identifier of the second shard.
[0054] S105: Delete the first fragment.
[0055] Since the data table to be migrated in the first shard has been stored in each node of the second shard, the first shard can be deleted, thereby achieving capacity reduction of the distributed storage system.
[0056] In the process of reducing the capacity of the distributed storage system in the embodiment of the present disclosure, since the reduction server can store the full amount of data of the data table to be migrated stored in the first shard, and migrate the full amount of data to each node of the second shard, that is, the first shard does not need to directly migrate data with the second shard, and therefore does not need to block the read and write operations on the first shard, reducing the impact of the reduction process on the business. In addition, the embodiment of the present disclosure can directly set the correspondence between the data table and the shard in the distributed storage system, so when searching for the shard where the data table is located, it is not necessary to rely on the hash value of the data table identifier, which removes the restriction of the hash operation on the shard storing the data table, making the migration of the data table more flexible, and improving the flexibility and efficiency of reduction.
[0057] The following is a detailed description of the steps of the distributed storage system scaling method provided in the embodiment of the present disclosure:
[0058] In some embodiments of the present disclosure, each shard includes at least one spare node. At this time, the above-mentioned S102 scaling-down server obtains the full amount of data of the data table to be migrated stored in a node of the first shard, which can be implemented as follows: obtaining the full amount of data of the data table to be migrated stored in a spare node of the first shard.
[0059] That is, the reduced capacity server can send a full backup request to a backup node of the first shard, so that the backup node performs a full backup task on the data table to be migrated stored in itself, and obtains the full data of the data table to be migrated in a preset format. For example, the backup node can use a dump function to export the full data of the data table to be migrated stored in itself in a preset format.
[0060] In some embodiments of the present disclosure, in order to improve the success rate of scaling down, the scaling down server may also perform a pre-check on the distributed storage system before executing the above S102 to obtain the full amount of data of the data table to be migrated stored in a node of the first shard.
[0061] That is, the shrinking server can also: check whether the preset shrinking condition is met, and if the check is passed, execute S102 to obtain the full amount of data of the to-be-migrated data table stored in a node of the first shard. Otherwise, do not continue to execute S102, and output a prompt message to the user to prompt the user that the distributed storage system cannot be shrunk at present.
[0062] The preset shrinking condition includes: the available storage space of the second shard is greater than the product of the used storage space of the first shard and a preset multiple.
[0063] The available storage space of the second shard indicates the unoccupied storage space in the second shard. The used storage space of the first shard indicates the storage space occupied by the data table to be migrated in the first shard.
[0064] The preset multiple is greater than 1, for example, the preset multiple is 1.5. In an actual scenario, the preset multiple can be set by a person who manages the distributed storage system based on experience.
[0065] The disclosed embodiment controls the available storage space of the second shard to be larger than the product of the used storage space of the first shard and a preset multiple, thereby avoiding the situation where the second shard is unable to store the data table to be migrated due to insufficient available storage space, thereby improving the success rate of migrating the data table to be migrated, that is, improving the success rate of shrinking the distributed storage system.
[0066] In the embodiment of the present disclosure, the above-mentioned preset shrinking condition may also include: there is no other shrinking task in the distributed storage system at present.
[0067] The shrinking server may record the task identifier of the shrinking task corresponding to the shrinking request after receiving each shrinking request, and record the shrinking status corresponding to the task identifier. For example, the shrinking status may be: shrinking in progress or shrinking completed.
[0068] On this basis, the shrinking server can check whether there is a corresponding shrinking task identifier with a shrinking status of being shrunk, in addition to the shrinking task corresponding to the shrinking request received in S101. If so, it is determined that there are other shrinking tasks in the distributed storage system; if not, it is determined that there are no other shrinking tasks in the distributed storage system.
[0069] By controlling the distributed storage system to shrink only when there are no other shrinking tasks, it is possible to avoid executing different shrinking tasks at the same time, which may lead to errors in data table migration and errors in recording the correspondence between the data table identifier and the shard identifier, thereby ensuring the accuracy of shrinking the distributed storage system.
[0070] In some embodiments of the present disclosure, since the distributed storage system further includes a metadata server, and the metadata server stores metadata of each shard included in the distributed storage system, before checking whether the preset scaling-down condition is met, the scaling-down server may also send a shard data acquisition request to the metadata server, and then receive a shard information acquisition response sent by the metadata server.
[0071] The shard data acquisition request is used to request the metadata of the first shard and the metadata of the second shard. The shard information acquisition response includes the metadata of the first shard and the metadata of the second shard, and the metadata of the shard includes the used storage space and the available storage space.
[0072] A monitoring module may be configured in the metadata server to monitor and update metadata such as the used storage space and available storage space of each shard included in the distributed storage system in real time.
[0073] The metadata of the shard may also include: the IP address and port number of the storage server where each node included in the shard is located, and the master-slave status of each node.
[0074] After the reduced capacity server obtains the IP address and port number of the storage server where the node is located, it can subsequently use the IP address and port number of the storage server where the node is located to communicate with the storage server, thereby instructing the storage server to perform corresponding operations on the node. For example, the reduced capacity server sends a request to the storage server based on the IP address and port number of the storage server where a node of the first shard is located, requesting to obtain the full amount of data of the data table to be migrated stored by the node. The storage server obtains the full amount of data of the data table to be migrated stored by the node and sends it to the reduced capacity server.
[0075] The capacity reduction server can obtain the metadata of the first shard and the second shard from the metadata server, so as to perform a preliminary check on the distributed storage system based on the metadata, thereby improving the stability and accuracy of capacity reduction.
[0076] After the distributed storage system is pre-checked and passed, the downscaling server executes the above step S102 to obtain the full data of the data table to be migrated stored in a node of the first shard. When executing S102, if the downscaling server cannot successfully obtain the full data of the data table to be migrated from a spare node of the first shard, it can select another spare node of the first shard and obtain the full data from the spare node. If it still fails to obtain, the downscaling failure is reported to the metadata server, so that the metadata server records the failure of this downscaling task in the log.
[0077] In some embodiments of the present disclosure, the above-mentioned S103, in which the shrinking server migrates all the data of the to-be-migrated data table to each node included in the second shard, includes the following steps:
[0078] Step 1: Migrate all data to each non-primary node included in the second shard.
[0079] The second shard includes a master node and at least one non-master node.
[0080] Since the downsizing server can obtain the metadata of the second shard from the metadata server, and the metadata of the second shard records the master-slave status of each node, the downsizing server can determine each non-master node included in the second shard based on the master-slave status of each node included in the second shard, and then migrate the full data to each non-master node included in the second shard.
[0081] During migration, the shrinking server can initiate data migration tasks in batches, each of which is used to migrate all data to a non-primary node included in the second shard. The shrinking server can also cyclically check the status of each data migration task until the status of each data migration task is completed.
[0082] Step 2: Switch the master node included in the second shard to a non-master node, and switch a non-master node included in the second shard to the master node, and migrate all data to the master node of the second shard before the master-slave switch.
[0083] The downsizing server may send a master-slave switching instruction to the storage server where the master node of the second shard is located, so that the storage server switches the master node to a non-master node, and selects a slave node of the second shard to switch the slave node to the master node.
[0084] When migrating the full amount of data of the data table to be migrated to the second shard, the disclosed embodiment first migrates the full amount of data to the non-master node of the second shard, and then performs a master-slave switch on the second shard, and then migrates the full amount of data to the master node before the master-slave switch, ensuring that each data migration is targeted at the slave node of the second shard. Since the master node of each shard needs to perform a data write operation, and the data migration process may affect the data write operation, resulting in inaccurate data stored in the master node or causing a response delay in the data write operation, the disclosed embodiment only performs data migration on the slave node, ensuring the continuity of the data read and write business.
[0085] In some embodiments of the present disclosure, before executing the above step 2 to switch the master node included in the second shard to a non-master node, the scaling-down server may also check whether the full amount of data has been successfully stored in each non-master node included in the second shard.
[0086] The checking process can be implemented as: checking whether each non-primary node included in the second shard stores the full amount of data completely.
[0087] If any non-master node does not store the full amount of data completely, and the number of retries for the non-master node does not reach the first preset number, the full amount of data is stored in the non-master node again, and the number of retries for the non-master node + 1 is recorded. The first preset number can be set according to actual needs, for example, the first preset number is set to 3.
[0088] If any non-master node fails to store the full amount of data completely, and the number of retries for the non-master node reaches the first preset number, the full amount of data stored in each non-master node included in the second shard is deleted, that is, the data is rolled back for each non-master node included in the second shard, and the full amount of data stored in the reduced capacity server itself is deleted.
[0089] If all non-master nodes included in the second shard store the full amount of data completely, the step of switching the master node included in the second shard to a non-master node is executed.
[0090] The shrinking server can compare whether the difference between the global transaction identifier (GTID) stored in itself and the GTID in the non-primary node is less than the preset difference. If so, it is determined that the non-primary node has stored complete full data, otherwise, it is determined that the full data stored in the non-primary node is incomplete.
[0091] In order to reduce the impact of the time-consuming data migration on the inspection process, the reduced capacity server can cyclically check the data migration status of each non-primary node of the second shard, and perform the above inspection process when the data migration status of each non-primary node is completed.
[0092] Through the above method, the shrinking server can retry when the non-master node of the second shard fails to store the full data. If the full data cannot be successfully stored in the non-master node after the first preset number of retries, it means that the second shard cannot store the data table to be migrated, and the current shrinking task fails. The shrinking server can delete the full data stored in each non-master node included in the second shard and the full data stored in itself, thereby reducing the storage of useless data in the second shard and the shrinking server.
[0093] In some embodiments of the present disclosure, the second shard may include: a master node, at least one slave node and a backup node. In this case, the non-master node includes: a slave node and a backup node. The master node provides a data writing function, the slave node provides a data reading function, and the backup node is used to back up the data stored in the master node, thereby improving the disaster recovery capability of the distributed storage system.
[0094] In this case, the step of performing master-slave switching by the reduced capacity server in step 2 can be implemented as follows: switching the master node included in the second shard to a slave node, and switching a slave node included in the second shard to a master node.
[0095] Through master-slave switching, it can be ensured that after the master-slave switching, the original master node is switched to a slave node, and then the data in the data table to be migrated is stored as a slave node. In addition, when an original slave node is switched to a master node, it can continue to provide the data writing function that the master node can provide, reducing the impact of data table migration on read and write services.
[0096] In some embodiments of the present disclosure, the second shard may include: a master node and at least one backup node. In this case, the above-mentioned non-master node is a backup node. Among them, the master node provides data writing function and data reading function, and the backup node is used to back up the data stored in the master node. In this case, the second shard does not include a slave node, thereby reducing the types of nodes included in the shard, and can reduce the number of nodes included in the shard. For example, the second shard may include only one master node and one backup node, reducing storage costs.
[0097] In this case, the step of performing master-slave switching in step 2 performed by the reduced capacity server can be implemented as follows: switching the master node included in the second shard to a backup node, and switching a backup node included in the second shard to the master node.
[0098] Through active-standby switching, it can be ensured that after active-standby switching, the original active node is switched to the standby node, and then the data in the data table to be migrated is stored as a standby node. In addition, an original standby node is switched to the active node, and continues to provide the data writing and data reading functions that the active node can provide, reducing the impact of data table migration on read and write services.
[0099] After the above S103 stores the full data in each node included in the second shard, since the user can still perform read and write operations on the data table to be migrated stored in the first shard during the data migration of the full data, the data table to be migrated is modified during the full data migration process, generating incremental data in addition to the full data.
[0100] In order to ensure the consistency between the data tables to be migrated in the first shard and the second shard, the downscaling server may also synchronize the incremental data in the data table to be migrated stored in the first shard except for the full data to the master node included in the second shard before recording the correspondence between the identifier of the data table to be migrated and the identifier of the second shard in the above S103.
[0101] That is, the downsizing server can determine the data table to be migrated during this downsizing process based on the difference between the distribution metadata of the distributed storage system before downsizing and the distribution metadata of the distributed storage system after downsizing. The distribution metadata represents the shard where each data table in the distributed storage system is located. Afterwards, the downsizing server sends an incremental migration instruction to the master node of the second shard, so that the master node of the second shard initiates a differential synchronization process to the master node of the first shard. The master node of the second shard is a logical slave node in the differential synchronization process, and the master node of the first shard is a logical master node in the differential synchronization process, so that the incremental data in the master node of the first shard is synchronized to the master node of the second shard. At the same time, differential synchronization can also avoid overwriting the data stored in the master node of the first shard.
[0102] Since there is a data synchronization mechanism between the master node and the non-master node of the second shard, the non-master node of the second shard can synchronize the incremental data stored in the master node of the second shard.
[0103] By synchronizing the incremental data except the full data in the data table to be migrated stored in the first shard to the master node included in the second shard, the consistency of the data to be migrated stored in the master node of the first shard and the master node of the second shard can be guaranteed, and the accuracy of data migration can be improved. In addition, the amount of incremental data is generally small, so the incremental data migration process has little impact on the read and write business involved in the data table to be migrated.
[0104] In some embodiments of the present disclosure, the metadata server of the distributed storage system records the distribution metadata, and the distribution metadata is used to indicate the shard where each data table stored in the distributed storage system is located. For example, the distribution metadata records the shard identifier corresponding to the identifier of each data table in the distributed storage system.
[0105] Before recording the correspondence between the identifier of the to-be-migrated data table and the identifier of the second shard, the shrinking server may also send a meta information acquisition request to the metadata server and receive a meta information acquisition response sent by the metadata server.
[0106] The meta information acquisition request is used to request the acquisition of distributed meta information of the distributed storage system, and the meta information acquisition response includes the distributed meta information.
[0107] On this basis, the way in which the downsizing server executes the above S104 to record the correspondence between the identifier of the data table to be migrated and the identifier of the second shard can be implemented as follows: in the distribution meta information, the shard identifier corresponding to the identifier of the data table to be migrated is updated to the identifier of the second shard.
[0108] When the identifier of the data table to be migrated recorded in the distribution meta-information before updating corresponds to the identifier of the first shard, the identifier of the first shard in the corresponding relationship may be modified to the identifier of the second shard.
[0109] Alternatively, when only the identifier of the data table to be migrated is recorded in the distribution meta-information before the update, but the identifier of the shard corresponding to the identifier of the data table to be migrated is not recorded, the identifier of the data table to be migrated corresponding to the identifier of the second shard may be recorded. Wherein, when only the identifier of the data table to be migrated is recorded in the distribution meta-information, a hash value may be obtained by performing a hash operation on the identifier of the data table to be migrated, and the shard where the data table to be migrated is located may be determined based on the hash value.
[0110] The capacity reduction server can update the shard identifier corresponding to the identifier of the data table to be migrated to the identifier of the second shard in the distributed meta information, thereby achieving unified management of each data table stored in the distributed storage system and improving management efficiency and accuracy.
[0111] After recording the correspondence between the to-be-migrated data table and the second shard in S104, and before deleting the first shard in S105, the capacity reduction server may also synchronize the updated distribution metadata to other devices included in the distributed management system. Figure 2 As shown, the synchronization process of the distributed metadata by the shrinking server includes the following steps:
[0112] S201, sending migration status information to a metadata server, wherein the distributed storage system further includes a proxy server, and the migration status information includes updated distribution metadata, so that the metadata server modifies the distribution metadata stored in itself into the updated distribution metadata, and modifies the distribution metadata stored in the proxy server into the updated distribution metadata.
[0113] Optionally, scaling down the server can be performed during off-peak hours Figure 2 The steps shown are used to reduce the impact of changes in distributed metadata on data read and write services in the distributed storage system. The service off-peak period may be a preset time period, for example, the service off-peak period is 00:00-05:00.
[0114] When modifying the distribution meta information of the proxy server, the metadata server may send a modification instruction to the proxy server, so that the proxy server obtains the updated distribution meta information from the metadata server and modifies the distribution meta information stored in itself to the updated distribution meta information.
[0115] The migration status information may further include: metadata of the first shard, metadata of the second shard, and / or progress information of differential synchronization of the first shard to the second shard, etc., which is not specifically limited in the embodiments of the present disclosure.
[0116] S202: If it is detected that the metadata server fails to modify the distribution metadata, the metadata server deletes the to-be-migrated data table stored in the metadata server itself, and deletes the to-be-migrated data table stored in each node included in the second shard.
[0117] In some embodiments of the present disclosure, the metadata server may also generate a task identifier for this downsizing task, and carry the task identifier in the above-mentioned meta-information acquisition response. At this time, the migration status information sent by the above-mentioned S201 downsizing server to the metadata server also includes the task identifier extracted from the meta-information acquisition response, so that the metadata server can check whether the task identifier included in the migration status information is the same as the task identifier generated by itself.
[0118] After the scaling-down server sends the migration status information to the metadata server in S201, if it receives a modification failure message sent by the metadata server, it determines that the metadata server has failed to modify the distribution metadata. The scaling-down failure message is a message sent by the metadata server indicating that the modification of the distribution metadata has failed when the metadata server checks that the task identifier included in the migration status information is different from the task identifier generated by itself.
[0119] When the metadata server detects that the task identifier included in the migration status information is different from the task identifier generated by itself, it will not modify the distribution metadata stored in itself and in the proxy server.
[0120] On the contrary, if the downscaling server receives a modification success message sent by the metadata server, or does not receive a downscaling failure message within a preset time after sending the migration status information, it is determined that the metadata server has successfully modified the distribution metadata. The downscaling success message is a message sent by the metadata server indicating that the modification of the distribution metadata is successful when the metadata server checks that the task identifier included in the migration status information is the same as the task identifier generated by itself.
[0121] When the metadata server detects that the task identifier included in the migration status information is the same as the task identifier generated by itself, it executes the steps of modifying the distributed metadata stored in itself to the updated distributed metadata and modifying the distributed metadata stored in the proxy server to the updated distributed metadata.
[0122] Through the above method, the reduced capacity server can detect whether the metadata server has successfully modified the distributed metadata stored in itself, thereby ensuring the consistency of the distributed metadata stored in the reduced capacity server and the metadata server.
[0123] If the metadata server fails to successfully modify the distribution metadata, it means that the scaling-down task has failed and the previously executed scaling-down steps need to be rolled back, that is, the scaling-down server deletes the data table to be migrated stored in itself and deletes the data table to be migrated stored in each node included in the second shard.
[0124] S203. If it is detected that the proxy server has failed to modify the distribution meta information successfully, the distribution meta information stored in the metadata server and the proxy server is modified to the distribution meta information before the update, the data table to be migrated stored in itself is deleted, and the data table to be migrated stored in each node included in the second shard is deleted.
[0125] If the proxy server fails to successfully modify the distribution metadata, it means that the scaling-down task has failed and the previously executed scaling-down steps need to be rolled back. That is, the scaling-down server modifies the distribution metadata stored by the metadata server and the proxy server to the distribution metadata before the update, deletes the data table to be migrated stored in itself, and deletes the data table to be migrated stored in each node included in the second shard.
[0126] The method for determining whether the proxy server has successfully modified the distribution metadata may be referred to the description below.
[0127] S204: If it is detected that both the metadata server and the proxy server have successfully modified the distribution metadata, execute S105 to delete the first fragment.
[0128] If both the metadata server and the proxy server successfully modify the distribution metadata, it means that the scaling down task is successful. At this time, you can delete the first shard and the data table to be migrated stored in the scaling down server to reduce the storage space occupied by useless data on the scaling down server. At this time, the read and write operations of the data to be migrated have been converted to be executed by the second shard.
[0129] After deleting the first shard in S105, the metadata of the first shard stored in the metadata server may also be deleted, and the storage server where the first shard is located may be removed from the distributed storage system, thereby reducing the number of physical devices included in the distributed storage system.
[0130] Through the above method, the reduced capacity server can synchronize the updated distribution metadata of the distributed storage system to the metadata server and the proxy server, so as to avoid the proxy server, after receiving the read and write instructions issued by the user, searching for the shard where the data table targeted by the read and write instructions is located based on the erroneous distribution metadata stored in its own storage before the update, thereby reducing the probability of data reading and writing errors.
[0131] In the embodiment of the present disclosure, there are multiple proxy servers in the distributed storage system. In this case, after the reduction server sends the migration status information to the metadata server in the above S201, it can also perform consistency check on the distributed metadata stored by each proxy server.
[0132] If the consistency check fails, it is determined that the proxy servers have failed to successfully modify the distribution metadata.
[0133] If the consistency check passes, it is determined that each proxy server has successfully modified the distribution metadata.
[0134] The reduced capacity server can obtain the distribution meta information stored in each proxy server, and compare the distribution meta information in each proxy server with the updated distribution meta information stored in the reduced capacity server itself. If the comparison results are the same, it is determined that the consistency check has passed; if there is a comparison result that is different, it is determined that the consistency check has not passed.
[0135] Alternatively, the reduced capacity server can obtain the distribution meta-information stored in each proxy server, and compare whether the obtained distribution meta-information is the same. If the comparison results are the same, it is determined that the consistency check has passed; if there are comparison results that are different, it is determined that the consistency check has not passed. And it is determined that the proxy server where the distribution meta-information that is different from other distribution meta-information is located has not been successfully modified. Alternatively, the consistency of the distribution meta-information stored in each proxy server can also be checked by other means, which is not specifically limited in the embodiments of the present disclosure.
[0136] After the metadata server modifies the distribution metadata stored by each proxy server to the updated distribution metadata, under normal circumstances, the distribution metadata stored by each proxy server should be the same, so the reduction server performs a consistency check on the distribution metadata stored by each proxy server. If the consistency check succeeds, it means that each proxy server has stored the updated distribution metadata, so it is determined that each proxy server has successfully modified the distribution metadata. If the consistency check fails, it means that there is a proxy server that does not store the updated distribution metadata, so it is determined that each proxy server has not successfully modified the distribution metadata.
[0137] The reduced capacity server can perform consistency check on the distributed metadata stored in each proxy server, thereby ensuring that the distributed metadata stored in each proxy server is the same, and avoiding the situation where incorrect distributed metadata is stored in some proxy servers, resulting in errors in reading and writing data tables in the distributed storage system.
[0138] In the embodiment of the present disclosure, in order to improve the success rate of synchronizing the distribution meta information of the proxy server, when the consistency check fails, before determining that each proxy server has failed to modify the distribution meta information, the reduced capacity server can also determine the proxy server to be retried that has not been successfully modified, and determine whether the number of retries for the proxy server to be retried reaches a second preset number. The second preset number can be set according to actual needs, for example, the second preset number is 5 times.
[0139] If so, the step of determining that each proxy server has failed to modify the distribution metadata is performed.
[0140] If not, the distribution meta information stored in the proxy server to be retried is modified to the updated distribution meta information, and the number of retries of the proxy server to be retried + 1 is recorded.
[0141] The reduced capacity server may send a retry instruction to the metadata server, so that the metadata server again notifies the proxy server to be retried to obtain updated distribution meta information from the metadata server, and to modify the distribution meta information stored in itself to the updated distribution meta information.
[0142] Alternatively, the reduced capacity server may send updated distribution meta information to the proxy server to be retried, so that the proxy server to be retried modifies the distribution meta information stored in itself to the updated distribution meta information.
[0143] Alternatively, the distribution meta information stored in the proxy server to be retried may be updated in other ways, which is not specifically limited in the embodiments of the present disclosure.
[0144] Through the above method, the capacity reduction server can retry the proxy server that failed to successfully modify the distribution metadata, that is, re-modify the distribution metadata stored in the proxy server to the updated distribution metadata, thereby improving the success rate of updating the distribution metadata on the proxy server, and thereby improving the success rate of reducing the capacity of the distributed storage system.
[0145] See also Figure 3 The following describes the distributed storage system involved in the embodiment of the present disclosure in combination with actual application scenarios:
[0146] The distributed storage system includes: a capacity reduction server, a metadata server, a proxy server, a first shard and a second shard. The nodes included in the first shard and the second shard respectively run in the storage server, the first shard includes a master node 1 and a slave node 1, and the second shard includes a master node 2 and a slave node 2. The servers communicate with each other through a network, and the types of network communication include: wired communication, wireless communication or optical fiber cable communication, etc.
[0147] The proxy server can communicate with the metadata server and the storage server where each shard is located through the network, and is used to receive read and write instructions for the data table sent by the user, search for the shard identifier corresponding to the identifier of the data table based on the distributed metadata stored in itself, and perform data read and write operations on the data table included in the shard corresponding to the shard identifier.
[0148] The metadata server can communicate with the proxy server and the shrinking server over the network, and is used to store the metadata of each shard in the distributed storage system and the distributed metadata of the distributed storage system.
[0149] The capacity reduction server can perform network communication with the storage server and the metadata server, and is used to execute the capacity reduction method of the distributed storage system provided in the embodiment of the present disclosure.
[0150] It should be noted that the proxy server, metadata server, capacity reduction server and storage server can be hardware or software. When the proxy server, metadata server, capacity reduction server and storage server are hardware, each server can be one or more physical servers, or various servers can be integrated into the same physical server. When the proxy server, metadata server, capacity reduction server and storage server are software, each server can be an independent software module, or various servers can be integrated into the same software module. The embodiments of the present disclosure do not specifically limit this.
[0151] It should be understood that Figure 3 The number of proxy servers, metadata servers, shards, and capacity reduction servers included in the distributed storage system shown is only illustrative. According to implementation requirements, the distributed storage system can have any number of proxy servers, metadata servers, shards, and capacity reduction servers.
[0152] See also Figure 4 The interactive process involved in the capacity reduction method of the distributed storage system provided by the embodiment of the present disclosure is described in detail below:
[0153] S401: The shrinking server receives a shrinking request.
[0154] S402: The shrinking server sends a request for obtaining meta information to the metadata server.
[0155] S403: The metadata server sends a meta information acquisition response to the scaling-down server, wherein the meta information acquisition response includes: metadata of the first shard, metadata of the second shard, distributed metadata of the distributed storage system, and a task identifier generated by the metadata server for this scaling-down task.
[0156] S404: The reduced capacity server sends a data acquisition request to the backup node of the first shard.
[0157] S405. The standby node of the first shard sends the full amount of data of the data table to be migrated to the reduced capacity server.
[0158] S406. The shrinking server migrates all the data in the data table to be migrated to each node included in the second shard.
[0159] S407: Perform differential synchronization between the master node of the first shard and the master node of the second shard, so as to synchronize the incremental data in the to-be-migrated data table stored in the master node of the first shard except for the full data to the master node included in the second shard.
[0160] S408: The shrinking server sends migration status information to the metadata server, so that the metadata server updates the distribution metadata stored in itself and the proxy server.
[0161] S409: The shrinking server deletes the first shard.
[0162] The traditional scaling-down method requires blocking the write operation of the data table involved in the migration process until the migration is completed. This method will cause users to feel the data migration when using the service, which will reduce the user experience.
[0163] During the scaling down process of the disclosed embodiment, the full data of the data table to be migrated is obtained by the scaling down server from the backup node of the first shard, and is synchronized to each node of the second shard respectively, without the need for the master node of the first shard to synchronize to the second shard. Therefore, there is no need to block the master node and slave node of the first shard, that is, the first shard can continue to perform read and write operations, which reduces the impact of the full data migration process on the read and write services involved in the first shard. Moreover, after the full data synchronization is completed, the master node of the first shard synchronizes the incremental data to the master node of the second shard, and the amount of incremental data is generally small, and the synchronization consumes less time, so the impact on the read and write services involved in the first shard and the second shard is small. Therefore, the disclosed embodiment can improve the efficiency and stability of scaling down the distributed storage system and ensure the utilization rate of storage resources.
[0164] See also Figure 5 In the following, in combination with actual application scenarios, the complete process of the distributed storage system reduction method executed by the reduction server in the embodiment of the present disclosure is described:
[0165] S501. Receive a scaling-down request, obtain the metadata of the first shard, the metadata of the second shard, the distributed metadata of the distributed storage system, and the task identifier generated by the metadata server for this scaling-down task from the metadata server, and obtain the full data of the data table to be migrated from the backup node of the first shard.
[0166] S502: Determine whether the full amount of data of the data table to be migrated is successfully obtained from the backup node of the first shard. If yes, execute S503; if no, execute S504.
[0167] S503: Migrate the full amount of data in the data table to be migrated to each node included in the second shard, and synchronize the incremental data in the data table to be migrated stored in the master node of the first shard except the full amount of data to the master node included in the second shard.
[0168] S504: Report the failure of scaling down to the metadata server, and delete the data table to be migrated stored in itself and the second shard.
[0169] S505: Determine whether the second shard successfully stores the full data and the incremental data. If yes, execute S506; if no, execute S504.
[0170] S506: Send migration status information to the metadata server, so that the metadata server updates the distribution metadata stored in itself and the proxy server.
[0171] S507: Determine whether the metadata server and each proxy server have successfully modified the distributed metadata. If yes, execute S508; if no, execute S509.
[0172] S508: Delete the first shard and delete the data table to be migrated stored in the shard.
[0173] S509: modify the distribution meta information stored in the metadata server and the proxy server to the distribution meta information before the update, delete the data table to be migrated stored in itself, and delete the data table to be migrated stored in each node included in the second shard.
[0174] It can be seen that in the embodiments of the present disclosure, even if an exception occurs during the scaling down process, resulting in interruption of data migration, the steps executed in the scaling down process can be rolled back, so that the scaling down server, the second shard, the metadata server and the proxy server return to the state before the scaling down, thereby reducing the impact of scaling down errors on the stability of the distributed storage system.
[0175] In the technical solution of the present disclosure, the collection, storage, use, processing, transmission, provision and disclosure of the data tables involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0176] Based on the same inventive concept, corresponding to the above method embodiment, the embodiment of the present disclosure also provides a capacity reduction device for a distributed storage system, wherein the distributed storage system includes a first shard and a second shard, each shard includes a plurality of nodes, and each node in the same shard stores the same data table. Figure 6 As shown, the device includes: a receiving module 601, an acquiring module 602, a migrating module 603, a recording module 604 and a deleting module 605.
[0177] A receiving module 601 is used to receive a shrink request, where the shrink request is used to request to migrate the to-be-migrated data table stored in the first shard to the second shard;
[0178] An acquisition module 602 is used to acquire the full amount of data of the data table to be migrated stored in a node of the first shard;
[0179] Migration module 603, used to migrate all the data of the data table to be migrated to each node included in the second shard;
[0180] A recording module 604 is used to record a correspondence between the identifier of the data table to be migrated and the identifier of the second shard, where the correspondence indicates that the data table to be migrated is stored in the second shard;
[0181] The deleting module 605 is used to delete the first fragment.
[0182] In some embodiments of the present disclosure, the second shard includes a master node and at least one non-master node, and the migration module 603 is specifically configured to:
[0183] Migrate all data to each non-primary node included in the second shard;
[0184] Switch the master node included in the second shard to a non-master node, and switch a non-master node included in the second shard to a master node;
[0185] Migrate all data to the primary node of the second shard before the master-slave switch.
[0186] In some embodiments of the present disclosure, the non-master node includes a slave node and a standby node, and the migration module 603 is specifically used to:
[0187] The master node included in the second shard is switched to a slave node, and a slave node included in the second shard is switched to a master node.
[0188] In some embodiments of the present disclosure, the non-primary node is a standby node, and the migration module 603 is specifically used to:
[0189] The primary node included in the second shard is switched to a backup node, and a backup node included in the second shard is switched to a primary node.
[0190] In some embodiments of the present disclosure, a checking module is further included; the checking module is used to:
[0191] Before switching the master node included in the second shard to a non-master node, check whether each non-master node included in the second shard completely stores the full amount of data;
[0192] If any non-master node fails to store the full amount of data completely, and the number of retries for the non-master node does not reach the first preset number, the full amount of data is stored in the non-master node again, and the number of retries for the non-master node + 1 is recorded;
[0193] If any non-master node does not store the full amount of data completely, and the number of retries for the non-master node reaches the first preset number, the full amount of data stored in each non-master node included in the second shard is deleted, and the full amount of data stored in itself is deleted;
[0194] If all non-master nodes included in the second shard store the full amount of data completely, the step of switching the master node included in the second shard to a non-master node is executed.
[0195] In some embodiments of the present disclosure, each shard includes a master node; the apparatus further includes:
[0196] The synchronization module is used to synchronize the incremental data in the data table to be migrated stored in the first shard except the full data to the master node included in the second shard before recording the correspondence between the identifier of the data table to be migrated and the identifier of the second shard.
[0197] In some embodiments of the present disclosure, the distributed storage system further includes a metadata server; the device further includes:
[0198] A sending module, used for sending a meta information acquisition request to a metadata server before recording the correspondence between the identifier of the data table to be migrated and the identifier of the second shard, the meta information acquisition request being used to request to acquire the distributed meta information of the distributed storage system, the distributed meta information being used to indicate the shard where each data table stored in the distributed storage system is located;
[0199] The receiving module 601 is further used to receive a meta information acquisition response sent by the metadata server, where the meta information acquisition response includes distribution meta information;
[0200] The recording module 604 is specifically used for:
[0201] In the distribution meta information, the shard identifier corresponding to the identifier of the data table to be migrated is updated to the identifier of the second shard.
[0202] In some embodiments of the present disclosure, the distributed storage system further includes a proxy server; the device further includes:
[0203] The sending module is further used to send migration status information to the metadata server before deleting the first shard, the migration status information including the updated distribution meta information, so that the metadata server modifies the distribution meta information stored in itself to the updated distribution meta information, and modifies the distribution meta information stored in the proxy server to the updated distribution meta information;
[0204] The deletion module is further used to delete the to-be-migrated data table stored in the metadata server and the to-be-migrated data table stored in each node included in the second shard if it is detected that the metadata server has failed to modify the distribution metadata;
[0205] A modification module, for modifying the distribution meta information stored in the metadata server and the proxy server to the distribution meta information before the update, deleting the data table to be migrated stored in itself, and deleting the data table to be migrated stored in each node included in the second shard, if it is detected that the proxy server has failed to modify the distribution meta information;
[0206] The calling module is used to call the deleting module to execute the step of deleting the first fragment if it is detected that both the metadata server and the proxy server have successfully modified the distribution metadata.
[0207] In some embodiments of the present disclosure, the migration status information further includes a task identifier extracted from the meta information acquisition response, where the task identifier is an identifier generated by the metadata server for the current scaling-down task; the device further includes a determination module, which is used to:
[0208] After sending the migration status information to the metadata server, if a modification failure message sent by the metadata server is received, it is determined that the metadata server has failed to modify the distribution metadata, wherein the scaling failure message is a message sent by the metadata server indicating that the modification of the distribution metadata has failed when the metadata server checks that the task identifier included in the migration status information is different from the task identifier generated by itself;
[0209] If a modification success message is received from the metadata server, or if no scaling down failure message is received within the preset time after sending the migration status information, it is determined that the metadata server has successfully modified the distribution metadata. The scaling down success message is a message sent by the metadata server indicating that the modification of the distribution metadata is successful when the metadata server checks that the task identifier included in the migration status information is the same as the task identifier generated by itself.
[0210] In some embodiments of the present disclosure, there are multiple proxy servers; the device further includes a verification module, the verification module is used to:
[0211] After sending the migration status information to the metadata server, a consistency check is performed on the distributed metadata stored in each proxy server;
[0212] If the consistency check fails, it is determined that the proxy servers have failed to successfully modify the distribution metadata;
[0213] If the consistency check passes, it is determined that each proxy server has successfully modified the distribution metadata.
[0214] In some embodiments of the present disclosure, the device further includes a judgment module, the judgment module being configured to:
[0215] Before determining that each proxy server has failed to modify the distribution meta-information successfully, determining the proxy server to be retried that has not been successfully modified, and determining whether the number of retries of the proxy server to be retried has reached a second preset number;
[0216] If so, the verification module is called to execute the step of determining whether each proxy server has failed to modify the distribution metadata successfully; if not, the distribution metadata stored in the proxy server to be retried is modified to the updated distribution metadata, and the number of retries for the proxy server to be retried + 1 is recorded.
[0217] In some embodiments of the present disclosure, the device further includes an inspection module and a detection module, which are used to:
[0218] Before obtaining the full amount of data of the data table to be migrated stored in a node of the first shard, checking whether a preset shrinking condition is met, the preset shrinking condition includes: the available storage space of the second shard is greater than the product of the used storage space of the first shard and a preset multiple, and the preset multiple is greater than 1;
[0219] If the check passes, the acquisition module is called to execute the step of acquiring the full amount of data of the data table to be migrated stored in a node of the first shard.
[0220] In some embodiments of the present disclosure, the distributed storage system further includes a metadata server; the device further includes:
[0221] A sending module, used for sending a shard information acquisition request to a metadata server before checking whether a preset shrinking condition is met, wherein the shard information acquisition request is used for requesting to acquire metadata of a first shard and metadata of a second shard;
[0222] The receiving module 601 is also used to receive a shard information acquisition response sent by the metadata server, where the shard information acquisition response includes metadata of the first shard and metadata of the second shard, wherein the metadata of the shard includes used storage space and available storage space.
[0223] In some embodiments of the present disclosure, the preset shrinking condition further includes: there are currently no other shrinking tasks in the distributed storage system.
[0224] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
[0225] Figure 7A schematic block diagram of an example electronic device 700 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0226] like Figure 7 As shown, the electronic device 700 includes a computing unit 701, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 702 or a computer program loaded from a storage unit 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the electronic device 700 can also be stored. The computing unit 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0227] Multiple components in the electronic device 700 are connected to the I / O interface 705, including: an input unit 706, such as a keyboard, a mouse, etc.; an output unit 707, such as various types of displays, speakers, etc.; a storage unit 708, such as a disk, an optical disk, etc.; and a communication unit 709, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 709 allows the electronic device 700 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0228] The computing unit 701 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 701 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 701 performs the various methods and processes described above, such as the capacity reduction method of the distributed storage system. For example, in some embodiments, the capacity reduction method of the distributed storage system may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 708. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 700 via the ROM 702 and / or the communication unit 709. When the computer program is loaded into the RAM 703 and executed by the computing unit 701, one or more steps of the capacity reduction method of the distributed storage system described above may be performed. Alternatively, in other embodiments, the computing unit 701 may be configured to perform the capacity reduction method of the distributed storage system in any other appropriate manner (e.g., by means of firmware).
[0229] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0230] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0231] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0232] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0233] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0234] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0235] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0236] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A method for reducing the capacity of a distributed storage system, wherein the distributed storage system includes a first shard and a second shard, each shard includes a plurality of nodes, and each node in the same shard stores the same data table, the method comprising: receiving a shrink request, the shrink request being used to request migration of the to-be-migrated data table stored in the first shard to the second shard; Obtaining the full amount of data of the data table to be migrated stored in a node of the first shard; Migrating all the data in the to-be-migrated data table to each node included in the second shard; Recording a correspondence between the identifier of the data table to be migrated and the identifier of the second shard, wherein the correspondence indicates that the data table to be migrated is stored in the second shard; Delete the first fragment.
2. The method according to claim 1, wherein: The second shard includes a master node and at least one non-master node, and the step of migrating all the data of the to-be-migrated data table to each node included in the second shard includes: Migrating the full amount of data to each non-primary node included in the second shard; Switching the master node included in the second shard to a non-master node, and switching a non-master node included in the second shard to a master node; Migrate the full amount of data to the master node of the second shard before the master-slave switch.
3. The method according to claim 2, wherein: The non-master node includes a slave node and a standby node, and the switching of the master node included in the second shard to a non-master node, and the switching of a non-master node included in the second shard to a master node, includes: The master node included in the second shard is switched to a slave node, and a slave node included in the second shard is switched to a master node.
4. The method according to claim 2, wherein: The non-primary node is a standby node, and the switching of the primary node included in the second shard to the non-primary node, and the switching of a non-primary node included in the second shard to the primary node, comprises: The primary node included in the second shard is switched to a backup node, and a backup node included in the second shard is switched to a primary node.
5. The method according to any one of claims 2 to 4, before switching the master node included in the second shard to a non-master node, further comprising: Check whether each non-primary node included in the second shard completely stores the full amount of data; If any non-master node fails to store the full amount of data completely, and the number of retries for the non-master node does not reach the first preset number, the full amount of data is stored in the non-master node again, and the number of retries for the non-master node + 1 is recorded; If any non-master node fails to store the full amount of data completely, and the number of retries for the non-master node reaches the first preset number, the full amount of data stored in each non-master node included in the second shard is deleted, and the full amount of data stored in itself is deleted; If all non-master nodes included in the second shard completely store the full amount of data, the step of switching the master node included in the second shard to a non-master node is executed.
6. The method according to claim 1, wherein each shard includes a master node; before recording the correspondence between the identifier of the data table to be migrated and the identifier of the second shard, further comprising: The incremental data in the to-be-migrated data table stored in the first shard, except for the full data, is synchronized to the master node included in the second shard.
7. The method according to claim 1, wherein the distributed storage system further comprises a metadata server; and before recording the correspondence between the identifier of the data table to be migrated and the identifier of the second shard, further comprising: Sending a meta information acquisition request to the metadata server, wherein the meta information acquisition request is used to request to acquire the distributed meta information of the distributed storage system, wherein the distributed meta information is used to indicate the shard where each data table stored in the distributed storage system is located; Receiving a meta information acquisition response sent by the metadata server, wherein the meta information acquisition response includes the distributed meta information; The recording of the correspondence between the identifier of the to-be-migrated data table and the identifier of the second shard includes: In the distribution meta information, the shard identifier corresponding to the identifier of the to-be-migrated data table is updated to be the identifier of the second shard.
8. The method according to claim 7, wherein the distributed storage system further comprises a proxy server; and before deleting the first shard, further comprising: Sending migration status information to the metadata server, the migration status information including updated distribution meta information, so that the metadata server modifies the distribution meta information stored in itself into the updated distribution meta information, and modifies the distribution meta information stored in the proxy server into the updated distribution meta information; If it is detected that the metadata server fails to modify the distribution metadata, the metadata server deletes the to-be-migrated data table stored in the metadata server, and deletes the to-be-migrated data table stored in each node included in the second shard; If it is detected that the proxy server has failed to modify the distribution meta information, the distribution meta information stored in the metadata server and the proxy server is modified to the distribution meta information before the update, the data table to be migrated stored in the proxy server is deleted, and the data table to be migrated stored in each node included in the second shard is deleted; If it is detected that both the metadata server and the proxy server have successfully modified the distribution metadata, the step of deleting the first fragment is executed.
9. The method according to claim 8, wherein the migration status information further comprises a task identifier extracted from the meta information acquisition response, wherein the task identifier is an identifier generated by the metadata server for the current shrinking task; After sending the migration status information to the metadata server, the method further includes: If a modification failure message sent by the metadata server is received, it is determined that the metadata server has failed to modify the distribution metadata, wherein the scaling failure message is a message sent by the metadata server indicating that the modification of the distribution metadata has failed when the metadata server checks that the task identifier included in the migration status information is different from the task identifier generated by itself; If a modification success message is received from the metadata server, or the scaling down failure message is not received within the preset time after sending the migration status information, it is determined that the metadata server has successfully modified the distribution metadata, wherein the scaling down success message is a message indicating that the distribution metadata has been successfully modified, and is sent when the metadata server checks that the task identifier included in the migration status information is the same as the task identifier generated by itself.
10. The method according to claim 8, wherein there are multiple proxy servers; after sending the migration status information to the metadata server, the method further comprises: Perform consistency check on the distributed metadata stored in each proxy server; If the consistency check fails, it is determined that the proxy servers have failed to successfully modify the distribution metadata; If the consistency check passes, it is determined that each proxy server has successfully modified the distribution metadata.
11. The method according to claim 10, before determining that each proxy server has failed to modify the distribution meta information, further comprising: Determine the proxy server to be retried that has not been successfully modified, and determine whether the number of retries for the proxy server to be retried reaches the second preset number; If yes, then executing the step of determining that each proxy server has failed to modify the distribution meta information; If not, the distribution meta information stored in the proxy server to be retried is modified to the updated distribution meta information, and the number of retries for the proxy server to be retried + 1 is recorded.
12. The method according to claim 1, before obtaining the full amount of data of the to-be-migrated data table stored in a node of the first shard, further comprises: Checking whether a preset shrinking condition is met, the preset shrinking condition comprising: the available storage space of the second shard is greater than the product of the used storage space of the first shard and a preset multiple, and the preset multiple is greater than 1; If the check passes, the step of obtaining the full amount of data of the data table to be migrated stored in a node of the first shard is executed.
13. The method according to claim 12, wherein the distributed storage system further comprises a metadata server; and before the checking whether the preset shrinking condition is met, the method further comprises: Sending a shard information acquisition request to the metadata server, wherein the shard information acquisition request is used to request to acquire metadata of the first shard and metadata of the second shard, wherein the metadata of the shard includes used storage space and available storage space; A shard information acquisition response sent by the metadata server is received, where the shard information acquisition response includes metadata of the first shard and metadata of the second shard.
14. The method according to claim 12 or 13, wherein: The preset shrinking condition also includes: the distributed storage system currently has no other shrinking tasks.
15. A device for reducing capacity of a distributed storage system, the distributed storage system comprising a first shard and a second shard, each shard comprising a plurality of nodes, each node in the same shard storing the same data table, the device comprising: A receiving module, configured to receive a shrink request, wherein the shrink request is used to request to migrate the to-be-migrated data table stored in the first shard to the second shard; An acquisition module, used to acquire the full amount of data of the data table to be migrated stored in a node of the first shard; A migration module, used to migrate all the data of the data table to be migrated to each node included in the second shard; A recording module, used for recording a correspondence between an identifier of the data table to be migrated and an identifier of the second shard, wherein the correspondence indicates that the data table to be migrated is stored in the second shard; A deletion module is used to delete the first fragment.
16. The device according to claim 15, wherein: The second shard includes a master node and at least one non-master node, and the migration module is specifically used to: Migrating the full amount of data to each non-primary node included in the second shard; Switching the master node included in the second shard to a non-master node, and switching a non-master node included in the second shard to a master node; Migrate the full amount of data to the master node of the second shard before the master-slave switch.
17. The device according to claim 16, wherein: The non-master nodes include slave nodes and standby nodes, and the migration module is specifically used for: The master node included in the second shard is switched to a slave node, and a slave node included in the second shard is switched to a master node.
18. The device according to claim 16, wherein: The non-master node is a standby node, and the migration module is specifically used for: The primary node included in the second shard is switched to a backup node, and a backup node included in the second shard is switched to a primary node.
19. The device according to any one of claims 16 to 18, further comprising an inspection module; the inspection module is used to: Before switching the master node included in the second shard to a non-master node, checking whether each non-master node included in the second shard completely stores the full amount of data; If any non-master node fails to store the full amount of data completely, and the number of retries for the non-master node does not reach the first preset number, the full amount of data is stored in the non-master node again, and the number of retries for the non-master node + 1 is recorded; If any non-master node fails to store the full amount of data completely, and the number of retries for the non-master node reaches the first preset number, the full amount of data stored in each non-master node included in the second shard is deleted, and the full amount of data stored in itself is deleted; If all non-master nodes included in the second shard completely store the full amount of data, the step of switching the master node included in the second shard to a non-master node is executed.
20. The apparatus according to claim 15, wherein each shard comprises a master node; the apparatus further comprising: A synchronization module is used to synchronize the incremental data in the data table to be migrated stored in the first shard except the full data to the master node included in the second shard before recording the correspondence between the identifier of the data table to be migrated and the identifier of the second shard.
21. The apparatus according to claim 15, wherein the distributed storage system further comprises a metadata server; the apparatus further comprises: A sending module, used for sending a meta information acquisition request to the metadata server before recording the correspondence between the identifier of the data table to be migrated and the identifier of the second shard, wherein the meta information acquisition request is used to request to obtain the distributed meta information of the distributed storage system, and the distributed meta information is used to indicate the shard where each data table stored in the distributed storage system is located; The receiving module is further configured to receive a meta information acquisition response sent by the metadata server, wherein the meta information acquisition response includes the distributed meta information; The recording module is specifically used for: In the distribution meta information, the shard identifier corresponding to the identifier of the to-be-migrated data table is updated to be the identifier of the second shard.
22. The apparatus according to claim 21, wherein the distributed storage system further comprises a proxy server; the apparatus further comprises: The sending module is further used to send migration status information to the metadata server before deleting the first shard, the migration status information including the updated distribution meta information, so that the metadata server modifies the distribution meta information stored in itself into the updated distribution meta information, and modifies the distribution meta information stored in the proxy server into the updated distribution meta information; The deletion module is further configured to delete the to-be-migrated data table stored in the metadata server itself and delete the to-be-migrated data table stored in each node included in the second shard if it is detected that the metadata server has failed to modify the distribution metadata; A modification module, configured to modify the distribution meta-information stored in the metadata server and the proxy server to the distribution meta-information before the update, delete the data table to be migrated stored in the proxy server, and delete the data table to be migrated stored in each node included in the second shard, if it is detected that the proxy server has failed to modify the distribution meta-information; The calling module is used to call the deleting module to execute the step of deleting the first fragment if it is detected that both the metadata server and the proxy server have successfully modified the distribution metadata.
23. The device according to claim 22, wherein the migration status information further comprises a task identifier extracted from the meta information acquisition response, wherein the task identifier is an identifier generated by the metadata server for the current scaling-down task; and the device further comprises a determination module, wherein the determination module is configured to: After the migration status information is sent to the metadata server, if a modification failure message sent by the metadata server is received, it is determined that the metadata server has failed to modify the distribution metadata, wherein: The shrink failure message is a message sent by the metadata server indicating failure to modify the distribution metadata when the metadata server checks that the task identifier included in the migration status information is different from the task identifier generated by itself; If a modification success message is received from the metadata server, or the scaling down failure message is not received within the preset time after sending the migration status information, it is determined that the metadata server has successfully modified the distribution metadata, wherein the scaling down success message is a message indicating that the distribution metadata has been successfully modified, and is sent when the metadata server checks that the task identifier included in the migration status information is the same as the task identifier generated by itself.
24. The device according to claim 22, wherein there are multiple proxy servers; the device further comprises a verification module, wherein the verification module is used to: After sending the migration status information to the metadata server, performing consistency check on the distributed metadata stored in each proxy server; If the consistency check fails, it is determined that the proxy servers have failed to successfully modify the distribution metadata; If the consistency check passes, it is determined that each proxy server has successfully modified the distribution metadata.
25. The device according to claim 24, further comprising a judgment module, wherein the judgment module is configured to: Before determining that each proxy server has failed to modify the distribution meta-information successfully, determining a proxy server to be retried that has not been successfully modified, and determining whether the number of retries for the proxy server to be retried has reached the second preset number; If yes, calling the verification module to execute the step of determining that each proxy server has failed to modify the distribution metadata; If not, the distribution meta information stored in the proxy server to be retried is modified to the updated distribution meta information, and the number of retries for the proxy server to be retried + 1 is recorded.
26. The device according to claim 15, further comprising an inspection module, wherein the detection module is configured to: Before obtaining the full amount of data of the data table to be migrated stored in a node of the first shard, checking whether a preset shrinking condition is met, the preset shrinking condition includes: The available storage space of the second shard is greater than the product of the used storage space of the first shard and a preset multiple, and the preset multiple is greater than 1; If the check passes, the acquisition module is called to execute the step of acquiring the full amount of data of the data table to be migrated stored in a node of the first shard.
27. The apparatus according to claim 26, wherein the distributed storage system further comprises a metadata server; the apparatus further comprises: A sending module, used for sending a shard information acquisition request to the metadata server before checking whether the preset scaling-down condition is met, wherein the shard information acquisition request is used for requesting to acquire metadata of the first shard and metadata of the second shard; The receiving module is further used to receive a shard information acquisition response sent by the metadata server, wherein the shard information acquisition response includes metadata of the first shard and metadata of the second shard, wherein the metadata of the shard includes used storage space and available storage space.
28. The device according to claim 26 or 27, wherein The preset shrinking condition also includes: the distributed storage system currently has no other shrinking tasks.
29. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 14.
30. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-14.
31. A computer program product comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 14.
Citation Information
Patent Citations
Expanding and shrinking method for distributed cluster with nodes supporting multiple data fragments
CN104615657A
Data migration method and system
CN106777225A
Method and device for migrating data between nodes, computing equipment and computer storage medium
CN108228102A
Partition expansion method and device and data storage method and device
CN109995813A
Data migration method and device, computer equipment and readable storage medium
CN114218193A
Cited By
Flow control method and device for distributed database system and electronic equipment
CN120030001A
A traffic control method, device and electronic equipment of a distributed database system
CN120030001B
Method, system, device and equipment for data transmission among multiple sites and medium
CN120560573A
Data migration method, device and equipment and computer readable storage medium
CN121807816A
A data migration method, device, equipment and computer readable storage medium
CN121807816B
