WO2016029744A1 - Metadata recovery method and relevant device - Google Patents

Metadata recovery method and relevant device Download PDF

Info

Publication number
WO2016029744A1
WO2016029744A1 PCT/CN2015/083226 CN2015083226W WO2016029744A1 WO 2016029744 A1 WO2016029744 A1 WO 2016029744A1 CN 2015083226 W CN2015083226 W CN 2015083226W WO 2016029744 A1 WO2016029744 A1 WO 2016029744A1
Authority
WO
WIPO (PCT)
Prior art keywords
metadata
target file
information
data
data block
Prior art date
Application number
PCT/CN2015/083226
Other languages
French (fr)
Chinese (zh)
Inventor
刘洋
张克星
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2016029744A1 publication Critical patent/WO2016029744A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L65/00Network arrangements, protocols or services for supporting real-time applications in data packet communication
    • H04L65/40Support for services or applications

Definitions

  • the present invention relates to the field of communications, and in particular, to a metadata recovery method and related apparatus.
  • Hadoop is a widely distributed distributed system architecture in the communication field. It contains a very important storage component in Hadoop, namely Hadoop Distributed File System (HDFS).
  • the HDFS includes a metadata node (NameNode, NN for short) and a data node (DataNode, DN for short).
  • the NN is mainly used to provide a metadata service for the file. In the service, the NN generates metadata of the file in the memory, and the metadata. Can represent the data structure of the file, and DN is mainly used to store the actual data of the file. In an actual application, when an NN is abnormal, the NN will have a problem of metadata loss, causing the NN to fail.
  • a timing thread is opened inside the NN, which periodically writes the metadata in the NN memory to the local disk or the remote storage device to form a specific file.
  • the NN loads the specific file during the restart process to recover the metadata of the previous period to achieve the memory state of the NN recovery to this period.
  • the metadata in the NN is periodically stored, for example, the metadata is stored every ten minutes, so that when the time when the NN is abnormal has not reached the storage time point of ten minutes, then the NN Metadata in the event of an exception is not stored, so this part of the metadata cannot be recovered. It can be seen that the metadata of the NN anomaly cannot be recovered in the above technical solution.
  • the invention provides a metadata recovery method and related device, which can recover metadata when an NN is abnormal.
  • the present invention provides a metadata recovery method, including:
  • the target file is divided into multiple data blocks, where the multiple data blocks are saved on the multiple DNs;
  • the acquiring the metadata of the target file from the NN, and generating the metadata recovery information according to the metadata of the target file includes:
  • the metadata of each data block includes information of each data block and information of a DN where each of the data blocks is located;
  • the acquiring, by the NN, the metadata of the multiple data blocks includes:
  • the received metadata includes at least metadata of the first data block and the second data block Metadata, where:
  • the generated metadata recovery information of the first data block includes:
  • Attribute information of the target file and location information of the first data block in the target file are Attribute information of the target file and location information of the first data block in the target file
  • the generated metadata recovery information of the second data block includes:
  • the present invention provides a metadata recovery method, including:
  • the metadata recovery information is sent to the NN, and the metadata recovery information is used by the NN to perform recovery of the metadata.
  • the target file is divided into multiple data blocks, and the metadata recovery information of the target file sent by the receiving client includes:
  • the receiving the metadata recovery information of the data block of the target file that is sent by the client includes:
  • the received metadata recovery information is at least The metadata recovery information of the first data block and the metadata recovery information of the second data block, wherein:
  • the metadata recovery information of the first data block includes:
  • Attribute information of the target file and location information of the first data block in the target file are Attribute information of the target file and location information of the first data block in the target file
  • the metadata recovery information of the second data block includes:
  • the present invention provides a metadata recovery method, including:
  • the target file is divided into multiple data blocks, where the multiple data blocks are saved on the multiple DNs;
  • And generating the metadata of the target file, and sending the metadata to the client includes:
  • Receiving the metadata recovery information sent by the at least one of the plurality of DNs, and recovering the metadata according to the metadata recovery information including:
  • the sending, by the client, the metadata of the multiple data blocks includes:
  • the multiple data blocks include at least a first data block and a second Data block, where:
  • the metadata recovery information of the first data block includes:
  • Attribute information of the target file and location information of the first data block in the target file are Attribute information of the target file and location information of the first data block in the target file
  • the metadata recovery information of the second data block includes:
  • the present invention provides a client, including: a receiving unit, an obtaining unit, a generating unit, and a sending unit, where:
  • the receiving unit is configured to receive a write operation request for the target file, where the target file is saved on multiple DNs;
  • the acquiring unit is configured to acquire metadata of the target file from an NN, where metadata of the target file includes information of the multiple DNs;
  • the generating unit is configured to generate metadata recovery information according to metadata of the target file
  • the sending unit is configured to send the metadata recovery information to at least one of the plurality of DNs, where the metadata recovery information is used to be saved by the at least one DN, and
  • the NN is sent to the NN for recovery of the metadata after an abnormality occurs.
  • the target file is divided into multiple data blocks, where the multiple data blocks are saved on the multiple DNs;
  • the obtaining unit is configured to acquire metadata of the plurality of data blocks from the NN, and the metadata of each data block includes information of each data block and information of a DN where each of the data blocks is located;
  • the generating unit is configured to generate metadata recovery information of each of the data blocks according to the metadata of each of the data blocks.
  • the acquiring unit is configured to sequentially receive metadata of each data block that is sent by the NN; Alternatively, the obtaining unit is configured to receive metadata of all data blocks that are sent by the NN according to a write operation of the target file.
  • the received metadata includes at least metadata of the first data block And the metadata of the second data block, where:
  • the generated metadata recovery information of the first data block includes:
  • Attribute information of the target file and location information of the first data block in the target file are Attribute information of the target file and location information of the first data block in the target file
  • the generated metadata recovery information of the second data block includes:
  • the present invention provides a DN, including: a receiving unit and a sending unit, where:
  • the receiving unit is configured to receive metadata recovery information of the target file sent by the client, and save the metadata recovery information, where the metadata recovery information is that the client receives a write operation on the target file.
  • the metadata of the target file obtained from the NN is based on Metadata recovery information generated by the metadata.
  • the sending unit is configured to send the metadata recovery information to the NN after an abnormality occurs in the NN, where the metadata recovery information is used by the NN to perform recovery of the metadata.
  • the target file is divided into multiple data blocks
  • the receiving unit is configured to receive metadata recovery of the data block of the target file that is sent by the client Information
  • the metadata recovery information of the data block is metadata recovery information generated by the client according to metadata of the data block.
  • the receiving unit is configured to receive, in sequence, multiple data blocks of the target file that are sent by the client endpoint The metadata recovery information is used; or the receiving unit is configured to receive metadata recovery information of the plurality of data blocks of the target file that are sent by the client at one time.
  • the received metadata recovery information includes at least metadata recovery information of the first data block. And metadata recovery information for the second data block, wherein:
  • the metadata recovery information of the first data block includes:
  • Attribute information of the target file and location information of the first data block in the target file are Attribute information of the target file and location information of the first data block in the target file
  • the metadata recovery information of the second data block includes:
  • the present invention provides an NN, including: a receiving unit, a generating unit, and a restoring unit, where:
  • the receiving unit is configured to receive a write operation request for the target file sent by the client, where the target file is saved on multiple DNs;
  • the generating unit is configured to generate metadata of the target file, and send the data to the client The metadata, wherein the metadata includes information of the plurality of DNs;
  • the recovery unit is configured to receive metadata recovery information sent by at least one of the plurality of DNs when an abnormality occurs on the local end, and recover the metadata according to the metadata recovery information, where
  • the metadata recovery information is metadata recovery information generated by the client according to the metadata, and sent by the client to the at least one DN for saving.
  • the target file is divided into multiple data blocks, where the multiple data blocks are saved on the multiple DNs;
  • the generating unit is configured to generate metadata of the plurality of data blocks, and send metadata of the plurality of data blocks to the client, where metadata of each data block includes information and information of each data block Information about the DN where each data block is located;
  • the recovery unit is configured to receive metadata recovery information of the plurality of data blocks sent by at least one of the plurality of DNs when an abnormality occurs on the local end, and recover the metadata according to the plurality of data blocks.
  • the information recovers the metadata of the target file.
  • the generating unit is configured to generate metadata of the multiple data blocks, and send the Metadata of a plurality of data blocks; or the generating unit is configured to generate metadata of the plurality of data blocks, and send metadata of all data blocks to the client at a time according to a write operation request of the target file .
  • the multiple data blocks include at least a first data block and a second data block, where :
  • the metadata recovery information of the first data block includes:
  • Attribute information of the target file and location information of the first data block in the target file are Attribute information of the target file and location information of the first data block in the target file
  • the metadata recovery information of the second data block includes:
  • receiving a write operation request for the target file acquiring metadata of the target file from the NN, generating metadata recovery information according to the metadata of the target file, and then performing at least one of the plurality of DNs A DN sends the metadata recovery information.
  • the metadata recovery information can be used for saving by the at least one DN and sent to the NN for recovery of the metadata after an exception occurs in the NN.
  • the metadata when the NN is abnormal can be restored.
  • FIG. 1 is a schematic diagram of an optional metadata provided by an embodiment of the present invention.
  • FIG. 2 is a schematic flowchart of a metadata recovery method according to an embodiment of the present invention.
  • FIG. 3 is a schematic flowchart of another metadata recovery method according to an embodiment of the present invention.
  • FIG. 4 is a schematic diagram of an optional data information provided by an embodiment of the present invention.
  • FIG. 5 is a schematic flowchart diagram of another metadata recovery method according to an embodiment of the present invention.
  • FIG. 6 is a schematic flowchart diagram of another metadata recovery method according to an embodiment of the present invention.
  • FIG. 7 is a schematic flowchart diagram of another metadata recovery method according to an embodiment of the present invention.
  • FIG. 8 is a schematic structural diagram of a client according to an embodiment of the present disclosure.
  • FIG. 9 is a schematic structural diagram of a DN according to an embodiment of the present invention.
  • FIG. 10 is a schematic structural diagram of a NN according to an embodiment of the present disclosure.
  • FIG. 11 is a schematic structural diagram of another metadata recovery device according to an embodiment of the present invention.
  • FIG. 12 is a schematic structural diagram of a DN device according to an embodiment of the present disclosure.
  • FIG. 13 is a schematic structural diagram of an NN device according to an embodiment of the present invention.
  • the metadata may be data for indicating a file data structure, where the metadata of the file may specifically represent version information of the HDFS system where the file is located and attribute information of the file, for example, metadata of the file.
  • the version information of the included HDFS system may include one or more of the following:
  • the version information of the HDFS system for example, imgVersion
  • the namespace identifier for example, namespaceID
  • the number of files of the HDFS system for example, numFiles
  • the time stamp of the HDFS system for example, genStamp
  • the attribute information of the file included in the metadata of the file may include one or more of the following:
  • the path of the file (for example: Path), the number of copies of the file (for example: replicas), the access time of the file (for example: atime), the size of each data block of the file (for example: blockSize), and the number of blocks of the data block of the file ( For example: numBlock), limit information for the space occupied by the file (for example: nsQuota and dsQuota) and user permission information (for example: username, group, and perm).
  • Path The path of the file
  • the number of copies of the file for example: replicas
  • the access time of the file for example: atime
  • the size of each data block of the file for example: blockSize
  • the number of blocks of the data block of the file For example: numBlock
  • limit information for the space occupied by the file for example: nsQuota and dsQuota
  • user permission information for example: username, group, and perm
  • the metadata of the file may further include metadata of each data block, where the metadata of the data block includes attribute information of the file to which the data block belongs and attribute information of the data block;
  • the attribute information of the data block may include one or more of the following:
  • the data block identifier for example: BlockId
  • the amount of data stored in the data block for example: numBytes
  • the time stamp of the data block for example: genStamp
  • the metadata of the file can be as shown in FIG. 1, and the metadata of the file can include the one in FIG. Three lines of data, where the first line represents the version information of the HDFS system, the second line represents the attribute information of the file, and the third line represents the metadata of the data block. That is, the metadata of the file may include version information of the HDFS system, attribute information of the file, and metadata of the data block.
  • the scenario to which the embodiment of the present invention is applied may be a single device, that is, the client including the HDFS, the at least one NN, and the at least one DN; or the scenario applied by the embodiment of the present invention may be a device cluster, that is, a client of the HDFS.
  • At least one NN and at least one DN are deployed on multiple devices.
  • the device may be a network side device, for example, a base station, a server, a controller, etc., and the device may also be a user side device, such as a computer, a tablet computer, a mobile phone, an e-reader, a remote controller, a notebook computer, and a car.
  • a smart device with network capabilities such as devices, network TVs, and wearable devices.
  • FIG. 2 is a schematic flowchart of a metadata recovery method according to an embodiment of the present invention. As shown in FIG. 2, the method includes the following steps:
  • the foregoing target file is saved on multiple DNs, and may be in response to the foregoing write operation request, and the target file is saved on multiple DNs, wherein the time of the save process is not limited, for example, after step 204, or in step Before 204.
  • the local end may apply to the NN for multiple DNs for saving the target file, so that the NN may allocate the NN for the target file, and generate metadata of the target file. And return the metadata of the target file to the above end.
  • the information of the plurality of DNs may be path information in which the DN stores the target file, for example, the path of the file in the attribute information of the file introduced above.
  • the metadata recovery information may include metadata of the target file, for example, including attribute information of the target file.
  • the attribute information may include one or more of the following:
  • Version information of the HDFS system file name, space limit information occupied by the file, user authority information, each data block size of the file, and the number of blocks of the data block of the file.
  • the file name may also carry path information of the file.
  • the foregoing method can be applied to a client of the HDFS, that is, the client can implement the foregoing method.
  • receiving a write operation request for the target file acquiring metadata of the target file from the NN, generating metadata recovery information according to the metadata of the target file, and then performing at least one of the plurality of DNs A DN sends the metadata recovery information.
  • the metadata recovery information can be used for saving by the at least one DN and sent to the NN for recovery of the metadata after an exception occurs in the NN.
  • the metadata when the NN is abnormal can be restored.
  • FIG. 3 is a schematic flowchart of another metadata recovery method according to an embodiment of the present invention. As shown in FIG. 3, the method includes the following steps:
  • the data write operation on the target file may be performed in units of data blocks, that is, an object file may be divided into multiple data blocks, wherein the size of each data block is Can be the same.
  • each data block can be 64 megabytes (MB) or 128 MB.
  • the size of the foregoing data block may be the storage space size of the data block, but in actual applications, the data amount of the file stored in each data block of one file may be different, for example, one file contains 150 MB of data, and each The size of the data block is 64MB, then the first data block of the file can store 64MB of data of the file, and the second data block can store 64MB of data of the file, and the third data block can store the data. 22MB of data for the file.
  • Metadata of the plurality of data blocks from the NN and metadata of each data block includes information of each data block and information of a DN where each of the data blocks is located.
  • the local end may apply to the NN for multiple data blocks for saving the target file, and save multiple DNs of the data block.
  • the NN can allocate a data block for the object file, and the DN of the data block, and generate metadata for each data block, and return the metadata of each data block to the above end.
  • the information of the foregoing data block may be attribute information of the data block, for example, a data block identifier and a time stamp of the data block.
  • the information of the plurality of DNs may be path information of each DN save data block, for example, the path of the file in the attribute information of the file described above.
  • the metadata recovery information of the data block may include metadata of the data block, for example, including attribute information of the target file.
  • the NN performs recovery of the metadata of the target file.
  • the obtaining the metadata of the multiple data blocks from the NN may include:
  • the metadata of each of the data blocks sent by the NN is sequentially received.
  • the local end may apply for a data block to the NN each time, so that the NN allocates a data block to the target file, and generates metadata of the data block, and returns the metadata of the data block to the local end.
  • the local end requests another data block from the NN, and the NN allocates another data block for the target file, and generates metadata of the data block. And return the metadata of the data block to the above end.
  • step 303 may be that the local end acquires the metadata recovery information of the data block for each time, and then generates the metadata recovery information of the data block to the at least one DN.
  • the obtaining the metadata of the multiple data blocks from the NN may include:
  • the local end may apply for multiple data blocks to the NN at one time, so that the NN allocates multiple data blocks for the target file, and generates metadata of the data blocks, and returns the metadata of the data blocks to the local end.
  • step 303 may be to generate metadata recovery information of a plurality of data blocks at a time, and step 304 further transmits metadata recovery information of the plurality of data blocks to the at least one DN.
  • the received metadata includes at least metadata of the first data block and metadata of the second data block, that is, the target file is at least divided into the first data block and the second data block.
  • the metadata recovery information of the generated first data block may include:
  • Attribute information of the object file and location information of the first data block in the object file are Attribute information of the object file and location information of the first data block in the object file.
  • the attribute information of the target file may include:
  • the version information of the HDFS system the file name, the number of copies of the file, the size of each block of the file, the limit information of the space occupied by the file, and the user authority information.
  • the location information of the first data block in the target file may be a data block number of the target file of the first data block.
  • the first data block may be a data block with a sequence number of 1 of the target file, where The data block with the sequence number 1 may be one of the earliest data blocks in the target file; the location information of the first data block in the target file may include:
  • the metadata recovery information of the generated second data block may include:
  • the location information of the second data block in the target file may include:
  • the metadata recovery information of the second data block may further include version information and a file name of the HDFS system, so that it can be clearly known that the metadata recovery information of the second data block is a data block for recovering which file, and the The version information of the file's HDFS system.
  • the metadata recovery information of the first data block may include:
  • the version information of the HDFS system the file name, the number of copies of the file, the size of each data block of the file, the restriction information of the space occupied by the file, the user authority information, the data block number, and the file end block information.
  • the metadata recovery information of the first data block may include:
  • Version information file name, data block number, and file end block information of the HDFS system.
  • the file end data block information may be represented by whether the current data block is an end block.
  • the file end data block information in the metadata recovery information of the first data block may be represented by a false (false);
  • the file end data block information in the metadata recovery information of the first data block may be a true (true) table.
  • the metadata recovery information of the first data block and the file end data block information in the metadata recovery information of the second data block may be false ( False) indicates that in this embodiment, only the file end block information corresponding to the last data block of the target file is represented by true (true), and the rest are represented by false (false), so that the data block can be ended according to the file.
  • the information can determine the number of data blocks included in the target file.
  • the metadata of each data block in a file may include the attribute information of the file, and the attribute information of the file is the same, for example, the restriction information of the space occupied by the file, the user authority information, the size information and the copy of the data block.
  • the number of information is the same, so that only the information needs to be written in the metadata recovery information of one of the data blocks, thereby saving the storage space of other DNs.
  • Information can also include:
  • Version information of the HDFS system file name, number of copies of the file, access time of the file, number of blocks of the data block of the file, limit information of the space occupied by the file, user permission information, data block identifier, size of the data block, and data block Timestamp.
  • the method may be an application request for sending a data block to the NN, and after receiving the request, the NN may allocate a data block for the target file, and store the data.
  • the DN of the data block may further include the following steps:
  • the foregoing method can be applied to a client of the HDFS, that is, the client can implement the foregoing method.
  • FIG. 5 is a schematic flowchart of another metadata recovery method according to an embodiment of the present invention. As shown in FIG. 5, the method includes the following steps:
  • the target file of the target file is saved on multiple DNs, and the metadata includes information of the plurality of DNs.
  • step 501 may be to store the metadata recovery information locally, or store the metadata recovery information on the third aspect storage device.
  • the NN After the NN is abnormal, send the metadata recovery information to the NN, where the metadata recovery information is used by the NN to perform recovery of the metadata.
  • the method can be applied to the DN of the HDFS.
  • the metadata recovery information of the target file sent by the client is received, and the metadata recovery information is saved; after the NN is abnormal, the metadata recovery information is sent to the NN, and the metadata recovery is performed. Information is used by the NN to perform recovery of the metadata. Thereby, it is possible to restore the metadata when the NN is abnormal.
  • FIG. 6 is a schematic flowchart of another metadata recovery method according to an embodiment of the present invention. As shown in FIG. 6, the method includes the following steps:
  • the object file is divided into a plurality of data blocks, and the metadata of each of the data blocks includes information of each data block and information of a DN of each of the data blocks.
  • the metadata recovery information received in step 601 may be metadata recovery information of one or more data blocks.
  • the target file is divided into a plurality of data blocks, wherein the DN performing the method may be metadata recovery information for storing one or more of the data blocks.
  • step 601 is to save the foregoing metadata recovery information in a specific file, for example, in a file named: blk_blockId_genstamp.blockmeta, where the name of the file may include an identifier of the data block, and the The file name may also include a time stamp of the data block.
  • the DN may receive the identifier of the data sent by the client and the time stamp of the data block while receiving the metadata recovery information of the data block.
  • the file may also save the data of the target file written by the client in the above data block to another specific file, for example, in a file named: blk_blockId.
  • the method may also save the CRC for storing the metadata in the specific file of the metadata recovery information, that is, the metadata.
  • the recovery information and CRC are stored in the same specific file.
  • the method can also store the CRC in a specific file dedicated to storing the CRC.
  • the two specific files may be set before receiving the data information, for example, when the write request sent by the client is received, the two specific files are generated. Since step 601 stores the above data information in the form of a file, this It can implement data warehouse workers (for example: Hive) or Spark functions. Spark is an open source cluster computing system based on memory computing, which aims to make data analysis faster.
  • the metadata recovery information may also be saved in a predefined data format, for example, in a HBase data format, where HBase is a distributed, column-oriented open source database.
  • the metadata recovery information when the metadata recovery information is obtained, the metadata recovery information may also be saved in the memory, so that the metadata recovery information may be sent more quickly.
  • the metadata recovery information of the memory can be directly uploaded to the NN.
  • the locally stored metadata recovery information may be scanned, and the metadata recovery information is uploaded to the NN.
  • the DN when the DN is restarted, the DN receives a notification message sent by the NN, and the notification message is used to request to send the data information, so that the message notification message can be returned to return the metadata recovery information.
  • the receiving, by the receiving, the metadata recovery information of the data block of the target file sent by the client includes:
  • the received metadata recovery information may include at least metadata recovery information of the first data block and metadata recovery information of the second data block, where:
  • the metadata recovery information of the first data block may include:
  • Attribute information of the target file and location information of the first data block in the target file are Attribute information of the target file and location information of the first data block in the target file
  • the metadata recovery information of the second data block may include:
  • the metadata recovery information of all the data blocks of the target file may be sent to the NN.
  • the DN receives the notification message of the NN abnormal restart, the DN scans the metadata recovery information of all the data blocks in the local or the memory in response to the notification message, and uploads the metadata recovery information of all the data blocks to the NN.
  • the foregoing method may be applied to the DN of the HDFS, that is, the DN may implement the foregoing method.
  • the metadata recovery information of the data block of the target file sent by the client is received, and the metadata recovery information is saved, and after the abnormality occurs in the NN, the element is sent to the NN.
  • Data recovery information the metadata recovery information is used by the NN to perform recovery of the metadata.
  • FIG. 7 is a schematic flowchart of another metadata recovery method according to an embodiment of the present invention. As shown in FIG. 7, the method includes the following steps:
  • step 702 after receiving the foregoing write operation request, the multiple DNs are allocated to the target file, and the metadata of the target file is generated.
  • the metadata recovery information sent by the at least one DN can be received, so that the metadata of the target file can be recovered.
  • the foregoing target file may be divided into multiple data blocks, where the multiple data blocks are saved on the multiple DNs;
  • generating the metadata of the target file and sending the metadata to the client may include:
  • the receiving the metadata recovery information sent by the at least one of the plurality of DNs, and recovering the metadata according to the metadata recovery information may include:
  • sending the metadata of the multiple data blocks to the client includes:
  • the foregoing multiple data blocks may include at least a first data block and a second data block, where:
  • the metadata recovery information of the first data block may include:
  • Attribute information of the target file and location information of the first data block in the target file are Attribute information of the target file and location information of the first data block in the target file
  • the metadata recovery information of the second data block may include:
  • the above method can be applied to the NN in the HDFS.
  • the receiving client sends a write operation request to the target file, generates metadata of the target file, and sends the metadata to the client; Metadata recovery information transmitted by at least one of the plurality of DNs, and recovering the metadata according to the metadata recovery information.
  • the device embodiment of the present invention is used to perform the method implemented in Embodiments 1 to 5 of the method of the present invention.
  • Embodiments 1 to 5 of the method of the present invention For the convenience of description, only parts related to the embodiment of the present invention are shown, and the specific technical details are not disclosed. Please refer to Embodiment 1, Example 2, Embodiment 3, Embodiment 4 and Embodiment 5 of the present invention.
  • FIG. 8 is a schematic structural diagram of a client according to an embodiment of the present invention. As shown in FIG. 8, the method includes: a receiving unit 81, an obtaining unit 82, a generating unit 83, and a sending unit 84, where:
  • the receiving unit 81 is configured to receive a write operation request for the target file, where the target file is saved on multiple DNs.
  • the obtaining unit 82 is configured to acquire metadata of the target file from an NN, where metadata of the target file includes information of the plurality of DNs.
  • the generating unit 83 is configured to generate a metadata recovery signal according to the metadata of the target file. interest.
  • the sending unit 84 is configured to send the metadata recovery information to at least one of the plurality of DNs, where the metadata recovery information is used to be saved by the at least one DN, and appears in the NN The exception is sent to the NN for recovery of the metadata.
  • the target file is divided into a plurality of data blocks, and the plurality of data blocks are saved on the plurality of DNs;
  • the obtaining unit 82 may be configured to acquire metadata of the plurality of data blocks from the NN, where metadata of each data block includes information of each data block and information of a DN where each of the data blocks is located;
  • the generating unit 83 may be configured to generate metadata recovery information of each of the data blocks according to the metadata of each of the data blocks.
  • metadata recovery information for generating each data block may be implemented such that the NN restores the metadata of the target file according to the metadata recovery information of the plurality of data blocks.
  • the obtaining unit 82 may be configured to sequentially receive metadata of each of the data blocks sent by the NN; or the acquiring unit 82 may be configured to receive the NN according to the target file.
  • the received metadata may include at least metadata of the first data block and metadata of the second data block, where:
  • the generated metadata recovery information of the first data block may include:
  • Attribute information of the target file and location information of the first data block in the target file are Attribute information of the target file and location information of the first data block in the target file
  • the generated metadata recovery information of the second data block may include:
  • the client may be an HDFS client.
  • receiving a write operation request for the target file acquiring metadata of the target file from the NN, generating metadata recovery information according to the metadata of the target file, and then performing at least one of the plurality of DNs A DN sends the metadata recovery information.
  • the metadata recovery information can be used for saving by the at least one DN and sent to the NN for recovery of the metadata after an exception occurs in the NN.
  • the metadata when the NN is abnormal can be restored.
  • FIG. 9 is a schematic structural diagram of a DN according to an embodiment of the present invention. As shown in FIG. 9, the method includes: a receiving unit 91 and a sending unit 92, where:
  • the receiving unit 91 is configured to receive metadata recovery information of the target file sent by the client, and save the metadata recovery information, where the metadata recovery information is that the client receives a write operation request for the target file.
  • the metadata recovery information is that the client receives a write operation request for the target file.
  • the sending unit 92 is configured to send the metadata recovery information to the NN after the NN is abnormal, and the metadata recovery information is used by the NN to perform recovery of the metadata.
  • the target file is divided into a plurality of data blocks
  • the receiving unit 91 may be configured to receive metadata recovery information of the data block of the target file sent by the client, where the data
  • the metadata recovery information of the block is metadata recovery information generated by the client according to the metadata of the data block.
  • the receiving unit 91 may be configured to sequentially receive metadata recovery information of multiple data blocks of the target file sent by the client endpoint; or the receiving unit 91 may be configured to receive the client for one time. Metadata recovery information of a plurality of data blocks of the target file transmitted.
  • the received metadata recovery information may include at least metadata recovery information of the first data block and metadata recovery information of the second data block, where:
  • the metadata recovery information of the first data block may include:
  • Attribute information of the target file and location information of the first data block in the target file are Attribute information of the target file and location information of the first data block in the target file
  • the metadata recovery information of the second data block may include:
  • the node can be the DN of the HDFS.
  • the metadata recovery information of the target file sent by the client is received, and the metadata recovery information is saved; after the NN is abnormal, the metadata recovery information is sent to the NN, and the metadata recovery is performed. Information is used by the NN to perform recovery of the metadata. Thereby, it is possible to restore the metadata when the NN is abnormal.
  • FIG. 10 is a schematic structural diagram of a NN according to an embodiment of the present invention. As shown in FIG. 10, the method includes: a receiving unit 101, a generating unit 102, and a restoring unit 103, where:
  • the receiving unit 101 is configured to receive a write operation request for the target file sent by the client, where the target file is saved on multiple DNs.
  • the generating unit 102 is configured to generate metadata of the target file, and send the metadata to the client, where the metadata includes information of the multiple DNs.
  • the recovery unit 103 is configured to receive metadata recovery information sent by at least one of the plurality of DNs when an abnormality occurs on the local end, and recover the metadata according to the metadata recovery information, where The metadata recovery information is generated by the client according to the metadata, and is sent by the client to the at least one DN for saving metadata recovery information.
  • the target file is divided into a plurality of data blocks, and the plurality of data blocks are saved on the plurality of DNs;
  • the generating unit 102 may be configured to generate metadata of the plurality of data blocks, and send metadata of the plurality of data blocks to the client, where metadata of each data block includes each data block Information and information about the DN of each of the data blocks;
  • the recovery unit 103 may be configured to receive metadata recovery information of the plurality of data blocks sent by at least one of the plurality of DNs when an abnormality occurs on the local end, and according to the elements of the multiple data blocks.
  • the data recovery information restores the metadata of the target file.
  • the generating unit 102 may be configured to generate metadata of the multiple data blocks, and sequentially send metadata of the multiple data blocks to the client; or, the generating unit 102 may be configured to generate Metadata of the plurality of data blocks, and transmitting metadata of all data blocks to the client at a time according to a write operation request of the target file.
  • the foregoing multiple data blocks may include at least a first data block and a second data block, where:
  • the metadata recovery information of the first data block may include:
  • Attribute information of the target file and location information of the first data block in the target file are Attribute information of the target file and location information of the first data block in the target file
  • the metadata recovery information of the second data block may include:
  • the foregoing node may be an NN in the HDFS.
  • the receiving client sends a write operation request to the target file, generates metadata of the target file, and sends the metadata to the client; Metadata recovery information transmitted by at least one of the plurality of DNs, and recovering the metadata according to the metadata recovery information.
  • FIG. 11 is a schematic structural diagram of another metadata recovery device according to an embodiment of the present invention, including at least one processor 1102 (for example, a CPU), at least one network interface 1105 or other communication interface, a memory 1106, and At least one communication bus 1103 for implementing this Connection communication between these devices.
  • the processor 1102 is configured to execute executable modules, such as computer programs, stored in the memory 1106.
  • the memory 1106 may include a high speed random access memory (RAM), and may also include a non-volatile memory such as at least one disk memory.
  • the communication connection between the system gateway and at least one other network element is implemented by at least one network interface 1105 (which may be wired or wireless), and may use an Internet, a wide area network, a local network, a metropolitan area network, or the like.
  • the memory 1106 stores a program 11061 that can be executed by the processor 1102.
  • This program includes:
  • the object file may be divided into a plurality of data blocks, the plurality of data blocks may be saved on the plurality of DNs; and the processor 1102 performs the acquisition of the target file from the NN.
  • the metadata, the program for generating the metadata recovery information according to the metadata of the target file may include:
  • the metadata of each data block includes information of each data block and information of a DN where each of the data blocks is located;
  • the metadata executed by the processor 1102 is used to acquire the metadata of the multiple data blocks from the NN.
  • the program can include:
  • the received metadata may include at least metadata of the first data block and metadata of the second data block, where:
  • the generated metadata recovery information of the first data block may include:
  • Attribute information of the target file and location information of the first data block in the target file are Attribute information of the target file and location information of the first data block in the target file
  • the generated metadata recovery information of the second data block may include:
  • the device may be a device to which the client of the HDFS belongs.
  • the metadata recovery information can be used to be saved by the at least one DN, and after the NN has an abnormality, it is sent to the NN to recover the metadata, so that the metadata when the NN is abnormal can be restored.
  • FIG. 12 is a schematic structural diagram of a DN device according to an embodiment of the present invention, including at least one processor 1202 (for example, a CPU), at least one network interface 1205 or other communication interface, a memory 1206, and at least one communication. Bus 1203 is used to implement connection communication between these devices.
  • the processor 1202 is configured to execute executable modules, such as computer programs, stored in the memory 1206.
  • the memory 1206 may include a high speed random access memory (RAM), and may also include a non-volatile memory such as at least one disk memory.
  • RAM high speed random access memory
  • Through at least one network interface 1205 realizes the communication connection between the system gateway and at least one other network element, and can use the Internet, a wide area network, a local network, a metropolitan area network, and the like.
  • the memory 1206 stores a program 12061 that can be executed by the processor 1202.
  • the program includes:
  • the metadata recovery information is sent to the NN, and the metadata recovery information is used by the NN to perform recovery of the metadata.
  • the target file is divided into a plurality of data blocks
  • the program executed by the processor 1202 to receive the metadata recovery information of the target file sent by the client may include:
  • the program that is executed by the processor 1202 to receive the metadata recovery information of the data block of the target file that is sent by the client may include:
  • the received metadata recovery information may include at least metadata recovery information of the first data block and metadata recovery information of the second data block, where:
  • the metadata recovery information of the first data block may include:
  • the metadata recovery information of the second data block may include:
  • the device of the local node may be the device to which the DN of the HDFS belongs.
  • the metadata recovery information of the target file sent by the client is received, and the metadata recovery information is saved; after the NN is abnormal, the metadata recovery information is sent to the NN, and the metadata recovery is performed. Information is used by the NN to perform recovery of the metadata. Thereby, it is possible to restore the metadata when the NN is abnormal.
  • FIG. 13 is a schematic structural diagram of an NN device according to an embodiment of the present invention, including at least one processor 1302 (eg, a CPU), at least one network interface 1305 or other communication interface, a memory 1306, and at least one communication.
  • a bus 1303 is used to implement connection communication between these devices.
  • the processor 1302 is configured to execute executable modules, such as computer programs, stored in the memory 1306.
  • the memory 1306 may include a high speed random access memory (RAM) and may also include a non-volatile memory such as at least one disk memory.
  • the communication connection between the system gateway and at least one other network element is implemented by at least one network interface 1305 (which may be wired or wireless), and may use an Internet, a wide area network, a local network, a metropolitan area network, or the like.
  • the memory 1306 stores a program 13061 that can be executed by the processor 1302. This program includes:
  • the object file is divided into a plurality of data blocks, the plurality of data blocks are saved on the plurality of DNs; the processor 1302 performs metadata generation of the object file, and Sending the metadata to the client may include:
  • the program executed by the processor 1302, which receives the metadata recovery information sent by the at least one of the plurality of DNs, and recovers the metadata according to the metadata recovery information, may include:
  • the program executed by the processor 1302 to send the metadata of the multiple data blocks to the client may include:
  • the foregoing multiple data blocks may include at least a first data block and a second data block, where:
  • the metadata recovery information of the first data block may include:
  • Attribute information of the target file and location information of the first data block in the target file are Attribute information of the target file and location information of the first data block in the target file
  • the metadata recovery information of the second data block may include:
  • the foregoing node device may be a device to which the NN in the HDFS belongs.
  • the receiving client sends a write operation request to the target file; generating metadata of the target file, and sending the metadata to the client; and when the local end is abnormal, receiving the multiple Metadata recovery information transmitted by at least one of the DNs, and the metadata is restored according to the metadata recovery information.
  • the metadata when the NN is abnormal can be restored.
  • the storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

