Metadata backup method, device, equipment, and storage medium
By reserving storage space in the storage nodes of the distributed storage system and backing up the metadata of the management nodes, the problem of long metadata recovery time is solved, achieving efficient metadata recovery and enhancing the robustness of business data.
Patent Information
- Application Number
- CN202010383777.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-05-08
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2040-05-08
AI Technical Summary
In a distributed storage system, when a management node failure causes metadata to be lost, metadata needs to be regenerated based on the business data of the storage node, resulting in a long recovery time. There is a lack of metadata backup technology to shorten the recovery time.
Reserve storage space in the storage node of the distributed storage system, back up the metadata of the management node, and store it through the virtual space pool to achieve metadata backup and recovery.
Metadata backup shortens the recovery time, avoids the continuous occupation of storage node processing resources, enhances the robustness of business data, and eliminates the need to introduce additional storage environments.
Smart Images

Figure CN111638995B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of big data technology, and in particular to a metadata backup method, device and equipment, and a storage medium. Background Art
[0002] A distributed storage system, such as a cloud storage system, includes multiple storage nodes and at least one management node, wherein business data is usually stored in multiple storage nodes, and metadata of business data is stored in the management node. During the execution of business, the distributed storage system can find relevant business data in the storage node based on the metadata in the management node.
[0003] Generally speaking, when a management node fails, metadata may be lost. In this case, it is necessary to regenerate metadata based on the business data in the storage node to restore the metadata. However, storage nodes usually store a large amount of business data, so in the above method, when regenerating metadata based on business data, a large amount of metadata needs to be regenerated, and the recovery time is too long.
[0004] If the metadata in the management node can be backed up, there is no need to regenerate the metadata based on the business data, which can shorten the metadata recovery time. However, there is currently no related technology for backing up metadata in a distributed storage system. Summary of the invention
[0005] In view of this, the present invention provides a metadata backup method, device, equipment, and storage medium, which can realize metadata backup, thereby shortening the time required for metadata recovery.
[0006] A first aspect of the present invention provides a metadata backup method, which is applied to a management node in a distributed storage system, wherein the distributed storage system further includes a storage node, and the method includes:
[0007] Controlling each storage node in the distributed storage system to reserve corresponding storage space for backing up metadata;
[0008] Determine the virtual space pool based on the storage space reserved by each storage node;
[0009] The metadata stored in at least one management node in the distributed storage system is backed up to the virtual space pool.
[0010] According to an embodiment of the present invention, controlling each storage node in the distributed storage system to reserve corresponding storage space for backing up metadata includes:
[0011] A reservation instruction is issued to each storage node in the distributed storage system, wherein the reservation instruction is used to indicate that storage space is reserved for backing up metadata. The reservation instruction carries reserved storage space information to control each storage node in the distributed storage system to reserve corresponding storage space for backing up metadata according to the reserved storage space information.
[0012] According to an embodiment of the present invention, the reserved storage space information is obtained by the following steps:
[0013] An externally input space division instruction is received, where the space division instruction carries the reserved storage space information.
[0014] According to an embodiment of the present invention, backing up metadata stored in at least one management node in the distributed storage system to the virtual space pool includes:
[0015] Determining target metadata to be backed up from metadata stored in each management node in the distributed storage system;
[0016] Selecting a target storage space for backing up the target metadata from the virtual space pool;
[0017] The target metadata is stored in the target storage space.
[0018] According to an embodiment of the present invention, selecting a target storage space for backing up the target metadata from the virtual space pool includes:
[0019] Encapsulating the target metadata into a target data file in a specified format;
[0020] At least one target storage space is found from the virtual space pool according to the size of the target data file; the sum of the sizes of the remaining unoccupied spaces in all target storage spaces is greater than or equal to the size of the target data file.
[0021] According to an embodiment of the present invention, finding at least one target storage space from the virtual space pool according to the size of the target data file includes:
[0022] Check whether the sum of the remaining space sizes of all storage spaces in the virtual space pool is less than the size of the target data file; if so, find the file with the earliest storage time from each storage space in the virtual space pool and delete it, and return to the step of checking whether the sum of the remaining space sizes of all storage spaces in the virtual space pool is less than the size of the target data file;
[0023] If not, find at least one target storage space from the virtual space pool according to the size of the target data file.
[0024] According to an embodiment of the present invention, storing the target metadata in the target storage space includes:
[0025] When the number of target storage spaces is equal to 1, storing the target data file in the target storage space;
[0026] When the number of target storage spaces is greater than 1, the target data file is divided into multiple file blocks according to the size of the unoccupied remaining space in each target storage space, the size of the unoccupied remaining space in each target storage space corresponds to one file block, and the corresponding file block size is equal to the size of the unoccupied remaining space; each file block is stored in the corresponding target storage space respectively.
[0027] According to an embodiment of the present invention, the file name of the target data file or file block stored in the target storage space includes the generation time of the target data file;
[0028] The method further comprises:
[0029] When there is a metadata recovery demand at the management node, searching for a file corresponding to the metadata recovery demand and having a file name that satisfies a condition from each storage space of the virtual space pool, wherein the condition is that the time difference between the generation time in the file name and the current time is the smallest;
[0030] Metadata is parsed from the found files that meet the conditions, and the parsed metadata is stored in the management node where the metadata recovery requirement exists.
[0031] A second aspect of the present invention provides a metadata backup device, which is applied to a management node in a distributed storage system, wherein the distributed storage system further includes a storage node, and the device includes:
[0032] A storage space reservation module, used to control each storage node in the distributed storage system to reserve corresponding storage space for backing up metadata;
[0033] A virtual space pool determination module, used to determine a virtual space pool according to the storage space reserved by each storage node;
[0034] The metadata backup module is used to back up the metadata stored in at least one management node in the distributed storage system to the virtual space pool.
[0035] According to an embodiment of the present invention, when the storage space reservation module controls each storage node in the distributed storage system to reserve corresponding storage space for backing up metadata, it is specifically used to:
[0036] A reservation instruction is issued to each storage node in the distributed storage system, wherein the reservation instruction is used to indicate that storage space is reserved for backing up metadata. The reservation instruction carries reserved storage space information to control each storage node in the distributed storage system to reserve corresponding storage space for backing up metadata according to the reserved storage space information.
[0037] According to an embodiment of the present invention, the reserved storage space information is obtained through the following modules:
[0038] The external instruction input module is used to receive an externally input space division instruction, wherein the space division instruction carries the reserved storage space information.
[0039] According to an embodiment of the present invention, when the metadata backup module backs up the metadata stored in at least one management node in the distributed storage system to the virtual space pool, it is specifically used to:
[0040] Determining target metadata to be backed up from metadata stored in each management node in the distributed storage system;
[0041] Selecting a target storage space for backing up the target metadata from the virtual space pool;
[0042] The target metadata is stored in the target storage space.
[0043] According to an embodiment of the present invention, when the metadata backup module selects the target storage space for backing up the target metadata from the virtual space pool, it is specifically configured to:
[0044] Encapsulating the target metadata into a target data file in a specified format;
[0045] At least one target storage space is found from the virtual space pool according to the size of the target data file; the sum of the sizes of the remaining unoccupied spaces in all target storage spaces is greater than or equal to the size of the target data file.
[0046] According to an embodiment of the present invention, finding at least one target storage space from the virtual space pool according to the size of the target data file includes:
[0047] Check whether the sum of the remaining space sizes of all storage spaces in the virtual space pool is less than the size of the target data file; if so, find the file with the earliest storage time from each storage space in the virtual space pool and delete it, and return to the step of checking whether the sum of the remaining space sizes of all storage spaces in the virtual space pool is less than the size of the target data file;
[0048] If not, find at least one target storage space from the virtual space pool according to the size of the target data file.
[0049] According to an embodiment of the present invention, when the metadata backup module stores the target metadata in the target storage space, it is specifically used to:
[0050] When the number of target storage spaces is equal to 1, storing the target data file in the target storage space;
[0051] When the number of target storage spaces is greater than 1, the target data file is divided into multiple file blocks according to the size of the unoccupied remaining space in each target storage space, the size of the unoccupied remaining space in each target storage space corresponds to one file block, and the corresponding file block size is equal to the size of the unoccupied remaining space; each file block is stored in the corresponding target storage space respectively.
[0052] According to an embodiment of the present invention, the file name of the target data file or file block stored in the target storage space includes the generation time of the target data file;
[0053] The device further comprises:
[0054] A file search module, used for searching, when a metadata recovery requirement exists in the management node, files corresponding to the metadata recovery requirement and having file names that meet a condition from each storage space of the virtual space pool, wherein the condition is that the time difference between the generation time in the file name and the current time is the smallest;
[0055] The metadata recovery module is used to parse metadata from the found files that meet the conditions, and store the parsed metadata in the management node where the metadata recovery requirement exists.
[0056] A third aspect of the present invention provides an electronic device, comprising a processor and a memory; the memory stores a program that can be called by the processor; wherein when the processor executes the program, the metadata backup method as described in the above embodiment is implemented.
[0057] A fourth aspect of the present invention provides a machine-readable storage medium having a program stored thereon, which, when executed by a processor, implements the metadata backup method as described in the foregoing embodiment.
[0058] The embodiments of the present invention have the following beneficial effects:
[0059] In an embodiment of the present invention, by reserving storage space in each storage node in a distributed storage system, metadata stored in a management node in the system can be backed up in the reserved storage space. In this way, when metadata recovery is required, the backed-up metadata can be obtained from the storage node of the distributed storage system, without the need to regenerate metadata based on business data stored in the storage node. This can greatly shorten the metadata recovery time, and can avoid the problem that the processing resources of the storage node are continuously occupied due to metadata recovery, resulting in impact on storage business. Moreover, the metadata backup stored in the management node is in the storage node of the same distributed storage system, so there is no need to introduce an additional storage environment, which can enhance the robustness of business data. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] Figure 1 is a flowchart of a metadata backup method according to an embodiment of the present invention;
[0061] Figure 2 is a schematic diagram of an application scenario of an embodiment of the present invention;
[0062] Figure 3 is a structural block diagram of a metadata backup device according to an embodiment of the present invention;
[0063] Figure 4 It is a structural block diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0064] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Instead, they are merely examples of devices and methods consistent with some aspects of the present invention as detailed in the appended claims.
[0065] The terms used in the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. The singular forms "a", "the" and "the" used in the present invention and the appended claims are also intended to include plural forms unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0066] It should be understood that although the terms first, second, third, etc. may be used to describe various devices in the present invention, this information should not be limited to these terms. These terms are only used to distinguish devices of the same type from each other. For example, without departing from the scope of the present invention, a first device may also be referred to as a second device, and similarly, a second device may also be referred to as a first device. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0067] In order to make the description of the present invention clearer and more concise, some technical terms in the present invention are explained below:
[0068] Metadata, also known as intermediary data or relay data, is used to describe data about data. It mainly describes the properties of data and is used to support functions such as indicating the storage location and size of data.
[0069] In the embodiment of the present invention, by reserving storage space in each storage node in the distributed storage system, the metadata stored in the management node in the system can be backed up in the reserved storage space. In this way, when metadata recovery is required, the backed-up metadata can be obtained from the storage node of the distributed storage system, without the need to regenerate the metadata based on the business data stored in the storage node, which can greatly shorten the metadata recovery time and avoid the problem that the processing resources of the storage node are continuously occupied due to metadata recovery, resulting in the impact on the storage business. Moreover, the metadata backup stored in the management node is in the storage node of the same distributed storage system, so there is no need to introduce an additional storage environment, which can enhance the robustness of the business data.
[0070] In the embodiment of the present invention, the distributed storage system may be a cloud storage system. Of course, the present invention is not limited thereto, and other distributed storage systems including management nodes and storage nodes are also applicable.
[0071] The metadata backup method of the embodiment of the present invention is described in more detail below, but the present invention should not be limited thereto.
[0072] In one embodiment, see Figure 1 , shows a metadata backup method according to an embodiment of the present invention, the method is applied to a management node in a distributed storage system, the distributed storage system also includes a storage node, the method may include the following steps:
[0073] S100: Control each storage node in the distributed storage system to reserve corresponding storage space for backing up metadata;
[0074] S200: Determine a virtual space pool according to the storage space reserved by each storage node;
[0075] S300: Backing up metadata stored in at least one management node in the distributed storage system to the virtual space pool.
[0076] In the embodiment of the present invention, the execution subject of the metadata backup method is a management node in a distributed storage system. The distributed storage system may include one management node; or may include multiple management nodes, and these management nodes may constitute a management cluster.
[0077] When the distributed storage system includes multiple management nodes, the above-mentioned metadata backup method can be executed by any management node; alternatively, in order to avoid waste of resources due to unnecessary competition between management nodes, a master management node can be elected from all management nodes, and the above-mentioned metadata backup method can be executed by the master management node. The specific election method is not limited.
[0078] Optionally, different management nodes may be elected as the primary management node in turn, with each management node serving as the primary management node for a period of time.
[0079] For example, see Figure 2 , the distributed storage system may include: management nodes M1-M3, and storage nodes S1-S3. Of course, the figure is only for illustration, and there may be more management nodes and / or storage nodes. Among them, the management nodes M1-M3 constitute a management cluster, and the management node M2 is elected as the main management node, so the management node M2 can perform the above steps S100-S300 to implement the above metadata backup method.
[0080] In step S100, each storage node in the distributed storage system is controlled to reserve corresponding storage space for backing up metadata.
[0081] Generally speaking, all the space in the storage node is used to store business data. However, in this embodiment, each storage node is controlled to reserve corresponding storage space, and this reserved storage space can be used to store metadata to be backed up. In other words, in this embodiment, the storage nodes in the distributed storage system can be used not only to store business data, but also to store metadata to be backed up.
[0082] Each storage node generally has multiple disks. Of course, it does not exclude the case where the storage node only includes one disk. When controlling each storage node to reserve corresponding storage space, the storage node can be controlled to divide a part from each disk as a storage space.
[0083] Preferably, a portion of space can be allocated at the head or tail of each disk as storage space. Specifically, if the storage space is allocated in the middle of the disk, it is necessary to determine the starting address and the ending address of the storage space, and positioning is relatively complicated; while if the storage space is allocated at the head or tail, it is only necessary to determine the ending address or the starting address of the storage space, and positioning is relatively simple.
[0084] For example, you can allocate 0.1% of the total disk space at the end of each disk as the corresponding storage space. Figure 2 There are six disks S11-S16 on the storage node S1, and 0.1% of the space at the end of each disk is divided as storage space; there are six disks S21-S26 on the storage node S2, and 0.1% of the space at the end of each disk is divided as storage space; there are six disks S31-S36 on the storage node S3, and 0.1% of the space at the end of each disk is divided as storage space.
[0085] Of course, the above division method is not a limitation, and the required storage space can be determined from the storage nodes as needed, as long as the divided storage space can meet the needs of backing up metadata.
[0086] In step S200, a virtual space pool is determined according to the storage space reserved by each storage node.
[0087] The storage space reserved by each storage node can be grouped into a virtual space pool. The virtual space pool can contain multiple storage spaces, which are distributed in each storage node of the distributed storage system.
[0088] The space information of each storage space in the virtual space pool can be recorded in the management node. The space information can include the space identification ID of the storage space, the remaining space size, the node identification of the storage node where the storage space is located, etc. This space information can be recorded in the space information table set by the management node, and the space information in the space information table can be referenced when backing up metadata later.
[0089] In step S300, metadata stored in at least one management node in the distributed storage system is backed up to the virtual space pool.
[0090] When a distributed storage system includes multiple management nodes, all management nodes can jointly maintain a database, and metadata can be stored in the database. The database is divided into multiple sub-libraries, and different sub-libraries are set up on different management nodes. The sub-libraries in all management nodes constitute the database. In this case, metadata can be obtained from the sub-libraries of all management nodes and backed up to the virtual space pool.
[0091] Alternatively, when a distributed storage system includes multiple management nodes, each management node may also be equipped with its own database. The data in the database of each management node is consistent. The database of each management node stores the full amount of metadata (metadata of business data stored by all storage nodes). In this case, metadata can be obtained from the database of any management node and backed up to the virtual space pool.
[0092] The metadata to be backed up can be exported from at least one management node using a backup tool, and the backup tool is not limited as long as it has a data export function. Of course, the method of obtaining the metadata to be backed up is not limited.
[0093] The full amount of metadata can be backed up; or, since the amount of metadata in the database is large, the metadata in the database can be backed up in detail by table, and all metadata in a table can be backed up. Of course, the specific metadata to be backed up is not limited to this and can be determined according to needs.
[0094] When backing up metadata stored in at least one management node in the distributed storage system to the virtual space pool, the management node may call the write file interface API of the node to write the metadata into the virtual space pool to implement metadata backup.
[0095] In this embodiment, some storage space is reserved from the storage nodes of the distributed storage system and organized into a virtual storage pool. The metadata in the management node of the same distributed storage system can be backed up to the virtual space pool. When metadata recovery is required, the metadata can be restored from the virtual space pool without the need to regenerate the metadata based on the business data in the storage node. This can greatly shorten the metadata recovery time. Moreover, the metadata is backed up in the storage node of the distributed storage system where the management node is located, without the need to introduce an additional distributed storage environment.
[0096] In addition, since the metadata is backed up in the storage space reserved by the storage node, the storage characteristics of the storage node can be used, and all storage and reading business logic can completely reuse the business logic of the storage node, which is simpler to implement and low-cost.
[0097] In one embodiment, in step S100, controlling each storage node in the distributed storage system to reserve corresponding storage space for backing up metadata may include the following steps:
[0098] S101: Send a reservation instruction to each storage node in the distributed storage system, wherein the reservation instruction is used to indicate that storage space is reserved for backing up metadata, and the reservation instruction carries reserved storage space information to control each storage node in the distributed storage system to reserve corresponding storage space for backing up metadata according to the reserved storage space information.
[0099] The reserved storage space information may indicate the size of the storage space to be reserved, for example, the proportion of the size of the storage space to be reserved in the total space of a disk, but is not limited thereto.
[0100] After the management node determines the storage space information, it may carry the reserved storage space information in a reservation instruction and send it to each storage node in the distributed storage system.
[0101] After receiving the reservation instruction, each storage node can immediately divide the local storage space according to the reserved storage space information in the reservation instruction; or, it can first save the reserved storage space information in the reservation instruction, and then divide the local disk according to the reserved storage space information in the reservation instruction when formatting is needed. There is no specific limitation.
[0102] When the storage node divides the local disk, the space of at least one disk can be divided into a user space and a storage space, where the storage space is the storage space reserved for backing up metadata. After that, corresponding space IDs can be set for the storage space and the user space, and the storage space and the user space can be formatted.
[0103] The space ID can uniquely represent the corresponding space. In order to distinguish between the user space and the storage space, a keyword representing the storage space can be set in the space ID corresponding to the storage space. For example, the space ID corresponding to the storage space can contain the keyword "backup". Of course, this is just an example and is not limited to this. As long as the user space and the storage space can be distinguished, it can be used.
[0104] Each storage node can upload the storage space of each disk in the storage node and the space ID corresponding to the user space to the management node. Of course, in addition to the space ID, other space information can also be uploaded, such as the remaining space size.
[0105] When the management node receives any space ID, it can check whether there is a keyword representing the storage space in the space ID. If so, it is determined that the space corresponding to the space ID is the storage space, and the space ID and other information (such as the remaining space size of the storage space, the device identifier of the storage space, etc.) are recorded, such as in the space information table set by the management node; otherwise, it is determined that the space corresponding to the space ID is the user space, and the space information of the user space can be displayed on the client for the user to use according to the business situation, or other processing can be performed.
[0106] In one embodiment, the reserved storage space information is obtained by the following steps:
[0107] S102: Receive an externally input space division instruction, where the space division instruction carries the reserved storage space information.
[0108] After the management cluster is deployed, the storage node can be online. The user can send a space partitioning instruction to the management node through the client, and the space partitioning instruction carries the reserved storage space information.
[0109] In this embodiment, the reserved storage space information is determined by the user, which can ensure that the divided storage space meets the needs of metadata backup. Of course, the above method is not a limitation, and the reserved storage space information can also be determined by other methods.
[0110] In one embodiment, in step S300, backing up metadata stored in at least one management node in the distributed storage system to the virtual space pool may include the following steps:
[0111] S301: Determine target metadata to be backed up from metadata stored in each management node in the distributed storage system;
[0112] S302: Selecting a target storage space for backing up the target metadata from the virtual space pool;
[0113] S303: Store the target metadata into the target storage space.
[0114] In this embodiment, the target metadata to be backed up may be all metadata stored in each management node, or may be all metadata stored in one or more management nodes, or may select part of the metadata stored in each management node as needed. Of course, the target metadata is not limited thereto, and may be determined as needed, such as by user selection or according to the generation time of the metadata.
[0115] The virtual space pool includes multiple storage spaces, from which a target storage space for backing up target metadata can be selected. The selection method is not limited. For example, one or several storage spaces can be randomly selected as the target storage space as long as they can accommodate all the target metadata.
[0116] After determining the target metadata and the target storage space, the target metadata is stored in the target storage space. For example, the target metadata and the space ID corresponding to the target storage space can be sent to the storage node where the target storage space is located, so that the storage node stores the received target metadata in the target storage space corresponding to the received space ID.
[0117] In one embodiment, in step S302, selecting a target storage space for backing up the target metadata from the virtual space pool may include the following steps:
[0118] S3021: Encapsulating the target metadata into a target data file in a specified format;
[0119] S3022: Find at least one target storage space from the virtual space pool according to the size of the target data file; the sum of the sizes of the remaining unoccupied spaces in all target storage spaces is greater than or equal to the size of the target data file.
[0120] Generally speaking, metadata has various formats, so different target metadata may have different formats. In this case, it is not convenient to directly transmit the target metadata.
[0121] Therefore, in step S3021, before transmission, the target metadata may be encapsulated into a target data file of a specified format, for example, by packaging the fragmented target metadata in a unified manner, which is more convenient for transmission.
[0122] Specifically, the target metadata can be packaged using a tar command (a packaging command) to obtain a target data file in a binary tar format. Of course, the specific packaging method is not limited, as long as the target metadata can be packaged into a target data file in a specified format.
[0123] After obtaining the target data file, the size of the target data file can be calculated. In addition, the target data file can be renamed according to the size of the target data file and the generation time of the target data file. For example, the file name of the target data file can include the generation time of the target data file. In this way, when the size or generation time of the target data file needs to be determined later, it can be directly obtained from the file name, and the acquisition method is more convenient. Of course, the size, generation time and other information related to the target data file can also be carried in the target data file in other ways, such as carried in a designated field of the target data file, but it is not limited to this.
[0124] Next, in step S3022, at least one target storage space is found from the virtual space pool according to the size of the target data file, ensuring that the sum of the unoccupied remaining space sizes in all target storage spaces is greater than or equal to the size of the target data file, so that all target storage spaces can accommodate all target metadata.
[0125] In one embodiment, in step S3022, finding at least one target storage space from the virtual space pool according to the size of the target data file may include the following steps:
[0126] S30221: Check whether the sum of the remaining space sizes of all storage spaces in the virtual space pool is less than the size of the target data file; if so, find the file with the earliest storage time from each storage space in the virtual space pool and delete it, and return to the step of checking whether the sum of the remaining space sizes of all storage spaces in the virtual space pool is less than the size of the target data file;
[0127] S30222: If not, find at least one target storage space from the virtual space pool according to the size of the target data file.
[0128] The size of the target data file can be calculated when determining the target storage space, or when renaming the file name of the target data file. Of course, the size of the target data file can also be obtained by other methods, and the specific method is not limited.
[0129] In step S30221, the sum of the remaining space sizes of all storage spaces in the virtual space pool can be counted, and specifically, the remaining space sizes of each storage space recorded in the space information table set by the management node can be counted to obtain the sum of the remaining space sizes. If the sum of the remaining space sizes is smaller than the size of the target data file, it means that the current virtual space pool cannot accommodate the target data file. At this time, the file with the earliest storage time (for example, the file with the earliest generation time in the file name) can be deleted from the virtual space pool. After deletion, the process returns to the step of checking whether the sum of the remaining space sizes of all storage spaces in the virtual space pool is smaller than the size of the target data file.
[0130] In step S30222, if the sum of the remaining space sizes is greater than or equal to the size of the target data file, it means that the current virtual space pool can accommodate the target data file, and at least one target storage space is selected from the virtual space pool, and the sum of the remaining space sizes of all target storage spaces is greater than or equal to the size of the target data file.
[0131] Specifically, in step S30222, when finding at least one target storage space from the virtual space pool according to the size of the target data file, the method may include:
[0132] Sort the space information in the space information table from large to small according to the remaining space of the storage space;
[0133] Traverse the sorted spatial information, and determine the storage space corresponding to the spatial ID in the traversed spatial information as the target storage space;
[0134] Calculate and add the remaining space size in the traversed spatial information and the accumulated size (the accumulated size is set to 0 before traversal) to obtain the current accumulated size. If the current accumulated size is greater than or equal to the size of the target data file, the traversal is terminated; otherwise, the traversal continues to the next spatial information.
[0135] Through the above traversal method, a target storage space whose sum of remaining space sizes is greater than or equal to the size of the target data file can be selected.
[0136] Of course, the specific selection method is not limited thereto, as long as the sum of the remaining space sizes of all target storage spaces is greater than or equal to the size of the target data file.
[0137] In one embodiment, in step S303, storing the target metadata in the target storage space includes:
[0138] S3031: When the number of target storage spaces is equal to 1, storing the target data file in the target storage space;
[0139] S3032: When the number of target storage spaces is greater than 1, the target data file is divided into multiple file blocks according to the size of the unoccupied remaining space in each target storage space, the size of the unoccupied remaining space in each target storage space corresponds to one file block, and the corresponding file block size is equal to the size of the unoccupied remaining space; each file block is stored in the corresponding target storage space respectively.
[0140] The amount of metadata in the management node will change dynamically, and the remaining space size of each storage space in the virtual space pool will also change dynamically. Therefore, the target storage space found from the virtual space pool according to the size of the target data file may be one or more.
[0141] When the number of target storage spaces found is equal to 1, it means that the target storage space can completely accommodate the target data file, so the target data file is stored in the target storage space. Specifically, the target data file and the space ID of the target storage space can be sent to the storage node where the target storage space is located through the write file interface, so that the storage node locates the target storage space according to the space ID and stores the target data file in the target storage space.
[0142] After the management node sends the target data file to the storage node, it can delete the local target data file and update the remaining space size of the target storage space in the space information table, specifically the difference between the remaining space size of the target storage space before storing the target data file and the size of the target data file.
[0143] When the number of target storage spaces found is greater than 1, it means that the target data file is too large for one target storage space and cannot be stored in one target storage space. At this time, the target data file can be divided into multiple file blocks according to the remaining space size of each target storage space. The number of file blocks can be the same as the number of target storage spaces. One file block corresponds to one target storage space, different file blocks correspond to different target storage spaces, and the size of each file block is less than or equal to the remaining space size of the corresponding target storage space. Each file block is stored in the corresponding target storage space.
[0144] For example, the management node finds two target storage spaces A1 and A2, then divides the target data file into two file blocks B1 and B2, file block B1 corresponds to the target storage space A1, and the size of file block B1 is less than or equal to the target storage space A1, file block B2 corresponds to the target storage space A2, and the size of file block B2 is less than or equal to the target storage space A2; the management node sends file block B1 and the space ID of the target storage space A1 to the storage node where the target storage space A1 is located, so that the storage node locates the target storage space A1 according to the space ID, and stores file block B1 in the target storage space A1; the management node sends file block B2 and the space ID of the target storage space A2 to the storage node where the target storage space A2 is located, so that the storage node locates the target storage space A2 according to the space ID, and stores file block B2 in the target storage space A2.
[0145] The file name of the file block may include the file name of the target data file and the sequence number of the file block, etc. Of course, the present invention is not limited thereto, for example, the file name of the file block may also include the size of the file block.
[0146] After the management node sends the file block to the storage node, it can delete the local file block and update the remaining space size of the target storage space in the space information table, specifically the difference between the remaining space size of the target storage space before storing the corresponding file block and the size of the file block.
[0147] In one embodiment, the file name of the target data file or file block stored in the target storage space includes the generation time of the target data file;
[0148] The method further comprises the following steps:
[0149] S400: When there is a metadata recovery requirement at the management node, searching for a file corresponding to the metadata recovery requirement and having a file name that satisfies a condition from each storage space of the virtual space pool, wherein the condition is that the time difference between the generation time in the file name and the current time is the smallest;
[0150] S500: Parse metadata from the found files that meet the conditions, and store the parsed metadata in the management node that has the metadata recovery requirement.
[0151] When the target data file is completely stored in the same storage space, the file name of the target data file includes the generation time of the target data file. When the target data file is divided into multiple file blocks and stored in different storage spaces, the file name of each file block can include the generation time of the target data file. In other words, the generation time in the file names of these file blocks is the same.
[0152] When there is a metadata recovery demand on a management node, the management node may be a management node that executes the metadata backup method, or may be other management nodes, or all management nodes in the distributed storage system, without limitation.
[0153] In this case, files corresponding to the metadata recovery requirements and having file names that meet the conditions can be found from each storage space of the virtual space pool. The number of found files can be equal to 1 or greater than 1. If the number is equal to 1, it means that the file is a complete data file; if the number is greater than 1, it means that these files are multiple file blocks divided from the same data file, and the file names of these files include the generation time of the data file.
[0154] The time difference between the generation time in the file name of the found file and the current time is the smallest, that is, the found file is the data file or file block with the latest storage time, that is, it contains the metadata of the latest backup and is the metadata that can meet the metadata recovery requirements.
[0155] Therefore, metadata is parsed from the found files that meet the conditions, and the parsed metadata is stored in the management node that has the metadata recovery requirement, thereby meeting the metadata recovery requirement of the management node.
[0156] The present invention also provides a metadata backup device, which is applied to a management node in a distributed storage system. The distributed storage system also includes storage nodes.
[0157] In one embodiment, see Figure 3 , the device 100 comprises:
[0158] The storage space reservation module 101 is used to control each storage node in the distributed storage system to reserve corresponding storage space for backing up metadata;
[0159] A virtual space pool determination module 102, configured to determine a virtual space pool according to the storage space reserved by each storage node;
[0160] The metadata backup module 103 is used to back up the metadata stored in at least one management node in the distributed storage system to the virtual space pool.
[0161] In one embodiment, when the storage space reservation module controls each storage node in the distributed storage system to reserve corresponding storage space for backing up metadata, it is specifically used to:
[0162] A reservation instruction is issued to each storage node in the distributed storage system, wherein the reservation instruction is used to indicate that storage space is reserved for backing up metadata. The reservation instruction carries reserved storage space information to control each storage node in the distributed storage system to reserve corresponding storage space for backing up metadata according to the reserved storage space information.
[0163] In one embodiment, the reserved storage space information is obtained through the following modules:
[0164] The external instruction input module is used to receive an externally input space division instruction, wherein the space division instruction carries the reserved storage space information.
[0165] In one embodiment, when the metadata backup module backs up the metadata stored in at least one management node in the distributed storage system to the virtual space pool, it is specifically used to:
[0166] Determining target metadata to be backed up from metadata stored in each management node in the distributed storage system;
[0167] Selecting a target storage space for backing up the target metadata from the virtual space pool;
[0168] The target metadata is stored in the target storage space.
[0169] In one embodiment, when the metadata backup module selects the target storage space for backing up the target metadata from the virtual space pool, it is specifically configured to:
[0170] Encapsulating the target metadata into a target data file in a specified format;
[0171] At least one target storage space is found from the virtual space pool according to the size of the target data file; the sum of the sizes of the remaining unoccupied spaces in all target storage spaces is greater than or equal to the size of the target data file.
[0172] In one embodiment, finding at least one target storage space from the virtual space pool according to the size of the target data file includes:
[0173] Check whether the sum of the remaining space sizes of all storage spaces in the virtual space pool is less than the size of the target data file; if so, find the file with the earliest storage time from each storage space in the virtual space pool and delete it, and return to the step of checking whether the sum of the remaining space sizes of all storage spaces in the virtual space pool is less than the size of the target data file;
[0174] If not, find at least one target storage space from the virtual space pool according to the size of the target data file.
[0175] In one embodiment, when the metadata backup module stores the target metadata in the target storage space, it is specifically used to:
[0176] When the number of target storage spaces is equal to 1, storing the target data file in the target storage space;
[0177] When the number of target storage spaces is greater than 1, the target data file is divided into multiple file blocks according to the size of the unoccupied remaining space in each target storage space, the size of the unoccupied remaining space in each target storage space corresponds to one file block, and the corresponding file block size is equal to the size of the unoccupied remaining space; each file block is stored in the corresponding target storage space respectively.
[0178] In one embodiment, the file name of the target data file or file block stored in the target storage space includes the generation time of the target data file;
[0179] The device further comprises:
[0180] A file search module, used for searching, when a metadata recovery requirement exists in the management node, files corresponding to the metadata recovery requirement and having file names that meet a condition from each storage space of the virtual space pool, wherein the condition is that the time difference between the generation time in the file name and the current time is the smallest;
[0181] The metadata recovery module is used to parse metadata from the found files that meet the conditions, and store the parsed metadata in the management node where the metadata recovery requirement exists.
[0182] The implementation process of the functions and effects of each unit in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, and will not be repeated here.
[0183] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to the partial description of the method embodiments. The device embodiments described above are only illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units.
[0184] The present invention also provides an electronic device, comprising a processor and a memory; the memory stores a program that can be called by the processor; wherein when the processor executes the program, the metadata backup method as described in the above embodiment is implemented.
[0185] The metadata backup device of the present invention can be applied to electronic devices. Taking software implementation as an example, as a device in a logical sense, the processor of the electronic device in which it is located reads the corresponding computer program instructions in the non-volatile memory into the memory and runs them. From the hardware level, if Figure 4 As shown, Figure 4 is a hardware structure diagram of an electronic device where a metadata backup device 100 is located according to an exemplary embodiment of the present invention, except Figure 4 In addition to the processor 510, memory 530, interface 520, and non-volatile memory 540 shown, the electronic device where the device 100 is located in the embodiment may also include other hardware according to the actual function of the electronic device, which will not be described in detail.
[0186] The present invention also provides a machine-readable storage medium on which a program is stored. When the program is executed by a processor, the metadata backup method as described in any one of the aforementioned embodiments is implemented.
[0187] The present invention may take the form of a computer program product implemented on one or more storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing program code. Machine-readable storage media include permanent and non-permanent, removable and non-removable media, and information storage can be achieved by any method or technology. The information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of machine-readable storage media include but are not limited to: phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices or any other non-transmission medium that can be used to store information that can be accessed by a computing device.
[0188] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A metadata backup method, characterized in that: The method is applied to a management node in a distributed storage system, the distributed storage system also includes a storage node, and the method includes: Controlling each storage node in the distributed storage system to reserve corresponding storage space for backing up metadata; Determine the virtual space pool based on the storage space reserved by each storage node; Determining target metadata to be backed up from metadata stored in each management node in the distributed storage system; Encapsulating the target metadata into a target data file in a specified format; Find at least one target storage space from the virtual space pool according to the size of the target data file; the sum of the sizes of the remaining unoccupied spaces in all target storage spaces is greater than or equal to the size of the target data file; storing the target data file in the target storage space; wherein the file name of the target data file stored in the target storage space includes the generation time of the target data file; When there is a metadata recovery demand at the management node, searching for a file corresponding to the metadata recovery demand and having a file name that satisfies a condition from each storage space of the virtual space pool, wherein the condition is that the time difference between the generation time in the file name and the current time is the smallest; Metadata is parsed from the found files that meet the conditions, and the parsed metadata is stored in the management node where the metadata recovery requirement exists.
2. The metadata backup method according to claim 1, characterized in that: The controlling each storage node in the distributed storage system to reserve corresponding storage space for backing up metadata includes: A reservation instruction is issued to each storage node in the distributed storage system, wherein the reservation instruction is used to indicate that storage space is reserved for backing up metadata. The reservation instruction carries reserved storage space information to control each storage node in the distributed storage system to reserve corresponding storage space for backing up metadata according to the reserved storage space information.
3. The metadata backup method according to claim 2, characterized in that: The reserved storage space information is obtained by the following steps: An externally input space division instruction is received, where the space division instruction carries the reserved storage space information.
4. The metadata backup method according to claim 1, characterized in that: Finding at least one target storage space from the virtual space pool according to the size of the target data file includes: Check whether the sum of the remaining space sizes of all storage spaces in the virtual space pool is less than the size of the target data file; if so, find the file with the earliest storage time from each storage space in the virtual space pool and delete it, and return to the step of checking whether the sum of the remaining space sizes of all storage spaces in the virtual space pool is less than the size of the target data file; If not, find at least one target storage space from the virtual space pool according to the size of the target data file.
5. The metadata backup method according to claim 1, characterized in that: The storing the target data file to the target storage space comprises: When the number of target storage spaces is equal to 1, storing the target data file in the target storage space; When the number of target storage spaces is greater than 1, the target data file is divided into multiple file blocks according to the size of the unoccupied remaining space in each target storage space, the size of the unoccupied remaining space in each target storage space corresponds to one file block, and the corresponding file block size is equal to the size of the unoccupied remaining space; each file block is stored in the corresponding target storage space respectively.
6. A metadata backup device, characterized in that: The device is applied to a management node in a distributed storage system, wherein the distributed storage system also includes a storage node. The device includes: A storage space reservation module, used to control each storage node in the distributed storage system to reserve corresponding storage space for backing up metadata; A virtual space pool determination module, used to determine a virtual space pool according to the storage space reserved by each storage node; A metadata backup module, used to determine target metadata to be backed up from metadata stored in each management node in the distributed storage system; Encapsulating the target metadata into a target data file in a specified format; Find at least one target storage space from the virtual space pool according to the size of the target data file; the sum of the sizes of the remaining unoccupied spaces in all target storage spaces is greater than or equal to the size of the target data file; storing the target data file in the target storage space; wherein the file name of the target data file stored in the target storage space includes the generation time of the target data file; When there is a metadata recovery demand at the management node, searching for a file corresponding to the metadata recovery demand and having a file name that satisfies a condition from each storage space of the virtual space pool, wherein the condition is that the time difference between the generation time in the file name and the current time is the smallest; Metadata is parsed from the found files that meet the conditions, and the parsed metadata is stored in the management node where the metadata recovery requirement exists.
7. An electronic device, characterized in that: It comprises a processor and a memory; the memory stores a program that can be called by the processor; wherein when the processor executes the program, the metadata backup method as described in any one of claims 1-5 is implemented.
8. A machine-readable storage medium, characterized in that: A program is stored thereon, and when the program is executed by a processor, the metadata backup method as described in any one of claims 1 to 5 is implemented.