Disclosed are a metadata recovery method and a relevant device. The method can comprise: receiving a write operation request for a target file, wherein the target file is saved in multiple data nodes; acquiring metadata of the target file from a namenode, the metadata of the target file containing information about the multiple data nodes; generating metadata recovery information according to the metadata of the target file; and sending the metadata recovery information to at least one data node of the multiple data nodes, the metadata recovery information being used for being saved by the at least one data node, and being sent to the namenode for recovering the metadata when abnormality occurs to the namenode. The embodiments of the present invention can recover metadata when abnormality occurs to an NN.

Description

一种元数据恢复方法及相关装置Metadata recovery method and related device 技术领域Technical field
本发明涉及通信领域,尤其涉及一种元数据恢复方法及相关装置。The present invention relates to the field of communications, and in particular, to a metadata recovery method and related apparatus.
背景技术Background technique
Hadoop是目前通信领域中应用十分广泛的分布式系统架构,在Hadoop中包含一个非常重要的存储组件,即Hadoop分布式文件系统(Hadoop Distributed File System,简称HDFS)。其中,HDFS包括元数据节点(NameNode,简称NN)和数据节点(DataNode,简称DN),NN主要用来提供文件的元数据服务,该服务中NN在内存会生成该文件的元数据,元数据可以表示该文件的数据结构,而DN主要用来存储文件的实际数据。在实际应用中当NN出现异常时,这样该NN就会出现元数据丢失的问题,以导致该NN失效。Hadoop is a widely distributed distributed system architecture in the communication field. It contains a very important storage component in Hadoop, namely Hadoop Distributed File System (HDFS). The HDFS includes a metadata node (NameNode, NN for short) and a data node (DataNode, DN for short). The NN is mainly used to provide a metadata service for the file. In the service, the NN generates metadata of the file in the memory, and the metadata. Can represent the data structure of the file, and DN is mainly used to store the actual data of the file. In an actual application, when an NN is abnormal, the NN will have a problem of metadata loss, causing the NN to fail.
其中,目前主要通过如下技术解决上述问题:Among them, the above problems are mainly solved by the following technologies:
在NN内部开启一个定时线程,该线程定期将NN内存中的元数据写到本地磁盘或者远端存储设备形成一个特定文件。当NN出现异常后,NN在重新启动过程中加载该特定文件,以恢复之前的某一时段的元数据,以实现NN恢复到这一时段的内存状态。A timing thread is opened inside the NN, which periodically writes the metadata in the NN memory to the local disk or the remote storage device to form a specific file. When the NN is abnormal, the NN loads the specific file during the restart process to recover the metadata of the previous period to achieve the memory state of the NN recovery to this period.
但上述技术方案中,由于是定期的存储NN内的元数据,例如:每隔十分钟存储一次元数据,这样当NN出现异常的时间点还未到十分钟一次的存储时间点时,那么NN内的出现异常时的元数据不会存储,从而这部分元数据就无法恢复。可见,上述技术方案中无法恢复NN异常时的元数据。However, in the above technical solution, since the metadata in the NN is periodically stored, for example, the metadata is stored every ten minutes, so that when the time when the NN is abnormal has not reached the storage time point of ten minutes, then the NN Metadata in the event of an exception is not stored, so this part of the metadata cannot be recovered. It can be seen that the metadata of the NN anomaly cannot be recovered in the above technical solution.
发明内容Summary of the invention
本发明提供了一种元数据恢复方法及相关装置,可以恢复NN异常时的元数据。 The invention provides a metadata recovery method and related device, which can recover metadata when an NN is abnormal.
第一方面,本发明提供一种元数据恢复方法,包括:In a first aspect, the present invention provides a metadata recovery method, including:
接收对目标文件的写操作请求,其中,所述目标文件保存在多个DN上;Receiving a write operation request to the target file, wherein the target file is saved on multiple DNs;
从NN获取所述目标文件的元数据,所述目标文件的元数据包含所述多个DN的信息;Obtaining metadata of the target file from the NN, the metadata of the target file containing information of the plurality of DNs;
根据所述目标文件的元数据生成元数据恢复信息;Generating metadata recovery information according to metadata of the target file;
向所述多个DN中的至少一个DN发送所述元数据恢复信息,所述元数据恢复信息用于被所述至少一个DN进行保存,并在所述NN出现异常后被发送到所述NN进行所述元数据的恢复。Transmitting the metadata recovery information to at least one of the plurality of DNs for saving by the at least one DN and transmitting to the NN after an exception occurs in the NN The recovery of the metadata is performed.
在第一方面的第一种可能的实现方式中,所述目标文件被划分为多个数据块,所述多个数据块被保存在所述多个DN上;In a first possible implementation manner of the first aspect, the target file is divided into multiple data blocks, where the multiple data blocks are saved on the multiple DNs;
则,所述从NN获取所述目标文件的元数据,根据所述目标文件的元数据生成元数据恢复信息包括:Then, the acquiring the metadata of the target file from the NN, and generating the metadata recovery information according to the metadata of the target file includes:
从所述NN获取所述多个数据块的元数据,每个数据块的元数据包含每个数据块的信息和所述每个数据块所在的DN的信息;Obtaining metadata of the plurality of data blocks from the NN, the metadata of each data block includes information of each data block and information of a DN where each of the data blocks is located;
根据所述每个数据块的元数据,生成所述每个数据块的元数据恢复信息。Generating metadata recovery information for each of the data blocks based on the metadata of each of the data blocks.
结合第一方面的第一种可能的实现方式,在第二种可能实现方式中,所述从所述NN获取所述多个数据块的元数据包括:With reference to the first possible implementation of the first aspect, in a second possible implementation, the acquiring, by the NN, the metadata of the multiple data blocks includes:
依次接收所述NN发送的所述每个数据块的元数据;或者,接收所述NN根据所述目标文件的写操作请求一次性发送的所有数据块的元数据。Receiving metadata of each of the data blocks sent by the NN in sequence; or receiving metadata of all data blocks that the NN requests to be sent at one time according to a write operation of the target file.
结合第一方面的第一种可能的实现方式或者第二种可能的实现方式,在第三种可能实现方式中,所述接收的元数据至少包括第一数据块的元数据和第二数据块的元数据,其中:With reference to the first possible implementation manner of the first aspect or the second possible implementation manner, in a third possible implementation manner, the received metadata includes at least metadata of the first data block and the second data block Metadata, where:
所述生成的所述第一数据块的元数据恢复信息包括: The generated metadata recovery information of the first data block includes:
所述目标文件的属性信息和所述第一数据块在所述目标文件中的位置信息;Attribute information of the target file and location information of the first data block in the target file;
所述生成的所述第二数据块的元数据恢复信息包括:The generated metadata recovery information of the second data block includes:
所述第二数据块在所述目标文件中的位置信息。Location information of the second data block in the target file.
第三方面,本发明提供一种元数据恢复方法,包括:In a third aspect, the present invention provides a metadata recovery method, including:
接收客户端发送的目标文件的元数据恢复信息,并保存所述元数据恢复信息,其中,所述元数据恢复信息是所述客户端在接收对目标文件的写操作请求时,从NN获取的所述目标文件的元数据,并根据所述元数据生成的元数据恢复信息.;Receiving metadata recovery information of the target file sent by the client, and saving the metadata recovery information, wherein the metadata recovery information is obtained by the client from the NN when receiving a write operation request for the target file Metadata of the target file, and metadata recovery information generated according to the metadata.
在所述NN出现异常后,向所述NN发送所述元数据恢复信息,元数据恢复信息被所述NN用于进行所述元数据的恢复。After the NN has an abnormality, the metadata recovery information is sent to the NN, and the metadata recovery information is used by the NN to perform recovery of the metadata.
在第二方面的第一种可能的实现方式中,所述目标文件被划分为多个数据块,所述接收客户端发送的目标文件的元数据恢复信息,包括:In a first possible implementation manner of the second aspect, the target file is divided into multiple data blocks, and the metadata recovery information of the target file sent by the receiving client includes:
接收所述客户端发送的所述目标文件的数据块的元数据恢复信息,所述数据块的元数据恢复信息为所述客户端根据该数据块的元数据生成的元数据恢复信息。And receiving metadata recovery information of the data block of the target file sent by the client, where the metadata recovery information of the data block is metadata recovery information generated by the client according to the metadata of the data block.
结合第二方面的第一种可能的实现方式,在第二方面的第二种可能的实现方式中,所述接收所述客户端发送的所述目标文件的数据块的元数据恢复信息包括:With reference to the first possible implementation of the second aspect, in a second possible implementation manner of the second aspect, the receiving the metadata recovery information of the data block of the target file that is sent by the client includes:
依次接收所述客户端点发送的所述目标文件的多个数据块的元数据恢复信息;或者,接收所述客户端一次性发送的所述目标文件的多个数据块的元数据恢复信息。Receiving metadata recovery information of the plurality of data blocks of the target file sent by the client endpoint in sequence; or receiving metadata recovery information of the plurality of data blocks of the target file sent by the client at one time.
结合第二方面的第一种可能的实现方式或者第二种可能的实现方式中,在第二方面的第三种可能的实现方式中,所述接收的元数据恢复信息至少包 括第一数据块的元数据恢复信息和第二数据块的元数据恢复信息,其中:In conjunction with the first possible implementation of the second aspect or the second possible implementation, in a third possible implementation of the second aspect, the received metadata recovery information is at least The metadata recovery information of the first data block and the metadata recovery information of the second data block, wherein:
所述第一数据块的元数据恢复信息包括:The metadata recovery information of the first data block includes:
所述目标文件的属性信息和所述第一数据块在所述目标文件中的位置信息;Attribute information of the target file and location information of the first data block in the target file;
所述第二数据块的元数据恢复信息包括:The metadata recovery information of the second data block includes:
所述第二数据块在所述目标文件中的位置信息。Location information of the second data block in the target file.
第三方面,本发明提供一种元数据恢复方法,包括:In a third aspect, the present invention provides a metadata recovery method, including:
接收客户端发送的对目标文件进行写操作请求,其中,所述目标文件保存在多个DN上;Receiving a write operation request to the target file sent by the client, where the target file is saved on multiple DNs;
生成所述目标文件的元数据,并向所述客户端发送所述元数据,其中,所述元数据包含所述多个DN的信息;Generating metadata of the target file, and transmitting the metadata to the client, wherein the metadata includes information of the plurality of DNs;
当本端出现异常时,接收所述多个DN中的至少一个DN发送的元数据恢复信息,并根据所述元数据恢复信息恢复所述元数据,其中,所述元数据恢复信息是所述客户端根据所述元数据生成的,由所述客户端发送至所述至少一个DN进行保存的元数据恢复信息。Receiving, by the local end, metadata recovery information sent by at least one of the plurality of DNs, and recovering the metadata according to the metadata recovery information, wherein the metadata recovery information is The metadata recovery information generated by the client according to the metadata and sent by the client to the at least one DN for saving.
在第三方面的第一种可能的实现方式中,所述目标文件被划分为多个数据块,所述多个数据块被保存在所述多个DN上;In a first possible implementation manner of the third aspect, the target file is divided into multiple data blocks, where the multiple data blocks are saved on the multiple DNs;
则所述生成所述目标文件的元数据,并向所述客户端发送所述元数据包括:And generating the metadata of the target file, and sending the metadata to the client includes:
生成所述多个数据块的元数据,并向所述客户端发送所述多个数据块的元数据,每个数据块的元数据包含每个数据块的信息和所述每个数据块所在的DN的信息;Generating metadata of the plurality of data blocks, and transmitting metadata of the plurality of data blocks to the client, where metadata of each data block includes information of each data block and where each of the data blocks is located Information of the DN;
所述接收所述多个DN中的至少一个DN发送的元数据恢复信息,并根据所述元数据恢复信息恢复所述元数据,包括: Receiving the metadata recovery information sent by the at least one of the plurality of DNs, and recovering the metadata according to the metadata recovery information, including:
接收所述多个DN中的至少一个DN发送的所述多个数据块的元数据恢复信息,并根据所述多个数据块的元数据恢复信息恢复所述目标文件的元数据。Receiving metadata recovery information of the plurality of data blocks transmitted by at least one of the plurality of DNs, and recovering metadata of the target file according to metadata recovery information of the plurality of data blocks.
结合第三方面的第一种可能的实现方式,在第三方面的第二种可能的实现方式中,所述向所述客户端发送所述多个数据块的元数据包括:In conjunction with the first possible implementation of the third aspect, in a second possible implementation manner of the third aspect, the sending, by the client, the metadata of the multiple data blocks includes:
依次向所述客户端发送所述多个数据块的元数据;或者,根据所述目标文件的写操作请求一次性向所述客户端发送所有数据块的元数据。Transmitting metadata of the plurality of data blocks to the client in turn; or sending metadata of all data blocks to the client at a time according to a write operation request of the target file.
结合第三方面的第一种可能的实现方式或者第二种可能的实现方式,在第三方面的第三种可能的实现方式中,所述多个数据块至少包括第一数据块和第二数据块,其中:With reference to the first possible implementation manner of the third aspect, or the second possible implementation manner, in a third possible implementation manner of the third aspect, the multiple data blocks include at least a first data block and a second Data block, where:
所述第一数据块的元数据恢复信息包括:The metadata recovery information of the first data block includes:
所述目标文件的属性信息和所述第一数据块在所述目标文件中的位置信息;Attribute information of the target file and location information of the first data block in the target file;
所述第二数据块的元数据恢复信息包括:The metadata recovery information of the second data block includes:
所述第二数据块在所述目标文件中的位置信息。Location information of the second data block in the target file.
第四方面,本发明提供一种客户端,包括:接收单元、获取单元、生成单元和发送单元,其中:In a fourth aspect, the present invention provides a client, including: a receiving unit, an obtaining unit, a generating unit, and a sending unit, where:
所述接收单元,用于接收对目标文件的写操作请求,其中,所述目标文件保存在多个DN上;The receiving unit is configured to receive a write operation request for the target file, where the target file is saved on multiple DNs;
所述获取单元,用于从NN获取所述目标文件的元数据,所述目标文件的元数据包含所述多个DN的信息;The acquiring unit is configured to acquire metadata of the target file from an NN, where metadata of the target file includes information of the multiple DNs;
所述生成单元,用于根据所述目标文件的元数据生成元数据恢复信息;The generating unit is configured to generate metadata recovery information according to metadata of the target file;
所述发送单元,用于向所述多个DN中的至少一个DN发送所述元数据恢复信息,所述元数据恢复信息用于被所述至少一个DN进行保存,并在所 述NN出现异常后被发送到所述NN进行所述元数据的恢复。The sending unit is configured to send the metadata recovery information to at least one of the plurality of DNs, where the metadata recovery information is used to be saved by the at least one DN, and The NN is sent to the NN for recovery of the metadata after an abnormality occurs.
在第四方面的第一种可能的实现方式中,所述目标文件被划分为多个数据块,所述多个数据块被保存在所述多个DN上;In a first possible implementation manner of the fourth aspect, the target file is divided into multiple data blocks, where the multiple data blocks are saved on the multiple DNs;
则,所述获取单元用于从所述NN获取所述多个数据块的元数据,每个数据块的元数据包含每个数据块的信息和所述每个数据块所在的DN的信息;Then, the obtaining unit is configured to acquire metadata of the plurality of data blocks from the NN, and the metadata of each data block includes information of each data block and information of a DN where each of the data blocks is located;
所述生成单元用于根据所述每个数据块的元数据,生成所述每个数据块的元数据恢复信息。The generating unit is configured to generate metadata recovery information of each of the data blocks according to the metadata of each of the data blocks.
结合第四方面的第一种可能的实现方式,在第四方面的第二种可能的实现方式中,所述获取单元用于依次接收所述NN发送的所述每个数据块的元数据;或者,所述获取单元用于接收所述NN根据所述目标文件的写操作请求一次性发送的所有数据块的元数据。With reference to the first possible implementation manner of the fourth aspect, in a second possible implementation manner of the fourth aspect, the acquiring unit is configured to sequentially receive metadata of each data block that is sent by the NN; Alternatively, the obtaining unit is configured to receive metadata of all data blocks that are sent by the NN according to a write operation of the target file.
结合第四方面的第一种可能的实现方式或者第二种可能的实现方式,在第四方面的第三种可能的实现方式中,所述接收的元数据至少包括第一数据块的元数据和第二数据块的元数据,其中:With reference to the first possible implementation manner of the fourth aspect, or the second possible implementation manner, in a third possible implementation manner of the fourth aspect, the received metadata includes at least metadata of the first data block And the metadata of the second data block, where:
所述生成的所述第一数据块的元数据恢复信息包括:The generated metadata recovery information of the first data block includes:
所述目标文件的属性信息和所述第一数据块在所述目标文件中的位置信息;Attribute information of the target file and location information of the first data block in the target file;
所述生成的所述第二数据块的元数据恢复信息包括:The generated metadata recovery information of the second data block includes:
所述第二数据块在所述目标文件中的位置信息。Location information of the second data block in the target file.
第五方面,本发明提供一种DN,包括:接收单元和发送单元,其中:In a fifth aspect, the present invention provides a DN, including: a receiving unit and a sending unit, where:
所述接收单元,用于接收客户端发送的目标文件的元数据恢复信息,并保存所述元数据恢复信息,其中,所述元数据恢复信息是所述客户端在接收对目标文件的写操作请求时,从NN获取的所述目标文件的元数据,并根据 所述元数据生成的元数据恢复信息.;The receiving unit is configured to receive metadata recovery information of the target file sent by the client, and save the metadata recovery information, where the metadata recovery information is that the client receives a write operation on the target file. When requested, the metadata of the target file obtained from the NN is based on Metadata recovery information generated by the metadata.
所述发送单元,用于在所述NN出现异常后,向所述NN发送所述元数据恢复信息,元数据恢复信息被所述NN用于进行所述元数据的恢复。The sending unit is configured to send the metadata recovery information to the NN after an abnormality occurs in the NN, where the metadata recovery information is used by the NN to perform recovery of the metadata.
在第五方面的第一种可能的实现方式中,所述目标文件被划分为多个数据块,所述接收单元用于接收所述客户端发送的所述目标文件的数据块的元数据恢复信息,所述数据块的元数据恢复信息为所述客户端根据该数据块的元数据生成的元数据恢复信息。In a first possible implementation manner of the fifth aspect, the target file is divided into multiple data blocks, and the receiving unit is configured to receive metadata recovery of the data block of the target file that is sent by the client Information, the metadata recovery information of the data block is metadata recovery information generated by the client according to metadata of the data block.
结合第五方面的第一种可能的实现方式,在第五方面的第二种可能的实现方式中,所述接收单元用于依次接收所述客户端点发送的所述目标文件的多个数据块的元数据恢复信息;或者,所述接收单元用于接收所述客户端一次性发送的所述目标文件的多个数据块的元数据恢复信息。With reference to the first possible implementation manner of the fifth aspect, in a second possible implementation manner of the fifth aspect, the receiving unit is configured to receive, in sequence, multiple data blocks of the target file that are sent by the client endpoint The metadata recovery information is used; or the receiving unit is configured to receive metadata recovery information of the plurality of data blocks of the target file that are sent by the client at one time.
结合第五方面的第一种可能的实现方式或者第二种可能的实现方式,在第三种可能的实现方式中,所述接收的元数据恢复信息至少包括第一数据块的元数据恢复信息和第二数据块的元数据恢复信息,其中:With reference to the first possible implementation manner of the fifth aspect, or the second possible implementation manner, in a third possible implementation manner, the received metadata recovery information includes at least metadata recovery information of the first data block. And metadata recovery information for the second data block, wherein:
所述第一数据块的元数据恢复信息包括:The metadata recovery information of the first data block includes:
所述目标文件的属性信息和所述第一数据块在所述目标文件中的位置信息;Attribute information of the target file and location information of the first data block in the target file;
所述第二数据块的元数据恢复信息包括:The metadata recovery information of the second data block includes:
所述第二数据块在所述目标文件中的位置信息。Location information of the second data block in the target file.
第六方面,本发明提供一种NN,包括:接收单元、生成单元和恢复单元,其中:In a sixth aspect, the present invention provides an NN, including: a receiving unit, a generating unit, and a restoring unit, where:
所述接收单元,用于接收客户端发送的对目标文件进行写操作请求,其中,所述目标文件保存在多个DN上;The receiving unit is configured to receive a write operation request for the target file sent by the client, where the target file is saved on multiple DNs;
所述生成单元,用于生成所述目标文件的元数据,并向所述客户端发送 所述元数据,其中,所述元数据包含所述多个DN的信息;The generating unit is configured to generate metadata of the target file, and send the data to the client The metadata, wherein the metadata includes information of the plurality of DNs;
所述恢复单元,用于当本端出现异常时,接收所述多个DN中的至少一个DN发送的元数据恢复信息,并根据所述元数据恢复信息恢复所述元数据,其中,所述元数据恢复信息是所述客户端根据所述元数据生成的,由所述客户端发送至所述至少一个DN进行保存的元数据恢复信息。The recovery unit is configured to receive metadata recovery information sent by at least one of the plurality of DNs when an abnormality occurs on the local end, and recover the metadata according to the metadata recovery information, where The metadata recovery information is metadata recovery information generated by the client according to the metadata, and sent by the client to the at least one DN for saving.
在第六方面的第一种可能的实现方式中,所述目标文件被划分为多个数据块,所述多个数据块被保存在所述多个DN上;In a first possible implementation manner of the sixth aspect, the target file is divided into multiple data blocks, where the multiple data blocks are saved on the multiple DNs;
所述生成单元用于生成所述多个数据块的元数据,并向所述客户端发送所述多个数据块的元数据,每个数据块的元数据包含每个数据块的信息和所述每个数据块所在的DN的信息;The generating unit is configured to generate metadata of the plurality of data blocks, and send metadata of the plurality of data blocks to the client, where metadata of each data block includes information and information of each data block Information about the DN where each data block is located;
所述恢复单元用于当本端出现异常时,接收所述多个DN中的至少一个DN发送的所述多个数据块的元数据恢复信息,并根据所述多个数据块的元数据恢复信息恢复所述目标文件的元数据。The recovery unit is configured to receive metadata recovery information of the plurality of data blocks sent by at least one of the plurality of DNs when an abnormality occurs on the local end, and recover the metadata according to the plurality of data blocks. The information recovers the metadata of the target file.
结合第六方面的第一种可能的实现方式,在第二种可能的实现方式中,所述生成单元用于生成所述多个数据块的元数据,并依次向所述客户端发送所述多个数据块的元数据;或者,所述生成单元用于生成所述多个数据块的元数据,并根据所述目标文件的写操作请求一次性向所述客户端发送所有数据块的元数据。With reference to the first possible implementation manner of the sixth aspect, in a second possible implementation, the generating unit is configured to generate metadata of the multiple data blocks, and send the Metadata of a plurality of data blocks; or the generating unit is configured to generate metadata of the plurality of data blocks, and send metadata of all data blocks to the client at a time according to a write operation request of the target file .
结合第六方面的第一种可能的实现方式或者第二种可能的实现方式,在第三种可能的实现方式中,所述多个数据块至少包括第一数据块和第二数据块,其中:With reference to the first possible implementation or the second possible implementation of the sixth aspect, in a third possible implementation, the multiple data blocks include at least a first data block and a second data block, where :
所述第一数据块的元数据恢复信息包括:The metadata recovery information of the first data block includes:
所述目标文件的属性信息和所述第一数据块在所述目标文件中的位置信息; Attribute information of the target file and location information of the first data block in the target file;
所述第二数据块的元数据恢复信息包括:The metadata recovery information of the second data block includes:
所述第二数据块在所述目标文件中的位置信息。Location information of the second data block in the target file.
上述技术方案中,接收对目标文件的写操作请求,再从NN获取所述目标文件的元数据,根据所述目标文件的元数据生成元数据恢复信息,再向所述多个DN中的至少一个DN发送所述元数据恢复信息。这样该元数据恢复信息就可以用于被所述至少一个DN进行保存,并在所述NN出现异常后被发送到所述NN进行所述元数据的恢复。从而可以恢复NN出异常时的元数据。In the above technical solution, receiving a write operation request for the target file, acquiring metadata of the target file from the NN, generating metadata recovery information according to the metadata of the target file, and then performing at least one of the plurality of DNs A DN sends the metadata recovery information. Thus the metadata recovery information can be used for saving by the at least one DN and sent to the NN for recovery of the metadata after an exception occurs in the NN. Thereby, the metadata when the NN is abnormal can be restored.
附图说明DRAWINGS
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the embodiments or the description of the prior art will be briefly described below. Obviously, the drawings in the following description are only It is a certain embodiment of the present invention, and other drawings can be obtained from those skilled in the art without any creative work.
图1是本发明实施例提供的一种可选的元数据的示意图;1 is a schematic diagram of an optional metadata provided by an embodiment of the present invention;
图2是本发明实施例提供的一种元数据恢复方法的流程示意图;2 is a schematic flowchart of a metadata recovery method according to an embodiment of the present invention;
图3是本发明实施例提供的另一种元数据恢复方法的流程示意图;3 is a schematic flowchart of another metadata recovery method according to an embodiment of the present invention;
图4是本发明实施例提供的一种可选的数据信息的示意图;4 is a schematic diagram of an optional data information provided by an embodiment of the present invention;
图5是本发明实施例提供的另一种元数据恢复方法的流程示意图;FIG. 5 is a schematic flowchart diagram of another metadata recovery method according to an embodiment of the present invention;
图6是本发明实施例提供的另一种元数据恢复方法的流程示意图;FIG. 6 is a schematic flowchart diagram of another metadata recovery method according to an embodiment of the present invention;
图7是本发明实施例提供的另一种元数据恢复方法的流程示意图;FIG. 7 is a schematic flowchart diagram of another metadata recovery method according to an embodiment of the present invention;
图8是本发明实施例提供的一种客户端的结构示意图;FIG. 8 is a schematic structural diagram of a client according to an embodiment of the present disclosure;
图9是本发明实施例提供的一种DN的结构示意图;9 is a schematic structural diagram of a DN according to an embodiment of the present invention;
图10是本发明实施例提供的一种NN的结构示意图;FIG. 10 is a schematic structural diagram of a NN according to an embodiment of the present disclosure;
图11是本发明实施例提供的另一种元数据恢复设备的结构示意图;FIG. 11 is a schematic structural diagram of another metadata recovery device according to an embodiment of the present invention;
图12是本发明实施例提供的一种DN设备的结构示意图;FIG. 12 is a schematic structural diagram of a DN device according to an embodiment of the present disclosure;
图13是本发明实施例提供的一种NN设备的结构示意图。 FIG. 13 is a schematic structural diagram of an NN device according to an embodiment of the present invention.
具体实施方式detailed description
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the embodiments of the present invention are clearly and completely described in the following with reference to the accompanying drawings in the embodiments of the present invention. It is obvious that the described embodiments are only a part of the embodiments of the present invention, but not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative efforts are within the scope of the present invention.
本发明实施例中,元数据可以是用于表示文件数据结构的数据,其中,文件的元数据具体可以表示该文件所在的HDFS系统的版本信息和该文件的属性信息,例如:文件的元数据包括的HDFS系统的版本信息可以包括如下一项或者多项:In the embodiment of the present invention, the metadata may be data for indicating a file data structure, where the metadata of the file may specifically represent version information of the HDFS system where the file is located and attribute information of the file, for example, metadata of the file. The version information of the included HDFS system may include one or more of the following:
HDFS系统的版本信息(例如:imgVersion)、名称空间标识(例如:namespaceID)、HDFS系统的文件个数(例如:numFiles)和HDFS系统的时间戳(例如:genStamp);The version information of the HDFS system (for example, imgVersion), the namespace identifier (for example, namespaceID), the number of files of the HDFS system (for example, numFiles), and the time stamp of the HDFS system (for example, genStamp);
文件的元数据包括的该文件的属性信息可以包括如下一项或者多项:The attribute information of the file included in the metadata of the file may include one or more of the following:
文件的路径(例如:Path)、文件的副本数(例如:replicas)、文件的访问时间(例如:atime)、文件的每个数据块大小(例如:blockSize)、文件的数据块的块数(例如:numBlock)、文件占据的空间的限制信息(例如:nsQuota和dsQuota)和用户权限信息(例如:username、group和perm)。The path of the file (for example: Path), the number of copies of the file (for example: replicas), the access time of the file (for example: atime), the size of each data block of the file (for example: blockSize), and the number of blocks of the data block of the file ( For example: numBlock), limit information for the space occupied by the file (for example: nsQuota and dsQuota) and user permission information (for example: username, group, and perm).
另外,当文件包括多个数据块时,文件的元数据还可以包括各数据块的元数据,其中,数据块的元数据包括该数据块所属的文件的属性信息和该数据块的属性信息;其中,数据块的属性信息可以包括如下一项或者多项:In addition, when the file includes a plurality of data blocks, the metadata of the file may further include metadata of each data block, where the metadata of the data block includes attribute information of the file to which the data block belongs and attribute information of the data block; The attribute information of the data block may include one or more of the following:
数据块标识(例如:BlockId)、数据块存储的数据量(例如:numBytes)和数据块的时间戳(例如:genStamp)。另外,文件的属性信息上面已经介绍,此处不重复说明。The data block identifier (for example: BlockId), the amount of data stored in the data block (for example: numBytes), and the time stamp of the data block (for example: genStamp). In addition, the attribute information of the file has been described above, and the description is not repeated here.
例如:文件的元数据可以如图1所示,文件的元数据可以包括图1中的 三行数据,其中,第一行表示HDFS系统的版本信息,第二行表示文件的属性信息,第三行表示数据块的元数据。即文件的元数据可以包括HDFS系统的版本信息、文件的属性信息和数据块的元数据。For example, the metadata of the file can be as shown in FIG. 1, and the metadata of the file can include the one in FIG. Three lines of data, where the first line represents the version information of the HDFS system, the second line represents the attribute information of the file, and the third line represents the metadata of the data block. That is, the metadata of the file may include version information of the HDFS system, attribute information of the file, and metadata of the data block.
另外,本发明实施例应用的场景可以是单个设备,即该设备上包括HDFS的客户端、至少一个NN和至少一个DN;或者本发明实施例应用的场景可以是设备集群,即HDFS的客户端、至少一个NN和至少一个DN部署在多个设备上。其中,上述设备可以是网络侧设备,例如:基站、服务器、控制器等设备,上述设备还可以是用户侧设备,例如:计算机、平板电脑、手机、电子阅读器、遥控器、笔记本电脑、车载设备、网络电视、可穿戴设备等具有网络功能的智能设备。In addition, the scenario to which the embodiment of the present invention is applied may be a single device, that is, the client including the HDFS, the at least one NN, and the at least one DN; or the scenario applied by the embodiment of the present invention may be a device cluster, that is, a client of the HDFS. At least one NN and at least one DN are deployed on multiple devices. The device may be a network side device, for example, a base station, a server, a controller, etc., and the device may also be a user side device, such as a computer, a tablet computer, a mobile phone, an e-reader, a remote controller, a notebook computer, and a car. A smart device with network capabilities such as devices, network TVs, and wearable devices.
请参阅图2,图2是本发明实施例提供的一种元数据恢复方法的流程示意图,如图2所示,包括以下步骤:Referring to FIG. 2, FIG. 2 is a schematic flowchart of a metadata recovery method according to an embodiment of the present invention. As shown in FIG. 2, the method includes the following steps:
201、接收对目标文件的写操作请求,其中,所述目标文件保存在多个DN上。201. Receive a write operation request for the target file, where the target file is saved on multiple DNs.
上述目标文件保存在多个DN上可以是响应上述写操作请求,将上述目标文件保存在多个DN上,其中,该保存过程的时间不作限定,例如:可以是在步骤204之后,或者在步骤204之前。The foregoing target file is saved on multiple DNs, and may be in response to the foregoing write operation request, and the target file is saved on multiple DNs, wherein the time of the save process is not limited, for example, after step 204, or in step Before 204.
202、从NN获取所述目标文件的元数据,所述目标文件的元数据包含所述多个DN的信息。202. Obtain metadata of the target file from an NN, where metadata of the target file includes information of the multiple DNs.
可选的,当接收到上述写操作请求时,本端就可以向NN申请用于保存目标文件的多个DN,从而NN就可以为该目标文件分配NN,以及生成该目标文件的元数据,并将该目标文件的元数据返回到上述本端。另外,上述多个DN的信息可以是各DN保存上述目标文件的路径信息,例如:上述介绍的文件的属性信息中的文件的路径。Optionally, when receiving the foregoing write operation request, the local end may apply to the NN for multiple DNs for saving the target file, so that the NN may allocate the NN for the target file, and generate metadata of the target file. And return the metadata of the target file to the above end. Further, the information of the plurality of DNs may be path information in which the DN stores the target file, for example, the path of the file in the attribute information of the file introduced above.
203、根据所述目标文件的元数据生成元数据恢复信息。 203. Generate metadata recovery information according to metadata of the target file.
可选的,上述元数据恢复信息可以包括该目标文件的元数据,例如:包括目标文件的属性信息。其中,该属性信息可以包括该目标文件的如下一项或者多项:Optionally, the metadata recovery information may include metadata of the target file, for example, including attribute information of the target file. The attribute information may include one or more of the following:
HDFS系统的版本信息、文件名、文件占据的空间的限制信息、用户权限信息、文件的每个数据块大小、文件的数据块的块数。Version information of the HDFS system, file name, space limit information occupied by the file, user authority information, each data block size of the file, and the number of blocks of the data block of the file.
其中,上述文件名还可以携带有文件的路径信息。The file name may also carry path information of the file.
204、向所述多个DN中的至少一个DN发送所述元数据恢复信息,所述元数据恢复信息用于被所述至少一个DN进行保存,并在所述NN出现异常后被发送到所述NN进行所述元数据的恢复。204. Send the metadata recovery information to at least one of the plurality of DNs, where the metadata recovery information is used to be saved by the at least one DN, and is sent to the The NN performs the recovery of the metadata.
可选的,上述方法可以应用于HDFS的客户端(Client),即该客户端可以实现上述方法。Optionally, the foregoing method can be applied to a client of the HDFS, that is, the client can implement the foregoing method.
上述技术方案中,接收对目标文件的写操作请求,再从NN获取所述目标文件的元数据,根据所述目标文件的元数据生成元数据恢复信息,再向所述多个DN中的至少一个DN发送所述元数据恢复信息。这样该元数据恢复信息就可以用于被所述至少一个DN进行保存,并在所述NN出现异常后被发送到所述NN进行所述元数据的恢复。从而可以恢复NN出异常时的元数据。In the above technical solution, receiving a write operation request for the target file, acquiring metadata of the target file from the NN, generating metadata recovery information according to the metadata of the target file, and then performing at least one of the plurality of DNs A DN sends the metadata recovery information. Thus the metadata recovery information can be used for saving by the at least one DN and sent to the NN for recovery of the metadata after an exception occurs in the NN. Thereby, the metadata when the NN is abnormal can be restored.
请参阅图3,图3是本发明实施例提供的另一种元数据恢复方法的流程示意图,如图3所示,包括以下步骤:Referring to FIG. 3, FIG. 3 is a schematic flowchart of another metadata recovery method according to an embodiment of the present invention. As shown in FIG. 3, the method includes the following steps:
301、接收对目标文件的写操作请求,其中,所述目标文件被划分为多个数据块,所述多个数据块被保存在所述多个DN上。301. Receive a write operation request for a target file, where the target file is divided into a plurality of data blocks, and the plurality of data blocks are saved on the plurality of DNs.
可选的,对目标文件进行数据写操作可以是以数据块为单位进行写操作,即一个目标文件可以被划分为多个数据块中,其中,每个数据块的大小 可以是相同。例如:每个数据块可以是64兆(MB)或者128MB等。另外,上述数据块的大小可以是数据块的存储空间大小,但在实际应用中一个文件的各数据块存储的该文件的数据量可以是不同的,例如:一个文件包含150MB数据,而每个数据块的大小为64MB,那么该文件的第一个数据块就可以存储该文件的64MB数据,而第二个数据块就可以存储该文件的64MB数据,而第三个数据块就可以存储该文件的22MB数据。Optionally, the data write operation on the target file may be performed in units of data blocks, that is, an object file may be divided into multiple data blocks, wherein the size of each data block is Can be the same. For example: each data block can be 64 megabytes (MB) or 128 MB. In addition, the size of the foregoing data block may be the storage space size of the data block, but in actual applications, the data amount of the file stored in each data block of one file may be different, for example, one file contains 150 MB of data, and each The size of the data block is 64MB, then the first data block of the file can store 64MB of data of the file, and the second data block can store 64MB of data of the file, and the third data block can store the data. 22MB of data for the file.
302、从所述NN获取所述多个数据块的元数据,每个数据块的元数据包含每个数据块的信息和所述每个数据块所在的DN的信息。302. Obtain metadata of the plurality of data blocks from the NN, and metadata of each data block includes information of each data block and information of a DN where each of the data blocks is located.
可选的,当接收到上述写操作请求时,本端就可以向NN申请用于保存目标文件的多个数据块,以及保存数据块的多个DN。这样从而NN就可以为该目标文件分配数据块,以及数据块所在的DN,以及生成每个数据块的元数据,并将每个数据块的元数据返回到上述本端。另外,上述数据块的信息可以是数据块的属性信息,例如:数据块标识和数据块的时间戳。上述多个DN的信息可以是各DN保存数据块的路径信息,例如:上述介绍的文件的属性信息中的文件的路径。Optionally, when receiving the foregoing write operation request, the local end may apply to the NN for multiple data blocks for saving the target file, and save multiple DNs of the data block. Thus, the NN can allocate a data block for the object file, and the DN of the data block, and generate metadata for each data block, and return the metadata of each data block to the above end. In addition, the information of the foregoing data block may be attribute information of the data block, for example, a data block identifier and a time stamp of the data block. The information of the plurality of DNs may be path information of each DN save data block, for example, the path of the file in the attribute information of the file described above.
303、根据所述每个数据块的元数据,生成所述每个数据块的元数据恢复信息。303. Generate metadata recovery information of each data block according to the metadata of each data block.
可选的,上述数据块的元数据恢复信息可以包括该数据块的元数据,例如:包括目标文件的属性信息。Optionally, the metadata recovery information of the data block may include metadata of the data block, for example, including attribute information of the target file.
304、向所述多个DN中的至少一个DN发送所述元数据恢复信息,所述元数据恢复信息用于被所述至少一个DN进行保存,并在所述NN出现异常后被发送到所述NN进行所述目标文件的元数据的恢复。304. Send the metadata recovery information to at least one of the plurality of DNs, where the metadata recovery information is used to be saved by the at least one DN, and is sent to the NN after an abnormality occurs in the NN. The NN performs recovery of the metadata of the target file.
由于上述元数据恢复信息被一个或者多个DN保存,这样可以防止单个DN出现异常后,导致该元数据恢复信息丢失。Since the above metadata recovery information is saved by one or more DNs, it is possible to prevent the metadata recovery information from being lost after an abnormality occurs in a single DN.
可选的,上述从所述NN获取所述多个数据块的元数据可以包括: Optionally, the obtaining the metadata of the multiple data blocks from the NN may include:
依次接收所述NN发送的所述每个数据块的元数据。The metadata of each of the data blocks sent by the NN is sequentially received.
例如:本端可以是每次向NN申请一个数据块,这样NN就会为目标文件分配一个数据块,以及生成该数据块的元数据,并将该数据块的元数据返回到上述本端。当上述数据块被写完时,而目标文件还没有被写完,本端再向NN申请另一个数据块,NN就会为目标文件分配另一个数据块,以及生成该数据块的元数据,并将该数据块的元数据返回到上述本端。当上述数据块被写完时,而目标文件还没有被写完,继续向NN申请数据块,直到目标文件被写完。从而步骤303可以是本端每获取一个数据块的元数据,再生成该数据块的元数据恢复信息,步骤304再将该数据块的元数据恢复信息发送至上述至少一个DN。For example, the local end may apply for a data block to the NN each time, so that the NN allocates a data block to the target file, and generates metadata of the data block, and returns the metadata of the data block to the local end. When the data block is written, and the target file has not been written, the local end requests another data block from the NN, and the NN allocates another data block for the target file, and generates metadata of the data block. And return the metadata of the data block to the above end. When the above data block is written, and the target file has not been written, continue to apply for the data block to the NN until the target file is written. Therefore, step 303 may be that the local end acquires the metadata recovery information of the data block for each time, and then generates the metadata recovery information of the data block to the at least one DN.
可选的,上述从所述NN获取所述多个数据块的元数据可以包括:Optionally, the obtaining the metadata of the multiple data blocks from the NN may include:
接收所述NN根据所述目标文件的写操作请求一次性发送的所有数据块的元数据。Receiving, by the NN, metadata of all data blocks that are sent at one time according to a write operation of the target file.
例如:本端可以是一次性向NN申请多个数据块,这样NN就会为目标文件分配多个数据块,以及生成这些数据块的元数据,并将这些数据块的元数据返回到上述本端。从而步骤303可以是一次性生成多个数据块的元数据恢复信息,步骤304再将这多个数据块的元数据恢复信息发送至上述至少一个DN。For example, the local end may apply for multiple data blocks to the NN at one time, so that the NN allocates multiple data blocks for the target file, and generates metadata of the data blocks, and returns the metadata of the data blocks to the local end. . Thus, step 303 may be to generate metadata recovery information of a plurality of data blocks at a time, and step 304 further transmits metadata recovery information of the plurality of data blocks to the at least one DN.
可选的,上述接收的元数据至少包括第一数据块的元数据和第二数据块的元数据,即目标文件至少被划分为第一数据块和第二数据块。Optionally, the received metadata includes at least metadata of the first data block and metadata of the second data block, that is, the target file is at least divided into the first data block and the second data block.
其中,上述生成的所述第一数据块的元数据恢复信息可以包括:The metadata recovery information of the generated first data block may include:
所述目标文件的属性信息和所述第一数据块在所述目标文件中的位置信息。Attribute information of the object file and location information of the first data block in the object file.
其中,目标文件的属性信息可以包括: The attribute information of the target file may include:
HDFS系统的版本信息、文件名、文件的副本数、文件的每个数据块大小、文件占据的空间的限制信息和用户权限信息。The version information of the HDFS system, the file name, the number of copies of the file, the size of each block of the file, the limit information of the space occupied by the file, and the user authority information.
上述第一数据块在所述目标文件中的位置信息可以是指,第一数据块的目标文件的数据块序号,例如:第一数据块可以是目标文件的序号为1的数据块,其中,序号为1的数据块可以是目标文件中时间戳最早的一个数据块;上述第一数据块在所述目标文件中的位置信息可以包括:The location information of the first data block in the target file may be a data block number of the target file of the first data block. For example, the first data block may be a data block with a sequence number of 1 of the target file, where The data block with the sequence number 1 may be one of the earliest data blocks in the target file; the location information of the first data block in the target file may include:
数据块序号和文件结束数据块信息。Data block number and file end block information.
上述生成的所述第二数据块的元数据恢复信息可以包括:The metadata recovery information of the generated second data block may include:
所述第二数据块在所述目标文件中的位置信息。Location information of the second data block in the target file.
上述第二数据块在所述目标文件中的位置信息可以包括:The location information of the second data block in the target file may include:
数据块序号和文件结束数据块信息。Data block number and file end block information.
另外,第二数据块的元数据恢复信息还可以包括HDFS系统的版本信息和文件名,这样就可以清楚地知道第二数据块的元数据恢复信息是用于恢复哪个文件的数据块,以及该文件的HDFS系统的版本信息。In addition, the metadata recovery information of the second data block may further include version information and a file name of the HDFS system, so that it can be clearly known that the metadata recovery information of the second data block is a data block for recovering which file, and the The version information of the file's HDFS system.
例如:如图4a所示,第一数据块的元数据恢复信息可以包括:For example, as shown in FIG. 4a, the metadata recovery information of the first data block may include:
HDFS系统的版本信息、文件名、文件的副本数、文件的每个数据块大小、文件占据的空间的限制信息、用户权限信息、数据块序号和文件结束数据块信息。The version information of the HDFS system, the file name, the number of copies of the file, the size of each data block of the file, the restriction information of the space occupied by the file, the user authority information, the data block number, and the file end block information.
如图4b所示,第一数据块的元数据恢复信息可以包括:As shown in FIG. 4b, the metadata recovery information of the first data block may include:
HDFS系统的版本信息、文件名、数据块序号和文件结束数据块信息。Version information, file name, data block number, and file end block information of the HDFS system.
其中,文件结束数据块信息可以是用当前数据块是否为结束Block的信息表示,例如:上述第一数据块的元数据恢复信息中的文件结束数据块信息可以用假(false)表示;当上述目标文件只包括两个数据块时,那么,上述第一数据块的元数据恢复信息中的文件结束数据块信息可以用真(true)表 示;当上述目标文件包括三个或者三个以上的数据块时,上述第一数据块的元数据恢复信息和上述第二数据块的元数据恢复信息中的文件结束数据块信息可以用假(false)表示;即该实施方式中,只有目标文件的最后一个数据块对应的文件结束数据块信息才用真(true)表示,其余的都用假(false)表示,从而可以根据文件结束数据块信息可以确定目标文件包括的数据块的个数。The file end data block information may be represented by whether the current data block is an end block. For example, the file end data block information in the metadata recovery information of the first data block may be represented by a false (false); When the target file includes only two data blocks, then the file end data block information in the metadata recovery information of the first data block may be a true (true) table. When the target file includes three or more data blocks, the metadata recovery information of the first data block and the file end data block information in the metadata recovery information of the second data block may be false ( False) indicates that in this embodiment, only the file end block information corresponding to the last data block of the target file is represented by true (true), and the rest are represented by false (false), so that the data block can be ended according to the file. The information can determine the number of data blocks included in the target file.
另外,由于一个文件内各数据块的元数据都可以包括文件的属性信息,而文件的属性信息是相同的,例如:文件占据的空间的限制信息、用户权限信息、数据块的大小信息和副本数等信息是相同的,这样就只需要在其中一个数据块的元数据恢复信息中写入这些信息即可,从而可以节省其他DN的存储空间。In addition, since the metadata of each data block in a file may include the attribute information of the file, and the attribute information of the file is the same, for example, the restriction information of the space occupied by the file, the user authority information, the size information and the copy of the data block. The number of information is the same, so that only the information needs to be written in the metadata recovery information of one of the data blocks, thereby saving the storage space of other DNs.
另外,上述仅举例了所述第一数据块和第二数据块的元数据恢复信息的多种可选的实施方式,本实施例中对此不作限定,例如:第一数据块的元数据恢复信息也可以包括:In addition, the foregoing describes only a plurality of optional implementation manners of the metadata recovery information of the first data block and the second data block, which is not limited in this embodiment, for example, metadata recovery of the first data block. Information can also include:
HDFS系统的版本信息、文件名、文件的副本数、文件的访问时间、文件的数据块的块数、文件占据的空间的限制信息、用户权限信息、数据块标识、数据块的大小和数据块时间戳。Version information of the HDFS system, file name, number of copies of the file, access time of the file, number of blocks of the data block of the file, limit information of the space occupied by the file, user permission information, data block identifier, size of the data block, and data block Timestamp.
可选的,本方法中每获取NN发送的数据块的元数据之前,都可以是向NN发送数据块的申请请求,NN接收到该请求后,就可以为目标文件分配数据块,以及存储该数据块的DN。另外,在步骤301之前,所述方法还可以包括以下步骤:Optionally, before obtaining the metadata of the data block sent by the NN, the method may be an application request for sending a data block to the NN, and after receiving the request, the NN may allocate a data block for the target file, and store the data. The DN of the data block. In addition, before step 301, the method may further include the following steps:
创建目标文件,并生成该目标文件的概要信息。例如:生成该文件的文件名等信息。Create a target file and generate summary information about the target file. For example: generate information such as the file name of the file.
可选的,上述方法可以应用于HDFS的客户端(Client),即该客户端可以实现上述方法。 Optionally, the foregoing method can be applied to a client of the HDFS, that is, the client can implement the foregoing method.
上述技术方案中,接收对目标文件的写操作请求,从NN获取多个数据块的元数据,再根据所述每个数据块的元数据,生成所述每个数据块的元数据恢复信息,从而可以向所述多个DN中的至少一个DN发送所述元数据恢复信息。这样元数据恢复信息可以用于被所述至少一个DN进行保存,并在所述NN出现异常后被发送到所述NN进行所述元数据的恢复。从而当NN出现异常后,可以及时恢复NN在出现异常时生成的元数据。In the above technical solution, receiving a write operation request for the target file, acquiring metadata of the plurality of data blocks from the NN, and generating metadata recovery information of each of the data blocks according to the metadata of each of the data blocks, Thereby the metadata recovery information can be sent to at least one of the plurality of DNs. Such metadata recovery information can be used to be saved by the at least one DN and sent to the NN for recovery of the metadata after an exception occurs in the NN. Therefore, when the NN is abnormal, the metadata generated by the NN when an abnormality occurs can be restored in time.
请参阅图5,图5是本发明实施例提供的另一种元数据恢复方法的流程示意图,如图5所示,包括以下步骤:Referring to FIG. 5, FIG. 5 is a schematic flowchart of another metadata recovery method according to an embodiment of the present invention. As shown in FIG. 5, the method includes the following steps:
501、接收客户端发送的目标文件的元数据恢复信息,并保存所述元数据恢复信息,其中,所述元数据恢复信息是所述客户端在接收对目标文件的写操作请求时,从NN获取的所述目标文件的元数据,并根据所述元数据生成的元数据恢复信息.。501. Receive metadata recovery information of the target file sent by the client, and save the metadata recovery information, where the metadata recovery information is that the client receives the write operation request for the target file from the NN. Obtaining metadata of the target file, and recovering information according to the metadata generated by the metadata.
其中,上述目标文件所述目标文件保存在多个DN上,且上述元数据包括所述多个DN的信息。The target file of the target file is saved on multiple DNs, and the metadata includes information of the plurality of DNs.
可选的,步骤501可以是将元数据恢复信息存储在本地,或者将元数据恢复信息存储第三方面存储设备上。Optionally, step 501 may be to store the metadata recovery information locally, or store the metadata recovery information on the third aspect storage device.
502、在所述NN出现异常后,向所述NN发送所述元数据恢复信息,元数据恢复信息被所述NN用于进行所述元数据的恢复。502. After the NN is abnormal, send the metadata recovery information to the NN, where the metadata recovery information is used by the NN to perform recovery of the metadata.
可选的,本方法可以应用于HDFS的DN。Optionally, the method can be applied to the DN of the HDFS.
上述技术方案中,接收客户端发送的目标文件的元数据恢复信息,并保存所述元数据恢复信息;在所述NN出现异常后,向所述NN发送所述元数据恢复信息,元数据恢复信息被所述NN用于进行所述元数据的恢复。从而可以实现恢复NN出异常时的元数据。 In the above technical solution, the metadata recovery information of the target file sent by the client is received, and the metadata recovery information is saved; after the NN is abnormal, the metadata recovery information is sent to the NN, and the metadata recovery is performed. Information is used by the NN to perform recovery of the metadata. Thereby, it is possible to restore the metadata when the NN is abnormal.
请参阅图6,图6是本发明实施例提供的另一种元数据恢复方法的流程示意图,如图6所示,包括以下步骤:Referring to FIG. 6, FIG. 6 is a schematic flowchart of another metadata recovery method according to an embodiment of the present invention. As shown in FIG. 6, the method includes the following steps:
601、接收所述客户端发送的所述目标文件的数据块的元数据恢复信息,并保存所述元数据恢复信息,其中,所述元数据恢复信息是所述客户端在接收对目标文件的写操作请求时,所述客户端根据该数据块的元数据生成的元数据恢复信息.。601. Receive metadata recovery information of a data block of the target file sent by the client, and save the metadata recovery information, where the metadata recovery information is that the client receives the target file. When the operation request is written, the client recovers the metadata according to the metadata generated by the metadata of the data block.
其中,上述目标文件被划分为多个数据块,且上述每个数据块的元数据包含每个数据块的信息和所述每个数据块所在的DN的信息。The object file is divided into a plurality of data blocks, and the metadata of each of the data blocks includes information of each data block and information of a DN of each of the data blocks.
可选的,步骤601接收到元数据恢复信息可以是一个或者多个数据块的元数据恢复信息。例如:目标文件被划分为多个数据块,其中,执行本方法的DN可以是保存其中一个或者多个数据块的元数据恢复信息。Optionally, the metadata recovery information received in step 601 may be metadata recovery information of one or more data blocks. For example, the target file is divided into a plurality of data blocks, wherein the DN performing the method may be metadata recovery information for storing one or more of the data blocks.
可选的,步骤601可以是将上述元数据恢复信息保存在一个特定文件内,例如:保存在命名为:blk_blockId_genstamp.blockmeta的文件内,其中,该文件的名称可以包括数据块的标识,且该文件名称还可以包括数据块的时间戳,例如:DN在接收到数据块的元数据恢复信息的同时,还可以接收到客户端发送的数据的标识和数据块的时间戳。另外,该文件内还可以将客户端在上述数据块中写入的该目标文件的数据保存至另一个特定的文件内,例如:保存在命名为:blk_blockId的文件内。当客户端还写入了上述数据块的循环冗余校验码(Cyclic Redundancy Check,CRC),本方法还可以将该CRC保存用于保存上述元数据恢复信息的特定文件内,即将上述元数据恢复信息和CRC存储在同一个特定文件内,当然,本方法还可以将CRC存储在一个专门用于存储CRC的特定文件内。另外,上述两个特定文件可以是接收到上述数据信息之前设置好的,例如:接收到客户端发送的写请求时,生成上述两个特定文件。由于步骤601将上述数据信息以文件的形式进行存储,这 样可以实现数据仓库工(例如:Hive)功能,或者Spark功能,其中,Spark是一个基于内存计算的开源的集群计算系统,目的是让数据分析更加快速。Optionally, step 601 is to save the foregoing metadata recovery information in a specific file, for example, in a file named: blk_blockId_genstamp.blockmeta, where the name of the file may include an identifier of the data block, and the The file name may also include a time stamp of the data block. For example, the DN may receive the identifier of the data sent by the client and the time stamp of the data block while receiving the metadata recovery information of the data block. In addition, the file may also save the data of the target file written by the client in the above data block to another specific file, for example, in a file named: blk_blockId. When the client also writes a Cyclic Redundancy Check (CRC) of the above data block, the method may also save the CRC for storing the metadata in the specific file of the metadata recovery information, that is, the metadata. The recovery information and CRC are stored in the same specific file. Of course, the method can also store the CRC in a specific file dedicated to storing the CRC. In addition, the two specific files may be set before receiving the data information, for example, when the write request sent by the client is received, the two specific files are generated. Since step 601 stores the above data information in the form of a file, this It can implement data warehouse workers (for example: Hive) or Spark functions. Spark is an open source cluster computing system based on memory computing, which aims to make data analysis faster.
另外,上述元数据恢复信息还可以是预定义的数据格式进行保存,例如:以HBase的数据格式进行保存,其中,HBase是一个分布式的、面向列的开源数据库。In addition, the metadata recovery information may also be saved in a predefined data format, for example, in a HBase data format, where HBase is a distributed, column-oriented open source database.
可选的,在获取到上述元数据恢复信息时,还可以在内存中保存上述元数据恢复信息,这样可以更快速地发送该元数据恢复信息。可以直接将内存的元数据恢复信息上传到NN。另外,当实现本方法的DN重新启动后,可以扫描本地存储的元数据恢复信息,再将该元数据恢复信息上传给NN。Optionally, when the metadata recovery information is obtained, the metadata recovery information may also be saved in the memory, so that the metadata recovery information may be sent more quickly. The metadata recovery information of the memory can be directly uploaded to the NN. In addition, after the DN of the method is restarted, the locally stored metadata recovery information may be scanned, and the metadata recovery information is uploaded to the NN.
602、在所述NN出现异常后,向所述NN发送所述元数据恢复信息,元数据恢复信息被所述NN用于进行所述目标文件的元数据的恢复。602. After the NN is abnormal, send the metadata recovery information to the NN, where the metadata recovery information is used by the NN to perform metadata recovery of the target file.
例如:DN在NN重新启动时,会接收到该NN发送的通知消息,该通知消息用于请求发送上述数据信息,这样就可以响应消息通知消息,以返回上述元数据恢复信息。For example, when the DN is restarted, the DN receives a notification message sent by the NN, and the notification message is used to request to send the data information, so that the message notification message can be returned to return the metadata recovery information.
可选的,所述接收所述客户端发送的所述目标文件的数据块的元数据恢复信息包括:Optionally, the receiving, by the receiving, the metadata recovery information of the data block of the target file sent by the client includes:
依次接收所述客户端点发送的所述目标文件的多个数据块的元数据恢复信息;或者,接收所述客户端一次性发送的所述目标文件的多个数据块的元数据恢复信息。Receiving metadata recovery information of the plurality of data blocks of the target file sent by the client endpoint in sequence; or receiving metadata recovery information of the plurality of data blocks of the target file sent by the client at one time.
可选的,所述接收的元数据恢复信息至少可以包括第一数据块的元数据恢复信息和第二数据块的元数据恢复信息,其中:Optionally, the received metadata recovery information may include at least metadata recovery information of the first data block and metadata recovery information of the second data block, where:
所述第一数据块的元数据恢复信息可以包括:The metadata recovery information of the first data block may include:
所述目标文件的属性信息和所述第一数据块在所述目标文件中的位置信息; Attribute information of the target file and location information of the first data block in the target file;
所述第二数据块的元数据恢复信息可以包括:The metadata recovery information of the second data block may include:
所述第二数据块在所述目标文件中的位置信息。Location information of the second data block in the target file.
另外,本实施例中,当所述生成的元数据出现异常后,可以是向NN发送目标文件的所有数据块的元数据恢复信息。例如:当DN接收到NN异常重启的通知消息后,响应该通知消息扫描本地或者内存中所有数据块的元数据恢复信息,并向NN上传所有数据块的元数据恢复信息。In addition, in this embodiment, after the generated metadata is abnormal, the metadata recovery information of all the data blocks of the target file may be sent to the NN. For example, when the DN receives the notification message of the NN abnormal restart, the DN scans the metadata recovery information of all the data blocks in the local or the memory in response to the notification message, and uploads the metadata recovery information of all the data blocks to the NN.
可选的,上述方法可以应用于HDFS的DN,即该DN可以实现上述方法。Optionally, the foregoing method may be applied to the DN of the HDFS, that is, the DN may implement the foregoing method.
上述技术方案中,接收所述客户端发送的所述目标文件的数据块的元数据恢复信息,并保存所述元数据恢复信息,在所述NN出现异常后,向所述NN发送所述元数据恢复信息,元数据恢复信息被所述NN用于进行所述元数据的恢复。从而可以及时恢复NN在出现异常时生成的元数据。In the above technical solution, the metadata recovery information of the data block of the target file sent by the client is received, and the metadata recovery information is saved, and after the abnormality occurs in the NN, the element is sent to the NN. Data recovery information, the metadata recovery information is used by the NN to perform recovery of the metadata. Thereby, the metadata generated by the NN when an abnormality occurs can be restored in time.
请参阅图7,图7是本发明实施例提供的另一种元数据恢复方法的流程示意图,如图7所示,包括以下步骤:Referring to FIG. 7, FIG. 7 is a schematic flowchart of another metadata recovery method according to an embodiment of the present invention. As shown in FIG. 7, the method includes the following steps:
701、接收客户端发送的对目标文件进行写操作请求,其中,所述目标文件保存在多个DN上。701. Receive a write operation request to the target file sent by the client, where the target file is saved on multiple DNs.
702、生成所述目标文件的元数据,并向所述客户端发送所述元数据,其中,所述元数据包含所述多个DN的信息。702. Generate metadata of the target file, and send the metadata to the client, where the metadata includes information of the multiple DNs.
可选的,步骤702可以是接收到上述写操作请求后,为上述目标文件分配所述多个DN,再生成上述目标文件的元数据。Optionally, in step 702, after receiving the foregoing write operation request, the multiple DNs are allocated to the target file, and the metadata of the target file is generated.
703、当本端出现异常时,接收所述多个DN中的至少一个DN发送的元数据恢复信息,并根据所述元数据恢复信息恢复所述元数据,其中,所述元数据恢复信息是所述客户端根据所述元数据生成的,由所述客户端发送至 所述至少一个DN进行保存的元数据恢复信息。703. Receive metadata recovery information sent by at least one of the multiple DNs when an abnormality occurs on the local end, and recover the metadata according to the metadata recovery information, where the metadata recovery information is Generated by the client according to the metadata, sent by the client to The at least one DN performs the saved metadata recovery information.
这样当本端,即NN出现异常时,可以接收到上述至少一个DN发送的元数据恢复信息,从而可以恢复出上述目标文件的元数据。In this way, when the local end, that is, the NN is abnormal, the metadata recovery information sent by the at least one DN can be received, so that the metadata of the target file can be recovered.
可选的,上述目标文件可以被划分为多个数据块,所述多个数据块被保存在所述多个DN上;Optionally, the foregoing target file may be divided into multiple data blocks, where the multiple data blocks are saved on the multiple DNs;
则,上述生成所述目标文件的元数据,并向所述客户端发送所述元数据可以包括:Then, generating the metadata of the target file and sending the metadata to the client may include:
生成所述多个数据块的元数据,并向所述客户端发送所述多个数据块的元数据,每个数据块的元数据包含每个数据块的信息和所述每个数据块所在的DN的信息。Generating metadata of the plurality of data blocks, and transmitting metadata of the plurality of data blocks to the client, where metadata of each data block includes information of each data block and where each of the data blocks is located DN information.
上述接收所述多个DN中的至少一个DN发送的元数据恢复信息,并根据所述元数据恢复信息恢复所述元数据,可以包括:The receiving the metadata recovery information sent by the at least one of the plurality of DNs, and recovering the metadata according to the metadata recovery information, may include:
接收所述多个DN中的至少一个DN发送的所述多个数据块的元数据恢复信息,并根据所述多个数据块的元数据恢复信息恢复所述目标文件的元数据。Receiving metadata recovery information of the plurality of data blocks transmitted by at least one of the plurality of DNs, and recovering metadata of the target file according to metadata recovery information of the plurality of data blocks.
这样可以实现根据多个数据块的元数据恢复信息恢复目标文件的元数据。This makes it possible to recover the metadata of the target file based on the metadata recovery information of the plurality of data blocks.
可选的,向所述客户端发送所述多个数据块的元数据包括:Optionally, sending the metadata of the multiple data blocks to the client includes:
依次向所述客户端发送所述多个数据块的元数据;或者,根据所述目标文件的写操作请求一次性向所述客户端发送所有数据块的元数据。Transmitting metadata of the plurality of data blocks to the client in turn; or sending metadata of all data blocks to the client at a time according to a write operation request of the target file.
可选的,上述多个数据块至少可以包括第一数据块和第二数据块,其中:Optionally, the foregoing multiple data blocks may include at least a first data block and a second data block, where:
所述第一数据块的元数据恢复信息可以包括:The metadata recovery information of the first data block may include:
所述目标文件的属性信息和所述第一数据块在所述目标文件中的位置信息; Attribute information of the target file and location information of the first data block in the target file;
所述第二数据块的元数据恢复信息可以包括:The metadata recovery information of the second data block may include:
所述第二数据块在所述目标文件中的位置信息。Location information of the second data block in the target file.
需要说明的是,本实施例中针对元数据和元数据恢复信息的定义可以参考图2或者图3所示的实施例,此处不作重复说明。It should be noted that, for the definition of the metadata and the metadata recovery information in this embodiment, reference may be made to the embodiment shown in FIG. 2 or FIG. 3, which is not repeatedly described herein.
可选的,上述方法可以应用于HDFS内的NN。Optionally, the above method can be applied to the NN in the HDFS.
上述技术方案中,接收客户端发送的对目标文件进行写操作请求,生成所述目标文件的元数据,并向所述客户端发送所述元数据;这样当本端出现异常时,接收所述多个DN中的至少一个DN发送的元数据恢复信息,并根据所述元数据恢复信息恢复所述元数据。从而可以恢复NN出异常时的元数据。In the above technical solution, the receiving client sends a write operation request to the target file, generates metadata of the target file, and sends the metadata to the client; Metadata recovery information transmitted by at least one of the plurality of DNs, and recovering the metadata according to the metadata recovery information. Thereby, the metadata when the NN is abnormal can be restored.
下面为本发明装置实施例,本发明装置实施例用于执行本发明方法实施例一至五实现的方法,为了便于说明,仅示出了与本发明实施例相关的部分,具体技术细节未揭示的,请参照本发明实施例一、实施例二、实施例三、实施例四和实施例五。The following is a device embodiment of the present invention. The device embodiment of the present invention is used to perform the method implemented in Embodiments 1 to 5 of the method of the present invention. For the convenience of description, only parts related to the embodiment of the present invention are shown, and the specific technical details are not disclosed. Please refer to Embodiment 1, Example 2, Embodiment 3, Embodiment 4 and Embodiment 5 of the present invention.
请参阅图8,图8是本发明实施例提供的一种客户端的结构示意图,如图8所示,包括:接收单元81、获取单元82、生成单元83和发送单元84,其中:Referring to FIG. 8, FIG. 8 is a schematic structural diagram of a client according to an embodiment of the present invention. As shown in FIG. 8, the method includes: a receiving unit 81, an obtaining unit 82, a generating unit 83, and a sending unit 84, where:
所述接收单元81,用于接收对目标文件的写操作请求,其中,所述目标文件保存在多个DN上。The receiving unit 81 is configured to receive a write operation request for the target file, where the target file is saved on multiple DNs.
所述获取单元82,用于从NN获取所述目标文件的元数据,所述目标文件的元数据包含所述多个DN的信息。The obtaining unit 82 is configured to acquire metadata of the target file from an NN, where metadata of the target file includes information of the plurality of DNs.
所述生成单元83,用于根据所述目标文件的元数据生成元数据恢复信 息。The generating unit 83 is configured to generate a metadata recovery signal according to the metadata of the target file. interest.
所述发送单元84,用于向所述多个DN中的至少一个DN发送所述元数据恢复信息,所述元数据恢复信息用于被所述至少一个DN进行保存,并在所述NN出现异常后被发送到所述NN进行所述元数据的恢复。The sending unit 84 is configured to send the metadata recovery information to at least one of the plurality of DNs, where the metadata recovery information is used to be saved by the at least one DN, and appears in the NN The exception is sent to the NN for recovery of the metadata.
在另一个实施例中,所述目标文件被划分为多个数据块,所述多个数据块被保存在所述多个DN上;In another embodiment, the target file is divided into a plurality of data blocks, and the plurality of data blocks are saved on the plurality of DNs;
则,获取单元82可以用于从所述NN获取所述多个数据块的元数据,每个数据块的元数据包含每个数据块的信息和所述每个数据块所在的DN的信息;Then, the obtaining unit 82 may be configured to acquire metadata of the plurality of data blocks from the NN, where metadata of each data block includes information of each data block and information of a DN where each of the data blocks is located;
生成单元83可以用于根据所述每个数据块的元数据,生成所述每个数据块的元数据恢复信息。The generating unit 83 may be configured to generate metadata recovery information of each of the data blocks according to the metadata of each of the data blocks.
该实施方式中,可以实现生成每个数据块的元数据恢复信息,以使NN根据多个数据块的元数据恢复信息恢复目标文件的元数据。In this embodiment, metadata recovery information for generating each data block may be implemented such that the NN restores the metadata of the target file according to the metadata recovery information of the plurality of data blocks.
可选的,所述获取单元82可以用于依次接收所述NN发送的所述每个数据块的元数据;或者,所述获取单元82可以用于接收所述NN根据所述目标文件的写操作请求一次性发送的所有数据块的元数据。Optionally, the obtaining unit 82 may be configured to sequentially receive metadata of each of the data blocks sent by the NN; or the acquiring unit 82 may be configured to receive the NN according to the target file. The metadata of all data blocks that are requested to be sent at one time.
可选的,上述接收的元数据至少可以包括第一数据块的元数据和第二数据块的元数据,其中:Optionally, the received metadata may include at least metadata of the first data block and metadata of the second data block, where:
所述生成的所述第一数据块的元数据恢复信息可以包括:The generated metadata recovery information of the first data block may include:
所述目标文件的属性信息和所述第一数据块在所述目标文件中的位置信息;Attribute information of the target file and location information of the first data block in the target file;
所述生成的所述第二数据块的元数据恢复信息可以包括:The generated metadata recovery information of the second data block may include:
所述第二数据块在所述目标文件中的位置信息。Location information of the second data block in the target file.
可选的,上述客户端可以是HDFS的客户端(Client)。 Optionally, the client may be an HDFS client.
上述技术方案中,接收对目标文件的写操作请求,再从NN获取所述目标文件的元数据,根据所述目标文件的元数据生成元数据恢复信息,再向所述多个DN中的至少一个DN发送所述元数据恢复信息。这样该元数据恢复信息就可以用于被所述至少一个DN进行保存,并在所述NN出现异常后被发送到所述NN进行所述元数据的恢复。从而可以恢复NN出异常时的元数据。In the above technical solution, receiving a write operation request for the target file, acquiring metadata of the target file from the NN, generating metadata recovery information according to the metadata of the target file, and then performing at least one of the plurality of DNs A DN sends the metadata recovery information. Thus the metadata recovery information can be used for saving by the at least one DN and sent to the NN for recovery of the metadata after an exception occurs in the NN. Thereby, the metadata when the NN is abnormal can be restored.
请参阅图9,图9是本发明实施例提供的一种DN的结构示意图,如图9所示,包括:接收单元91和发送单元92,其中:Referring to FIG. 9, FIG. 9 is a schematic structural diagram of a DN according to an embodiment of the present invention. As shown in FIG. 9, the method includes: a receiving unit 91 and a sending unit 92, where:
接收单元91,用于接收客户端发送的目标文件的元数据恢复信息,并保存所述元数据恢复信息,其中,所述元数据恢复信息是所述客户端在接收对目标文件的写操作请求时,从NN获取的所述目标文件的元数据,并根据所述元数据生成的元数据恢复信息.。The receiving unit 91 is configured to receive metadata recovery information of the target file sent by the client, and save the metadata recovery information, where the metadata recovery information is that the client receives a write operation request for the target file. At the time, the metadata of the object file acquired from the NN, and the metadata recovery information generated from the metadata.
发送单元92,用于在所述NN出现异常后,向所述NN发送所述元数据恢复信息,元数据恢复信息被所述NN用于进行所述元数据的恢复。The sending unit 92 is configured to send the metadata recovery information to the NN after the NN is abnormal, and the metadata recovery information is used by the NN to perform recovery of the metadata.
在另一个实施例中,所述目标文件被划分为多个数据块,所述接收单元91可以用于接收所述客户端发送的所述目标文件的数据块的元数据恢复信息,所述数据块的元数据恢复信息为所述客户端根据该数据块的元数据生成的元数据恢复信息。In another embodiment, the target file is divided into a plurality of data blocks, and the receiving unit 91 may be configured to receive metadata recovery information of the data block of the target file sent by the client, where the data The metadata recovery information of the block is metadata recovery information generated by the client according to the metadata of the data block.
可选的,接收单元91可以用于依次接收所述客户端点发送的所述目标文件的多个数据块的元数据恢复信息;或者,所述接收单元91可以用于接收所述客户端一次性发送的所述目标文件的多个数据块的元数据恢复信息。Optionally, the receiving unit 91 may be configured to sequentially receive metadata recovery information of multiple data blocks of the target file sent by the client endpoint; or the receiving unit 91 may be configured to receive the client for one time. Metadata recovery information of a plurality of data blocks of the target file transmitted.
可选的,上述接收的元数据恢复信息至少可以包括第一数据块的元数据恢复信息和第二数据块的元数据恢复信息,其中:Optionally, the received metadata recovery information may include at least metadata recovery information of the first data block and metadata recovery information of the second data block, where:
所述第一数据块的元数据恢复信息可以包括: The metadata recovery information of the first data block may include:
所述目标文件的属性信息和所述第一数据块在所述目标文件中的位置信息;Attribute information of the target file and location information of the first data block in the target file;
所述第二数据块的元数据恢复信息可以包括:The metadata recovery information of the second data block may include:
所述第二数据块在所述目标文件中的位置信息。Location information of the second data block in the target file.
可选的,本节点可以是HDFS的DN。Optionally, the node can be the DN of the HDFS.
上述技术方案中,接收客户端发送的目标文件的元数据恢复信息,并保存所述元数据恢复信息;在所述NN出现异常后,向所述NN发送所述元数据恢复信息,元数据恢复信息被所述NN用于进行所述元数据的恢复。从而可以实现恢复NN出异常时的元数据。In the above technical solution, the metadata recovery information of the target file sent by the client is received, and the metadata recovery information is saved; after the NN is abnormal, the metadata recovery information is sent to the NN, and the metadata recovery is performed. Information is used by the NN to perform recovery of the metadata. Thereby, it is possible to restore the metadata when the NN is abnormal.
请参阅图10,图10是本发明实施例提供的一种NN的结构示意图,如图10所示,包括:接收单元101、生成单元102和恢复单元103,其中:Referring to FIG. 10, FIG. 10 is a schematic structural diagram of a NN according to an embodiment of the present invention. As shown in FIG. 10, the method includes: a receiving unit 101, a generating unit 102, and a restoring unit 103, where:
所述接收单元101,用于接收客户端发送的对目标文件进行写操作请求,其中,所述目标文件保存在多个DN上。The receiving unit 101 is configured to receive a write operation request for the target file sent by the client, where the target file is saved on multiple DNs.
所述生成单元102,用于生成所述目标文件的元数据,并向所述客户端发送所述元数据,其中,所述元数据包含所述多个DN的信息。The generating unit 102 is configured to generate metadata of the target file, and send the metadata to the client, where the metadata includes information of the multiple DNs.
所述恢复单元103,用于当本端出现异常时,接收所述多个DN中的至少一个DN发送的元数据恢复信息,并根据所述元数据恢复信息恢复所述元数据,其中,所述元数据恢复信息是所述客户端根据所述元数据生成的,由所述客户端发送至所述至少一个DN进行保存的元数据恢复信息。The recovery unit 103 is configured to receive metadata recovery information sent by at least one of the plurality of DNs when an abnormality occurs on the local end, and recover the metadata according to the metadata recovery information, where The metadata recovery information is generated by the client according to the metadata, and is sent by the client to the at least one DN for saving metadata recovery information.
在另一个实施例中,所述目标文件被划分为多个数据块,所述多个数据块被保存在所述多个DN上;In another embodiment, the target file is divided into a plurality of data blocks, and the plurality of data blocks are saved on the plurality of DNs;
所述生成单元102可以用于生成所述多个数据块的元数据,并向所述客户端发送所述多个数据块的元数据,每个数据块的元数据包含每个数据块的 信息和所述每个数据块所在的DN的信息;The generating unit 102 may be configured to generate metadata of the plurality of data blocks, and send metadata of the plurality of data blocks to the client, where metadata of each data block includes each data block Information and information about the DN of each of the data blocks;
所述恢复单元103可以用于当本端出现异常时,接收所述多个DN中的至少一个DN发送的所述多个数据块的元数据恢复信息,并根据所述多个数据块的元数据恢复信息恢复所述目标文件的元数据。The recovery unit 103 may be configured to receive metadata recovery information of the plurality of data blocks sent by at least one of the plurality of DNs when an abnormality occurs on the local end, and according to the elements of the multiple data blocks. The data recovery information restores the metadata of the target file.
可选的,生成单元102可以用于生成所述多个数据块的元数据,并依次向所述客户端发送所述多个数据块的元数据;或者,所述生成单元102可以用于生成所述多个数据块的元数据,并根据所述目标文件的写操作请求一次性向所述客户端发送所有数据块的元数据。Optionally, the generating unit 102 may be configured to generate metadata of the multiple data blocks, and sequentially send metadata of the multiple data blocks to the client; or, the generating unit 102 may be configured to generate Metadata of the plurality of data blocks, and transmitting metadata of all data blocks to the client at a time according to a write operation request of the target file.
可选的,上述多个数据块至少可以包括第一数据块和第二数据块,其中:Optionally, the foregoing multiple data blocks may include at least a first data block and a second data block, where:
所述第一数据块的元数据恢复信息可以包括:The metadata recovery information of the first data block may include:
所述目标文件的属性信息和所述第一数据块在所述目标文件中的位置信息;Attribute information of the target file and location information of the first data block in the target file;
所述第二数据块的元数据恢复信息可以包括:The metadata recovery information of the second data block may include:
所述第二数据块在所述目标文件中的位置信息。Location information of the second data block in the target file.
可选的,上述节点可以是HDFS内的NN。Optionally, the foregoing node may be an NN in the HDFS.
上述技术方案中,接收客户端发送的对目标文件进行写操作请求,生成所述目标文件的元数据,并向所述客户端发送所述元数据;这样当本端出现异常时,接收所述多个DN中的至少一个DN发送的元数据恢复信息,并根据所述元数据恢复信息恢复所述元数据。从而可以恢复NN出异常时的元数据。In the above technical solution, the receiving client sends a write operation request to the target file, generates metadata of the target file, and sends the metadata to the client; Metadata recovery information transmitted by at least one of the plurality of DNs, and recovering the metadata according to the metadata recovery information. Thereby, the metadata when the NN is abnormal can be restored.
请参阅图11,图11是本发明实施例提供的另一种元数据恢复设备的结构示意图,包括至少一个处理器1102(例如CPU),至少一个网络接口1105或者其他通信接口,存储器1106,和至少一个通信总线1103,用于实现这 些装置之间的连接通信。处理器1102用于执行存储器1106中存储的可执行模块,例如计算机程序。存储器1106可能包含高速随机存取存储器(RAM:Random Access Memory),也可能还包括非不稳定的存储器(non-volatile memory),例如至少一个磁盘存储器。通过至少一个网络接口1105(可以是有线或者无线)实现该系统网关与至少一个其他网元之间的通信连接,可以使用互联网,广域网,本地网,城域网等。Referring to FIG. 11, FIG. 11 is a schematic structural diagram of another metadata recovery device according to an embodiment of the present invention, including at least one processor 1102 (for example, a CPU), at least one network interface 1105 or other communication interface, a memory 1106, and At least one communication bus 1103 for implementing this Connection communication between these devices. The processor 1102 is configured to execute executable modules, such as computer programs, stored in the memory 1106. The memory 1106 may include a high speed random access memory (RAM), and may also include a non-volatile memory such as at least one disk memory. The communication connection between the system gateway and at least one other network element is implemented by at least one network interface 1105 (which may be wired or wireless), and may use an Internet, a wide area network, a local network, a metropolitan area network, or the like.
在一些实施方式中,存储器1106存储了程序11061,程序11061可以被处理器1102执行,这个程序包括:In some embodiments, the memory 1106 stores a program 11061 that can be executed by the processor 1102. This program includes:
接收对目标文件的写操作请求,其中,所述目标文件保存在多个DN上;Receiving a write operation request to the target file, wherein the target file is saved on multiple DNs;
从NN获取所述目标文件的元数据,所述目标文件的元数据包含所述多个DN的信息;Obtaining metadata of the target file from the NN, the metadata of the target file containing information of the plurality of DNs;
根据所述目标文件的元数据生成元数据恢复信息;Generating metadata recovery information according to metadata of the target file;
向所述多个DN中的至少一个DN发送所述元数据恢复信息,所述元数据恢复信息用于被所述至少一个DN进行保存,并在所述NN出现异常后被发送到所述NN进行所述元数据的恢复。Transmitting the metadata recovery information to at least one of the plurality of DNs for saving by the at least one DN and transmitting to the NN after an exception occurs in the NN The recovery of the metadata is performed.
在另一个实施例中,所述目标文件可以被划分为多个数据块,所述多个数据块可以被保存在所述多个DN上;处理器1102执行的从NN获取所述目标文件的元数据,根据所述目标文件的元数据生成元数据恢复信息的程序,可以包括:In another embodiment, the object file may be divided into a plurality of data blocks, the plurality of data blocks may be saved on the plurality of DNs; and the processor 1102 performs the acquisition of the target file from the NN. The metadata, the program for generating the metadata recovery information according to the metadata of the target file, may include:
从所述NN获取所述多个数据块的元数据,每个数据块的元数据包含每个数据块的信息和所述每个数据块所在的DN的信息;Obtaining metadata of the plurality of data blocks from the NN, the metadata of each data block includes information of each data block and information of a DN where each of the data blocks is located;
根据所述每个数据块的元数据,生成所述每个数据块的元数据恢复信息。Generating metadata recovery information for each of the data blocks based on the metadata of each of the data blocks.
可选的,处理器1102执行的从所述NN获取所述多个数据块的元数据 的程序,可以包括:Optionally, the metadata executed by the processor 1102 is used to acquire the metadata of the multiple data blocks from the NN. The program can include:
依次接收所述NN发送的所述每个数据块的元数据;或者,接收所述NN根据所述目标文件的写操作请求一次性发送的所有数据块的元数据。Receiving metadata of each of the data blocks sent by the NN in sequence; or receiving metadata of all data blocks that the NN requests to be sent at one time according to a write operation of the target file.
可选的,所述接收的元数据至少可以包括第一数据块的元数据和第二数据块的元数据,其中:Optionally, the received metadata may include at least metadata of the first data block and metadata of the second data block, where:
所述生成的所述第一数据块的元数据恢复信息可以包括:The generated metadata recovery information of the first data block may include:
所述目标文件的属性信息和所述第一数据块在所述目标文件中的位置信息;Attribute information of the target file and location information of the first data block in the target file;
所述生成的所述第二数据块的元数据恢复信息可以包括:The generated metadata recovery information of the second data block may include:
所述第二数据块在所述目标文件中的位置信息。Location information of the second data block in the target file.
可选的,上述设备可以是HDFS的客户端(Client)所属的设备。Optionally, the device may be a device to which the client of the HDFS belongs.
上述技术方案中,接收对目标文件的写操作请求;从NN获取所述目标文件的元数据;根据所述目标文件的元数据生成元数据恢复信息;向所述多个DN中的至少一个DN发送所述元数据恢复信息。这样元数据恢复信息可以用于被所述至少一个DN进行保存,并在所述NN出现异常后被发送到所述NN进行所述元数据的恢复,从而可以恢复NN出异常时的元数据。In the above technical solution, receiving a write operation request for the target file; acquiring metadata of the target file from the NN; generating metadata recovery information according to the metadata of the target file; and at least one DN of the plurality of DNs Sending the metadata recovery information. Thus, the metadata recovery information can be used to be saved by the at least one DN, and after the NN has an abnormality, it is sent to the NN to recover the metadata, so that the metadata when the NN is abnormal can be restored.
请参阅图12,图12是本发明实施例提供的一种DN设备的结构示意图,包括至少一个处理器1202(例如CPU),至少一个网络接口1205或者其他通信接口,存储器1206,和至少一个通信总线1203,用于实现这些装置之间的连接通信。处理器1202用于执行存储器1206中存储的可执行模块,例如计算机程序。存储器1206可能包含高速随机存取存储器(RAM:Random Access Memory),也可能还包括非不稳定的存储器(non-volatile memory),例如至少一个磁盘存储器。通过至少一个网络接口1205(可以是有线或者无 线)实现该系统网关与至少一个其他网元之间的通信连接,可以使用互联网,广域网,本地网,城域网等。Referring to FIG. 12, FIG. 12 is a schematic structural diagram of a DN device according to an embodiment of the present invention, including at least one processor 1202 (for example, a CPU), at least one network interface 1205 or other communication interface, a memory 1206, and at least one communication. Bus 1203 is used to implement connection communication between these devices. The processor 1202 is configured to execute executable modules, such as computer programs, stored in the memory 1206. The memory 1206 may include a high speed random access memory (RAM), and may also include a non-volatile memory such as at least one disk memory. Through at least one network interface 1205 (can be wired or not Line) realizes the communication connection between the system gateway and at least one other network element, and can use the Internet, a wide area network, a local network, a metropolitan area network, and the like.
在一些实施方式中,存储器1206存储了程序12061,程序12061可以被处理器1202执行,这个程序包括:In some embodiments, the memory 1206 stores a program 12061 that can be executed by the processor 1202. The program includes:
接收客户端发送的目标文件的元数据恢复信息,并保存所述元数据恢复信息,其中,所述元数据恢复信息是所述客户端在接收对目标文件的写操作请求时,从NN获取的所述目标文件的元数据,并根据所述元数据生成的元数据恢复信息.;Receiving metadata recovery information of the target file sent by the client, and saving the metadata recovery information, wherein the metadata recovery information is obtained by the client from the NN when receiving a write operation request for the target file Metadata of the target file, and metadata recovery information generated according to the metadata.
在所述NN出现异常后,向所述NN发送所述元数据恢复信息,元数据恢复信息被所述NN用于进行所述元数据的恢复。After the NN has an abnormality, the metadata recovery information is sent to the NN, and the metadata recovery information is used by the NN to perform recovery of the metadata.
在另一个实施例中,所述目标文件被划分为多个数据块,处理器1202执行的接收客户端发送的目标文件的元数据恢复信息的程序,可以包括:In another embodiment, the target file is divided into a plurality of data blocks, and the program executed by the processor 1202 to receive the metadata recovery information of the target file sent by the client may include:
接收所述客户端发送的所述目标文件的数据块的元数据恢复信息,所述数据块的元数据恢复信息为所述客户端根据该数据块的元数据生成的元数据恢复信息。And receiving metadata recovery information of the data block of the target file sent by the client, where the metadata recovery information of the data block is metadata recovery information generated by the client according to the metadata of the data block.
可选的,处理器1202执行的接收所述客户端发送的所述目标文件的数据块的元数据恢复信息的程序,可以包括:Optionally, the program that is executed by the processor 1202 to receive the metadata recovery information of the data block of the target file that is sent by the client may include:
依次接收所述客户端点发送的所述目标文件的多个数据块的元数据恢复信息;或者,接收所述客户端一次性发送的所述目标文件的多个数据块的元数据恢复信息。Receiving metadata recovery information of the plurality of data blocks of the target file sent by the client endpoint in sequence; or receiving metadata recovery information of the plurality of data blocks of the target file sent by the client at one time.
可选的,所述接收的元数据恢复信息至少可以包括第一数据块的元数据恢复信息和第二数据块的元数据恢复信息,其中:Optionally, the received metadata recovery information may include at least metadata recovery information of the first data block and metadata recovery information of the second data block, where:
所述第一数据块的元数据恢复信息可以包括:The metadata recovery information of the first data block may include:
所述目标文件的属性信息和所述第一数据块在所述目标文件中的位置 信息;Attribute information of the target file and a location of the first data block in the target file information;
所述第二数据块的元数据恢复信息可以包括:The metadata recovery information of the second data block may include:
所述第二数据块在所述目标文件中的位置信息。Location information of the second data block in the target file.
可选的,本节点设备可以是HDFS的DN所属的设备。Optionally, the device of the local node may be the device to which the DN of the HDFS belongs.
上述技术方案中,接收客户端发送的目标文件的元数据恢复信息,并保存所述元数据恢复信息;在所述NN出现异常后,向所述NN发送所述元数据恢复信息,元数据恢复信息被所述NN用于进行所述元数据的恢复。从而可以实现恢复NN出异常时的元数据。In the above technical solution, the metadata recovery information of the target file sent by the client is received, and the metadata recovery information is saved; after the NN is abnormal, the metadata recovery information is sent to the NN, and the metadata recovery is performed. Information is used by the NN to perform recovery of the metadata. Thereby, it is possible to restore the metadata when the NN is abnormal.
请参阅图13,图13是本发明实施例提供的一种NN设备的结构示意图,包括至少一个处理器1302(例如CPU),至少一个网络接口1305或者其他通信接口,存储器1306,和至少一个通信总线1303,用于实现这些装置之间的连接通信。处理器1302用于执行存储器1306中存储的可执行模块,例如计算机程序。存储器1306可能包含高速随机存取存储器(RAM:Random Access Memory),也可能还包括非不稳定的存储器(non-volatile memory),例如至少一个磁盘存储器。通过至少一个网络接口1305(可以是有线或者无线)实现该系统网关与至少一个其他网元之间的通信连接,可以使用互联网,广域网,本地网,城域网等。Referring to FIG. 13, FIG. 13 is a schematic structural diagram of an NN device according to an embodiment of the present invention, including at least one processor 1302 (eg, a CPU), at least one network interface 1305 or other communication interface, a memory 1306, and at least one communication. A bus 1303 is used to implement connection communication between these devices. The processor 1302 is configured to execute executable modules, such as computer programs, stored in the memory 1306. The memory 1306 may include a high speed random access memory (RAM) and may also include a non-volatile memory such as at least one disk memory. The communication connection between the system gateway and at least one other network element is implemented by at least one network interface 1305 (which may be wired or wireless), and may use an Internet, a wide area network, a local network, a metropolitan area network, or the like.
在一些实施方式中,存储器1306存储了程序13061,程序13061可以被处理器1302执行,这个程序包括:In some embodiments, the memory 1306 stores a program 13061 that can be executed by the processor 1302. This program includes:
接收客户端发送的对目标文件进行写操作请求,其中,所述目标文件保存在多个DN上;Receiving a write operation request to the target file sent by the client, where the target file is saved on multiple DNs;
生成所述目标文件的元数据,并向所述客户端发送所述元数据,其中,所述元数据包含所述多个DN的信息; Generating metadata of the target file, and transmitting the metadata to the client, wherein the metadata includes information of the plurality of DNs;
当本端出现异常时,接收所述多个DN中的至少一个DN发送的元数据恢复信息,并根据所述元数据恢复信息恢复所述元数据,其中,所述元数据恢复信息是所述客户端根据所述元数据生成的,由所述客户端发送至所述至少一个DN进行保存的元数据恢复信息。Receiving, by the local end, metadata recovery information sent by at least one of the plurality of DNs, and recovering the metadata according to the metadata recovery information, wherein the metadata recovery information is The metadata recovery information generated by the client according to the metadata and sent by the client to the at least one DN for saving.
在另一个实施例中,所述目标文件被划分为多个数据块,所述多个数据块被保存在所述多个DN上;处理器1302执行的生成所述目标文件的元数据,并向所述客户端发送所述元数据,可以包括:In another embodiment, the object file is divided into a plurality of data blocks, the plurality of data blocks are saved on the plurality of DNs; the processor 1302 performs metadata generation of the object file, and Sending the metadata to the client may include:
生成所述多个数据块的元数据,并向所述客户端发送所述多个数据块的元数据,每个数据块的元数据包含每个数据块的信息和所述每个数据块所在的DN的信息。Generating metadata of the plurality of data blocks, and transmitting metadata of the plurality of data blocks to the client, where metadata of each data block includes information of each data block and where each of the data blocks is located DN information.
处理器1302执行的接收所述多个DN中的至少一个DN发送的元数据恢复信息,并根据所述元数据恢复信息恢复所述元数据的程序,可以包括:The program executed by the processor 1302, which receives the metadata recovery information sent by the at least one of the plurality of DNs, and recovers the metadata according to the metadata recovery information, may include:
接收所述多个DN中的至少一个DN发送的所述多个数据块的元数据恢复信息,并根据所述多个数据块的元数据恢复信息恢复所述目标文件的元数据。Receiving metadata recovery information of the plurality of data blocks transmitted by at least one of the plurality of DNs, and recovering metadata of the target file according to metadata recovery information of the plurality of data blocks.
可选的,处理器1302执行的向所述客户端发送所述多个数据块的元数据的程序,可以包括:Optionally, the program executed by the processor 1302 to send the metadata of the multiple data blocks to the client may include:
依次向所述客户端发送所述多个数据块的元数据;或者,根据所述目标文件的写操作请求一次性向所述客户端发送所有数据块的元数据。Transmitting metadata of the plurality of data blocks to the client in turn; or sending metadata of all data blocks to the client at a time according to a write operation request of the target file.
可选的,上述多个数据块至少可以包括第一数据块和第二数据块,其中:Optionally, the foregoing multiple data blocks may include at least a first data block and a second data block, where:
所述第一数据块的元数据恢复信息可以包括:The metadata recovery information of the first data block may include:
所述目标文件的属性信息和所述第一数据块在所述目标文件中的位置信息;Attribute information of the target file and location information of the first data block in the target file;
所述第二数据块的元数据恢复信息可以包括: The metadata recovery information of the second data block may include:
所述第二数据块在所述目标文件中的位置信息。Location information of the second data block in the target file.
可选的,上述节点设备可以是HDFS内的NN所属的设备。Optionally, the foregoing node device may be a device to which the NN in the HDFS belongs.
上述技术方案中,接收客户端发送的对目标文件进行写操作请求;生成所述目标文件的元数据,并向所述客户端发送所述元数据;当本端出现异常时,接收所述多个DN中的至少一个DN发送的元数据恢复信息,并根据所述元数据恢复信息恢复所述元数据。从而可以恢复NN出异常时的元数据。In the above technical solution, the receiving client sends a write operation request to the target file; generating metadata of the target file, and sending the metadata to the client; and when the local end is abnormal, receiving the multiple Metadata recovery information transmitted by at least one of the DNs, and the metadata is restored according to the metadata recovery information. Thereby, the metadata when the NN is abnormal can be restored.
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,所述的程序可存储于一计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。其中,所述的存储介质可为磁碟、光盘、只读存储记忆体(Read-Only Memory,ROM)或随机存取存储器(Random Access Memory,简称RAM)等。One of ordinary skill in the art can understand that all or part of the process of implementing the foregoing embodiments can be completed by a computer program to instruct related hardware, and the program can be stored in a computer readable storage medium. When executed, the flow of an embodiment of the methods as described above may be included. The storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
以上所揭露的仅为本发明较佳实施例而已,当然不能以此来限定本发明之权利范围,因此依本发明权利要求所作的等同变化,仍属本发明所涵盖的范围。 The above is only the preferred embodiment of the present invention, and the scope of the present invention is not limited thereto, and thus equivalent changes made in the claims of the present invention are still within the scope of the present invention.

Claims (24)

  1. 一种元数据恢复方法,其特征在于,包括:A metadata recovery method, comprising:
    接收对目标文件的写操作请求,其中,所述目标文件保存在多个数据节点上;Receiving a write operation request to the target file, wherein the target file is saved on a plurality of data nodes;
    从元数据节点获取所述目标文件的元数据,所述目标文件的元数据包含所述多个数据节点的信息;Obtaining metadata of the target file from a metadata node, where metadata of the target file includes information of the plurality of data nodes;
    根据所述目标文件的元数据生成元数据恢复信息;Generating metadata recovery information according to metadata of the target file;
    向所述多个数据节点中的至少一个数据节点发送所述元数据恢复信息,所述元数据恢复信息用于被所述至少一个数据节点进行保存,并在所述元数据节点出现异常后被发送到所述元数据节点进行所述元数据的恢复。Transmitting the metadata recovery information to at least one of the plurality of data nodes, the metadata recovery information being used for being saved by the at least one data node, and being Sending to the metadata node for recovery of the metadata.
  2. 如权利要求1所述的方法,其特征在于,所述目标文件被划分为多个数据块,所述多个数据块被保存在所述多个数据节点上;The method of claim 1, wherein the object file is divided into a plurality of data blocks, the plurality of data blocks being stored on the plurality of data nodes;
    则,所述从元数据节点获取所述目标文件的元数据,根据所述目标文件的元数据生成元数据恢复信息包括:Then, the acquiring the metadata of the target file from the metadata node, and generating the metadata recovery information according to the metadata of the target file includes:
    从所述元数据节点获取所述多个数据块的元数据,每个数据块的元数据包含每个数据块的信息和所述每个数据块所在的数据节点的信息;Obtaining metadata of the plurality of data blocks from the metadata node, the metadata of each data block includes information of each data block and information of a data node where each of the data blocks is located;
    根据所述每个数据块的元数据,生成所述每个数据块的元数据恢复信息。Generating metadata recovery information for each of the data blocks based on the metadata of each of the data blocks.
  3. 如权利要求2所述的方法,其特征在于,所述从所述元数据节点获取所述多个数据块的元数据包括:The method of claim 2, wherein the obtaining metadata of the plurality of data blocks from the metadata node comprises:
    依次接收所述元数据节点发送的所述每个数据块的元数据;或者,接收所述元数据节点根据所述目标文件的写操作请求一次性发送的所有数据块的元数据。Receiving metadata of each of the data blocks sent by the metadata node in sequence; or receiving metadata of all data blocks that are sent by the metadata node in one time according to a write operation of the target file.
  4. 如权利要求2或3所述的方法,其特征在于,所述接收的元数据至少包括第一数据块的元数据和第二数据块的元数据,其中: The method according to claim 2 or 3, wherein the received metadata includes at least metadata of the first data block and metadata of the second data block, wherein:
    所述生成的所述第一数据块的元数据恢复信息包括:The generated metadata recovery information of the first data block includes:
    所述目标文件的属性信息和所述第一数据块在所述目标文件中的位置信息;Attribute information of the target file and location information of the first data block in the target file;
    所述生成的所述第二数据块的元数据恢复信息包括:The generated metadata recovery information of the second data block includes:
    所述第二数据块在所述目标文件中的位置信息。Location information of the second data block in the target file.
  5. 一种元数据恢复方法,其特征在于,包括:A metadata recovery method, comprising:
    接收客户端发送的目标文件的元数据恢复信息,并保存所述元数据恢复信息,其中,所述元数据恢复信息是所述客户端在接收对目标文件的写操作请求时,从元数据节点获取的所述目标文件的元数据,并根据所述元数据生成的元数据恢复信息.;Receiving metadata recovery information of the target file sent by the client, and saving the metadata recovery information, wherein the metadata recovery information is from the metadata node when the client receives a write operation request for the target file Obtaining metadata of the target file, and recovering information according to the metadata generated by the metadata.
    在所述元数据节点出现异常后,向所述元数据节点发送所述元数据恢复信息,元数据恢复信息被所述元数据节点用于进行所述元数据的恢复。After the metadata node is abnormal, the metadata recovery information is sent to the metadata node, and the metadata recovery information is used by the metadata node to perform recovery of the metadata.
  6. 如权利要求5所述的方法,其特征在于,所述目标文件被划分为多个数据块,所述接收客户端发送的目标文件的元数据恢复信息,包括:The method of claim 5, wherein the target file is divided into a plurality of data blocks, and the metadata recovery information of the target file sent by the receiving client comprises:
    接收所述客户端发送的所述目标文件的数据块的元数据恢复信息,所述数据块的元数据恢复信息为所述客户端根据该数据块的元数据生成的元数据恢复信息。And receiving metadata recovery information of the data block of the target file sent by the client, where the metadata recovery information of the data block is metadata recovery information generated by the client according to the metadata of the data block.
  7. 如权利要求6所述的方法,其特征在于,所述接收所述客户端发送的所述目标文件的数据块的元数据恢复信息包括:The method of claim 6, wherein the receiving the metadata recovery information of the data block of the target file sent by the client comprises:
    依次接收所述客户端点发送的所述目标文件的多个数据块的元数据恢复信息;或者,接收所述客户端一次性发送的所述目标文件的多个数据块的元数据恢复信息。Receiving metadata recovery information of the plurality of data blocks of the target file sent by the client endpoint in sequence; or receiving metadata recovery information of the plurality of data blocks of the target file sent by the client at one time.
  8. 如权利要求6或7所述的方法,其特征在于,所述接收的元数据恢复信息至少包括第一数据块的元数据恢复信息和第二数据块的元数据恢复信息,其中:The method according to claim 6 or 7, wherein the received metadata recovery information comprises at least metadata recovery information of the first data block and metadata recovery information of the second data block, wherein:
    所述第一数据块的元数据恢复信息包括: The metadata recovery information of the first data block includes:
    所述目标文件的属性信息和所述第一数据块在所述目标文件中的位置信息;Attribute information of the target file and location information of the first data block in the target file;
    所述第二数据块的元数据恢复信息包括:The metadata recovery information of the second data block includes:
    所述第二数据块在所述目标文件中的位置信息。Location information of the second data block in the target file.
  9. 一种元数据恢复方法,其特征在于,包括:A metadata recovery method, comprising:
    接收客户端发送的对目标文件进行写操作请求,其中,所述目标文件保存在多个数据节点上;Receiving a write operation request to the target file sent by the client, where the target file is saved on multiple data nodes;
    生成所述目标文件的元数据,并向所述客户端发送所述元数据,其中,所述元数据包含所述多个数据节点的信息;Generating metadata of the object file and transmitting the metadata to the client, wherein the metadata includes information of the plurality of data nodes;
    当本端出现异常时,接收所述多个数据节点中的至少一个数据节点发送的元数据恢复信息,并根据所述元数据恢复信息恢复所述元数据,其中,所述元数据恢复信息是所述客户端根据所述元数据生成的,由所述客户端发送至所述至少一个数据节点进行保存的元数据恢复信息。Receiving metadata recovery information sent by at least one of the plurality of data nodes when an abnormality occurs at the local end, and recovering the metadata according to the metadata recovery information, wherein the metadata recovery information is The metadata recovery information generated by the client according to the metadata and sent by the client to the at least one data node for saving.
  10. 如权利要求9所述的方法,其特征在于,所述目标文件被划分为多个数据块,所述多个数据块被保存在所述多个数据节点上;The method of claim 9, wherein the object file is divided into a plurality of data blocks, the plurality of data blocks being stored on the plurality of data nodes;
    则所述生成所述目标文件的元数据,并向所述客户端发送所述元数据包括:And generating the metadata of the target file, and sending the metadata to the client includes:
    生成所述多个数据块的元数据,并向所述客户端发送所述多个数据块的元数据,每个数据块的元数据包含每个数据块的信息和所述每个数据块所在的数据节点的信息;Generating metadata of the plurality of data blocks, and transmitting metadata of the plurality of data blocks to the client, where metadata of each data block includes information of each data block and where each of the data blocks is located Information of the data node;
    所述接收所述多个数据节点中的至少一个数据节点发送的元数据恢复信息,并根据所述元数据恢复信息恢复所述元数据,包括:Receiving the metadata recovery information sent by the at least one of the plurality of data nodes, and recovering the metadata according to the metadata recovery information, including:
    接收所述多个数据节点中的至少一个数据节点发送的所述多个数据块的元数据恢复信息,并根据所述多个数据块的元数据恢复信息恢复所述目标文件的元数据。Receiving metadata recovery information of the plurality of data blocks sent by at least one of the plurality of data nodes, and recovering metadata of the target file according to metadata recovery information of the plurality of data blocks.
  11. 如权利要求10所述的方法,其特征在于,所述向所述客户端发送 所述多个数据块的元数据包括:The method of claim 10 wherein said sending to said client The metadata of the plurality of data blocks includes:
    依次向所述客户端发送所述多个数据块的元数据;或者,根据所述目标文件的写操作请求一次性向所述客户端发送所有数据块的元数据。Transmitting metadata of the plurality of data blocks to the client in turn; or sending metadata of all data blocks to the client at a time according to a write operation request of the target file.
  12. 如权利要求10或11所述的方法,其特征在于,所述多个数据块至少包括第一数据块和第二数据块,其中:The method according to claim 10 or 11, wherein said plurality of data blocks comprises at least a first data block and a second data block, wherein:
    所述第一数据块的元数据恢复信息包括:The metadata recovery information of the first data block includes:
    所述目标文件的属性信息和所述第一数据块在所述目标文件中的位置信息;Attribute information of the target file and location information of the first data block in the target file;
    所述第二数据块的元数据恢复信息包括:The metadata recovery information of the second data block includes:
    所述第二数据块在所述目标文件中的位置信息。Location information of the second data block in the target file.
  13. 一种客户端,其特征在于,包括:接收单元、获取单元、生成单元和发送单元,其中:A client, comprising: a receiving unit, an obtaining unit, a generating unit, and a sending unit, wherein:
    所述接收单元,用于接收对目标文件的写操作请求,其中,所述目标文件保存在多个数据节点上;The receiving unit is configured to receive a write operation request for the target file, where the target file is saved on multiple data nodes;
    所述获取单元,用于从元数据节点获取所述目标文件的元数据,所述目标文件的元数据包含所述多个数据节点的信息;The acquiring unit is configured to acquire metadata of the target file from a metadata node, where metadata of the target file includes information of the plurality of data nodes;
    所述生成单元,用于根据所述目标文件的元数据生成元数据恢复信息;The generating unit is configured to generate metadata recovery information according to metadata of the target file;
    所述发送单元,用于向所述多个数据节点中的至少一个数据节点发送所述元数据恢复信息,所述元数据恢复信息用于被所述至少一个数据节点进行保存,并在所述元数据节点出现异常后被发送到所述元数据节点进行所述元数据的恢复。The sending unit is configured to send the metadata recovery information to at least one of the plurality of data nodes, where the metadata recovery information is used to be saved by the at least one data node, and in the After the metadata node has an abnormality, it is sent to the metadata node for recovery of the metadata.
  14. 如权利要求13所述的客户端,其特征在于,所述目标文件被划分为多个数据块,所述多个数据块被保存在所述多个数据节点上;The client according to claim 13, wherein the object file is divided into a plurality of data blocks, and the plurality of data blocks are saved on the plurality of data nodes;
    则,所述获取单元用于从所述元数据节点获取所述多个数据块的元数据,每个数据块的元数据包含每个数据块的信息和所述每个数据块所在的数据节点的信息; Then, the obtaining unit is configured to acquire metadata of the plurality of data blocks from the metadata node, where metadata of each data block includes information of each data block and a data node where each of the data blocks is located Information;
    所述生成单元用于根据所述每个数据块的元数据,生成所述每个数据块的元数据恢复信息。The generating unit is configured to generate metadata recovery information of each of the data blocks according to the metadata of each of the data blocks.
  15. 如权利要求14所述的客户端,其特征在于,所述获取单元用于依次接收所述元数据节点发送的所述每个数据块的元数据;或者,所述获取单元用于接收所述元数据节点根据所述目标文件的写操作请求一次性发送的所有数据块的元数据。The client according to claim 14, wherein the obtaining unit is configured to sequentially receive metadata of each of the data blocks sent by the metadata node; or the acquiring unit is configured to receive the The metadata node requests metadata of all data blocks that are sent at one time according to a write operation of the target file.
  16. 如权利要求14或15所述的客户端,其特征在于,所述接收的元数据至少包括第一数据块的元数据和第二数据块的元数据,其中:The client according to claim 14 or 15, wherein the received metadata includes at least metadata of the first data block and metadata of the second data block, wherein:
    所述生成的所述第一数据块的元数据恢复信息包括:The generated metadata recovery information of the first data block includes:
    所述目标文件的属性信息和所述第一数据块在所述目标文件中的位置信息;Attribute information of the target file and location information of the first data block in the target file;
    所述生成的所述第二数据块的元数据恢复信息包括:The generated metadata recovery information of the second data block includes:
    所述第二数据块在所述目标文件中的位置信息。Location information of the second data block in the target file.
  17. 一种数据节点,其特征在于,包括:接收单元和发送单元,其中:A data node, comprising: a receiving unit and a sending unit, wherein:
    所述接收单元,用于接收客户端发送的目标文件的元数据恢复信息,并保存所述元数据恢复信息,其中,所述元数据恢复信息是所述客户端在接收对目标文件的写操作请求时,从元数据节点获取的所述目标文件的元数据,并根据所述元数据生成的元数据恢复信息.;The receiving unit is configured to receive metadata recovery information of the target file sent by the client, and save the metadata recovery information, where the metadata recovery information is that the client receives a write operation on the target file. At the time of request, the metadata of the object file acquired from the metadata node, and the metadata recovery information generated according to the metadata.
    所述发送单元,用于在所述元数据节点出现异常后,向所述元数据节点发送所述元数据恢复信息,元数据恢复信息被所述元数据节点用于进行所述元数据的恢复。The sending unit is configured to send the metadata recovery information to the metadata node after an abnormality occurs in the metadata node, where the metadata recovery information is used by the metadata node to perform recovery of the metadata .
  18. 如权利要求17所述的数据节点,其特征在于,所述目标文件被划分为多个数据块,所述接收单元用于接收所述客户端发送的所述目标文件的数据块的元数据恢复信息,所述数据块的元数据恢复信息为所述客户端根据该数据块的元数据生成的元数据恢复信息。The data node according to claim 17, wherein the object file is divided into a plurality of data blocks, and the receiving unit is configured to receive metadata recovery of the data block of the target file sent by the client. Information, the metadata recovery information of the data block is metadata recovery information generated by the client according to metadata of the data block.
  19. 如权利要求18所述的数据节点,其特征在于,所述接收单元用于 依次接收所述客户端点发送的所述目标文件的多个数据块的元数据恢复信息;或者,所述接收单元用于接收所述客户端一次性发送的所述目标文件的多个数据块的元数据恢复信息。A data node according to claim 18, wherein said receiving unit is for Receiving, in sequence, metadata recovery information of the plurality of data blocks of the target file sent by the client endpoint; or, the receiving unit is configured to receive, by the client, a plurality of data blocks of the target file that are sent by the client at one time Metadata recovery information.
  20. 如权利要求17或18所述的数据节点,其特征在于,所述接收的元数据恢复信息至少包括第一数据块的元数据恢复信息和第二数据块的元数据恢复信息,其中:The data node according to claim 17 or 18, wherein said received metadata recovery information comprises at least metadata recovery information of said first data block and metadata recovery information of said second data block, wherein:
    所述第一数据块的元数据恢复信息包括:The metadata recovery information of the first data block includes:
    所述目标文件的属性信息和所述第一数据块在所述目标文件中的位置信息;Attribute information of the target file and location information of the first data block in the target file;
    所述第二数据块的元数据恢复信息包括:The metadata recovery information of the second data block includes:
    所述第二数据块在所述目标文件中的位置信息。Location information of the second data block in the target file.
  21. 一种元数据节点,其特征在于,包括:接收单元、生成单元和恢复单元,其中:A metadata node, comprising: a receiving unit, a generating unit, and a restoring unit, wherein:
    所述接收单元,用于接收客户端发送的对目标文件进行写操作请求,其中,所述目标文件保存在多个数据节点上;The receiving unit is configured to receive a write operation request for the target file sent by the client, where the target file is saved on multiple data nodes;
    所述生成单元,用于生成所述目标文件的元数据,并向所述客户端发送所述元数据,其中,所述元数据包含所述多个数据节点的信息;The generating unit is configured to generate metadata of the target file, and send the metadata to the client, where the metadata includes information of the multiple data nodes;
    所述恢复单元,用于当本端出现异常时,接收所述多个数据节点中的至少一个数据节点发送的元数据恢复信息,并根据所述元数据恢复信息恢复所述元数据,其中,所述元数据恢复信息是所述客户端根据所述元数据生成的,由所述客户端发送至所述至少一个数据节点进行保存的元数据恢复信息。The recovery unit is configured to receive metadata recovery information sent by at least one of the plurality of data nodes when an abnormality occurs on the local end, and recover the metadata according to the metadata recovery information, where The metadata recovery information is metadata recovery information that is generated by the client according to the metadata and sent by the client to the at least one data node for saving.
  22. 如权利要求21所述的元数据节点,其特征在于,所述目标文件被划分为多个数据块,所述多个数据块被保存在所述多个数据节点上;The metadata node according to claim 21, wherein said object file is divided into a plurality of data blocks, said plurality of data blocks being stored on said plurality of data nodes;
    所述生成单元用于生成所述多个数据块的元数据,并向所述客户端发送所述多个数据块的元数据,每个数据块的元数据包含每个数据块的信息 和所述每个数据块所在的数据节点的信息;The generating unit is configured to generate metadata of the plurality of data blocks, and send metadata of the plurality of data blocks to the client, where metadata of each data block includes information of each data block And information of the data node where each of the data blocks is located;
    所述恢复单元用于当本端出现异常时,接收所述多个数据节点中的至少一个数据节点发送的所述多个数据块的元数据恢复信息,并根据所述多个数据块的元数据恢复信息恢复所述目标文件的元数据。The recovery unit is configured to receive metadata recovery information of the plurality of data blocks sent by at least one of the plurality of data nodes when an abnormality occurs on the local end, and according to the elements of the multiple data blocks The data recovery information restores the metadata of the target file.
  23. 如权利要求21所述的元数据节点,其特征在于,所述生成单元用于生成所述多个数据块的元数据,并依次向所述客户端发送所述多个数据块的元数据;或者,所述生成单元用于生成所述多个数据块的元数据,并根据所述目标文件的写操作请求一次性向所述客户端发送所有数据块的元数据。The metadata node according to claim 21, wherein the generating unit is configured to generate metadata of the plurality of data blocks, and sequentially send metadata of the plurality of data blocks to the client; Alternatively, the generating unit is configured to generate metadata of the plurality of data blocks, and send metadata of all data blocks to the client at one time according to a write operation request of the target file.
  24. 如权利要求10或11所述的元数据节点,其特征在于,所述多个数据块至少包括第一数据块和第二数据块,其中:The metadata node according to claim 10 or 11, wherein said plurality of data blocks comprises at least a first data block and a second data block, wherein:
    所述第一数据块的元数据恢复信息包括:The metadata recovery information of the first data block includes:
    所述目标文件的属性信息和所述第一数据块在所述目标文件中的位置信息;Attribute information of the target file and location information of the first data block in the target file;
    所述第二数据块的元数据恢复信息包括:The metadata recovery information of the second data block includes:
    所述第二数据块在所述目标文件中的位置信息。 Location information of the second data block in the target file.
PCT/CN2015/083226 2014-08-27 2015-07-02 Metadata recovery method and relevant device WO2016029744A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201410427894.2A CN104202387B (en) 2014-08-27 2014-08-27 A kind of metadata restoration methods and relevant apparatus
CN201410427894.2 2014-08-27

Publications (1)

Publication Number Publication Date
WO2016029744A1 true WO2016029744A1 (en) 2016-03-03

Family

ID=52087612

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/083226 WO2016029744A1 (en) 2014-08-27 2015-07-02 Metadata recovery method and relevant device

Country Status (2)

Country Link
CN (1) CN104202387B (en)
WO (1) WO2016029744A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112947864A (en) * 2021-03-29 2021-06-11 南方电网数字电网研究院有限公司 Metadata storage method, device, equipment and storage medium

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104202387B (en) * 2014-08-27 2017-11-24 华为技术有限公司 A kind of metadata restoration methods and relevant apparatus
CN107562368B (en) * 2016-06-30 2019-11-22 杭州海康威视数字技术股份有限公司 A kind of data processing method and device
CN108241555B (en) * 2016-12-26 2022-03-01 阿里巴巴集团控股有限公司 Backup and recovery method and device of distributed database and server
CN109947730B (en) * 2017-07-25 2024-02-02 中兴通讯股份有限公司 Metadata recovery method, device, distributed file system and readable storage medium
CN109426587B (en) * 2017-08-25 2020-08-28 杭州海康威视数字技术股份有限公司 Data recovery method and device
CN108390771B (en) * 2018-01-25 2021-04-16 中国银联股份有限公司 Network topology reconstruction method and device
CN111984460B (en) * 2019-05-21 2023-11-24 华为云计算技术有限公司 Metadata recovery method and device
CN115185723B (en) * 2022-06-02 2023-06-02 广州市玄武无线科技股份有限公司 Region meta-information restoration method, system, device and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030220943A1 (en) * 2002-05-23 2003-11-27 International Business Machines Corporation Recovery of a single metadata controller failure in a storage area network environment
CN102024044A (en) * 2010-12-08 2011-04-20 华为技术有限公司 Distributed file system
CN102843403A (en) * 2011-06-23 2012-12-26 盛大计算机(上海)有限公司 File processing method based on distributed file system, system, and client
CN103076994A (en) * 2012-12-31 2013-05-01 北京中科大洋科技发展股份有限公司 Method for realizing off-line file writing in SAN (Storage Area Network) shared-file system
CN104202387A (en) * 2014-08-27 2014-12-10 华为技术有限公司 Metadata recovery method and related device

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100587692C (en) * 2007-01-26 2010-02-03 华中科技大学 Method and system for promoting metadata service reliability
CN101539873B (en) * 2009-04-15 2011-02-09 成都市华为赛门铁克科技有限公司 Data recovery method, data node and distributed file system
CN101986276B (en) * 2010-10-21 2013-07-10 华为数字技术(成都)有限公司 Methods and systems for storing and recovering files and server
JP5611889B2 (en) * 2011-05-17 2014-10-22 株式会社東芝 Data transfer device, data transmission system, and data transmission method
CN103067418A (en) * 2011-10-19 2013-04-24 北大方正集团有限公司 Method, device and system for reconstructing metadata
CN103761162B (en) * 2014-01-11 2016-12-07 深圳清华大学研究院 The data back up method of distributed file system

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030220943A1 (en) * 2002-05-23 2003-11-27 International Business Machines Corporation Recovery of a single metadata controller failure in a storage area network environment
CN102024044A (en) * 2010-12-08 2011-04-20 华为技术有限公司 Distributed file system
CN102843403A (en) * 2011-06-23 2012-12-26 盛大计算机(上海)有限公司 File processing method based on distributed file system, system, and client
CN103076994A (en) * 2012-12-31 2013-05-01 北京中科大洋科技发展股份有限公司 Method for realizing off-line file writing in SAN (Storage Area Network) shared-file system
CN104202387A (en) * 2014-08-27 2014-12-10 华为技术有限公司 Metadata recovery method and related device

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112947864A (en) * 2021-03-29 2021-06-11 南方电网数字电网研究院有限公司 Metadata storage method, device, equipment and storage medium
CN112947864B (en) * 2021-03-29 2024-03-08 南方电网数字平台科技(广东)有限公司 Metadata storage method, apparatus, device and storage medium

Also Published As

Publication number Publication date
CN104202387B (en) 2017-11-24
CN104202387A (en) 2014-12-10

Similar Documents

Publication Publication Date Title
WO2016029744A1 (en) Metadata recovery method and relevant device
CN110019235B (en) Block chain based data storage and recovery method, device, equipment and medium
WO2019095577A1 (en) Method and device for processing data request, computer apparatus, and storage medium
US10719260B2 (en) Techniques for storing and retrieving data from a computing device
TWI751402B (en) Data synchronization method, distributed system, computer readable storage and retrieval media, computer equipment and distributed equipment
US11221995B2 (en) Data replication from a cloud-based storage resource
US9779153B2 (en) Data transfer between storage systems using data fingerprints
CN107528872B (en) Data recovery method and device and cloud storage system
WO2019075978A1 (en) Data transmission method and apparatus, computer device, and storage medium
CA2959999C (en) Distributed data synchronization and conflict resolution
KR20180105675A (en) Method, apparatus, and system for synchronizing data
WO2016180055A1 (en) Method, device and system for storing and reading data
CN107018185B (en) Synchronization method and device of cloud storage system
WO2020151181A1 (en) Cross-platform data updating method and apparatus based on block chain, and computer device
CN107153644B (en) Data synchronization method and device
CN105450682B (en) Method, device and system for synchronously storing data and synchronizing data to client
CN109739435B (en) File storage and updating method and device
CN109254998B (en) Data management method, Internet of things equipment, database server and system
CN103716384A (en) Method and device for realizing cloud storage data synchronization in cross-data-center manner
CN106817387B (en) Data synchronization method, device and system
WO2017096942A1 (en) File storage system, data scheduling method, and data node
US10545667B1 (en) Dynamic data partitioning for stateless request routing
CN107516048B (en) Method and equipment for controlling file access in distributed file system
WO2017005116A1 (en) Intermediate file processing method, clients, servers and system
US10853892B2 (en) Social networking relationships processing method, system, and storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 15836410

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 15836410

Country of ref document: EP

Kind code of ref document: A1