WO2015101084A1 - Method, server and system for data recovery - Google Patents

Method, server and system for data recovery Download PDF

Info

Publication number
WO2015101084A1
WO2015101084A1 PCT/CN2014/088962 CN2014088962W WO2015101084A1 WO 2015101084 A1 WO2015101084 A1 WO 2015101084A1 CN 2014088962 W CN2014088962 W CN 2014088962W WO 2015101084 A1 WO2015101084 A1 WO 2015101084A1
Authority
WO
WIPO (PCT)
Prior art keywords
log file
recovery log
server
data
information
Prior art date
Application number
PCT/CN2014/088962
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 WO2015101084A1 publication Critical patent/WO2015101084A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1471Saving, restoring, recovering or retrying involving logging of persistent data for recovery

Definitions

  • the present invention relates to the field of information technology, and in particular, to a method, a server, and a system for recovering data.
  • the first method is to scan the file system by the fsck command to find the data to be recovered and restore the data to be recovered.
  • the second method is: reading the log information of the data to be restored in the system operation log through the metadata server, and controlling the data server to perform the operation on the data according to the read log information of the data to be restored, thereby restoring the data.
  • the third method is: reading the log information of the data to be restored through the metadata server, and controlling the data server to perform the operation on the data according to the read log information to be restored, thereby restoring the data.
  • the first way is to scan all the data, causing a waste of system resources.
  • the second and third methods require the metadata server to recover data, while the metadata server recovers data at a slower rate, resulting in less efficient data recovery.
  • the embodiment of the invention provides a method, a server and a system for restoring data, which can solve the problems of the prior art.
  • the technical solution is as follows:
  • a method for recovering data is provided, the method being applied to a primary server of a storage system, the storage system including a primary server and a secondary server, both the primary server and the secondary server are configured to store the same data
  • the primary server is the first server that successfully stores data, and the method includes:
  • the primary server When any one of the storage systems fails to store data, the primary server is Each of the storage systems sends a log obtaining request, where the log obtaining request carries the data identifier to be restored;
  • each first recovery log file records location information and operation information of the to-be-recovered data identified by the to-be-recovered data identifier
  • the second recovery log file is generated by the primary server, and records location information and operation information of the to-be-recovered data identified by the to-be-recovered data identifier.
  • the method before the sending a log obtaining request to the server in the storage system, the method further includes:
  • the total write status information sent by the client includes the write failure information, determining that the data sent by the client is the data to be restored, and generating the second location information and the operation information for recording the data to be restored. Restore the log file.
  • the performing the data to be restored according to the latest operation information in the operation information recorded by all the first recovery log file and the second recovery log file Operations including:
  • the index information includes a recovery log file identifier, an offset information, and data length information, where the preset structure stores index information and an operation time;
  • the determining whether the index information of the currently read recovery log file is in a preset structure also includes:
  • the operation time of the currently read recovery log file and the operation time of the index information corresponding to the currently read recovery log file in the preset structure Compare;
  • the operation time of the currently read recovery log file is later than the operation time of the index information corresponding to the currently read recovery log file in the preset structure, the operation time of the currently read recovery log file is replaced with the preset structure and The operation time corresponding to the index information of the currently read recovery log file, and the step of continuing to read the next recovery log file.
  • obtaining the preset The index information in the structure and the recovery log file corresponding to the operation time, including:
  • index information of the recovery log file that is currently read is the same as the index information of the currently read recovery log file, compare the operation time of the currently read recovery log file with the currently read recovery log in the preset structure.
  • the operation time of the index information of the file is the same as the index information of the currently read recovery log file
  • the currently read recovery log file is added to the filtered Restore the log file and read the next recovery log file;
  • the recovering the information corresponding to the index information and the operation time in the preset structure After the complex log file is used as the filtered recovery log file, it also includes:
  • the filtered recovery log file is sent to each slave server, and the data to be recovered is restored by each slave server according to the filtered recovery log file.
  • a method for recovering data is provided, the method being applied to a primary server of a storage system, the storage system including the primary server and a secondary server, the primary server and the secondary server are both used for storage The same data, the primary server is the first server to successfully store data, and the method includes:
  • a first recovery log file according to the log obtaining request, and causing the primary server to recover the to-be-recovered data according to the first recovery log file and the second recovery log file generated by the primary server;
  • the first recovery log file and the second recovery log file respectively record location information and operation information of the to-be-recovered data identified by the to-be-recovered data identifier.
  • the method before the returning the first recovery log file to the primary server according to the log obtaining request, the method further includes:
  • Second write status information including an identification identifier of the data, where the second write status information includes write success information or write failure information;
  • the total write status information sent by the client includes the write failure information, determining that the data sent by the client is the data to be restored, and generating the first location information and the operation information for recording the data to be restored. Complex log file.
  • the method further includes:
  • a server for recovering data is provided, the server being a primary server applied to a storage system, the storage system including the primary server and a secondary server, the primary server and the secondary server are both used The same data is stored, and the primary server is the first server that successfully stores data, and the server includes:
  • a first sending module configured to send a log obtaining request to each of the slave servers in the storage system when the storage of the data in the storage system fails, where the log obtaining request carries the data identifier to be restored;
  • a first receiving module configured to receive a first recovery log file returned by each slave server according to the log obtaining request, where each first recovery log file records location information of the to-be-recovered data identified by the to-be-recovered data identifier and Operational information;
  • a recovery module configured to perform, according to the latest operation information in the operation information recorded by the first recovery log file and the second recovery log file, the data to be restored according to the location information of the data to be restored
  • the second recovery log file is generated by the primary server, and the location information and operation information of the to-be-recovered data identified by the to-be-recovered data identifier are recorded.
  • the server further includes:
  • a storage module configured to receive and store data sent by the client
  • a returning module configured to return, to the client, first write state information that includes an identifier of the data, where the first write state information includes write success information or write failure information;
  • a second receiving module configured to receive total write status information sent by the client, where the total write status information includes first write status information returned by the primary server to the client, and each slave server Second write status information returned to the client;
  • a generating module configured to: when the total write status information sent by the client includes the write failure information, determine that the data sent by the client is the data to be restored, and generate location information that records the to-be-recovered data and The second recovery log file of the operation information.
  • the recovery module includes:
  • a first reading unit configured to sequentially read each of the first recovery log file and the second recovery log file
  • a determining unit configured to determine whether the index information of the currently read recovery log file is in a preset structure
  • the index information includes a recovery log file identifier, an offset information, and data length information, where the preset structure is used to store index information and an operation time;
  • An adding unit configured to add index information and an operation time of the currently read recovery log file to the preset structure when the index information of the currently read recovery log file is not in the preset structure
  • a second reading unit configured to continue to read the next recovery log file
  • a processing unit configured to process the read next recovery log file in a manner of processing the currently read recovery log file, until the last recovery log file is processed, to obtain a preset structure for storing the duplicate index information and the operation time;
  • An obtaining unit configured to acquire a recovery log file corresponding to the index information and the operation time in the preset structure, and use the recovery log file corresponding to the index information and the operation time in the preset structure as the filtered recovery Log file
  • a recovery unit configured to operate on the restored data according to the operation information in the filtered recovery log file.
  • the recovery module further includes:
  • a comparison unit configured to: when the index information of the currently read recovery log file is in the preset structure, the operation time of the currently read recovery log file and the correspondingly read recovery log file in the preset structure The operation time of the index information is compared;
  • a replacement unit configured to replace the operation time of the currently read recovery log file when the operation time of the currently read recovery log file is later than the operation time of the index information corresponding to the currently read recovery log file in the preset structure The operation time in the preset structure corresponding to the index information of the currently read recovery log file;
  • the second reading unit is further configured to perform the step of continuing to read the next recovery log file.
  • the acquiring unit includes :
  • a first reading subunit configured to sequentially read the first recovery log file and a second recovery log file corresponding to the to-be-recovered data identifier
  • the comparison subunit is configured to compare the index information of the currently read recovery log file with the index information in the preset structure
  • a comparison subunit configured to: when the index information of the recovery log file currently read is the same as the index information of the currently read recovery log file, compare the operation time of the currently read recovery log file with the preset structure The operation time of the index information of the currently read recovery log file;
  • Adding a subunit configured to: when the operation time of the index information corresponding to the currently read recovery log file is the same as the operation time of the currently read recovery log file in the preset structure, the currently read recovery log The file is added to the filtered recovery log file;
  • the second read subunit is configured to read the next recovery log file; and so on, until the last recovery log file is compared, and the recovery log file corresponding to each index information in the preset structure is obtained.
  • the server further includes:
  • the second sending module is configured to send the filtered recovery log file to each slave server, and the slave servers recover the data to be restored according to the filtered recovery log file.
  • a fourth aspect provides a server for recovering data, the server being a slave server applied to a storage system, the storage system including a master server and the slave server, the master server and the slave server are both used The same data is stored, and the primary server is the first server that successfully stores data, and the server includes:
  • a first receiving module configured to receive a log obtaining request sent by the primary server, where the log obtaining request carries a data identifier to be restored;
  • a first returning module configured to return a first recovery log file to the primary server according to the log obtaining request, so that the primary server generates a second recovery log file according to the first recovery log file and the primary server Recovering the data to be recovered;
  • a second receiving module configured to receive the filtered recovery log file sent by the primary server
  • a recovery module configured to perform operation on the restored data according to the operation information recorded by the filtered recovery log file
  • the first recovery log file and the second recovery log file respectively record location information and operation information of the to-be-recovered data identified by the to-be-recovered data identifier.
  • the server further includes:
  • a storage module configured to receive and store data sent by the client
  • a second returning module configured to return, to the client, a second write that includes the identification identifier of the data Entering status information, the second write status information includes write success information or write failure information;
  • a third receiving module configured to receive total write status information sent by the client, where the total write status information includes the second write status information returned from the server to the client, and the primary server First write status information returned to the client;
  • a generating module configured to: when the total write status information sent by the client includes the write failure information, determine that the data sent by the client is the data to be restored, and generate location information that records the to-be-recovered data and The first recovery log file for operational information.
  • a system for recovering data comprising: a primary server and at least one secondary server;
  • the primary server is the first type of server as described above
  • the secondary server is the second type of server as described above.
  • the primary server After the primary server sends a log obtaining request to each slave server in the storage system, the first recovery log file returned by each slave server is received, and the first recovery log file and the second recovery log file generated by the master server are restored to be restored. Data, so you don't need to scan all the data, you can restore data without using a metadata server, and improve the efficiency of restoring data.
  • FIG. 1 is a flowchart of a method for restoring data according to Embodiment 1 of the present invention
  • FIG. 2 is a flowchart of another method for restoring data according to Embodiment 1 of the present invention.
  • FIG. 3 is a flowchart of a method for restoring data according to Embodiment 2 of the present invention.
  • Embodiment 4 is a schematic diagram of an interaction process provided by Embodiment 2 of the present invention.
  • FIG. 5 is a schematic structural diagram of a server for restoring data according to Embodiment 3 of the present invention.
  • FIG. 6 is a schematic structural diagram of a server for recovering data according to Embodiment 4 of the present invention.
  • FIG. 7 is a schematic structural diagram of a system for restoring data according to Embodiment 5 of the present invention.
  • An embodiment of the present invention provides a method for recovering data, where the method is applied to a primary server of a storage system, where the storage system includes a primary server and a secondary server, and the primary server and the secondary server are both used to store the same data, and the primary server is the first
  • the server of the embodiment of the present invention includes:
  • the primary server sends a log obtaining request to each of the secondary servers in the storage system, and the log obtaining request carries the data identifier to be restored.
  • the method before sending a log obtaining request to each slave server in the storage system, the method further includes:
  • the client Receiving and storing the data sent by the client, and returning, to the client, the first write status information that includes the identification identifier of the data, where the first write status information is a write success information or a write failure information;
  • the total write status information sent by the client includes the write failure information, it is determined that the data sent by the client is the data to be restored, and the second recovery log file that records the location information of the data to be restored and the operation information is generated.
  • Step 102 Receive a first recovery log file returned by each slave server according to the log obtaining request, where each first recovery log file records location information and operation information of the to-be-recovered data identified by the to-be-recovered data identifier;
  • the primary server performs and records location information and operation information of the to-be-recovered data identified by the to-be-recovered data identifier.
  • the data is to be restored according to the latest operation information in the operation information recorded by all the first recovery log files and the second recovery log file, including:
  • the recovery log file identifier, the offset information, and the data length information are used, and the preset structure is used to store the index information and the operation time;
  • the index information of the currently read recovery log file is not in the preset structure, the index information and the operation time of the currently read recovery log file are added to the preset structure;
  • the method further includes:
  • the operation time of the currently read recovery log file is later than the operation time of the index information corresponding to the currently read recovery log file in the preset structure, the operation time of the currently read recovery log file is replaced with the preset structure and The operation time corresponding to the index information of the currently read recovery log file, and the step of continuing to read the next recovery log file.
  • the recovery log file corresponding to the index information and the operation time in the preset structure is obtained, including:
  • the first recovery log file and the second recovery log file corresponding to the to-be-recovered data identifier are sequentially read, and the index information of the currently-recovered recovery log file is sequentially compared with the index information in the preset structure.
  • the currently read recovery log file is added to the filtered recovery log. File and read the next recovery log file;
  • the method further includes:
  • the filtered recovery log file is sent to each slave server, and each slave server recovers the data to be restored according to the filtered recovery log file.
  • the method is applied to the primary server of the storage system.
  • the storage system includes a primary server and a secondary server.
  • the primary server and the secondary server are used to store the same data.
  • the primary server is the first server that successfully stores data.
  • the method flow provided by the embodiment of the invention includes:
  • Each slave server receives a log obtaining request sent by the primary server, where the log obtaining request carries the data identifier to be restored;
  • the first recovery log file and the second recovery log file record the location information and operation information of the to-be-recovered data identified by the to-be-recovered data identifier.
  • the method before returning the first recovery log file to the primary server according to the log obtaining request, the method further includes:
  • Second write status information including an identification identifier of the data, where the second write status information includes write success information or write failure information;
  • the total write status information sent by the client includes the write failure information, it is determined that the data sent by the client is the data to be restored, and the first recovery log file that records the location information and the operation information of the data to be restored is generated.
  • the method provided by the embodiment of the present invention after the primary server sends a log obtaining request to each slave server in the storage system, according to the first recovery log file returned by each slave server, and generated according to all the first recovery log files and the primary server.
  • the second recovery log file recovers the data to be recovered, thereby eliminating the need to scan all the data and recovering the data without using a metadata server, thereby improving the efficiency of restoring data.
  • the embodiment of the present invention provides a method for restoring data.
  • the storage system includes a primary server and at least two secondary servers.
  • the primary server is the first server that successfully stores data
  • the secondary server is a server other than the primary server in the storage system. Referring to FIG. 3, the method process provided by this embodiment includes:
  • the primary server and the secondary server respectively receive and store data sent by the client, and the primary server returns, to the client, first write status information including the identification identifier of the data, and returns a second identifier containing the identification identifier of the data from the server to the client.
  • Write status information, the first write status information and the second write status information include write success information or write failure information;
  • the client obtains the data in advance.
  • the manner in which the client obtains data is not specifically limited in this embodiment.
  • the user can write data to the client through the APP (Application), and then the client sends the data to each server.
  • APP Application
  • other methods may be used, which are not specifically limited in this embodiment.
  • the primary server and the secondary server store data through interaction with the client.
  • the interaction process between the primary server and the secondary server and the client adopts a two-phase transaction submission method, which is a preparation phase and a submission phase.
  • the primary server stores the data sent by the client, and returns the first write status information containing the identification identifier of the data to the client, stores the data sent by the client from the server, and returns the identification identifier containing the data to the client.
  • the second write status information that is, step 301 corresponds to the preparation phase.
  • FIG. 4 For ease of understanding, the interaction process shown in FIG. 4 is taken as an example for description.
  • the user writes the data 1 to the client through the APP, the client creates a transaction, and sends the data 1 written by the user to the server 1 to the server 3 respectively.
  • Server 1 to server 3 respectively receive and store data 1 sent by the client, that is, server 1 to server 3 store the same data 1; server 1 and server 2 store data 1 successfully, server 3 fails to store data 1; server 1 and server 2 Returning the write status information including the identifier of the data 1 to the client, the write status information is the write success information; the server 3 returns the write status information including the identifier of the data 1 to the client, where the write status information is a write failure information.
  • the server 1 is the first server that successfully stores the data 1, the server 1 is used as the primary server, and the write status information returned by the server 1 to the client is the first write status information;
  • the server other than the primary server, that is, the server 2 and the server 3 are used as the secondary server, and the write status information returned by the server 2 and the server 3 to the client is used as the second write status information.
  • the primary server and the secondary server respectively receive total write status information sent by the client, and the total write status information includes first write status information returned by the primary server to the client, and second return from each server to the client. Write status information;
  • the primary server Since the primary server returns the first write status information including the identification identifier of the data to the client, the second write status information including the identification identifier of the data is returned from the server to the client, and the client receives the information sent by each server. Writing the total write status information of the status information and the second write status information, and transmitting the total write status information including the write failure information to the server whose write status information is the write success information, thereby causing each server Ability to receive the total write status information sent by the client.
  • the primary server and the secondary server respectively receive the total write status information sent by the client, that is, step 302 corresponds to the submission phase.
  • the interaction process shown in FIG. 4 is still taken as an example for description.
  • the primary server and the secondary server respectively determine that the data sent by the client is data to be restored, and the primary server generates location information and operation information for recording the data to be restored.
  • a second recovery log file, and a first recovery log file for recording location information of the data to be restored and operation information from the server;
  • the total write status information sent by the client includes the write failure information, it indicates that at least one server fails to store data.
  • the primary server and the secondary server respectively determine that the data sent by the client is the data to be restored. .
  • the location information of the data to be recovered recorded in the recovery log file may be offset information, data length information, etc., used to determine the location of the data to be restored; the operation information may be writing data information, deleting data information. Etc., used to describe the operation of the data, this embodiment does not restore the log
  • the location information of the data to be recovered recorded in the file and the content of the operation information are specifically limited.
  • the interaction process shown in FIG. 4 is still taken as an example for description.
  • There are three servers in the storage system namely server 1, server 2 and server 3. Since the server 1, the server 2, and the server 3 receive the total write status information sent by the client including the write failure information, the server 1, the server 2, and the server 3 determine that the data 1 is the data to be restored, and generates the record write data.
  • Recovery log file for location information and operational information. For example, if the server 1 is a master server and the server 2 and the server 3 are slave servers, the server 1 generates a second recovery log file that records location information and operation information of the data to be restored.
  • the server 2 and the server 3 record the error log through the data brush, that is, generate the first recovery log file that records the location information of the data to be restored and the operation information.
  • the interaction process between the client and each server reflects the process of storing data and generating recovery log files for each server.
  • the primary server sends a log obtaining request to each of the secondary servers in the storage system, and the log obtaining request carries the data identifier to be restored.
  • the manner of triggering the primary server to send a log obtaining request to each of the secondary servers in the storage system is not specifically limited in this embodiment.
  • the server periodically checks the recovery log file and starts data recovery, thereby triggering the primary server to send to each slave server in the storage system.
  • the log gets the request.
  • other methods can be employed.
  • the server 1 and the server 2 still store the data 1 successfully, and the server 3 stores the data 1 failure as an example.
  • the server 1 is the main server.
  • the server 1 to the server 3 periodically check the recorded recovery log file, and it is found that the data 1 needs to be restored by checking.
  • a log acquisition request carrying the data identification of the data 1 is transmitted by the server 1 to the server 2 and the server 3.
  • the slave server can directly receive the log obtaining request sent by the master server to the slave server in the storage system.
  • the slave server can directly receive the log obtaining request sent by the master server.
  • the recovery log file is returned according to the to-be-recovered data identifier in the log obtaining request.
  • the server 1 and the server 2 still store the data 1 successfully, and the server 3 stores the data 1 failure as an example.
  • the server 1 is the main server.
  • Server 2 and server 3 Receiving a log obtaining request sent by the server 1, where the log obtaining request carries the data identifier of the data 1.
  • the slave server returns a first recovery log file to the primary server according to the log obtaining request, where the first recovery log file records location information and operation information of the to-be-recovered data identified by the to-be-recovered data identifier.
  • the log obtaining request carries the to-be-recovered data identifier
  • the slave server can search for the recovery log file corresponding to the to-be-recovered data identifier in the recorded recovery log file according to the to-be-recovered data identifier, and return the found recovery log to the primary server. file.
  • the manner in which the recovery log file is searched from the server is not specifically limited in this embodiment.
  • the recorded recovery log file may be sequentially read, and the data identifier in the read recovery log file is compared with the to-be-recovered data identifier carried in the log obtaining request; if the recovered recovery log file is read
  • the data identifier is the same as the to-be-recovered data identifier carried in the log obtaining request.
  • the recovered log file is used as the first recovered log file and returned to the primary server.
  • other methods can be used.
  • the server 1 and the server 2 still store the data 1 successfully, and the server 3 stores the data 1 failure as an example.
  • the server 1 is the main server.
  • the server 2 and the server 3 sequentially read the recovery log file. If the data identifier in the recovered recovery log file 1 is the same as the identifier of the data 1, the recovery log file 1 is used as the first recovery log file found, and Server 1 returns recovery log file 1.
  • the primary server receives the first recovery log file returned by each slave server according to the log obtaining request, and each recovery log file records location information and operation information of the data to be restored.
  • the primary server can directly receive the first recovery log file returned by each secondary server according to the log acquisition request.
  • the server 1 and the server 2 still store the data 1 successfully, and the server 3 stores the data 1 failure as an example.
  • the server 1 is the main server.
  • the server 1 receives the first recovery log file corresponding to the data 1 identifier returned by the server 2 and the server 3 according to the log acquisition request, and each of the first recovery log files records the location information and the operation information of the data 1.
  • the primary server operates, according to the latest operation information in the operation information recorded by the first recovery log file and the second recovery log file, the second recovery log file is generated by the primary server, and the data identifier to be restored is recorded. Location information and operation information of the identified data to be recovered;
  • the server may find the to-be-recovered according to the location information of the data to be restored in each recovery log file.
  • the data is processed according to the latest operation information in the operation information recorded in each recovery log file, thereby realizing data recovery for the data to be restored.
  • the method provided in this embodiment includes, but is not limited to, operating on the data to be restored according to the latest operation information in the operation information recorded by all the first recovery log files and the second recovery log file.
  • index information of the currently read recovery log file is in a preset structure, the index information includes a recovery log file identifier, an offset information, and a data length information, and the preset structure is configured to store the index information and the operation time; If the index information of the currently read recovery log file is not in the preset structure, execute (a3); if the index information of the currently read recovery log file is in the preset structure, execute (a4);
  • the preset structure is an empty structure.
  • the index information and the operation time of the recovery log file that meet the above comparison and comparison requirements are added to the preset structure, so that the preset structure includes the index information and operation of the filtered recovery log file.
  • the time, that is, the obtained preset structure is a preset structure in which the information without the repeated index and the operation time is stored, that is, the index information stored in the preset structure and the operation time do not overlap. Therefore, the recovery log file determined according to the preset structure will be a recovery log file with no repetitive operations.
  • the preset structure By filtering the recovery log file by using the preset structure, the efficiency of the recovery log file filtering is improved, and the workload of restoring the data to be restored according to the filtered recovery log file in the subsequent steps is reduced, and the speed of recovering the data is accelerated.
  • the specific form of the preset structure is not specifically limited in this embodiment.
  • the preset structure includes, but is not limited to, a hash table, a red black tree, and the like.
  • the server 1 is the main server, the first recovery log file 21 and the first recovery log file 22 returned by the server 2, and the first recovery log file 31 returned by the server 3 are taken as an example for description.
  • the first recovery log file 21 records the write data 1, the index information is a1+a2+a3, the operation time is December 12, 2013, 13:22;
  • the first recovery log file 22 records the deletion data 1, the index information For a1+a2+a3, the operation time is December 12, 2013, 13:49;
  • the first recovery log file 31 records the write data 1, the index information is a1+a2+a3, and the operation time is December 2013. 12, 13:22.
  • a1 is the recovery log file identifier
  • a2 is the offset information
  • a3 is the data length information.
  • the server 1 generates a second recovery log file 11 and a second recovery log file 12;
  • the second recovery log file 11 records the written data 1, the index information is a1+a2+a3, and the operation time is December 12, 2013. , 13:22;
  • the second recovery log file 12 records the deletion data 1, the index information is a1+a2+a3, and the operation time is December 12, 2013, 13:49.
  • the server 1 reads the second recovery log file 11. Since the recovery log file filtering has not been performed at this time, the preset structure is an empty structure, and the index information a1+a2+a3 of the second recovery log file 11 and the operation time 2013 are directly directly.
  • the content of the recovery log file operation with a late operation time will overwrite the contents of the recovery log file operation operation time earlier. In this case, it is necessary to perform the operation time later.
  • the log file can be recovered, and it is not necessary to perform an operation log recovery file early.
  • the operation time corresponding to the index information and the index information in the preset structure is unchanged, that is, the operation information corresponding to the index information a1+a2+a3 and the index information a1+a2+a3 is December 12, 2013. 13:49.
  • the client writes a piece of data A to generate a recovery log file; after a period of time, the client deletes a piece of data A previously written, and generates a recovery log file.
  • the operation time of the first recovery log file 22 is On December 12, 2013, 13:49 is compared with the operation time of the index information a1+a2+a3 in the preset structure on December 12, 2013, 13:49; by comparison, the first recovery log file 22 is Operation time December 12, 2013, 13:49
  • the operation time corresponding to the index information a1+a2+a3 in the preset structure is the same on December 12, 2013, 13:49, and continues to read the next first. Restore the log file.
  • the operation time corresponding to the index information and the index information in the preset structure is unchanged, that is, the operation information corresponding to the index information a1+a2+a3 and the index information a1+a2+a3 is December 12, 2013. 13:49.
  • the first recovery log file 31 is read, and the index information a1+a2+a3 of the first recovery log file 31 is determined to be in the preset structure, and the operation time of the first recovery log file 31 is December 12, 2013, 13: 22 is compared with the operation time of the index information a1+a2+a3 in the preset structure on December 12, 2013, 13:49; by comparison, the operation time of the first recovery log file 31 is December 12, 2013, 13:22
  • the operation time corresponding to the index information a1+a2+a3 in the preset structure is December 12, 2013, 13:49, and the next first recovery log file is continuously read. So far, the received first recovery log files 21, 22, 31 and the second recovery log files 11, 12 generated by the server 1 corresponding to the data 1 identification have been processed.
  • the preset structure includes the index information a1+a2+a3 and the operation time corresponding to the index information a1+a2+a3 on December 12, 2013, 13:49.
  • the recovery log file corresponding to the index information and the operation time in the preset structure is obtained in (a7), including but not limited to:
  • the operation time corresponding to the index information a1+a2+a3 and the index information a1+a2+a3 in the preset structure is December 12, 2013, 13:49 as an example.
  • the second recovery log file 11 is read, and the index information a1+a2+a3 of the second recovery log file 11 is compared with the index information a1+a2+a3 in the preset structure, and it is known that the preset structure exists and the second Restoring the same index information of the index information a1+a2+a3 of the log file 11; continuing to compare the operations of the second recovery log file 11 At the time of December 12, 2013, 13:22 and the operation time of the index information a1+a2+a3 in the preset structure, December 12, 2013, 13:49, by comparison, it is known that the preset structure does not exist and The operation time of the recovery log file 11 is the same operation time on December 12, 2013, 13:22, and the next recovery log file is continuously read.
  • the second recovery log file 12 is read, and the index information a1+a2+a3 of the second recovery log file 12 is compared with the index information a1+a2+a3 in the preset structure, and it is known that the preset structure exists and the second Restoring the same index information of the index information a1+a2+a3 of the log file 12; continuing to compare the operation time of the second recovery log file 12 on December 12, 2013, 13:49 with the index information a1+a2+ in the preset structure
  • the operation time of a3 is December 12, 2013, 13:49.
  • the second recovery log file 12 is added to the filtered recovery log file and continues to read the next recovery log file.
  • the index information and the operation time of the first recovery log files 21, 22, and 31 are compared with the index information and the operation time in the preset structure, and the first recovery log file is not obtained. Therefore, only The second recovery log file 12 is used as the filtered recovery log file.
  • the data to be restored may be operated according to the operation information recorded in the filtered recovery log file.
  • the manner of restoring data is not specifically limited in this embodiment.
  • the data may be re-operated by the primary server according to the operation information of the data to be recovered recorded in the recovery log file.
  • other methods can be employed.
  • a plurality of log information of the data to be restored may be recorded in a recovery log file. For this case, each log information of the data to be restored may be sequentially read by the primary server, and according to each log information of the data to be restored. The operational information re-operates on the data.
  • the filtered log file is a recovery log file 12 as an example.
  • the operation of deleting the data 1 is recorded in the recovery log file 12, and the server 1 can perform the operation of deleting the data 1 to complete the data recovery.
  • the primary server sends the filtered recovery log file to each slave server, and each slave server operates the data to be restored according to the operation information in the filtered recovery log file.
  • the method provided in this embodiment further includes, but is not limited to, the primary server sending the filtered recovery log file to each slave server, in order to improve the speed of restoring data in the storage system.
  • each slave server is based on the filtered recovery log.
  • the file is restored in parallel with the recovered data, so that the data can be recovered without the metadata server, which not only reduces the load of the metadata server, but also improves the speed of data recovery.
  • the filtered recovery log file is the second recovery log file 12 as an example.
  • the server 1 transmits the second recovery log file 12 to the server 2 and the server 3, and the server 2 and the server 3 restore the data 1 based on the second recovery log file 12.
  • the method provided in this embodiment further includes, but is not limited to, the primary server deleting all the first recovery log files and the second recovery log files, and notifying each of the secondary servers to delete all the first recovery log files and the first Second recovery log file;
  • the primary server Since the primary server has completed data recovery, there is no need to record the recovery log file for the recovered data, and in order to save the storage resources in the primary server, the primary server deletes all the first recovery log files and the second recovery log files.
  • the primary server will notify each slave server to delete all the first recovery log files and the second recovery log files for recovering the data to be restored after successfully recovering the data.
  • the embodiment is not specifically limited.
  • the slave server may be notified by sending a delete message to the slave server.
  • other methods can be employed.
  • the slave server may perform the recovery data according to the filtered recovery log file. restore.
  • the manner of restoring data refer to the manner in which the primary server recovers the data to be restored according to the filtered recovery log file in the foregoing step 308, and details are not described herein again.
  • the method provided in this embodiment further includes, but is not limited to, receiving, from the server, a notification sent by the primary server to delete all the first recovery log files and the second recovery log file, and deleting all the first recovery according to the notification.
  • the log file and the second recovery log file are not limited to, receiving, from the server, a notification sent by the primary server to delete all the first recovery log files and the second recovery log file, and deleting all the first recovery according to the notification.
  • the secondary server may receive a notification sent by the primary server to delete all the first recovery log files and the second recovery log files, thereby triggering the notification according to the notification. After successfully recovering the data, delete all the first recovery log files and the second recovery log files.
  • the method provided in this embodiment sends the date to each slave server in the storage system through the primary server. Acquiring the request, receiving the first recovery log file returned by each slave server, and restoring the data to be recovered to recover the data to be recovered according to all the first recovery log files and the second recovery log file generated by the main server, thereby eliminating the need to scan all data, Recover data without using a metadata server, improving the efficiency of restoring data.
  • an embodiment of the present invention provides a server for recovering data, which is a primary server applied to a storage system, where the storage system includes a primary server and a secondary server, and both the primary server and the secondary server are used to store the same data.
  • the server is the first server to successfully store data, and the server includes:
  • the first sending module 401 is configured to send a log obtaining request to each slave server in the storage system when the storage server fails to store data in the storage system, where the log obtaining request carries the data identifier to be restored;
  • the first receiving module 402 is configured to receive a first recovery log file returned by each slave server according to the log obtaining request, where each first recovery log file records location information and operation information of the to-be-recovered data identified by the to-be-recovered data identifier;
  • the recovery module 403 is configured to perform operation on the restored data according to the latest operation information in the operation information recorded by all the first recovery log files and the second recovery log file, and the data to be restored is searched according to the location information of the data to be restored, and the second The recovery log file is generated by the primary server, and records the location information and operation information of the data to be recovered identified by the data identifier to be restored.
  • the server further includes:
  • a storage module configured to receive and store data sent by the client
  • a returning module configured to return, to the client, first write state information that includes an identification identifier of the data, where the first write state information includes a write success information or a write failure information;
  • a second receiving module configured to receive total write status information sent by the client, where the total write status information includes first write status information returned by the primary server to the client, and second write returned from the server to the client. Status information;
  • a generating module configured to: when the total write status information sent by the client includes the write failure information, determine that the data sent by the client is the data to be restored, and generate a second recovery of the location information and the operation information for recording the data to be restored. Log file.
  • the recovery module 403 includes:
  • a first reading unit configured to sequentially read each of the first recovery log file and the second recovery log file
  • the determining unit is configured to determine whether the index information of the currently read recovery log file is in a preset structure, the index information includes a recovery log file identifier, an offset information, and a data length information, and the preset structure stores the index information and the operation time. ;
  • a second reading unit configured to continue to read the next recovery log file
  • a processing unit configured to process the read next recovery log file in a manner of processing the currently read recovery log file, until the last recovery log file is processed, to obtain a preset structure for storing the duplicate index information and the operation time;
  • the obtaining unit is configured to obtain a recovery log file corresponding to the index information and the operation time in the preset structure, and use the recovery log file corresponding to the index information and the operation time in the preset structure as the filtered recovery log file;
  • a recovery unit configured to operate on the restored data according to the operation information in the filtered recovery log file.
  • the recovery module 403 further includes:
  • a comparison unit configured to: when the index information of the currently read recovery log file is in the preset structure, the operation time of the currently read recovery log file and the index information of the currently read recovery log file in the preset structure Comparison of operating time;
  • a replacement unit configured to replace the operation time of the currently read recovery log file when the operation time of the currently read recovery log file is later than the operation time of the index information corresponding to the currently read recovery log file in the preset structure The operation time in the preset structure corresponding to the index information of the currently read recovery log file;
  • the second reading unit is further configured to perform the step of continuing to read the next recovery log file.
  • the obtaining unit includes:
  • a first reading subunit configured to sequentially read the first recovery log file and the second recovery log file corresponding to the to-be-recovered data identifier
  • the comparison subunit is configured to compare the index information of the currently read recovery log file with the index information in the preset structure
  • Comparison subunit for indexing information in the default structure that exists with the currently read recovery log file When the same index information is used, the operation time of the currently read recovery log file and the operation time of the index information corresponding to the currently read recovery log file in the preset structure are compared;
  • the second read subunit is configured to read the next recovery log file; and so on until the last recovery log file is compared, and the recovery log file corresponding to each index information in the preset structure is obtained.
  • the server further includes:
  • the second sending module is configured to send the filtered recovery log file to each slave server, and each slave server recovers the data to be restored according to the filtered recovery log file.
  • the server further includes:
  • the notification module is configured to notify each of the slave servers to delete all the first recovery log files and the second recovery log files.
  • the server provided by the embodiment of the present invention receives the first recovery log file returned by each slave server by sending a log acquisition request to each slave server in the storage system, and generates a second recovery according to all the first recovery log files and the primary server.
  • the log file recovers the data to be recovered, so that it is not necessary to scan all the data, and the metadata server can be used to recover the data, which improves the efficiency of restoring data.
  • an embodiment of the present invention provides a server for recovering data, which is a slave server applied to a storage system, where the storage system includes a primary server and a secondary server, and both the primary server and the secondary server are used to store the same data.
  • the server is the first server to successfully store data, and the server includes:
  • the first receiving module 501 is configured to receive a log obtaining request sent by the primary server, where the log obtaining request carries the data identifier to be restored;
  • the first returning module 502 is configured to return a first recovery log file to the primary server according to the log obtaining request, so that the primary server recovers the to-be-recovered data according to the first recovery log file and the second recovery log file generated by the primary server;
  • the second receiving module 503 is configured to receive the filtered recovery log file sent by the primary server.
  • the recovery module 504 is configured to perform operation on the restored data according to the operation information recorded by the filtered recovery log file;
  • the first recovery log file and the second recovery log file record the location information and operation information of the to-be-recovered data identified by the to-be-recovered data identifier.
  • the server further includes:
  • a storage module configured to receive and store data sent by the client
  • a second returning module configured to return, to the client, second writing state information that includes an identification identifier of the data, where the second writing state information includes a writing success information or a writing failure information;
  • a third receiving module configured to receive total write status information sent by the client, where the total write status information includes second write status information returned from the server to the client, and a first write status returned by the primary server to the client information;
  • a generating module configured to: when the total write status information sent by the client includes the write failure information, determine that the data sent by the client is the data to be restored, and generate the first recovery of the location information and the operation information of the data to be restored. Log file.
  • the server further includes:
  • a fourth receiving module configured to receive a notification sent by the primary server to delete all the first recovery log files and the second recovery log files
  • the deleting module is configured to delete all the first recovery log files and the second recovery log files according to the notification.
  • the server provided in this embodiment receives the log obtaining request sent by the primary server, and returns a first recovery log file to the primary server according to the log obtaining request, so that the primary server generates the second recovery log according to the first recovery log file and the primary server.
  • the file recovers the data to be recovered, so that it is not necessary to scan all the data, and the metadata server can be used to recover the data, which improves the efficiency of restoring data.
  • an embodiment of the present invention provides a system for recovering data, where the system includes a main server 701 and at least one slave server 702.
  • the master server 701 is a server for recovering data provided by the foregoing third embodiment.
  • the server 702 is the server for restoring data provided in the above-mentioned fourth embodiment.
  • the system provided by this embodiment sends the date to each slave server in the storage system through the primary server. Acquire the request, receive the first recovery log file returned from each server, and recover the data to be restored according to all the first recovery log files and the second recovery log file generated by the primary server, thereby eliminating the need to scan all data and use metadata
  • the server can recover data and improve the efficiency of data recovery.
  • the embodiment of the present invention provides a server for recovering data, which is a primary server applied to a storage system, where the storage system includes a primary server and a secondary server, and the primary server and the secondary server are both used to store the same data, and the primary server is the first server.
  • a server that successfully stores data the server including a transmitter, a receiver, and a processor;
  • the transmitter is configured to send a log obtaining request to each slave server in the storage system when the server fails to store data in the storage system, and the log obtaining request carries the data identifier to be restored.
  • a receiver configured to receive a first recovery log file returned by each slave server according to the log obtaining request, where each first recovery log file records location information and operation information of the to-be-recovered data identified by the to-be-recovered data identifier;
  • a processor configured to perform, according to the latest operation information in the operation information recorded by the first recovery log file and the second recovery log file, the data to be restored is searched according to the location information of the data to be restored, and the second recovery is performed.
  • the log file is generated by the primary server, and records the location information and operation information of the data to be recovered identified by the data identifier to be restored.
  • the processor is further configured to receive and store data sent by the client;
  • the transmitter is further configured to return, to the client, first write status information that includes an identification identifier of the data, where the first write status information includes write success information or write failure information;
  • the receiver is further configured to receive total write status information sent by the client, where the total write status information includes first write status information returned by the primary server to the client, and second write each returned from the server to the client. status information;
  • the processor is further configured to: when the total write status information sent by the client includes the write failure information, determine the data as the data to be restored, and generate a second recovery log file that records the location information and the operation information of the data to be restored.
  • the processor is configured to sequentially read each of the first recovery log file and the second recovery log file, and determine whether the index information of the currently read recovery log file is in a preset structure.
  • the index information includes a recovery log file identifier, an offset information, and a data length information, and the preset structure is used to store the index information and the operation time; when the index information of the currently read recovery log file is not in the preset structure, Adding the index information and operation time of the currently read recovery log file to the preset structure; continuing to read the next recovery log file; processing the next recovery log file read in the same manner as processing the currently read recovery log file Until the last recovery log file is processed, obtaining a preset structure for storing the duplicate index information and the operation time; acquiring the recovery log file corresponding to the index information and the operation time in the preset structure, and the preset structure is The index information and the recovery log file corresponding to the operation time are used as the filtered recovery log file, and the data to be restored is operated according to the operation information in the filtered
  • the processor is further configured to: when the index information of the currently read recovery log file is in the preset structure, compare the operation time of the currently read recovery log file with the current current in the preset structure. The operation time of the index information of the read recovery log file is compared; when the operation time of the currently read recovery log file is later than the operation time of the index information corresponding to the currently read recovery log file in the preset structure, the current The operation time of the read recovery log file replaces the operation time in the preset structure corresponding to the index information of the currently read recovery log file; and the step of continuing to read the next recovery log file is performed.
  • the processor is configured to sequentially read the first recovery log file and the second recovery log file corresponding to the to-be-recovered data identifier; and sequentially, the index information of the currently read recovery log file is The index information in the structure is compared; when there is the same index information in the preset structure as the index information of the currently read recovery log file, the operation time of the currently read recovery log file is compared with the preset structure.
  • the operation time of the index information of the currently read recovery log file when there is an operation time corresponding to the operation time of the currently read recovery log file in the preset structure corresponding to the index information of the currently read recovery log file, The currently read recovery log file is added to the filtered recovery log file; the next recovery log file is read; and so on, until the last recovery log file is compared, and each index information in the preset structure is obtained.
  • Recovery log file when there is an operation time corresponding to the operation time of the currently read recovery log file in the preset structure corresponding to the index information of the currently read recovery log file, The currently read recovery log file is added to the filtered recovery log file; the next recovery log file is read; and so on, until the last recovery log file is compared, and each index information in the preset structure is obtained.
  • the transmitter is further configured to send the filtered recovery log file to each slave server, and each slave server recovers the data to be restored according to the filtered recovery log file.
  • the processor is further configured to delete all the first recovery log files and the second recovery log files; notify each of the slave servers to delete all the first recovery log files and the second recovery log. file.
  • the server provided by the embodiment of the present invention receives the first recovery log file returned by each slave server in the storage system according to the log obtaining request sent by the primary server, and according to all the first recovery log files and the second recovery log generated by the primary server.
  • the file recovers the data to be recovered, so that it is not necessary to scan all the data, and the metadata server can be used to recover the data, which improves the efficiency of restoring data.
  • the embodiment of the invention provides a server for recovering data
  • the server is a slave server applied to the storage system
  • the storage system includes a master server and a slave server
  • the master server and the slave server are both used to store the same data
  • the master server is the first server.
  • a server that successfully stores data the server including a transmitter, a receiver, and a processor;
  • the receiver is configured to receive a log obtaining request sent by the primary server, where the log obtaining request carries the data identifier to be restored;
  • a transmitter configured to return a first recovery log file to the primary server according to the log obtaining request, so that the primary server recovers the to-be-recovered data according to the first recovery log file and the second recovery log file generated by the primary server;
  • the receiver is further configured to receive the filtered recovery log file sent by the primary server;
  • a processor configured to perform operation on the restored data according to the operation information recorded by the filtered recovery log file
  • Each of the first recovery log file and the second recovery log file records location information and operation information of the to-be-recovered data identified by the to-be-recovered data identifier.
  • the processor is further configured to receive and store data sent by the client;
  • the transmitter is further configured to return, to the client, second write status information that includes an identification identifier of the data, where the second write status information includes write success information or write failure information;
  • the receiver is further configured to receive total write status information sent by the client, where the total write status information includes second write status information returned from the server to the client, and first write status information returned by the primary server to the client. ;
  • the processor is further configured to: when the total write status information sent by the client includes the write failure information, determine that the data sent by the client is the data to be restored, and generate the first location information and operation information for recording the data to be restored. Restore the log file.
  • the receiver is further configured to receive all the first deletions sent by the primary server. Notification of recovery log file and second recovery log file;
  • the processor is further configured to delete all the first recovery log files and the second recovery log files according to the notification.
  • the server provided by the embodiment of the present invention receives the log obtaining request sent by the primary server, and returns a first recovery log file to the primary server according to the log obtaining request, so that the primary server generates the second recovery according to the first recovery log file and the primary server.
  • the log file recovers the data to be recovered, so that it is not necessary to scan all the data, and the metadata server can be used to recover the data, which improves the efficiency of restoring data.
  • the server for restoring data provided by the foregoing embodiment is only illustrated by dividing the foregoing functional modules. In actual applications, the function allocation may be completed by different functional modules as needed. The internal structure of the server is divided into different functional modules to complete all or part of the functions described above.
  • the server for restoring data and the method for restoring data provided by the foregoing embodiments are in the same concept, and the specific implementation process is described in detail in the method embodiment, and details are not described herein again.
  • a person skilled in the art may understand that all or part of the steps of implementing the above embodiments may be completed by hardware, or may be instructed by a program to execute related hardware, and the program may be stored in a computer readable storage medium.
  • the storage medium mentioned may be a read only memory, a magnetic disk or an optical disk or the like.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The present invention relates to the field of information technologies. Disclosed are a method, server and system for data recovery. The method comprises: a master server receiving first recovery log files returned by slave servers in a storage system according to a log acquisition request sent by the master server, and performing an operation on to-be-recovered data according to latest operation information recorded in all the first recovery log files and in a second recovery log file generated by the master server, the first recovery log files and the second recovery log file recording location information and operation information of the to-be-recovered data identified by a to-be-recovered data identifier. In the present invention, the master server sends a log acquisition request to the slave servers in the storage system and then recovers to-be-recovered data according to all first recovery log files returned by the slave servers and a second recovery log file generated by the master server, so that data recovery can be realized without scanning all data or using a metadata server, and the data recovery efficiency is improved.

Description

恢复数据的方法、服务器及系统Method, server and system for restoring data
本申请要求于2013年12月31日提交中国专利局、申请号201310754520.7、发明名称为“恢复数据的方法、服务器及系统”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。The present application claims priority to Chinese Patent Application No. 20131075452, filed on Dec. 31, 2013, the entire disclosure of which is incorporated herein by reference. .
技术领域Technical field
本发明涉及信息技术领域,特别涉及一种恢复数据的方法、服务器及系统。The present invention relates to the field of information technology, and in particular, to a method, a server, and a system for recovering data.
背景技术Background technique
随着信息技术的不断发展,存储系统的规模越来越大。在大规模的存储系统中,器件发生故障的频率也随之增加。在器件发生故障时,如何恢复数据,从而保证数据的安全成为人们关注的问题。With the continuous development of information technology, the scale of storage systems is growing. In large-scale storage systems, the frequency of device failures also increases. In the event of a device failure, how to recover data to ensure data security has become a concern.
目前,有三种恢复数据的方式,第一种方式:通过fsck命令扫描文件系统来查找待恢复数据,并恢复待恢复数据。第二种方式:通过元数据服务器读取系统操作日志中的待恢复数据的日志信息,并根据读取到的待恢复数据的日志信息控制数据服务器重新执行对数据的操作,从而恢复数据。第三种方式:通过元数据服务器读取待恢复数据的日志信息,并根据读取到的待恢复的日志信息控制数据服务器重新执行对数据的操作,从而恢复数据。Currently, there are three ways to recover data. The first method is to scan the file system by the fsck command to find the data to be recovered and restore the data to be recovered. The second method is: reading the log information of the data to be restored in the system operation log through the metadata server, and controlling the data server to perform the operation on the data according to the read log information of the data to be restored, thereby restoring the data. The third method is: reading the log information of the data to be restored through the metadata server, and controlling the data server to perform the operation on the data according to the read log information to be restored, thereby restoring the data.
现有技术至少存在以下问题:The prior art has at least the following problems:
第一种方式需要扫描所有的数据,造成系统资源的浪费。第二种方式和第三种方式,都需要使用元数据服务器恢复数据,而元数据服务器恢复数据的速度较慢,致使恢复数据的效率较低。The first way is to scan all the data, causing a waste of system resources. The second and third methods require the metadata server to recover data, while the metadata server recovers data at a slower rate, resulting in less efficient data recovery.
发明内容Summary of the invention
本发明实施例提供了一种恢复数据的方法、服务器及系统,可以解决现有技术的问题。所述技术方案如下:The embodiment of the invention provides a method, a server and a system for restoring data, which can solve the problems of the prior art. The technical solution is as follows:
第一方面,提供了一种恢复数据的方法,所述方法应用于存储系统的主服务器,所述存储系统包括主服务器和从服务器,所述主服务器和所述从服务器均用于存储相同数据,所述主服务器为第一个成功存储数据的服务器,所述方法包括:In a first aspect, a method for recovering data is provided, the method being applied to a primary server of a storage system, the storage system including a primary server and a secondary server, both the primary server and the secondary server are configured to store the same data The primary server is the first server that successfully stores data, and the method includes:
当所述存储系统中的任意一个服务器存储数据失败时,所述主服务器向所 述存储系统中的每个从服务器发送日志获取请求,所述日志获取请求中携带待恢复数据标识;When any one of the storage systems fails to store data, the primary server is Each of the storage systems sends a log obtaining request, where the log obtaining request carries the data identifier to be restored;
接收各个从服务器根据所述日志获取请求返回的第一恢复日志文件,每个第一恢复日志文件记录了所述待恢复数据标识所标识的待恢复数据的位置信息及操作信息;Receiving, by the respective slave server, the first recovery log file returned according to the log obtaining request, where each first recovery log file records location information and operation information of the to-be-recovered data identified by the to-be-recovered data identifier;
根据所有所述第一恢复日志文件及第二恢复日志文件所记录的操作信息中的最新操作信息对待恢复数据进行操作,所述待恢复数据根据所述待恢复数据的位置信息查找得到,所述第二恢复日志文件由所述主服务器生成,且记录了所述待恢复数据标识所标识的待恢复数据的位置信息及操作信息。And operating the restored data according to the latest operation information in the operation information recorded by the first recovery log file and the second recovery log file, where the to-be-recovered data is searched according to the location information of the to-be-recovered data, The second recovery log file is generated by the primary server, and records location information and operation information of the to-be-recovered data identified by the to-be-recovered data identifier.
结合第一方面,在第一方面的第一种可能的实现方式中,所述向所述存储系统中的每个从服务器发送日志获取请求之前,还包括:In conjunction with the first aspect, in a first possible implementation manner of the first aspect, before the sending a log obtaining request to the server in the storage system, the method further includes:
接收并存储客户端发送的数据,并向所述客户端返回包含所述数据的识别标识的第一写入状态信息,所述第一写入状态信息为写入成功信息或写入失败信息;Receiving and storing data sent by the client, and returning, to the client, first write status information that includes the identification identifier of the data, where the first write status information is write success information or write failure information;
接收所述客户端发送的总写入状态信息,所述总写入状态信息包括所述主服务器向所述客户端返回的第一写入状态信息及每个从服务器向所述客户端返回的第二写入状态信息;Receiving total write status information sent by the client, where the total write status information includes first write status information returned by the primary server to the client, and each slave server returns to the client Second write status information;
如果所述客户端发送的总写入状态信息中包含写入失败信息,则确定所述客户端发送的数据为待恢复数据,并生成记录所述待恢复数据的位置信息及操作信息的第二恢复日志文件。If the total write status information sent by the client includes the write failure information, determining that the data sent by the client is the data to be restored, and generating the second location information and the operation information for recording the data to be restored. Restore the log file.
结合第一方面,在第一方面的第二种可能的实现方式中,所述根据所有所述第一恢复日志文件及第二恢复日志文件所记录的操作信息中的最新操作信息对待恢复数据进行操作,包括:With reference to the first aspect, in a second possible implementation manner of the first aspect, the performing the data to be restored according to the latest operation information in the operation information recorded by all the first recovery log file and the second recovery log file Operations, including:
依次读取每个所述第一恢复日志文件及第二恢复日志文件;Reading each of the first recovery log file and the second recovery log file in sequence;
判断当前读取的恢复日志文件的索引信息是否在预设结构中,所述索引信息包括恢复日志文件标识、偏移量信息及数据长度信息,所述预设结构存储有索引信息及操作时间;Determining whether the index information of the currently read recovery log file is in a preset structure, the index information includes a recovery log file identifier, an offset information, and data length information, where the preset structure stores index information and an operation time;
若当前读取的恢复日志文件的索引信息未在所述预设结构中,则将当前读取的恢复日志文件的索引信息及操作时间添加到所述预设结构中;If the index information of the currently read recovery log file is not in the preset structure, adding the index information and the operation time of the currently read recovery log file to the preset structure;
继续读取下一个恢复日志文件,按照处理当前读取的恢复日志文件的方式处理读取的下一个恢复日志文件,直至处理完最后一个恢复日志文件,得到存 储有无重复索引信息及操作时间的预设结构;Continue to read the next recovery log file, process the next recovery log file read in the same way as the currently read recovery log file, until the last recovery log file is processed, and the file is saved. Prestored with or without repeated index information and operation time;
获取与所述预设结构中的索引信息及操作时间对应的恢复日志文件,并将与所述预设结构中的索引信息及操作时间对应的恢复日志文件作为筛选出的恢复日志文件,根据筛选出的恢复日志文件中的操作信息对待恢复数据进行操作。Obtaining a recovery log file corresponding to the index information and the operation time in the preset structure, and using the recovery log file corresponding to the index information and the operation time in the preset structure as the filtered recovery log file, according to the screening The operation information in the recovery log file is operated on the data to be restored.
结合第一方面至第一方面的第二种可能的实现方式,在第一方面的第三种可能的实现方式中,所述判断当前读取的恢复日志文件的索引信息是否在预设结构中之后,还包括:With reference to the first aspect to the second possible implementation of the first aspect, in a third possible implementation manner of the first aspect, the determining whether the index information of the currently read recovery log file is in a preset structure After that, it also includes:
若当前读取的恢复日志文件的索引信息在预设结构中,则将当前读取的恢复日志文件的操作时间与所述预设结构中对应当前读取的恢复日志文件的索引信息的操作时间进行比较;If the index information of the currently read recovery log file is in the preset structure, the operation time of the currently read recovery log file and the operation time of the index information corresponding to the currently read recovery log file in the preset structure Compare;
若当前读取的恢复日志文件的操作时间晚于预设结构中对应当前读取的恢复日志文件的索引信息的操作时间,则将当前读取的恢复日志文件的操作时间替换预设结构中与当前读取的恢复日志文件的索引信息相对应的操作时间,并执行继续读取下一个恢复日志文件的步骤。If the operation time of the currently read recovery log file is later than the operation time of the index information corresponding to the currently read recovery log file in the preset structure, the operation time of the currently read recovery log file is replaced with the preset structure and The operation time corresponding to the index information of the currently read recovery log file, and the step of continuing to read the next recovery log file.
结合第一方面至第一方面的第二种或第三种可能的实现方式中的任一种可能的实现方式,在第一方面的第四种可能的实现方式中,获取与所述预设结构中的索引信息及操作时间对应的恢复日志文件,包括:In combination with the first aspect to the second or the third possible implementation of the first aspect, in a fourth possible implementation of the first aspect, obtaining the preset The index information in the structure and the recovery log file corresponding to the operation time, including:
依次读取所述第一恢复日志文件及与所述待恢复数据标识相对应的第二恢复日志文件,并将当前读取的恢复日志文件的索引信息依次与预设结构中的索引信息进行比对;And sequentially reading the first recovery log file and the second recovery log file corresponding to the to-be-recovered data identifier, and sequentially comparing the index information of the currently read recovery log file with the index information in the preset structure. Correct;
若所述预设结构中存在与当前读取的恢复日志文件的索引信息相同的索引信息,则比较当前读取的恢复日志文件的操作时间与所述预设结构中对应当前读取的恢复日志文件的索引信息的操作时间;If the index information of the recovery log file that is currently read is the same as the index information of the currently read recovery log file, compare the operation time of the currently read recovery log file with the currently read recovery log in the preset structure. The operation time of the index information of the file;
若所述预设结构中存在与当前读取的恢复日志文件的操作时间相同的对应当前读取的恢复日志文件的索引信息的操作时间,则将当前读取的恢复日志文件添加到筛选出的恢复日志文件中,并读取下一个恢复日志文件;If the operation time of the index information corresponding to the currently read recovery log file is the same as the operation time of the currently read recovery log file in the preset structure, the currently read recovery log file is added to the filtered Restore the log file and read the next recovery log file;
以此类推,直至比对完最后一个恢复日志文件,得到所述预设结构中的每个索引信息对应的恢复日志文件。And so on, until the last recovery log file is compared, the recovery log file corresponding to each index information in the preset structure is obtained.
结合第一方面至第一方面的第二种可能的实现方式,在第一方面的第五种可能的实现方式中,所述将与所述预设结构中的索引信息及操作时间对应的恢 复日志文件作为筛选出的恢复日志文件之后,还包括:With reference to the first aspect to the second possible implementation of the first aspect, in a fifth possible implementation manner of the first aspect, the recovering the information corresponding to the index information and the operation time in the preset structure After the complex log file is used as the filtered recovery log file, it also includes:
将筛选出的恢复日志文件发送给各个从服务器,由各个从服务器根据所述筛选出的恢复日志文件对所述待恢复数据进行恢复。The filtered recovery log file is sent to each slave server, and the data to be recovered is restored by each slave server according to the filtered recovery log file.
第二方面,提供了一种恢复数据的方法,所述方法应用于存储系统的主服务器,所述存储系统包括所述主服务器和从服务器,所述主服务器和所述从服务器均用于存储相同数据,所述主服务器为第一个成功存储数据的服务器,所述方法包括:In a second aspect, a method for recovering data is provided, the method being applied to a primary server of a storage system, the storage system including the primary server and a secondary server, the primary server and the secondary server are both used for storage The same data, the primary server is the first server to successfully store data, and the method includes:
每个从服务器接收所述主服务器发送的日志获取请求,所述日志获取请求中携带待恢复数据标识;Receiving, by the server, a log obtaining request sent by the primary server, where the log obtaining request carries a data identifier to be restored;
根据所述日志获取请求向所述主服务器返回第一恢复日志文件,使所述主服务器根据所述第一恢复日志文件及所述主服务器生成的第二恢复日志文件恢复所述待恢复数据;Returning, to the primary server, a first recovery log file according to the log obtaining request, and causing the primary server to recover the to-be-recovered data according to the first recovery log file and the second recovery log file generated by the primary server;
接收所述主服务器发送的筛选出的恢复日志文件,并根据所述筛选出的恢复日志文件所记录的操作信息对待恢复数据进行操作;Receiving the filtered recovery log file sent by the primary server, and operating the restored data according to the operation information recorded by the filtered recovery log file;
其中,所述第一恢复日志文件及所述第二恢复日志文件均记录了所述待恢复数据标识所标识的待恢复数据的位置信息及操作信息。The first recovery log file and the second recovery log file respectively record location information and operation information of the to-be-recovered data identified by the to-be-recovered data identifier.
结合第二方面,在第二方面的第一种可能的实现方式中,所述根据所述日志获取请求向所述主服务器返回第一恢复日志文件之前,还包括:With reference to the second aspect, in a first possible implementation manner of the second aspect, before the returning the first recovery log file to the primary server according to the log obtaining request, the method further includes:
接收并存储客户端发送的数据,并向所述客户端返回包含所述数据的识别标识的第二写入状态信息,所述第二写入状态信息包括写入成功信息或写入失败信息;Receiving and storing data sent by the client, and returning, to the client, second write status information including an identification identifier of the data, where the second write status information includes write success information or write failure information;
接收所述客户端发送的总写入状态信息,所述总写入状态信息包括所述从服务器向所述客户端返回的第二写入状态信息及所述主服务器向所述客户端返回的第一写入状态信息;Receiving total write status information sent by the client, where the total write status information includes the second write status information returned from the server to the client, and the return of the primary server to the client First write status information;
如果所述客户端发送的总写入状态信息中包含写入失败信息,则确定所述客户端发送的数据为待恢复数据,并生成记录所述待恢复数据的位置信息及操作信息的第一复日志文件。If the total write status information sent by the client includes the write failure information, determining that the data sent by the client is the data to be restored, and generating the first location information and the operation information for recording the data to be restored. Complex log file.
结合第二方面,在第二方面的第二种可能的实现方式中,所述根据所述日志获取请求向所述主服务器返回第一恢复日志文件之后,还包括:With reference to the second aspect, in a second possible implementation manner of the second aspect, after the returning the first recovery log file to the primary server according to the log obtaining request, the method further includes:
接收所述主服务器发送的筛选出的恢复日志文件,并根据所述筛选出的恢复日志文件对所述待恢复数据进行恢复。 Receiving the filtered recovery log file sent by the primary server, and recovering the to-be-recovered data according to the filtered recovery log file.
第三方面,提供了一种恢复数据的服务器,所述服务器为应用于存储系统的主服务器,所述存储系统包括所述主服务器和从服务器,所述主服务器和所述从服务器均用于存储相同数据,所述主服务器为第一个成功存储数据的服务器,所述服务器包括:In a third aspect, a server for recovering data is provided, the server being a primary server applied to a storage system, the storage system including the primary server and a secondary server, the primary server and the secondary server are both used The same data is stored, and the primary server is the first server that successfully stores data, and the server includes:
第一发送模块,用于当所述存储系统中的任意一个服务器存储数据失败时,向所述存储系统中的每个从服务器发送日志获取请求,所述日志获取请求中携带待恢复数据标识;a first sending module, configured to send a log obtaining request to each of the slave servers in the storage system when the storage of the data in the storage system fails, where the log obtaining request carries the data identifier to be restored;
第一接收模块,用于接收各个从服务器根据所述日志获取请求返回的第一恢复日志文件,每个第一恢复日志文件记录了所述待恢复数据标识所标识的待恢复数据的位置信息及操作信息;a first receiving module, configured to receive a first recovery log file returned by each slave server according to the log obtaining request, where each first recovery log file records location information of the to-be-recovered data identified by the to-be-recovered data identifier and Operational information;
恢复模块,用于根据所有所述第一恢复日志文件及第二恢复日志文件所记录的操作信息中的最新操作信息对待恢复数据进行操作,所述待恢复数据根据所述待恢复数据的位置信息查找得到,所述第二恢复日志文件由所述主服务器生成,且记录了所述待恢复数据标识所标识的待恢复数据的位置信息及操作信息。a recovery module, configured to perform, according to the latest operation information in the operation information recorded by the first recovery log file and the second recovery log file, the data to be restored according to the location information of the data to be restored The second recovery log file is generated by the primary server, and the location information and operation information of the to-be-recovered data identified by the to-be-recovered data identifier are recorded.
结合第三方面,在第三方面的第一种可能的实现方式中,所述服务器,还包括:In conjunction with the third aspect, in a first possible implementation manner of the third aspect, the server further includes:
存储模块,用于接收并存储客户端发送的数据;a storage module, configured to receive and store data sent by the client;
返回模块,用于向所述客户端返回包含所述数据的识别标识的第一写入状态信息,所述第一写入状态信息包括写入成功信息或写入失败信息;a returning module, configured to return, to the client, first write state information that includes an identifier of the data, where the first write state information includes write success information or write failure information;
第二接收模块,用于接收所述客户端发送的总写入状态信息,所述总写入状态信息包括所述主服务器向所述客户端返回的第一写入状态信息及每个从服务器向所述客户端返回的第二写入状态信息;a second receiving module, configured to receive total write status information sent by the client, where the total write status information includes first write status information returned by the primary server to the client, and each slave server Second write status information returned to the client;
生成模块,用于当所述客户端发送的总写入状态信息中包含写入失败信息时,确定所述客户端发送的数据为待恢复数据,并生成记录所述待恢复数据的位置信息及操作信息的第二恢复日志文件。a generating module, configured to: when the total write status information sent by the client includes the write failure information, determine that the data sent by the client is the data to be restored, and generate location information that records the to-be-recovered data and The second recovery log file of the operation information.
结合第三方面,在第三方面的第二种可能的实现方式中,所述恢复模块,包括:With reference to the third aspect, in a second possible implementation manner of the third aspect, the recovery module includes:
第一读取单元,用于依次读取每个所述第一恢复日志文件及第二恢复日志文件;a first reading unit, configured to sequentially read each of the first recovery log file and the second recovery log file;
判断单元,用于判断当前读取的恢复日志文件的索引信息是否在预设结构 中,所述索引信息包括恢复日志文件标识、偏移量信息及数据长度信息,所述预设结构用于存储索引信息及操作时间;a determining unit, configured to determine whether the index information of the currently read recovery log file is in a preset structure The index information includes a recovery log file identifier, an offset information, and data length information, where the preset structure is used to store index information and an operation time;
添加单元,用于在当前读取的恢复日志文件的索引信息未在所述预设结构中时,将当前读取的恢复日志文件的索引信息及操作时间添加到所述预设结构中;An adding unit, configured to add index information and an operation time of the currently read recovery log file to the preset structure when the index information of the currently read recovery log file is not in the preset structure;
第二读取单元,用于继续读取下一个恢复日志文件;a second reading unit, configured to continue to read the next recovery log file;
处理单元,用于按照处理当前读取的恢复日志文件的方式处理读取的下一个恢复日志文件,直至处理完最后一个恢复日志文件,得到存储有无重复索引信息及操作时间的预设结构;a processing unit, configured to process the read next recovery log file in a manner of processing the currently read recovery log file, until the last recovery log file is processed, to obtain a preset structure for storing the duplicate index information and the operation time;
获取单元,用于获取与所述预设结构中的索引信息及操作时间对应的恢复日志文件,并将与所述预设结构中的索引信息及操作时间对应的恢复日志文件作为筛选出的恢复日志文件;An obtaining unit, configured to acquire a recovery log file corresponding to the index information and the operation time in the preset structure, and use the recovery log file corresponding to the index information and the operation time in the preset structure as the filtered recovery Log file
恢复单元,用于根据筛选出的恢复日志文件中的操作信息对待恢复数据进行操作。A recovery unit, configured to operate on the restored data according to the operation information in the filtered recovery log file.
结合第三方面至第三方面的第二种可能的实现方式,在第三方面的第三种可能的实现方式中,所述恢复模块,还包括:With reference to the third aspect to the second possible implementation of the third aspect, in a third possible implementation manner of the third aspect, the recovery module further includes:
比较单元,用于在当前读取的恢复日志文件的索引信息在预设结构中时,将当前读取的恢复日志文件的操作时间与所述预设结构中对应当前读取的恢复日志文件的索引信息的操作时间进行比较;a comparison unit, configured to: when the index information of the currently read recovery log file is in the preset structure, the operation time of the currently read recovery log file and the correspondingly read recovery log file in the preset structure The operation time of the index information is compared;
替换单元,用于在当前读取的恢复日志文件的操作时间晚于预设结构中对应当前读取的恢复日志文件的索引信息的操作时间时,将当前读取的恢复日志文件的操作时间替换预设结构中与当前读取的恢复日志文件的索引信息相对应的操作时间;a replacement unit, configured to replace the operation time of the currently read recovery log file when the operation time of the currently read recovery log file is later than the operation time of the index information corresponding to the currently read recovery log file in the preset structure The operation time in the preset structure corresponding to the index information of the currently read recovery log file;
所述第二读取单元,还用于执行继续读取下一个恢复日志文件的步骤。The second reading unit is further configured to perform the step of continuing to read the next recovery log file.
结合第三方面至第一方面的第二种或第三种可能的实现方式中的任一种可能的实现方式,在第三方面的第四种可能的实现方式中,所述获取单元,包括:With reference to the third aspect to any one of the second or the third possible implementation manners of the first aspect, in a fourth possible implementation manner of the third aspect, the acquiring unit includes :
第一读取子单元,用于依次读取所述第一恢复日志文件及与所述待恢复数据标识相对应的第二恢复日志文件;a first reading subunit, configured to sequentially read the first recovery log file and a second recovery log file corresponding to the to-be-recovered data identifier;
比对子单元,用于将当前读取的恢复日志文件的索引信息依次与预设结构中的索引信息进行比对; The comparison subunit is configured to compare the index information of the currently read recovery log file with the index information in the preset structure;
比较子单元,用于当所述预设结构中存在与当前读取的恢复日志文件的索引信息相同的索引信息时,比较当前读取的恢复日志文件的操作时间与所述预设结构中对应当前读取的恢复日志文件的索引信息的操作时间;a comparison subunit, configured to: when the index information of the recovery log file currently read is the same as the index information of the currently read recovery log file, compare the operation time of the currently read recovery log file with the preset structure The operation time of the index information of the currently read recovery log file;
添加子单元,用于当所述预设结构中存在与当前读取的恢复日志文件的操作时间相同的对应当前读取的恢复日志文件的索引信息的操作时间时,将当前读取的恢复日志文件添加到筛选出的恢复日志文件中;Adding a subunit, configured to: when the operation time of the index information corresponding to the currently read recovery log file is the same as the operation time of the currently read recovery log file in the preset structure, the currently read recovery log The file is added to the filtered recovery log file;
第二读取子单元,用于读取下一个恢复日志文件;以此类推,直至比对完最后一个恢复日志文件,得到所述预设结构中的每个索引信息对应的恢复日志文件。The second read subunit is configured to read the next recovery log file; and so on, until the last recovery log file is compared, and the recovery log file corresponding to each index information in the preset structure is obtained.
结合第三方面,在第三方面的第五种可能的实现方式中,所述服务器,还包括:In conjunction with the third aspect, in a fifth possible implementation manner of the third aspect, the server further includes:
第二发送模块,用于将筛选出的恢复日志文件发送给各个从服务器,由各个从服务器根据所述筛选出的恢复日志文件对所述待恢复数据进行恢复。The second sending module is configured to send the filtered recovery log file to each slave server, and the slave servers recover the data to be restored according to the filtered recovery log file.
第四方面,提供了一种恢复数据的服务器,所述服务器为应用于存储系统的从服务器,所述存储系统包括主服务器和所述从服务器,所述主服务器和所述从服务器均用于存储相同数据,所述主服务器为第一个成功存储数据的服务器,所述服务器包括:A fourth aspect provides a server for recovering data, the server being a slave server applied to a storage system, the storage system including a master server and the slave server, the master server and the slave server are both used The same data is stored, and the primary server is the first server that successfully stores data, and the server includes:
第一接收模块,用于接收所述主服务器发送的日志获取请求,所述日志获取请求中携带待恢复数据标识;a first receiving module, configured to receive a log obtaining request sent by the primary server, where the log obtaining request carries a data identifier to be restored;
第一返回模块,用于根据所述日志获取请求向所述主服务器返回第一恢复日志文件,使所述主服务器根据所述第一恢复日志文件及所述主服务器生成的第二恢复日志文件恢复所述待恢复数据;a first returning module, configured to return a first recovery log file to the primary server according to the log obtaining request, so that the primary server generates a second recovery log file according to the first recovery log file and the primary server Recovering the data to be recovered;
第二接收模块,用于接收所述主服务器发送的筛选出的恢复日志文件;a second receiving module, configured to receive the filtered recovery log file sent by the primary server;
恢复模块,用于根据所述筛选出的恢复日志文件所记录的操作信息对待恢复数据进行操作;a recovery module, configured to perform operation on the restored data according to the operation information recorded by the filtered recovery log file;
其中,所述第一恢复日志文件及所述第二恢复日志文件均记录了所述待恢复数据标识所标识的待恢复数据的位置信息及操作信息。The first recovery log file and the second recovery log file respectively record location information and operation information of the to-be-recovered data identified by the to-be-recovered data identifier.
结合第四方面,在第四方面的第一种可能的实现方式中,所述服务器,还包括:With reference to the fourth aspect, in a first possible implementation manner of the fourth aspect, the server further includes:
存储模块,用于接收并存储客户端发送的数据;a storage module, configured to receive and store data sent by the client;
第二返回模块,用于向所述客户端返回包含所述数据的识别标识的第二写 入状态信息,所述第二写入状态信息包括写入成功信息或写入失败信息;a second returning module, configured to return, to the client, a second write that includes the identification identifier of the data Entering status information, the second write status information includes write success information or write failure information;
第三接收模块,用于接收所述客户端发送的总写入状态信息,所述总写入状态信息包括所述从服务器向所述客户端返回的第二写入状态信息及所述主服务器向所述客户端返回的第一写入状态信息;a third receiving module, configured to receive total write status information sent by the client, where the total write status information includes the second write status information returned from the server to the client, and the primary server First write status information returned to the client;
生成模块,用于当所述客户端发送的总写入状态信息中包含写入失败信息时,确定所述客户端发送的数据为待恢复数据,并生成记录所述待恢复数据的位置信息及操作信息的第一恢复日志文件。a generating module, configured to: when the total write status information sent by the client includes the write failure information, determine that the data sent by the client is the data to be restored, and generate location information that records the to-be-recovered data and The first recovery log file for operational information.
第五方面,提供了一种恢复数据的系统,所述系统包括:主服务器和至少一个从服务器;In a fifth aspect, a system for recovering data is provided, the system comprising: a primary server and at least one secondary server;
其中,所述主服务器如上面所述的第一种服务器,所述从服务器如上面所述的第二种服务器。Wherein, the primary server is the first type of server as described above, and the secondary server is the second type of server as described above.
本发明实施例提供的技术方案带来的有益效果是:The beneficial effects brought by the technical solutions provided by the embodiments of the present invention are:
通过主服务器向存储系统中的各个从服务器发送日志获取请求后,接收各个从服务器返回的第一恢复日志文件,并根据所有第一恢复日志文件及主服务器生成的第二恢复日志文件恢复待恢复数据,从而无需扫描所有数据,也无需使用元数据服务器即可实现恢复数据,提高了恢复数据的效率。After the primary server sends a log obtaining request to each slave server in the storage system, the first recovery log file returned by each slave server is received, and the first recovery log file and the second recovery log file generated by the master server are restored to be restored. Data, so you don't need to scan all the data, you can restore data without using a metadata server, and improve the efficiency of restoring data.
附图说明DRAWINGS
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the description of the embodiments will be briefly described below. It is obvious that the drawings in the following description are only some embodiments of the present invention. Other drawings may also be obtained from those of ordinary skill in the art in light of the inventive work.
图1是本发明实施例一提供的一种恢复数据的方法流程图;1 is a flowchart of a method for restoring data according to Embodiment 1 of the present invention;
图2是本发明实施例一提供的另一种恢复数据的方法流程图;2 is a flowchart of another method for restoring data according to Embodiment 1 of the present invention;
图3是本发明实施例二提供的一种恢复数据的方法流程图;3 is a flowchart of a method for restoring data according to Embodiment 2 of the present invention;
图4是本发明实施例二提供的一种交互过程的示意图;4 is a schematic diagram of an interaction process provided by Embodiment 2 of the present invention;
图5是本发明实施例三提供的一种恢复数据的服务器的结构示意图;FIG. 5 is a schematic structural diagram of a server for restoring data according to Embodiment 3 of the present invention; FIG.
图6是本发明实施例四提供的一种恢复数据的服务器的结构示意图;6 is a schematic structural diagram of a server for recovering data according to Embodiment 4 of the present invention;
图7是本发明实施例五提供的一种恢复数据的系统的结构示意图。FIG. 7 is a schematic structural diagram of a system for restoring data according to Embodiment 5 of the present invention.
具体实施方式 detailed description
为使本发明的目的、技术方案和优点更加清楚,下面将结合附图对本发明实施方式作作为一种可选实施例详细描述。The embodiments of the present invention will be described in detail as an alternative embodiment with reference to the accompanying drawings.
实施例一Embodiment 1
本发明实施例提供了一种恢复数据的方法,以方法应用于存储系统的主服务器,存储系统包括主服务器和从服务器,主服务器和从服务器均用于存储相同数据,主服务器为第一个成功存储数据的服务器为例,参见图1,本发明实施例提供的方法流程包括:An embodiment of the present invention provides a method for recovering data, where the method is applied to a primary server of a storage system, where the storage system includes a primary server and a secondary server, and the primary server and the secondary server are both used to store the same data, and the primary server is the first For example, the server of the embodiment of the present invention includes:
101:当存储系统中的任意一个服务器存储数据失败时,主服务器向存储系统中的每个从服务器发送日志获取请求,日志获取请求中携带待恢复数据标识;When the storage of the data in the storage system fails, the primary server sends a log obtaining request to each of the secondary servers in the storage system, and the log obtaining request carries the data identifier to be restored.
作为一种可选实施例,向存储系统中的每个从服务器发送日志获取请求之前,还包括:As an optional embodiment, before sending a log obtaining request to each slave server in the storage system, the method further includes:
接收并存储客户端发送的数据,并向客户端返回包含数据的识别标识的第一写入状态信息,第一写入状态信息为写入成功信息或写入失败信息;Receiving and storing the data sent by the client, and returning, to the client, the first write status information that includes the identification identifier of the data, where the first write status information is a write success information or a write failure information;
接收客户端发送的总写入状态信息,总写入状态信息包括主服务器向客户端返回的第一写入状态信息及每个从服务器向客户端返回的第二写入状态信息;Receiving total write status information sent by the client, where the total write status information includes first write status information returned by the primary server to the client and second write status information returned from the server to the client;
如果客户端发送的总写入状态信息中包含写入失败信息,则确定客户端发送的数据为待恢复数据,并生成记录待恢复数据的位置信息及操作信息的第二恢复日志文件。If the total write status information sent by the client includes the write failure information, it is determined that the data sent by the client is the data to be restored, and the second recovery log file that records the location information of the data to be restored and the operation information is generated.
102:接收各个从服务器根据日志获取请求返回的第一恢复日志文件,每个第一恢复日志文件记录了待恢复数据标识所标识的待恢复数据的位置信息及操作信息;Step 102: Receive a first recovery log file returned by each slave server according to the log obtaining request, where each first recovery log file records location information and operation information of the to-be-recovered data identified by the to-be-recovered data identifier;
103:根据所有第一恢复日志文件及第二恢复日志文件所记录的操作信息中的最新操作信息对待恢复数据进行操作,待恢复数据根据待恢复数据的位置信息查找得到,第二恢复日志文件由主服务器生成,且记录了待恢复数据标识所标识的待恢复数据的位置信息及操作信息。103: Perform operation on the restored data according to the latest operation information in the operation information recorded by all the first recovery log files and the second recovery log file, and the data to be restored is searched according to the location information of the data to be restored, and the second recovery log file is obtained by The primary server generates and records location information and operation information of the to-be-recovered data identified by the to-be-recovered data identifier.
作为一种可选实施例,根据所有第一恢复日志文件及第二恢复日志文件所记录的操作信息中的最新操作信息对待恢复数据进行操作,包括:As an optional embodiment, the data is to be restored according to the latest operation information in the operation information recorded by all the first recovery log files and the second recovery log file, including:
依次读取每个第一恢复日志文件及第二恢复日志文件;Reading each first recovery log file and second recovery log file in turn;
判断当前读取的恢复日志文件的索引信息是否在预设结构中,索引信息包 括恢复日志文件标识、偏移量信息及数据长度信息,预设结构用于存储索引信息及操作时间;Determining whether the index information of the currently read recovery log file is in a preset structure, and indexing the information packet The recovery log file identifier, the offset information, and the data length information are used, and the preset structure is used to store the index information and the operation time;
若当前读取的恢复日志文件的索引信息未在预设结构中,则将当前读取的恢复日志文件的索引信息及操作时间添加到预设结构中;If the index information of the currently read recovery log file is not in the preset structure, the index information and the operation time of the currently read recovery log file are added to the preset structure;
继续读取下一个恢复日志文件,按照处理当前读取的恢复日志文件的方式处理读取的下一个恢复日志文件,直至处理完最后一个恢复日志文件,得到存储有无重复索引信息及操作时间的预设结构;Continue to read the next recovery log file, and process the next recovery log file read in the manner of processing the currently read recovery log file until the last recovery log file is processed, and whether the storage has duplicate index information and operation time is obtained. Preset structure;
获取与预设结构中的索引信息及操作时间对应的恢复日志文件,并将与预设结构中的索引信息及操作时间对应的恢复日志文件作为筛选出的恢复日志文件,根据筛选出的恢复日志文件中的操作信息对待恢复数据进行操作。Obtaining a recovery log file corresponding to the index information and the operation time in the preset structure, and using the recovery log file corresponding to the index information and the operation time in the preset structure as the filtered recovery log file, according to the filtered recovery log The operational information in the file operates on the recovered data.
作为一种可选实施例,判断当前读取的恢复日志文件的索引信息是否在预设结构中之后,还包括:As an optional embodiment, after determining whether the index information of the currently read recovery log file is in the preset structure, the method further includes:
若当前读取的恢复日志文件的索引信息在预设结构中,则将当前读取的恢复日志文件的操作时间与预设结构中对应当前读取的恢复日志文件的索引信息的操作时间进行比较;If the index information of the currently read recovery log file is in the preset structure, compare the operation time of the currently read recovery log file with the operation time of the index information corresponding to the currently read recovery log file in the preset structure. ;
若当前读取的恢复日志文件的操作时间晚于预设结构中对应当前读取的恢复日志文件的索引信息的操作时间,则将当前读取的恢复日志文件的操作时间替换预设结构中与当前读取的恢复日志文件的索引信息相对应的操作时间,并执行继续读取下一个恢复日志文件的步骤。If the operation time of the currently read recovery log file is later than the operation time of the index information corresponding to the currently read recovery log file in the preset structure, the operation time of the currently read recovery log file is replaced with the preset structure and The operation time corresponding to the index information of the currently read recovery log file, and the step of continuing to read the next recovery log file.
作为一种可选实施例,获取与预设结构中的索引信息及操作时间对应的恢复日志文件,包括:As an optional embodiment, the recovery log file corresponding to the index information and the operation time in the preset structure is obtained, including:
依次读取第一恢复日志文件及与待恢复数据标识相对应的第二恢复日志文件,并将当前读取的恢复日志文件的索引信息依次与预设结构中的索引信息进行比对;The first recovery log file and the second recovery log file corresponding to the to-be-recovered data identifier are sequentially read, and the index information of the currently-recovered recovery log file is sequentially compared with the index information in the preset structure.
若预设结构中存在与当前读取的恢复日志文件的索引信息相同的索引信息,则比较当前读取的恢复日志文件的操作时间与预设结构中对应当前读取的恢复日志文件的索引信息的操作时间;If there is index information in the preset structure that is the same as the index information of the currently-recovered recovery log file, compare the operation time of the currently-recovered recovery log file with the index information of the currently-recovered recovery log file in the preset structure. Operating time
若预设结构中存在与当前读取的恢复日志文件的操作时间相同的对应当前读取的恢复日志文件的索引信息的操作时间,则将当前读取的恢复日志文件添加到筛选出的恢复日志文件中,并读取下一个恢复日志文件;If the operation time of the index information corresponding to the currently read recovery log file is the same as the operation time of the currently read recovery log file in the preset structure, the currently read recovery log file is added to the filtered recovery log. File and read the next recovery log file;
以此类推,直至比对完最后一个恢复日志文件,得到预设结构中的每个索 引信息对应的恢复日志文件。And so on, until the last recovery log file is compared, get each cable in the default structure. The recovery log file corresponding to the information.
作为一种可选实施例,将与预设结构中的索引信息及操作时间对应的恢复日志文件作为筛选出的恢复日志文件之后,还包括:As an optional embodiment, after the recovery log file corresponding to the index information and the operation time in the preset structure is used as the filtered recovery log file, the method further includes:
将筛选出的恢复日志文件发送给各个从服务器,由各个从服务器根据筛选出的恢复日志文件对待恢复数据进行恢复。The filtered recovery log file is sent to each slave server, and each slave server recovers the data to be restored according to the filtered recovery log file.
以方法应用于存储系统的主服务器,存储系统包括主服务器和从服务器,主服务器和从服务器均用于存储相同数据,主服务器为第一个成功存储数据的服务器为例,参见图2,本发明实施例提供的方法流程包括:The method is applied to the primary server of the storage system. The storage system includes a primary server and a secondary server. The primary server and the secondary server are used to store the same data. The primary server is the first server that successfully stores data. For example, see FIG. 2, The method flow provided by the embodiment of the invention includes:
201:每个从服务器接收主服务器发送的日志获取请求,日志获取请求中携带待恢复数据标识;201: Each slave server receives a log obtaining request sent by the primary server, where the log obtaining request carries the data identifier to be restored;
202:根据日志获取请求向主服务器返回第一恢复日志文件,使主服务器根据第一恢复日志文件及主服务器生成的第二恢复日志文件恢复待恢复数据;202: Return, according to the log obtaining request, the first recovery log file to the primary server, so that the primary server recovers the data to be restored according to the first recovery log file and the second recovery log file generated by the primary server;
其中,第一恢复日志文件及第二恢复日志文件均记录了待恢复数据标识所标识的待恢复数据的位置信息及操作信息。The first recovery log file and the second recovery log file record the location information and operation information of the to-be-recovered data identified by the to-be-recovered data identifier.
作为一种可选实施例,根据日志获取请求向主服务器返回第一恢复日志文件之前,还包括:As an optional embodiment, before returning the first recovery log file to the primary server according to the log obtaining request, the method further includes:
接收并存储客户端发送的数据,并向客户端返回包含数据的识别标识的第二写入状态信息,第二写入状态信息包括写入成功信息或写入失败信息;Receiving and storing data sent by the client, and returning, to the client, second write status information including an identification identifier of the data, where the second write status information includes write success information or write failure information;
接收客户端发送的总写入状态信息,总写入状态信息包括从服务器向客户端返回的第二写入状态信息及主服务器向客户端返回的第一写入状态信息;Receiving total write status information sent by the client, where the total write status information includes second write status information returned from the server to the client and first write status information returned by the primary server to the client;
如果客户端发送的总写入状态信息中包含写入失败信息,则确定客户端发送的数据为待恢复数据,并生成记录待恢复数据的位置信息及操作信息的第一恢复日志文件。If the total write status information sent by the client includes the write failure information, it is determined that the data sent by the client is the data to be restored, and the first recovery log file that records the location information and the operation information of the data to be restored is generated.
203:接收主服务器发送的筛选出的恢复日志文件,并根据筛选出的恢复日志文件中的操作信息对待恢复数据进行操作。203: Receive the filtered recovery log file sent by the primary server, and perform operations on the restored data according to the operation information in the filtered recovery log file.
本发明实施例提供的方法,通过主服务器向存储系统中的各个从服务器发送日志获取请求后,根据各个从服务器返回的第一恢复日志文件,并根据所有第一恢复日志文件及主服务器生成的第二恢复日志文件恢复待恢复数据,从而无需扫描所有数据,也无需使用元数据服务器即可实现恢复数据,提高了恢复数据的效率。 The method provided by the embodiment of the present invention, after the primary server sends a log obtaining request to each slave server in the storage system, according to the first recovery log file returned by each slave server, and generated according to all the first recovery log files and the primary server. The second recovery log file recovers the data to be recovered, thereby eliminating the need to scan all the data and recovering the data without using a metadata server, thereby improving the efficiency of restoring data.
实施例二Embodiment 2
本发明实施例提供了一种恢复数据的方法,为了便于理解,结合上述实施例一的内容,以存储系统为例,对本发明实施例提供的数据处理方法进行详细地解释说明。其中,存储系统中包括主服务器和至少两个从服务器,主服务器为第一个成功存储数据的服务器,从服务器为存储系统中除主服务器以外的其他服务器。参见图3,本实施例提供的方法流程包括:The embodiment of the present invention provides a method for restoring data. For ease of understanding, the data processing method provided by the embodiment of the present invention is explained in detail by taking the storage system as an example in combination with the content of the first embodiment. The storage system includes a primary server and at least two secondary servers. The primary server is the first server that successfully stores data, and the secondary server is a server other than the primary server in the storage system. Referring to FIG. 3, the method process provided by this embodiment includes:
301:主服务器和从服务器分别接收并存储客户端发送的数据,主服务器向客户端返回包含数据的识别标识的第一写入状态信息,从服务器向客户端返回包含数据的识别标识的第二写入状态信息,第一写入状态信息及第二写入状态信息包括写入成功信息或写入失败信息;301: The primary server and the secondary server respectively receive and store data sent by the client, and the primary server returns, to the client, first write status information including the identification identifier of the data, and returns a second identifier containing the identification identifier of the data from the server to the client. Write status information, the first write status information and the second write status information include write success information or write failure information;
为了使主服务器和从服务器能够分别接收客户端发送的数据,客户端会提前获取数据。关于客户端获取数据的方式,本实施例不作具体限定。具体实施时,可以由用户通过APP(Application,应用)将数据写入客户端,再由客户端将数据发送给各个服务器。当然,除了上述接收数据的方式外,还可以采用其他方式,本实施例对此不作具体限定。In order to enable the primary server and the secondary server to receive the data sent by the client separately, the client obtains the data in advance. The manner in which the client obtains data is not specifically limited in this embodiment. During specific implementation, the user can write data to the client through the APP (Application), and then the client sends the data to each server. Of course, in addition to the above manner of receiving data, other methods may be used, which are not specifically limited in this embodiment.
作为一种可选实施例,主服务器和从服务器通过与客户端的交互存储数据。其中,主服务器和从服务器与客户端的交互过程采用两阶段事务提交的方式,分别为准备阶段和提交阶段。在准备阶段,主服务器存储客户端发送的数据,并向客户端返回包含数据的识别标识的第一写入状态信息,从服务器存储客户端发送的数据,并向客户端返回包含数据的识别标识的第二写入状态信息,即步骤301对应准备阶段。As an alternative embodiment, the primary server and the secondary server store data through interaction with the client. The interaction process between the primary server and the secondary server and the client adopts a two-phase transaction submission method, which is a preparation phase and a submission phase. In the preparation phase, the primary server stores the data sent by the client, and returns the first write status information containing the identification identifier of the data to the client, stores the data sent by the client from the server, and returns the identification identifier containing the data to the client. The second write status information, that is, step 301 corresponds to the preparation phase.
为了便于理解,以如图4所示的交互过程为例进行说明。其中,存储系统中共有3个服务器,分别为服务器1、服务器2及服务器3。用户通过APP将数据1写入客户端,客户端创建一个transaction(事务),并向服务器1至服务器3分别发送用户写入的数据1。服务器1至服务器3分别接收并存储客户端发送的数据1,即服务器1至服务器3存储相同的数据1;服务器1和服务器2存储数据1成功,服务器3存储数据1失败;服务器1和服务器2向客户端返回包含数据1标识的写入状态信息,该写入状态信息为写入成功信息;服务器3向客户端返回包含数据1标识的写入状态信息,该写入状态信息为写入失败信息。另外,由于服务器1为第一个成功存储数据1的服务器,则将服务器1作为主服务器,服务器1向客户端返回的写入状态信息为第一写入状态信息; 将存储系统中除主服务器以外的其他服务器,即服务器2和服务器3作为从服务器,并将服务器2和服务器3向客户端返回的写入状态信息作为第二写入状态信息。For ease of understanding, the interaction process shown in FIG. 4 is taken as an example for description. There are three servers in the storage system, namely server 1, server 2 and server 3. The user writes the data 1 to the client through the APP, the client creates a transaction, and sends the data 1 written by the user to the server 1 to the server 3 respectively. Server 1 to server 3 respectively receive and store data 1 sent by the client, that is, server 1 to server 3 store the same data 1; server 1 and server 2 store data 1 successfully, server 3 fails to store data 1; server 1 and server 2 Returning the write status information including the identifier of the data 1 to the client, the write status information is the write success information; the server 3 returns the write status information including the identifier of the data 1 to the client, where the write status information is a write failure information. In addition, since the server 1 is the first server that successfully stores the data 1, the server 1 is used as the primary server, and the write status information returned by the server 1 to the client is the first write status information; The server other than the primary server, that is, the server 2 and the server 3 are used as the secondary server, and the write status information returned by the server 2 and the server 3 to the client is used as the second write status information.
302:主服务器和从服务器分别接收客户端发送的总写入状态信息,总写入状态信息包括主服务器向客户端返回的第一写入状态信息及每个从服务器向客户端返回的第二写入状态信息;302: The primary server and the secondary server respectively receive total write status information sent by the client, and the total write status information includes first write status information returned by the primary server to the client, and second return from each server to the client. Write status information;
由于主服务器向客户端返回包含数据的识别标识的第一写入状态信息,从服务器向客户端返回包含数据的识别标识的第二写入状态信息,客户端会接收到各个服务器发送的包括第一写入状态信息及第二写入状态信息的总写入状态信息,并将包括写入失败信息的总写入状态信息发送给写入状态信息为写入成功信息的服务器,从而使各个服务器能够接收客户端发送的总写入状态信息。Since the primary server returns the first write status information including the identification identifier of the data to the client, the second write status information including the identification identifier of the data is returned from the server to the client, and the client receives the information sent by each server. Writing the total write status information of the status information and the second write status information, and transmitting the total write status information including the write failure information to the server whose write status information is the write success information, thereby causing each server Ability to receive the total write status information sent by the client.
作为一种可选实施例,在服务器与客户端的交互过程的提交阶段,主服务器和从服务器分别接收客户端发送的总写入状态信息,即步骤302对应提交阶段。As an optional embodiment, in the commit phase of the interaction process between the server and the client, the primary server and the secondary server respectively receive the total write status information sent by the client, that is, step 302 corresponds to the submission phase.
为了便于理解,仍以如图4所示的交互过程为例进行说明。其中,存储系统中共有3个服务器,分别为服务器1、服务器2及服务器3。由于服务器1和服务器2向客户端返回的写入状态信息为写入成功信息;服务器3向客户端返回的写入状态信息为写入失败信息,则在提交阶段,客户端向服务器1、服务器2及服务器3发送总写入状态信息,该总写入状态信息中包括数据1写入失败信息,服务器1、服务器2及服务器3接收客户端发送的总写入状态信息。For ease of understanding, the interaction process shown in FIG. 4 is still taken as an example for description. There are three servers in the storage system, namely server 1, server 2 and server 3. Since the write status information returned by the server 1 and the server 2 to the client is the write success information; the write status information returned by the server 3 to the client is the write failure information, then in the commit phase, the client goes to the server 1, the server 2 and the server 3 sends the total write status information, the total write status information includes the data 1 write failure information, and the server 1, the server 2, and the server 3 receive the total write status information sent by the client.
303:当客户端发送的总写入状态信息中包含写入失败信息时,主服务器和从服务器分别确定客户端发送的数据为待恢复数据,主服务器生成记录待恢复数据的位置信息及操作信息的第二恢复日志文件,从服务器生成记录待恢复数据的位置信息及操作信息的第一恢复日志文件;303: When the total write status information sent by the client includes the write failure information, the primary server and the secondary server respectively determine that the data sent by the client is data to be restored, and the primary server generates location information and operation information for recording the data to be restored. a second recovery log file, and a first recovery log file for recording location information of the data to be restored and operation information from the server;
当客户端发送的总写入状态信息中包含写入失败信息时,说明至少一个服务器存储数据失败,为了恢复数据,减少数据丢失,主服务器和从服务器分别确定客户端发送的数据为待恢复数据。When the total write status information sent by the client includes the write failure information, it indicates that at least one server fails to store data. In order to recover data and reduce data loss, the primary server and the secondary server respectively determine that the data sent by the client is the data to be restored. .
需要说明的是,恢复日志文件中记录的待恢复数据的位置信息可以为偏移量信息、数据长度信息等,用于确定待恢复数据的位置;操作信息可以为写入数据信息、删除数据信息等,用于描述对数据的操作,本实施例不对恢复日志 文件中记录的待恢复数据的位置信息及操作信息的内容作具体限定。It should be noted that the location information of the data to be recovered recorded in the recovery log file may be offset information, data length information, etc., used to determine the location of the data to be restored; the operation information may be writing data information, deleting data information. Etc., used to describe the operation of the data, this embodiment does not restore the log The location information of the data to be recovered recorded in the file and the content of the operation information are specifically limited.
为了便于理解,仍以图4所示的交互过程为例进行说明。其中,存储系统中共有3个服务器,分别为服务器1、服务器2及服务器3。由于服务器1、服务器2及服务器3接收到客户端发送的总写入状态信息包含写入失败信息,则服务器1、服务器2和服务器3确定数据1为待恢复数据,并生成记录写入数据1的位置信息及操作信息的恢复日志文件。例如,如果服务器1为主服务器,服务器2和服务器3为从服务器,则服务器1生成记录待恢复数据的位置信息及操作信息的第二恢复日志文件。服务器2和服务器3通过数据刷盘,记录错误日志,即生成记录待恢复数据的位置信息及操作信息的第一恢复日志文件。For ease of understanding, the interaction process shown in FIG. 4 is still taken as an example for description. There are three servers in the storage system, namely server 1, server 2 and server 3. Since the server 1, the server 2, and the server 3 receive the total write status information sent by the client including the write failure information, the server 1, the server 2, and the server 3 determine that the data 1 is the data to be restored, and generates the record write data. Recovery log file for location information and operational information. For example, if the server 1 is a master server and the server 2 and the server 3 are slave servers, the server 1 generates a second recovery log file that records location information and operation information of the data to be restored. The server 2 and the server 3 record the error log through the data brush, that is, generate the first recovery log file that records the location information of the data to be restored and the operation information.
以上客户端与各个服务器的交互过程体现了各个服务器存储数据以及生成恢复日志文件的过程,对于恢复数据的具体过程,详见如下步骤。The interaction process between the client and each server reflects the process of storing data and generating recovery log files for each server. For the specific process of restoring data, refer to the following steps.
304:当存储系统中的任意一个服务器存储数据失败时,主服务器向所在存储系统中的每个从服务器发送日志获取请求,日志获取请求中携带待恢复数据标识;304: When any one of the storage systems fails to store data, the primary server sends a log obtaining request to each of the secondary servers in the storage system, and the log obtaining request carries the data identifier to be restored.
关于触发主服务器向所在存储系统中的每个从服务器发送日志获取请求的方式,本实施例不作具体限定。具体实施时,在存储系统中的任意一个服务器存储数据失败,生成待恢复日志文件后,由服务器定时检查恢复日志文件,启动数据恢复,从而触发主服务器向所在存储系统中的每个从服务器发送日志获取请求。当然,除了上述方式外,还可以采用其他方式。The manner of triggering the primary server to send a log obtaining request to each of the secondary servers in the storage system is not specifically limited in this embodiment. During specific implementation, if any server in the storage system stores data fails, after the log file to be restored is generated, the server periodically checks the recovery log file and starts data recovery, thereby triggering the primary server to send to each slave server in the storage system. The log gets the request. Of course, in addition to the above methods, other methods can be employed.
为了便于理解,仍以服务器1和服务器2存储数据1成功,服务器3存储数据1失败为例进行说明。其中,服务器1为主服务器。服务器1至服务器3定时检查记录的恢复日志文件,通过检查发现数据1需要恢复。由服务器1向服务器2和服务器3发送携带数据1的数据标识的日志获取请求。For ease of understanding, the server 1 and the server 2 still store the data 1 successfully, and the server 3 stores the data 1 failure as an example. Among them, the server 1 is the main server. The server 1 to the server 3 periodically check the recorded recovery log file, and it is found that the data 1 needs to be restored by checking. A log acquisition request carrying the data identification of the data 1 is transmitted by the server 1 to the server 2 and the server 3.
305:从服务器接收主服务器发送的日志获取请求,日志获取请求中携带待恢复数据标识;305: Receive a log obtaining request sent by the primary server from the server, where the log obtaining request carries the data identifier to be restored;
由于主服务器向所在存储系统中的每个从服务器发送日志获取请求,则从服务器可直接接收主服务器发送的日志获取请求;又由于日志获取请求中携带待恢复数据标识,便于后续步骤中从服务器根据日志获取请求中的待恢复数据标识返回恢复日志文件。The slave server can directly receive the log obtaining request sent by the master server to the slave server in the storage system. The slave server can directly receive the log obtaining request sent by the master server. The recovery log file is returned according to the to-be-recovered data identifier in the log obtaining request.
为了便于理解,仍以服务器1和服务器2存储数据1成功,服务器3存储数据1失败为例进行说明。其中,服务器1为主服务器。服务器2和服务器3 接收服务器1发送的日志获取请求,该日志获取请求中携带数据1的数据标识。For ease of understanding, the server 1 and the server 2 still store the data 1 successfully, and the server 3 stores the data 1 failure as an example. Among them, the server 1 is the main server. Server 2 and server 3 Receiving a log obtaining request sent by the server 1, where the log obtaining request carries the data identifier of the data 1.
306:从服务器根据日志获取请求向主服务器返回第一恢复日志文件,第一恢复日志文件记录了待恢复数据标识所标识的待恢复数据的位置信息及操作信息;306: The slave server returns a first recovery log file to the primary server according to the log obtaining request, where the first recovery log file records location information and operation information of the to-be-recovered data identified by the to-be-recovered data identifier.
由于日志获取请求中携带待恢复数据标识,则从服务器可以根据待恢复数据标识在记录的恢复日志文件中查找与待恢复数据标识相对应的恢复日志文件,并向主服务器返回查找到的恢复日志文件。关于从服务器查找恢复日志文件的方式,本实施例不作具体限定。具体实施时,可以依次读取记录的恢复日志文件,将读取到的恢复日志文件中的数据标识与日志获取请求中携带的待恢复数据标识进行比较;如果读取到的恢复日志文件中的数据标识与日志获取请求中携带的待恢复数据标识相同,则将读取到的恢复日志文件作为查找到的第一恢复日志文件,并返回给主服务器。当然,除了上述方式,还可以采用其他方式。The log obtaining request carries the to-be-recovered data identifier, and the slave server can search for the recovery log file corresponding to the to-be-recovered data identifier in the recorded recovery log file according to the to-be-recovered data identifier, and return the found recovery log to the primary server. file. The manner in which the recovery log file is searched from the server is not specifically limited in this embodiment. During the specific implementation, the recorded recovery log file may be sequentially read, and the data identifier in the read recovery log file is compared with the to-be-recovered data identifier carried in the log obtaining request; if the recovered recovery log file is read The data identifier is the same as the to-be-recovered data identifier carried in the log obtaining request. The recovered log file is used as the first recovered log file and returned to the primary server. Of course, in addition to the above, other methods can be used.
为了便于理解,仍以服务器1和服务器2存储数据1成功,服务器3存储数据1失败为例进行说明。其中,服务器1为主服务器。服务器2和服务器3依次读取恢复日志文件,若读取到的恢复日志文件1中的数据标识与数据1的标识相同,则将恢复日志文件1作为查找到的第一恢复日志文件,并向服务器1返回恢复日志文件1。For ease of understanding, the server 1 and the server 2 still store the data 1 successfully, and the server 3 stores the data 1 failure as an example. Among them, the server 1 is the main server. The server 2 and the server 3 sequentially read the recovery log file. If the data identifier in the recovered recovery log file 1 is the same as the identifier of the data 1, the recovery log file 1 is used as the first recovery log file found, and Server 1 returns recovery log file 1.
307:主服务器接收各个从服务器根据日志获取请求返回的第一恢复日志文件,每个恢复日志文件记录了待恢复数据的位置信息及操作信息;307: The primary server receives the first recovery log file returned by each slave server according to the log obtaining request, and each recovery log file records location information and operation information of the data to be restored.
由于从服务器根据日志获取请求向主服务器返回第一恢复日志文件,则主服务器可以直接接收各个从服务器根据日志获取请求返回的第一恢复日志文件。Since the first recovery log file is returned from the server according to the log acquisition request to the primary server, the primary server can directly receive the first recovery log file returned by each secondary server according to the log acquisition request.
为了便于理解,仍以服务器1和服务器2存储数据1成功,服务器3存储数据1失败为例进行说明。其中,服务器1为主服务器。服务器1接收服务器2和服务器3根据日志获取请求返回的与数据1标识相对应的第一恢复日志文件,每个第一恢复日志文件记录了数据1的位置信息及操作信息。For ease of understanding, the server 1 and the server 2 still store the data 1 successfully, and the server 3 stores the data 1 failure as an example. Among them, the server 1 is the main server. The server 1 receives the first recovery log file corresponding to the data 1 identifier returned by the server 2 and the server 3 according to the log acquisition request, and each of the first recovery log files records the location information and the operation information of the data 1.
308:主服务器根据所有第一恢复日志文件及第二恢复日志文件所记录的操作信息中的最新操作信息对待恢复数据进行操作,第二恢复日志文件由主服务器生成,且记录了待恢复数据标识所标识的待恢复数据的位置信息及操作信息; 308: The primary server operates, according to the latest operation information in the operation information recorded by the first recovery log file and the second recovery log file, the second recovery log file is generated by the primary server, and the data identifier to be restored is recorded. Location information and operation information of the identified data to be recovered;
具体地,由于每个第一恢复日志文件及第二恢复日志文件均记录了待恢复数据的位置信息及操作信息,则服务器可以根据每个恢复日志文件中的待恢复数据的位置信息找到待恢复数据,并根据每个恢复日志文件所记录的操作信息中的最新操作信息对待恢复数据进行操作,进而实现对待恢复数据进行数据恢复。Specifically, since each of the first recovery log file and the second recovery log file records the location information and the operation information of the data to be restored, the server may find the to-be-recovered according to the location information of the data to be restored in each recovery log file. The data is processed according to the latest operation information in the operation information recorded in each recovery log file, thereby realizing data recovery for the data to be restored.
然而,由于主服务器获取到的所有第一恢复日志文件及第二恢复日志文件中有可能存在对同一待恢复数据执行相同操作的情况,因此,为了无需根据重复的恢复日志文件执行重复的数据恢复操作,从而节省恢复数据的时间,本实施例提供的方法在根据所有第一恢复日志文件及第二恢复日志文件所记录的操作信息中的最新操作信息对待恢复数据进行操作时,包括但不限于:However, since all the first recovery log files and the second recovery log files acquired by the primary server may have the same operation for the same to-be-recovered data, it is not necessary to perform repeated data recovery according to the repeated recovery log files. Operation, thereby saving time for restoring data. The method provided in this embodiment includes, but is not limited to, operating on the data to be restored according to the latest operation information in the operation information recorded by all the first recovery log files and the second recovery log file. :
(a1)依次读取每个第一恢复日志文件及第二恢复日志文件;(a1) sequentially reading each of the first recovery log file and the second recovery log file;
(a2)判断当前读取的恢复日志文件的索引信息是否在预设结构中,索引信息包括恢复日志文件标识、偏移量信息及数据长度信息,预设结构用于存储索引信息及操作时间;若当前读取的恢复日志文件的索引信息未在预设结构中,则执行(a3);若当前读取的恢复日志文件的索引信息在预设结构中,则执行(a4);(a2) determining whether the index information of the currently read recovery log file is in a preset structure, the index information includes a recovery log file identifier, an offset information, and a data length information, and the preset structure is configured to store the index information and the operation time; If the index information of the currently read recovery log file is not in the preset structure, execute (a3); if the index information of the currently read recovery log file is in the preset structure, execute (a4);
(a3)将当前读取的恢复日志文件的索引信息及操作时间添加到预设结构中,并执行(a6);(a3) adding the index information and operation time of the currently read recovery log file to the preset structure, and executing (a6);
(a4)将当前读取的恢复日志文件的操作时间与预设结构中对应当前读取的恢复日志文件的索引信息的操作时间进行比较;若当前读取的恢复日志文件的操作时间晚于预设结构中对应当前读取的恢复日志文件的索引信息的操作时间,则执行(a5);若当前读取的恢复日志文件的操作时间早于预设结构中与当前读取的恢复日志文件的索引信息相对应的操作时间,则执行(a6);(a4) comparing the operation time of the currently read recovery log file with the operation time of the index information corresponding to the currently read recovery log file in the preset structure; if the currently read recovery log file is operated later than Setting the operation time of the index information corresponding to the currently read recovery log file in the structure is performed (a5); if the currently read recovery log file is operated earlier than the preset structure and the currently read recovery log file The operation time corresponding to the index information is executed (a6);
(a5)将当前读取的恢复日志文件的操作时间替换预设结构中与当前读取的恢复日志文件的索引信息相对应的操作时间,并执行(a6)。(a5) Replace the operation time of the currently read recovery log file with the operation time corresponding to the index information of the currently read recovery log file in the preset structure, and execute (a6).
(a6)继续读取下一个恢复日志文件,按照处理当前读取的恢复日志文件的方式处理读取的下一个恢复日志文件,直至处理完最后一个恢复日志文件,并执行(a7);(a6) continue to read the next recovery log file, process the next recovery log file read in the same manner as the currently read recovery log file, until the last recovery log file is processed, and execute (a7);
(a7)获取与预设结构中的索引信息及操作时间对应的恢复日志文件,并将与预设结构中的索引信息及操作时间对应的恢复日志文件作为筛选出的恢复日志文件,根据筛选出的恢复日志文件中的操作信息对待恢复数据进行操 作。(a7) obtaining a recovery log file corresponding to the index information and the operation time in the preset structure, and using the recovery log file corresponding to the index information and the operation time in the preset structure as the filtered recovery log file, according to the screening Operation information in the recovery log file to operate on the recovered data Work.
需要说明的是,在根据所有第一恢复日志文件及第二恢复日志文件恢复待恢复数据之前,预设结构为空结构。在恢复待恢复数据的过程中,将符合上述判断比较要求的恢复日志文件的索引信息及操作时间添加到预设结构中,从而使预设结构中包含筛选出的恢复日志文件的索引信息及操作时间,即得到的预设结构为存储了无重复索引信息及操作时间的预设结构,也就是说,预设结构中存储的索引信息及操作时间不存在重复的情况。因此,根据预设结构所确定的恢复日志文件将是无重复操作的恢复日志文件。通过利用预设结构筛选恢复日志文件,提高了恢复日志文件筛选的效率,减少了后续步骤中根据筛选出的恢复日志文件恢复待恢复数据的工作量,加快了恢复数据的速度。关于预设结构的具体形式,本实施例不作具体限定。具体实施时,预设结构包括但不限于哈希表、红黑树等。It should be noted that, before restoring the data to be restored according to all the first recovery log files and the second recovery log file, the preset structure is an empty structure. In the process of restoring the data to be restored, the index information and the operation time of the recovery log file that meet the above comparison and comparison requirements are added to the preset structure, so that the preset structure includes the index information and operation of the filtered recovery log file. The time, that is, the obtained preset structure is a preset structure in which the information without the repeated index and the operation time is stored, that is, the index information stored in the preset structure and the operation time do not overlap. Therefore, the recovery log file determined according to the preset structure will be a recovery log file with no repetitive operations. By filtering the recovery log file by using the preset structure, the efficiency of the recovery log file filtering is improved, and the workload of restoring the data to be restored according to the filtered recovery log file in the subsequent steps is reduced, and the speed of recovering the data is accelerated. The specific form of the preset structure is not specifically limited in this embodiment. In a specific implementation, the preset structure includes, but is not limited to, a hash table, a red black tree, and the like.
为了便于理解,以服务器1为主服务器,接收服务器2返回的第一恢复日志文件21和第一恢复日志文件22,以及服务器3返回的第一恢复日志文件31为例进行说明。第一恢复日志文件21中记录写入数据1,索引信息为a1+a2+a3,操作时间为2013年12月12日,13:22;第一恢复日志文件22中记录删除数据1,索引信息为a1+a2+a3,操作时间为2013年12月12日,13:49;第一恢复日志文件31中记录写入数据1,索引信息为a1+a2+a3,操作时间为2013年12月12日,13:22。其中,a1为恢复日志文件标识,a2为偏移量信息;a3为数据长度信息。For the sake of understanding, the server 1 is the main server, the first recovery log file 21 and the first recovery log file 22 returned by the server 2, and the first recovery log file 31 returned by the server 3 are taken as an example for description. The first recovery log file 21 records the write data 1, the index information is a1+a2+a3, the operation time is December 12, 2013, 13:22; the first recovery log file 22 records the deletion data 1, the index information For a1+a2+a3, the operation time is December 12, 2013, 13:49; the first recovery log file 31 records the write data 1, the index information is a1+a2+a3, and the operation time is December 2013. 12, 13:22. Where a1 is the recovery log file identifier, a2 is the offset information, and a3 is the data length information.
另外,服务器1生成第二恢复日志文件11和第二恢复日志文件12;第二恢复日志文件11中记录写入数据1,索引信息为a1+a2+a3,操作时间为2013年12月12日,13:22;第二恢复日志文件12中记录删除数据1,索引信息为a1+a2+a3,操作时间为2013年12月12日,13:49。In addition, the server 1 generates a second recovery log file 11 and a second recovery log file 12; the second recovery log file 11 records the written data 1, the index information is a1+a2+a3, and the operation time is December 12, 2013. , 13:22; the second recovery log file 12 records the deletion data 1, the index information is a1+a2+a3, and the operation time is December 12, 2013, 13:49.
服务器1读取第二恢复日志文件11,由于此时还未进行恢复日志文件筛选,预设结构为空结构,则直接将第二恢复日志文件11的索引信息a1+a2+a3以及操作时间2013年12月12日,13:22添加到预设结构中;继续读取下一个第二恢复日志文件12,判断第二恢复日志文件12索引信息a1+a2+a3在预设结构中,则将第二恢复日志文件12的操作时间2013年12月12日,13:49与预设结构中第二恢复日志文件11的索引信息a1+a2+a3的操作时间2013年12月12日,13:22进行比较;通过比较可知,第二恢复日志文件12的操作时间2013 年12月12日,13:49晚于预设结构中第二恢复日志文件11的索引信息a1+a2+a3的操作时间2013年12月12日,13:22,则将第二恢复日志文件12的操作时间2013年12月12日,13:49替换预设结构中与第二恢复日志文件11的索引信息a1+a2+a3相对应的操作时间2013年12月12日,13:22,替换后的预设结构中包括索引信息a1+a2+a3以及索引信息a1+a2+a3相对应的操作时间2013年12月12日,13:49。The server 1 reads the second recovery log file 11. Since the recovery log file filtering has not been performed at this time, the preset structure is an empty structure, and the index information a1+a2+a3 of the second recovery log file 11 and the operation time 2013 are directly directly. On December 12th, 13:22 is added to the preset structure; continue to read the next second recovery log file 12, and judge that the second recovery log file 12 index information a1+a2+a3 is in the preset structure, Operation time of the second recovery log file 12 on December 12, 2013, 13:49 and the operation information of the index information a1+a2+a3 of the second recovery log file 11 in the preset structure, December 12, 2013, 13: 22 to compare; by comparison, the second recovery log file 12 operation time 2013 On December 12, 2013, 13:49 nights in the default structure, the second recovery log file 11 index information a1+a2+a3 operation time December 12, 2013, 13:22, the second recovery log file Operation time of 12, December 12, 2013, 13:49 replaces the operation time corresponding to the index information a1+a2+a3 of the second recovery log file 11 in the preset structure on December 12, 2013, 13:22, The replaced preset structure includes the index information a1+a2+a3 and the operation time corresponding to the index information a1+a2+a3 on December 12, 2013, 13:49.
继续读取下一个第一恢复日志文件21,判断第一恢复日志文件21的索引信息a1+a2+a3在预设结构中,则将第一恢复日志文件21的操作时间2013年12月12日,13:22与预设结构中索引信息a1+a2+a3的操作时间2013年12月12日,13:49进行比较;通过比较可知,第一恢复日志文件21的操作时间2013年12月12日,13:22早于预设结构中索引信息a1+a2+a3相对应的操作时间2013年12月12日,13:49,说明第一恢复日志文件21属于在服务器时效的期间,出现的交叠的恢复日志文件,即多个恢复日志文件操作同一个数据,操作时间晚的恢复日志文件操作的内容会覆盖操作时间早的恢复日志文件操作的内容,这时,需要执行操作时间晚的恢复日志文件即可,不需要执行操作时间早的恢复日志文件。此时,预设结构中包括索引信息和索引信息相对应的操作时间不变,即包括索引信息a1+a2+a3以及索引信息a1+a2+a3相对应的操作时间2013年12月12日,13:49。例如,在实际应用的场景中会出现,客户端写入一段数据A,生成一个恢复日志文件;过了一段时间之后,客户端将之前写入的一段数据A删除,又生成一个恢复日志文件。如果在恢复数据时,执行这两个恢复日志文件,则将出现写入一段数据A,再删除一段数据A的操作,而写入一段数据A的操作是无用的。所以,只需要删除一段数据A即可。Continue to read the next first recovery log file 21, determine that the index information a1+a2+a3 of the first recovery log file 21 is in the preset structure, and then operate the first recovery log file 21 on December 12, 2013. 13:22 is compared with the operation time of the index information a1+a2+a3 in the preset structure on December 12, 2013, 13:49; by comparison, the operation time of the first recovery log file 21 is December 12, 2013. On the day of 13:22, the operation time corresponding to the index information a1+a2+a3 in the preset structure is December 12, 2013, 13:49, indicating that the first recovery log file 21 belongs to the period of server aging, which occurs. Overlapping recovery log files, that is, multiple recovery log files operate with the same data. The content of the recovery log file operation with a late operation time will overwrite the contents of the recovery log file operation operation time earlier. In this case, it is necessary to perform the operation time later. The log file can be recovered, and it is not necessary to perform an operation log recovery file early. At this time, the operation time corresponding to the index information and the index information in the preset structure is unchanged, that is, the operation information corresponding to the index information a1+a2+a3 and the index information a1+a2+a3 is December 12, 2013. 13:49. For example, in the actual application scenario, the client writes a piece of data A to generate a recovery log file; after a period of time, the client deletes a piece of data A previously written, and generates a recovery log file. If the two recovery log files are executed while the data is being restored, an operation of writing a piece of data A and deleting a piece of data A will occur, and the operation of writing a piece of data A is useless. Therefore, you only need to delete a piece of data A.
为了筛选恢复日志文件,继续读取下一个第一恢复日志文件22,判断第一恢复日志文件22的索引信息a1+a2+a3在预设结构中,则将第一恢复日志文件22的操作时间2013年12月12日,13:49与预设结构中的索引信息a1+a2+a3的操作时间2013年12月12日,13:49进行比较;通过比较可知,第一恢复日志文件22的操作时间2013年12月12日,13:49与预设结构中的索引信息a1+a2+a3相对应的操作时间2013年12月12日,13:49相同,则继续读取下一个第一恢复日志文件。此时,预设结构中包括索引信息和索引信息相对应的操作时间不变,即包括索引信息a1+a2+a3以及索引信息a1+a2+a3相对应的操作时间2013年12月12日,13:49。 In order to filter the recovery log file, continue to read the next first recovery log file 22, and determine that the index information a1+a2+a3 of the first recovery log file 22 is in the preset structure, then the operation time of the first recovery log file 22 is On December 12, 2013, 13:49 is compared with the operation time of the index information a1+a2+a3 in the preset structure on December 12, 2013, 13:49; by comparison, the first recovery log file 22 is Operation time December 12, 2013, 13:49 The operation time corresponding to the index information a1+a2+a3 in the preset structure is the same on December 12, 2013, 13:49, and continues to read the next first. Restore the log file. At this time, the operation time corresponding to the index information and the index information in the preset structure is unchanged, that is, the operation information corresponding to the index information a1+a2+a3 and the index information a1+a2+a3 is December 12, 2013. 13:49.
读取第一恢复日志文件31,判断第一恢复日志文件31的索引信息a1+a2+a3在预设结构中,则将第一恢复日志文件31的操作时间2013年12月12日,13:22与预设结构中的索引信息a1+a2+a3的操作时间2013年12月12日,13:49进行比较;通过比较可知,第一恢复日志文件31的操作时间2013年12月12日,13:22早于预设结构中的索引信息a1+a2+a3相对应的操作时间2013年12月12日,13:49,则继续读取下一个第一恢复日志文件。至此,接收到的第一恢复日志文件21、22、31及服务器1生成的与数据1标识相对应的第二恢复日志文件11、12都已完成处理。此时,预设结构中包括索引信息a1+a2+a3以及索引信息a1+a2+a3相对应的操作时间2013年12月12日,13:49。The first recovery log file 31 is read, and the index information a1+a2+a3 of the first recovery log file 31 is determined to be in the preset structure, and the operation time of the first recovery log file 31 is December 12, 2013, 13: 22 is compared with the operation time of the index information a1+a2+a3 in the preset structure on December 12, 2013, 13:49; by comparison, the operation time of the first recovery log file 31 is December 12, 2013, 13:22 The operation time corresponding to the index information a1+a2+a3 in the preset structure is December 12, 2013, 13:49, and the next first recovery log file is continuously read. So far, the received first recovery log files 21, 22, 31 and the second recovery log files 11, 12 generated by the server 1 corresponding to the data 1 identification have been processed. At this time, the preset structure includes the index information a1+a2+a3 and the operation time corresponding to the index information a1+a2+a3 on December 12, 2013, 13:49.
作为一种可选实施例,(a7)中获取与预设结构中的索引信息及操作时间对应的恢复日志文件,包括但不限于:As an optional embodiment, the recovery log file corresponding to the index information and the operation time in the preset structure is obtained in (a7), including but not limited to:
(a71)依次读取第一恢复日志文件及与待恢复数据标识相对应的第二恢复日志文件,并将当前读取的恢复日志文件的索引信息依次与预设结构中的索引信息进行比对;若预设结构中存在与当前读取的恢复日志文件的索引信息相同的索引信息,则执行(a72);若预设结构中不存在与当前读取的恢复日志文件的索引信息相同的索引信息,则执行(a74);(a71) sequentially reading the first recovery log file and the second recovery log file corresponding to the to-be-recovered data identifier, and comparing the index information of the currently read recovery log file with the index information in the preset structure. If the index information in the preset structure is the same as the index information of the currently read recovery log file, execute (a72); if there is no index in the preset structure that is the same as the index information of the currently read recovery log file; Information is then executed (a74);
(a72)比较当前读取的恢复日志文件的操作时间与预设结构中对应当前读取的恢复日志文件的索引信息的操作时间;若预设结构中存在与当前读取的恢复日志文件的操作时间相同的对应当前读取的恢复日志文件的索引信息的操作时间,则执行(a73);若预设结构中不存在与当前读取的恢复日志文件的操作时间相同的对应当前读取的恢复日志文件的索引信息的操作时间,则执行(a74);(a72) comparing the operation time of the currently read recovery log file with the operation time of the index information corresponding to the currently read recovery log file in the preset structure; if the operation of the currently-recovered recovery log file exists in the preset structure The operation time of the same time corresponding to the index information of the currently read recovery log file is executed (a73); if the preset structure does not have the same operation time as the currently read recovery log file, the current read recovery is the same. The operation time of the index information of the log file is executed (a74);
(a73)将当前读取的恢复日志文件添加到筛选出的恢复日志文件中,并执行(a74);(a73) adding the currently read recovery log file to the filtered recovery log file and executing (a74);
(a74)读取下一个恢复日志文件;以此类推,直至比对完最后一个恢复日志文件,得到预设结构中的每个索引信息对应的恢复日志文件。(a74) Read the next recovery log file; and so on, until the last recovery log file is compared, and the recovery log file corresponding to each index information in the preset structure is obtained.
为了便于理解,以预设结构中包括索引信息a1+a2+a3以及索引信息a1+a2+a3相对应的操作时间2013年12月12日,13:49为例进行说明。读取第二恢复日志文件11,将第二恢复日志文件11的索引信息a1+a2+a3与预设结构中的索引信息a1+a2+a3进行比对,可知预设结构中存在与第二恢复日志文件11的索引信息a1+a2+a3相同的索引信息;继续比较第二恢复日志文件11的操 作时间2013年12月12日,13:22与预设结构中的索引信息a1+a2+a3的操作时间2013年12月12日,13:49,通过比较可知预设结构中不存在与第二恢复日志文件11的操作时间2013年12月12日,13:22相同的操作时间,则继续读取下一个恢复日志文件。For ease of understanding, the operation time corresponding to the index information a1+a2+a3 and the index information a1+a2+a3 in the preset structure is December 12, 2013, 13:49 as an example. The second recovery log file 11 is read, and the index information a1+a2+a3 of the second recovery log file 11 is compared with the index information a1+a2+a3 in the preset structure, and it is known that the preset structure exists and the second Restoring the same index information of the index information a1+a2+a3 of the log file 11; continuing to compare the operations of the second recovery log file 11 At the time of December 12, 2013, 13:22 and the operation time of the index information a1+a2+a3 in the preset structure, December 12, 2013, 13:49, by comparison, it is known that the preset structure does not exist and The operation time of the recovery log file 11 is the same operation time on December 12, 2013, 13:22, and the next recovery log file is continuously read.
读取第二恢复日志文件12,将第二恢复日志文件12的索引信息a1+a2+a3与预设结构中的索引信息a1+a2+a3进行比对,可知预设结构中存在与第二恢复日志文件12的索引信息a1+a2+a3相同的索引信息;继续比较第二恢复日志文件12的操作时间2013年12月12日,13:49与预设结构中的索引信息a1+a2+a3的操作时间2013年12月12日,13:49,通过比较可知预设结构中存在与恢复日志文件12的操作时间2013年12月12日,13:49相同的操作时间,则将当前读取的第二恢复日志文件12添加到筛选出的恢复日志文件中,并继续读取下一个恢复日志文件。以此类推,依次将第一恢复日志文件21、22、31的索引信息及操作时间与预设结构中的索引信息及操作时间进行比对,未得到匹配的第一恢复日志文件,因此,仅将第二恢复日志文件12作为筛选出的恢复日志文件。The second recovery log file 12 is read, and the index information a1+a2+a3 of the second recovery log file 12 is compared with the index information a1+a2+a3 in the preset structure, and it is known that the preset structure exists and the second Restoring the same index information of the index information a1+a2+a3 of the log file 12; continuing to compare the operation time of the second recovery log file 12 on December 12, 2013, 13:49 with the index information a1+a2+ in the preset structure The operation time of a3 is December 12, 2013, 13:49. By comparison, it is known that there is the same operation time in the preset structure as the operation time of the recovery log file 12, December 12, 2013, 13:49, the current reading will be The second recovery log file 12 is added to the filtered recovery log file and continues to read the next recovery log file. By analogy, the index information and the operation time of the first recovery log files 21, 22, and 31 are compared with the index information and the operation time in the preset structure, and the first recovery log file is not obtained. Therefore, only The second recovery log file 12 is used as the filtered recovery log file.
由于已经完成恢复日志文件的筛选,并且筛选出的恢复日志文件中记录了待恢复数据的最新操作信息,则可根据筛选出的恢复日志文件中记录的操作信息对待恢复数据进行操作。关于恢复数据的方式,本实施例不作具体限定。具体实施时,可以由主服务器根据恢复日志文件中记录的待恢复数据的操作信息重新对数据进行操作。当然,除了上述方式外,还可以采用其他方式。另外,一个恢复日志文件中可以记录待恢复数据的多条日志信息,针对该种情况,可以由主服务器依次读取待恢复数据的每条日志信息,并根据待恢复数据的每条日志信息中的操作信息重新对数据进行操作。Since the recovery log file is filtered and the filtered recovery log file records the latest operation information of the data to be restored, the data to be restored may be operated according to the operation information recorded in the filtered recovery log file. The manner of restoring data is not specifically limited in this embodiment. During specific implementation, the data may be re-operated by the primary server according to the operation information of the data to be recovered recorded in the recovery log file. Of course, in addition to the above methods, other methods can be employed. In addition, a plurality of log information of the data to be restored may be recorded in a recovery log file. For this case, each log information of the data to be restored may be sequentially read by the primary server, and according to each log information of the data to be restored. The operational information re-operates on the data.
为了便于理解,以筛选出的恢复日志文件是恢复日志文件12为例进行说明。恢复日志文件12中记录了删除数据1的操作,则服务器1可执行删除数据1的操作来完成数据恢复。For ease of understanding, the filtered log file is a recovery log file 12 as an example. The operation of deleting the data 1 is recorded in the recovery log file 12, and the server 1 can perform the operation of deleting the data 1 to complete the data recovery.
309:主服务器将筛选出的恢复日志文件发送给各个从服务器,由各个从服务器根据筛选出的恢复日志文件中的操作信息对待恢复数据进行操作;309: The primary server sends the filtered recovery log file to each slave server, and each slave server operates the data to be restored according to the operation information in the filtered recovery log file.
针对存储系统中主服务器和从服务器存储相同数据的特点,为了能够提高恢复数据的速度,本实施例提供的方法还包括但不限于:主服务器将筛选出的恢复日志文件发送给各个从服务器。这样各个从服务器根据筛选出的恢复日志 文件并行对待恢复数据进行恢复,从而无需元数据服务器即可实现数据的恢复,不仅减少了元数据服务器的负载,还提高了数据恢复的速度。The method provided in this embodiment further includes, but is not limited to, the primary server sending the filtered recovery log file to each slave server, in order to improve the speed of restoring data in the storage system. In this way, each slave server is based on the filtered recovery log. The file is restored in parallel with the recovered data, so that the data can be recovered without the metadata server, which not only reduces the load of the metadata server, but also improves the speed of data recovery.
为了便于理解,仍以筛选出的恢复日志文件是第二恢复日志文件12为例进行说明。服务器1将第二恢复日志文件12发送给服务器2和服务器3,服务器2和服务器3根据第二恢复日志文件12对数据1进行恢复。For ease of understanding, the filtered recovery log file is the second recovery log file 12 as an example. The server 1 transmits the second recovery log file 12 to the server 2 and the server 3, and the server 2 and the server 3 restore the data 1 based on the second recovery log file 12.
作为一种可选实施例,本实施例提供的方法还包括但不限于:主服务器删除所有第一恢复日志文件及第二恢复日志文件,并通知各个从服务器删除所有第一恢复日志文件及第二恢复日志文件;As an optional embodiment, the method provided in this embodiment further includes, but is not limited to, the primary server deleting all the first recovery log files and the second recovery log files, and notifying each of the secondary servers to delete all the first recovery log files and the first Second recovery log file;
由于主服务器已经完成数据恢复,因而针对已经恢复的数据无需再记录恢复日志文件,且为了节省主服务器中的存储资源,主服务器将删除所有第一恢复日志文件及第二恢复日志文件。Since the primary server has completed data recovery, there is no need to record the recovery log file for the recovered data, and in order to save the storage resources in the primary server, the primary server deletes all the first recovery log files and the second recovery log files.
同样地,为了节省从服务器中的存储资源,主服务器将通知各个从服务器在成功恢复数据后,删除所有用于恢复该待恢复数据的第一恢复日志文件及第二恢复日志文件。关于通知从服务器的方式,本实施例不作具体限定。具体实施时,可以采用向从服务器发送删除消息的方式来通知从服务器。当然,除了上述方式外,还可以采用其他方式。Similarly, in order to save storage resources from the server, the primary server will notify each slave server to delete all the first recovery log files and the second recovery log files for recovering the data to be restored after successfully recovering the data. Regarding the manner of notifying the slave server, the embodiment is not specifically limited. In a specific implementation, the slave server may be notified by sending a delete message to the slave server. Of course, in addition to the above methods, other methods can be employed.
310:从服务器接收主服务器发送的筛选出的恢复日志文件,并根据筛选出的恢复日志文件中的操作信息对待恢复数据进行操作。310: Receive, from the server, the filtered recovery log file sent by the primary server, and operate the restored data according to the operation information in the filtered recovery log file.
由于筛选出的恢复日志文件中记录了待恢复数据的位置信息及操作信息,则从服务器在接收到主服务器发送的筛选出的恢复日志文件后,可根据筛选出的恢复日志文件对待恢复数据进行恢复。关于恢复数据的方式,具体可参见上述步骤308中主服务器根据筛选出的恢复日志文件恢复待恢复数据的方式,此处不再赘述。After the filtered recovery log file records the location information and the operation information of the data to be restored, after receiving the filtered recovery log file sent by the primary server, the slave server may perform the recovery data according to the filtered recovery log file. restore. For the manner of restoring data, refer to the manner in which the primary server recovers the data to be restored according to the filtered recovery log file in the foregoing step 308, and details are not described herein again.
作为一种可选实施例,本实施例提供的方法还包括但不限于:从服务器接收主服务器发送的删除所有第一恢复日志文件及第二恢复日志文件的通知,根据通知删除所有第一恢复日志文件及第二恢复日志文件。As an optional embodiment, the method provided in this embodiment further includes, but is not limited to, receiving, from the server, a notification sent by the primary server to delete all the first recovery log files and the second recovery log file, and deleting all the first recovery according to the notification. The log file and the second recovery log file.
由于主服务器通知各个从服务器删除所有第一恢复日志文件及第二恢复日志文件,则从服务器可以接收主服务器发送的删除所有第一恢复日志文件及第二恢复日志文件的通知,从而触发根据通知在成功恢复数据后,删除所有第一恢复日志文件及第二恢复日志文件。Since the primary server notifies each of the secondary servers to delete all the first recovery log files and the second recovery log files, the secondary server may receive a notification sent by the primary server to delete all the first recovery log files and the second recovery log files, thereby triggering the notification according to the notification. After successfully recovering the data, delete all the first recovery log files and the second recovery log files.
本实施例提供的方法,通过主服务器向存储系统中的各个从服务器发送日 志获取请求,接收各个从服务器返回的第一恢复日志文件,并根据所有第一恢复日志文件及主服务器生成的第二恢复日志文件恢复待恢复数据恢复待恢复数据,从而无需扫描所有数据,也无需使用元数据服务器即可实现恢复数据,提高了恢复数据的效率。The method provided in this embodiment sends the date to each slave server in the storage system through the primary server. Acquiring the request, receiving the first recovery log file returned by each slave server, and restoring the data to be recovered to recover the data to be recovered according to all the first recovery log files and the second recovery log file generated by the main server, thereby eliminating the need to scan all data, Recover data without using a metadata server, improving the efficiency of restoring data.
实施例三Embodiment 3
参见图5,本发明实施例提供了一种恢复数据的服务器,该服务器为应用于存储系统的主服务器,存储系统包括主服务器和从服务器,主服务器和从服务器均用于存储相同数据,主服务器为第一个成功存储数据的服务器,该服务器包括:Referring to FIG. 5, an embodiment of the present invention provides a server for recovering data, which is a primary server applied to a storage system, where the storage system includes a primary server and a secondary server, and both the primary server and the secondary server are used to store the same data. The server is the first server to successfully store data, and the server includes:
第一发送模块401,用于当存储系统中的任意一个服务器存储数据失败时,向存储系统中的每个从服务器发送日志获取请求,日志获取请求中携带待恢复数据标识;The first sending module 401 is configured to send a log obtaining request to each slave server in the storage system when the storage server fails to store data in the storage system, where the log obtaining request carries the data identifier to be restored;
第一接收模块402,用于接收各个从服务器根据日志获取请求返回的第一恢复日志文件,每个第一恢复日志文件记录了待恢复数据标识所标识的待恢复数据的位置信息及操作信息;The first receiving module 402 is configured to receive a first recovery log file returned by each slave server according to the log obtaining request, where each first recovery log file records location information and operation information of the to-be-recovered data identified by the to-be-recovered data identifier;
恢复模块403,用于根据所有第一恢复日志文件及第二恢复日志文件所记录的操作信息中的最新操作信息对待恢复数据进行操作,待恢复数据根据待恢复数据的位置信息查找得到,第二恢复日志文件由主服务器生成,且记录了待恢复数据标识所标识的待恢复数据的位置信息及操作信息。The recovery module 403 is configured to perform operation on the restored data according to the latest operation information in the operation information recorded by all the first recovery log files and the second recovery log file, and the data to be restored is searched according to the location information of the data to be restored, and the second The recovery log file is generated by the primary server, and records the location information and operation information of the data to be recovered identified by the data identifier to be restored.
可选地,该服务器,还包括:Optionally, the server further includes:
存储模块,用于接收并存储客户端发送的数据;a storage module, configured to receive and store data sent by the client;
返回模块,用于向客户端返回包含数据的识别标识的第一写入状态信息,第一写入状态信息包括写入成功信息或写入失败信息;a returning module, configured to return, to the client, first write state information that includes an identification identifier of the data, where the first write state information includes a write success information or a write failure information;
第二接收模块,用于接收客户端发送的总写入状态信息,总写入状态信息包括主服务器向客户端返回的第一写入状态信息及每个从服务器向客户端返回的第二写入状态信息;a second receiving module, configured to receive total write status information sent by the client, where the total write status information includes first write status information returned by the primary server to the client, and second write returned from the server to the client. Status information;
生成模块,用于当客户端发送的总写入状态信息中包含写入失败信息时,确定客户端发送的数据为待恢复数据,并生成记录待恢复数据的位置信息及操作信息的第二恢复日志文件。a generating module, configured to: when the total write status information sent by the client includes the write failure information, determine that the data sent by the client is the data to be restored, and generate a second recovery of the location information and the operation information for recording the data to be restored. Log file.
可选地,恢复模块403,包括: Optionally, the recovery module 403 includes:
第一读取单元,用于依次读取每个第一恢复日志文件及第二恢复日志文件;a first reading unit, configured to sequentially read each of the first recovery log file and the second recovery log file;
判断单元,用于判断当前读取的恢复日志文件的索引信息是否在预设结构中,索引信息包括恢复日志文件标识、偏移量信息及数据长度信息,预设结构存储有索引信息及操作时间;The determining unit is configured to determine whether the index information of the currently read recovery log file is in a preset structure, the index information includes a recovery log file identifier, an offset information, and a data length information, and the preset structure stores the index information and the operation time. ;
添加单元,用于在当前读取的恢复日志文件的索引信息未在预设结构中时,将当前读取的恢复日志文件的索引信息及操作时间添加到预设结构中;Adding a unit, when the index information of the currently read recovery log file is not in the preset structure, adding the index information and the operation time of the currently read recovery log file to the preset structure;
第二读取单元,用于继续读取下一个恢复日志文件;a second reading unit, configured to continue to read the next recovery log file;
处理单元,用于按照处理当前读取的恢复日志文件的方式处理读取的下一个恢复日志文件,直至处理完最后一个恢复日志文件,得到存储有无重复索引信息及操作时间的预设结构;a processing unit, configured to process the read next recovery log file in a manner of processing the currently read recovery log file, until the last recovery log file is processed, to obtain a preset structure for storing the duplicate index information and the operation time;
获取单元,用于获取与预设结构中的索引信息及操作时间对应的恢复日志文件,并将与预设结构中的索引信息及操作时间对应的恢复日志文件作为筛选出的恢复日志文件;The obtaining unit is configured to obtain a recovery log file corresponding to the index information and the operation time in the preset structure, and use the recovery log file corresponding to the index information and the operation time in the preset structure as the filtered recovery log file;
恢复单元,用于根据筛选出的恢复日志文件中的操作信息对待恢复数据进行操作。A recovery unit, configured to operate on the restored data according to the operation information in the filtered recovery log file.
可选地,恢复模块403,还包括:Optionally, the recovery module 403 further includes:
比较单元,用于在当前读取的恢复日志文件的索引信息在预设结构中时,将当前读取的恢复日志文件的操作时间与预设结构中对应当前读取的恢复日志文件的索引信息的操作时间进行比较;a comparison unit, configured to: when the index information of the currently read recovery log file is in the preset structure, the operation time of the currently read recovery log file and the index information of the currently read recovery log file in the preset structure Comparison of operating time;
替换单元,用于在当前读取的恢复日志文件的操作时间晚于预设结构中对应当前读取的恢复日志文件的索引信息的操作时间时,将当前读取的恢复日志文件的操作时间替换预设结构中与当前读取的恢复日志文件的索引信息相对应的操作时间;a replacement unit, configured to replace the operation time of the currently read recovery log file when the operation time of the currently read recovery log file is later than the operation time of the index information corresponding to the currently read recovery log file in the preset structure The operation time in the preset structure corresponding to the index information of the currently read recovery log file;
第二读取单元,还用于执行继续读取下一个恢复日志文件的步骤。The second reading unit is further configured to perform the step of continuing to read the next recovery log file.
可选地,获取单元,包括:Optionally, the obtaining unit includes:
第一读取子单元,用于依次读取第一恢复日志文件及与待恢复数据标识相对应的第二恢复日志文件;a first reading subunit, configured to sequentially read the first recovery log file and the second recovery log file corresponding to the to-be-recovered data identifier;
比对子单元,用于将当前读取的恢复日志文件的索引信息依次与预设结构中的索引信息进行比对;The comparison subunit is configured to compare the index information of the currently read recovery log file with the index information in the preset structure;
比较子单元,用于当预设结构中存在与当前读取的恢复日志文件的索引信 息相同的索引信息时,比较当前读取的恢复日志文件的操作时间与预设结构中对应当前读取的恢复日志文件的索引信息的操作时间;Comparison subunit for indexing information in the default structure that exists with the currently read recovery log file When the same index information is used, the operation time of the currently read recovery log file and the operation time of the index information corresponding to the currently read recovery log file in the preset structure are compared;
添加子单元,用于当预设结构中存在与当前读取的恢复日志文件的操作时间相同的对应当前读取的恢复日志文件的索引信息的操作时间时,将当前读取的恢复日志文件添加到筛选出的恢复日志文件中;Adding a subunit, when the operation time corresponding to the index information of the currently read recovery log file is the same as the operation time of the currently read recovery log file in the preset structure, adding the currently read recovery log file To the filtered recovery log file;
第二读取子单元,用于读取下一个恢复日志文件;以此类推,直至比对完最后一个恢复日志文件,得到预设结构中的每个索引信息对应的恢复日志文件。The second read subunit is configured to read the next recovery log file; and so on until the last recovery log file is compared, and the recovery log file corresponding to each index information in the preset structure is obtained.
可选地,该服务器,还包括:Optionally, the server further includes:
第二发送模块,用于将筛选出的恢复日志文件发送给各个从服务器,由各个从服务器根据筛选出的恢复日志文件对待恢复数据进行恢复。The second sending module is configured to send the filtered recovery log file to each slave server, and each slave server recovers the data to be restored according to the filtered recovery log file.
可选地,该服务器,还包括:Optionally, the server further includes:
删除模块,用于删除所有第一恢复日志文件及第二恢复日志文件;Deleting a module for deleting all first recovery log files and second recovery log files;
通知模块,用于通知各个从服务器删除所有第一恢复日志文件及第二恢复日志文件。The notification module is configured to notify each of the slave servers to delete all the first recovery log files and the second recovery log files.
本发明实施例提供的服务器,通过向存储系统中的各个从服务器发送日志获取请求,接收各个从服务器返回的第一恢复日志文件,并根据所有第一恢复日志文件及主服务器生成的第二恢复日志文件恢复待恢复数据,从而无需扫描所有数据,也无需使用元数据服务器即可实现恢复数据,提高了恢复数据的效率。The server provided by the embodiment of the present invention receives the first recovery log file returned by each slave server by sending a log acquisition request to each slave server in the storage system, and generates a second recovery according to all the first recovery log files and the primary server. The log file recovers the data to be recovered, so that it is not necessary to scan all the data, and the metadata server can be used to recover the data, which improves the efficiency of restoring data.
实施例四Embodiment 4
参见图6,本发明实施例提供了一种恢复数据的服务器,该服务器为应用于存储系统的从服务器,存储系统包括主服务器和从服务器,主服务器和从服务器均用于存储相同数据,主服务器为第一个成功存储数据的服务器,该服务器包括:Referring to FIG. 6, an embodiment of the present invention provides a server for recovering data, which is a slave server applied to a storage system, where the storage system includes a primary server and a secondary server, and both the primary server and the secondary server are used to store the same data. The server is the first server to successfully store data, and the server includes:
第一接收模块501,用于接收主服务器发送的日志获取请求,日志获取请求中携带待恢复数据标识;The first receiving module 501 is configured to receive a log obtaining request sent by the primary server, where the log obtaining request carries the data identifier to be restored;
第一返回模块502,用于根据日志获取请求向主服务器返回第一恢复日志文件,使主服务器根据第一恢复日志文件及主服务器生成的第二恢复日志文件恢复待恢复数据; The first returning module 502 is configured to return a first recovery log file to the primary server according to the log obtaining request, so that the primary server recovers the to-be-recovered data according to the first recovery log file and the second recovery log file generated by the primary server;
第二接收模块503,用于接收主服务器发送的筛选出的恢复日志文件;The second receiving module 503 is configured to receive the filtered recovery log file sent by the primary server.
恢复模块504,用于根据筛选出的恢复日志文件所记录的操作信息对待恢复数据进行操作;The recovery module 504 is configured to perform operation on the restored data according to the operation information recorded by the filtered recovery log file;
其中,第一恢复日志文件及第二恢复日志文件均记录了待恢复数据标识所标识的待恢复数据的位置信息及操作信息。The first recovery log file and the second recovery log file record the location information and operation information of the to-be-recovered data identified by the to-be-recovered data identifier.
可选地,该服务器,还包括:Optionally, the server further includes:
存储模块,用于接收并存储客户端发送的数据;a storage module, configured to receive and store data sent by the client;
第二返回模块,用于向客户端返回包含数据的识别标识的第二写入状态信息,第二写入状态信息包括写入成功信息或写入失败信息;a second returning module, configured to return, to the client, second writing state information that includes an identification identifier of the data, where the second writing state information includes a writing success information or a writing failure information;
第三接收模块,用于接收客户端发送的总写入状态信息,总写入状态信息包括从服务器向客户端返回的第二写入状态信息及主服务器向客户端返回的第一写入状态信息;a third receiving module, configured to receive total write status information sent by the client, where the total write status information includes second write status information returned from the server to the client, and a first write status returned by the primary server to the client information;
生成模块,用于当客户端发送的总写入状态信息中包含写入失败信息时,确定客户端发送的数据为待恢复数据,并生成记录待恢复数据的位置信息及操作信息的第一恢复日志文件。a generating module, configured to: when the total write status information sent by the client includes the write failure information, determine that the data sent by the client is the data to be restored, and generate the first recovery of the location information and the operation information of the data to be restored. Log file.
可选地,该服务器,还包括:Optionally, the server further includes:
第四接收模块,用于接收主服务器发送的删除所有第一恢复日志文件及第二恢复日志文件的通知;a fourth receiving module, configured to receive a notification sent by the primary server to delete all the first recovery log files and the second recovery log files;
删除模块,用于根据通知删除所有第一恢复日志文件及第二恢复日志文件。The deleting module is configured to delete all the first recovery log files and the second recovery log files according to the notification.
本实施例提供的服务器,通过接收主服务器发送的日志获取请求,再根据日志获取请求向主服务器返回第一恢复日志文件,使主服务器根据第一恢复日志文件及主服务器生成的第二恢复日志文件恢复待恢复数据,从而无需扫描所有数据,也无需使用元数据服务器即可实现恢复数据,提高了恢复数据的效率。The server provided in this embodiment receives the log obtaining request sent by the primary server, and returns a first recovery log file to the primary server according to the log obtaining request, so that the primary server generates the second recovery log according to the first recovery log file and the primary server. The file recovers the data to be recovered, so that it is not necessary to scan all the data, and the metadata server can be used to recover the data, which improves the efficiency of restoring data.
实施例五Embodiment 5
参见图7,本发明实施例提供了一种恢复数据的系统,该系统包括主服务器701和至少一个从服务器702;其中,该主服务器701如上述实施例三提供的恢复数据的服务器,该从服务器702如上述实施例四提供的恢复数据的服务器,具体详见上述实施例三和四的内容,此处不再赘述。Referring to FIG. 7, an embodiment of the present invention provides a system for recovering data, where the system includes a main server 701 and at least one slave server 702. The master server 701 is a server for recovering data provided by the foregoing third embodiment. The server 702 is the server for restoring data provided in the above-mentioned fourth embodiment. For details, refer to the contents of the third and fourth embodiments, and details are not described herein again.
本实施例提供的系统,通过主服务器向存储系统中的各个从服务器发送日 志获取请求,接收各个从服务器返回的第一恢复日志文件,并根据所有第一恢复日志文件及主服务器生成的第二恢复日志文件恢复待恢复数据,从而无需扫描所有数据,也无需使用元数据服务器即可实现恢复数据,提高了恢复数据的效率。The system provided by this embodiment sends the date to each slave server in the storage system through the primary server. Acquire the request, receive the first recovery log file returned from each server, and recover the data to be restored according to all the first recovery log files and the second recovery log file generated by the primary server, thereby eliminating the need to scan all data and use metadata The server can recover data and improve the efficiency of data recovery.
实施例六Embodiment 6
本发明实施例提供了一种恢复数据的服务器,该服务器为应用于存储系统的主服务器,存储系统包括主服务器和从服务器,主服务器和从服务器均用于存储相同数据,主服务器为第一个成功存储数据的服务器,该服务器包括发射机、接收机、处理器;The embodiment of the present invention provides a server for recovering data, which is a primary server applied to a storage system, where the storage system includes a primary server and a secondary server, and the primary server and the secondary server are both used to store the same data, and the primary server is the first server. a server that successfully stores data, the server including a transmitter, a receiver, and a processor;
其中,发射机,用于当存储系统中的任意一个服务器存储数据失败时,向存储系统中的每个从服务器发送日志获取请求,日志获取请求中携带待恢复数据标识;The transmitter is configured to send a log obtaining request to each slave server in the storage system when the server fails to store data in the storage system, and the log obtaining request carries the data identifier to be restored.
接收机,用于接收各个从服务器根据日志获取请求返回的第一恢复日志文件,每个第一恢复日志文件记录了待恢复数据标识所标识的待恢复数据的位置信息及操作信息;a receiver, configured to receive a first recovery log file returned by each slave server according to the log obtaining request, where each first recovery log file records location information and operation information of the to-be-recovered data identified by the to-be-recovered data identifier;
处理器,用于根据所有第一恢复日志文件及第二恢复日志文件所记录的操作信息中的最新操作信息对待恢复数据进行操作,待恢复数据根据待恢复数据的位置信息查找得到,第二恢复日志文件由主服务器生成,且记录了待恢复数据标识所标识的待恢复数据的位置信息及操作信息。a processor, configured to perform, according to the latest operation information in the operation information recorded by the first recovery log file and the second recovery log file, the data to be restored is searched according to the location information of the data to be restored, and the second recovery is performed. The log file is generated by the primary server, and records the location information and operation information of the data to be recovered identified by the data identifier to be restored.
作为一种可选实施例,处理器,还用于接收并存储客户端发送的数据;As an optional embodiment, the processor is further configured to receive and store data sent by the client;
发射机,还用于向客户端返回包含数据的识别标识的第一写入状态信息,第一写入状态信息包括写入成功信息或写入失败信息;The transmitter is further configured to return, to the client, first write status information that includes an identification identifier of the data, where the first write status information includes write success information or write failure information;
接收机,还用于接收客户端发送的总写入状态信息,总写入状态信息包括主服务器向客户端返回的第一写入状态信息及每个从服务器向客户端返回的第二写入状态信息;The receiver is further configured to receive total write status information sent by the client, where the total write status information includes first write status information returned by the primary server to the client, and second write each returned from the server to the client. status information;
处理器,还用于当客户端发送的总写入状态信息中包含写入失败信息时,确定数据为待恢复数据,并生成记录待恢复数据的位置信息及操作信息的第二恢复日志文件。The processor is further configured to: when the total write status information sent by the client includes the write failure information, determine the data as the data to be restored, and generate a second recovery log file that records the location information and the operation information of the data to be restored.
作为一种可选实施例,处理器,用于依次读取每个第一恢复日志文件及第二恢复日志文件;判断当前读取的恢复日志文件的索引信息是否在预设结构 中,索引信息包括恢复日志文件标识、偏移量信息及数据长度信息,预设结构用于存储索引信息及操作时间;在当前读取的恢复日志文件的索引信息未在预设结构中时,将当前读取的恢复日志文件的索引信息及操作时间添加到预设结构中;继续读取下一个恢复日志文件;按照处理当前读取的恢复日志文件的方式处理读取的下一个恢复日志文件,直至处理完最后一个恢复日志文件,得到存储有无重复索引信息及操作时间的预设结构;获取与预设结构中的索引信息及操作时间对应的恢复日志文件,并将与预设结构中的索引信息及操作时间对应的恢复日志文件作为筛选出的恢复日志文件,根据筛选出的恢复日志文件中的操作信息对待恢复数据进行操作。As an optional embodiment, the processor is configured to sequentially read each of the first recovery log file and the second recovery log file, and determine whether the index information of the currently read recovery log file is in a preset structure. The index information includes a recovery log file identifier, an offset information, and a data length information, and the preset structure is used to store the index information and the operation time; when the index information of the currently read recovery log file is not in the preset structure, Adding the index information and operation time of the currently read recovery log file to the preset structure; continuing to read the next recovery log file; processing the next recovery log file read in the same manner as processing the currently read recovery log file Until the last recovery log file is processed, obtaining a preset structure for storing the duplicate index information and the operation time; acquiring the recovery log file corresponding to the index information and the operation time in the preset structure, and the preset structure is The index information and the recovery log file corresponding to the operation time are used as the filtered recovery log file, and the data to be restored is operated according to the operation information in the filtered recovery log file.
作为一种可选实施例,处理器,还用于在当前读取的恢复日志文件的索引信息在预设结构中时,将当前读取的恢复日志文件的操作时间与预设结构中对应当前读取的恢复日志文件的索引信息的操作时间进行比较;在当前读取的恢复日志文件的操作时间晚于预设结构中对应当前读取的恢复日志文件的索引信息的操作时间时,将当前读取的恢复日志文件的操作时间替换预设结构中与当前读取的恢复日志文件的索引信息相对应的操作时间;执行继续读取下一个恢复日志文件的步骤。As an optional embodiment, the processor is further configured to: when the index information of the currently read recovery log file is in the preset structure, compare the operation time of the currently read recovery log file with the current current in the preset structure. The operation time of the index information of the read recovery log file is compared; when the operation time of the currently read recovery log file is later than the operation time of the index information corresponding to the currently read recovery log file in the preset structure, the current The operation time of the read recovery log file replaces the operation time in the preset structure corresponding to the index information of the currently read recovery log file; and the step of continuing to read the next recovery log file is performed.
作为一种可选实施例,处理器,用于依次读取第一恢复日志文件及与待恢复数据标识相对应的第二恢复日志文件;将当前读取的恢复日志文件的索引信息依次与预设结构中的索引信息进行比对;当预设结构中存在与当前读取的恢复日志文件的索引信息相同的索引信息时,比较当前读取的恢复日志文件的操作时间与预设结构中对应当前读取的恢复日志文件的索引信息的操作时间;当预设结构中存在与当前读取的恢复日志文件的操作时间相同的对应当前读取的恢复日志文件的索引信息的操作时间时,将当前读取的恢复日志文件添加到筛选出的恢复日志文件中;读取下一个恢复日志文件;以此类推,直至比对完最后一个恢复日志文件,得到预设结构中的每个索引信息对应的恢复日志文件。As an optional embodiment, the processor is configured to sequentially read the first recovery log file and the second recovery log file corresponding to the to-be-recovered data identifier; and sequentially, the index information of the currently read recovery log file is The index information in the structure is compared; when there is the same index information in the preset structure as the index information of the currently read recovery log file, the operation time of the currently read recovery log file is compared with the preset structure. The operation time of the index information of the currently read recovery log file; when there is an operation time corresponding to the operation time of the currently read recovery log file in the preset structure corresponding to the index information of the currently read recovery log file, The currently read recovery log file is added to the filtered recovery log file; the next recovery log file is read; and so on, until the last recovery log file is compared, and each index information in the preset structure is obtained. Recovery log file.
作为一种可选实施例,发射机,还用于将筛选出的恢复日志文件发送给各个从服务器,由各个从服务器根据筛选出的恢复日志文件对待恢复数据进行恢复。As an optional embodiment, the transmitter is further configured to send the filtered recovery log file to each slave server, and each slave server recovers the data to be restored according to the filtered recovery log file.
作为一种可选实施例,处理器,还用于删除所有第一恢复日志文件及第二恢复日志文件;通知各个从服务器删除所有第一恢复日志文件及第二恢复日志 文件。As an optional embodiment, the processor is further configured to delete all the first recovery log files and the second recovery log files; notify each of the slave servers to delete all the first recovery log files and the second recovery log. file.
本发明实施例提供的服务器,通过接收存储系统中的各个从服务器根据主服务器发送的日志获取请求返回的第一恢复日志文件,并根据所有第一恢复日志文件及主服务器生成的第二恢复日志文件恢复待恢复数据,从而无需扫描所有数据,也无需使用元数据服务器即可实现恢复数据,提高了恢复数据的效率。The server provided by the embodiment of the present invention receives the first recovery log file returned by each slave server in the storage system according to the log obtaining request sent by the primary server, and according to all the first recovery log files and the second recovery log generated by the primary server. The file recovers the data to be recovered, so that it is not necessary to scan all the data, and the metadata server can be used to recover the data, which improves the efficiency of restoring data.
实施例七Example 7
本发明实施例提供了一种恢复数据的服务器,该服务器为应用于存储系统的从服务器,存储系统包括主服务器和从服务器,主服务器和从服务器均用于存储相同数据,主服务器为第一个成功存储数据的服务器,该服务器包括发射机、接收机、处理器;The embodiment of the invention provides a server for recovering data, the server is a slave server applied to the storage system, the storage system includes a master server and a slave server, and the master server and the slave server are both used to store the same data, and the master server is the first server. a server that successfully stores data, the server including a transmitter, a receiver, and a processor;
其中,接收机用于接收主服务器发送的日志获取请求,日志获取请求中携带待恢复数据标识;The receiver is configured to receive a log obtaining request sent by the primary server, where the log obtaining request carries the data identifier to be restored;
发射机,用于根据日志获取请求向主服务器返回第一恢复日志文件,使主服务器根据第一恢复日志文件及主服务器生成的第二恢复日志文件恢复待恢复数据;a transmitter, configured to return a first recovery log file to the primary server according to the log obtaining request, so that the primary server recovers the to-be-recovered data according to the first recovery log file and the second recovery log file generated by the primary server;
接收机,还用于接收主服务器发送的筛选出的恢复日志文件;The receiver is further configured to receive the filtered recovery log file sent by the primary server;
处理器,用于根据筛选出的恢复日志文件所记录的操作信息对待恢复数据进行操作;a processor, configured to perform operation on the restored data according to the operation information recorded by the filtered recovery log file;
其中,每个第一恢复日志文件及第二恢复日志文件均记录了待恢复数据标识所标识的待恢复数据的位置信息及操作信息。Each of the first recovery log file and the second recovery log file records location information and operation information of the to-be-recovered data identified by the to-be-recovered data identifier.
作为一种可选实施例,处理器,还用于接收并存储客户端发送的数据;As an optional embodiment, the processor is further configured to receive and store data sent by the client;
发射机,还用于向客户端返回包含数据的识别标识的第二写入状态信息,第二写入状态信息包括写入成功信息或写入失败信息;The transmitter is further configured to return, to the client, second write status information that includes an identification identifier of the data, where the second write status information includes write success information or write failure information;
接收机,还用于接收客户端发送的总写入状态信息,总写入状态信息包括从服务器向客户端返回的第二写入状态信息及主服务器向客户端返回的第一写入状态信息;The receiver is further configured to receive total write status information sent by the client, where the total write status information includes second write status information returned from the server to the client, and first write status information returned by the primary server to the client. ;
处理器,还用于当客户端发送的总写入状态信息中包含写入失败信息时,确定客户端发送的数据为待恢复数据,并生成记录待恢复数据的位置信息及操作信息的第一恢复日志文件。The processor is further configured to: when the total write status information sent by the client includes the write failure information, determine that the data sent by the client is the data to be restored, and generate the first location information and operation information for recording the data to be restored. Restore the log file.
作为一种可选实施例,接收机,还用于接收主服务器发送的删除所有第一 恢复日志文件及第二恢复日志文件的通知;As an optional embodiment, the receiver is further configured to receive all the first deletions sent by the primary server. Notification of recovery log file and second recovery log file;
处理器,还用于根据通知删除所有第一恢复日志文件及第二恢复日志文件。The processor is further configured to delete all the first recovery log files and the second recovery log files according to the notification.
本发明实施例提供的服务器,通过接收主服务器发送的日志获取请求,再根据日志获取请求向主服务器返回第一恢复日志文件,使主服务器根据第一恢复日志文件及主服务器生成的第二恢复日志文件恢复待恢复数据,从而无需扫描所有数据,也无需使用元数据服务器即可实现恢复数据,提高了恢复数据的效率。The server provided by the embodiment of the present invention receives the log obtaining request sent by the primary server, and returns a first recovery log file to the primary server according to the log obtaining request, so that the primary server generates the second recovery according to the first recovery log file and the primary server. The log file recovers the data to be recovered, so that it is not necessary to scan all the data, and the metadata server can be used to recover the data, which improves the efficiency of restoring data.
需要说明的是:上述实施例提供的恢复数据的服务器在恢复数据时,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将服务器的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。另外,上述实施例提供的恢复数据的服务器与恢复数据的方法实施例属于同一构思,其具体实现过程详见方法实施例,这里不再赘述。It should be noted that, when recovering data, the server for restoring data provided by the foregoing embodiment is only illustrated by dividing the foregoing functional modules. In actual applications, the function allocation may be completed by different functional modules as needed. The internal structure of the server is divided into different functional modules to complete all or part of the functions described above. In addition, the server for restoring data and the method for restoring data provided by the foregoing embodiments are in the same concept, and the specific implementation process is described in detail in the method embodiment, and details are not described herein again.
上述本发明实施例序号仅仅为了描述,不代表实施例的优劣。The serial numbers of the embodiments of the present invention are merely for the description, and do not represent the advantages and disadvantages of the embodiments.
本领域普通技术人员可以理解实现上述实施例的全部或部分步骤可以通过硬件来完成,也可以通过程序来指令相关的硬件完成,所述的程序可以存储于一种计算机可读存储介质中,上述提到的存储介质可以是只读存储器,磁盘或光盘等。A person skilled in the art may understand that all or part of the steps of implementing the above embodiments may be completed by hardware, or may be instructed by a program to execute related hardware, and the program may be stored in a computer readable storage medium. The storage medium mentioned may be a read only memory, a magnetic disk or an optical disk or the like.
以上所述仅为本发明的较佳实施例,并不用以限制本发明,凡在本发明的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。 The above are only the preferred embodiments of the present invention, and are not intended to limit the present invention. Any modifications, equivalents, improvements, etc., which are within the spirit and scope of the present invention, should be included in the protection of the present invention. Within the scope.

Claims (15)

  1. 一种恢复数据的方法,其特征在于,所述方法应用于存储系统的主服务器,所述存储系统包括主服务器和从服务器,所述主服务器和所述从服务器均用于存储相同数据,所述主服务器为第一个成功存储数据的服务器,所述方法包括:A method for restoring data, the method being applied to a primary server of a storage system, the storage system comprising a primary server and a secondary server, the primary server and the secondary server are both configured to store the same data, The primary server is the first server that successfully stores data, and the method includes:
    当所述存储系统中的任意一个服务器存储数据失败时,所述主服务器向所述存储系统中的每个从服务器发送日志获取请求,所述日志获取请求中携带待恢复数据标识;When the storage server fails to store the data in the storage system, the primary server sends a log acquisition request to each slave server in the storage system, where the log acquisition request carries the data identifier to be restored;
    接收各个从服务器根据所述日志获取请求返回的第一恢复日志文件,每个第一恢复日志文件记录了所述待恢复数据标识所标识的待恢复数据的位置信息及操作信息;Receiving, by the respective slave server, the first recovery log file returned according to the log obtaining request, where each first recovery log file records location information and operation information of the to-be-recovered data identified by the to-be-recovered data identifier;
    根据所有所述第一恢复日志文件及第二恢复日志文件所记录的操作信息中的最新操作信息对待恢复数据进行操作,所述待恢复数据根据所述待恢复数据的位置信息查找得到,所述第二恢复日志文件由所述主服务器生成,且记录了所述待恢复数据标识所标识的待恢复数据的位置信息及操作信息。And operating the restored data according to the latest operation information in the operation information recorded by the first recovery log file and the second recovery log file, where the to-be-recovered data is searched according to the location information of the to-be-recovered data, The second recovery log file is generated by the primary server, and records location information and operation information of the to-be-recovered data identified by the to-be-recovered data identifier.
  2. 根据权利要求1所述的方法,其特征在于,所述向所述存储系统中的每个从服务器发送日志获取请求之前,还包括:The method according to claim 1, wherein before the sending of the log obtaining request to each slave server in the storage system, the method further comprises:
    接收并存储客户端发送的数据,并向所述客户端返回包含所述数据的识别标识的第一写入状态信息,所述第一写入状态信息为写入成功信息或写入失败信息;Receiving and storing data sent by the client, and returning, to the client, first write status information that includes the identification identifier of the data, where the first write status information is write success information or write failure information;
    接收所述客户端发送的总写入状态信息,所述总写入状态信息包括所述主服务器向所述客户端返回的第一写入状态信息及每个从服务器向所述客户端返回的第二写入状态信息;Receiving total write status information sent by the client, where the total write status information includes first write status information returned by the primary server to the client, and each slave server returns to the client Second write status information;
    如果所述客户端发送的总写入状态信息中包含写入失败信息,则确定所述客户端发送的数据为待恢复数据,并生成记录所述待恢复数据的位置信息及操作信息的第二恢复日志文件。If the total write status information sent by the client includes the write failure information, determining that the data sent by the client is the data to be restored, and generating the second location information and the operation information for recording the data to be restored. Restore the log file.
  3. 根据权利要求1所述的方法,其特征在于,所述根据所有所述第一 恢复日志文件及第二恢复日志文件所记录的操作信息中的最新操作信息对待恢复数据进行操作,包括:The method of claim 1 wherein said first according to all of said first The latest operation information in the operation information recorded in the recovery log file and the second recovery log file is to be operated on the restored data, including:
    依次读取每个所述第一恢复日志文件及第二恢复日志文件;Reading each of the first recovery log file and the second recovery log file in sequence;
    判断当前读取的恢复日志文件的索引信息是否在预设结构中,所述索引信息包括恢复日志文件标识、偏移量信息及数据长度信息,所述预设结构用于存储索引信息及操作时间;Determining whether the index information of the currently read recovery log file is in a preset structure, the index information includes a recovery log file identifier, an offset information, and data length information, where the preset structure is used to store index information and operation time. ;
    若当前读取的恢复日志文件的索引信息未在所述预设结构中,则将当前读取的恢复日志文件的索引信息及操作时间添加到所述预设结构中;If the index information of the currently read recovery log file is not in the preset structure, adding the index information and the operation time of the currently read recovery log file to the preset structure;
    继续读取下一个恢复日志文件,按照处理当前读取的恢复日志文件的方式处理读取的下一个恢复日志文件,直至处理完最后一个恢复日志文件,得到存储有无重复索引信息及操作时间的预设结构;Continue to read the next recovery log file, and process the next recovery log file read in the manner of processing the currently read recovery log file until the last recovery log file is processed, and whether the storage has duplicate index information and operation time is obtained. Preset structure;
    获取与所述预设结构中的索引信息及操作时间对应的恢复日志文件,并将与所述预设结构中的索引信息及操作时间对应的恢复日志文件作为筛选出的恢复日志文件,根据筛选出的恢复日志文件中的操作信息对待恢复数据进行操作。Obtaining a recovery log file corresponding to the index information and the operation time in the preset structure, and using the recovery log file corresponding to the index information and the operation time in the preset structure as the filtered recovery log file, according to the screening The operation information in the recovery log file is operated on the data to be restored.
  4. 根据权利要求3所述的方法,其特征在于,所述判断当前读取的恢复日志文件的索引信息是否在预设结构中之后,还包括:The method according to claim 3, wherein the determining whether the index information of the currently read recovery log file is in the preset structure further comprises:
    若当前读取的恢复日志文件的索引信息在预设结构中,则将当前读取的恢复日志文件的操作时间与所述预设结构中对应当前读取的恢复日志文件的索引信息的操作时间进行比较;If the index information of the currently read recovery log file is in the preset structure, the operation time of the currently read recovery log file and the operation time of the index information corresponding to the currently read recovery log file in the preset structure Compare;
    若当前读取的恢复日志文件的操作时间晚于预设结构中对应当前读取的恢复日志文件的索引信息的操作时间,则将当前读取的恢复日志文件的操作时间替换预设结构中与当前读取的恢复日志文件的索引信息相对应的操作时间,并执行继续读取下一个恢复日志文件的步骤。If the operation time of the currently read recovery log file is later than the operation time of the index information corresponding to the currently read recovery log file in the preset structure, the operation time of the currently read recovery log file is replaced with the preset structure and The operation time corresponding to the index information of the currently read recovery log file, and the step of continuing to read the next recovery log file.
  5. 根据权利要求3或4所述的方法,其特征在于,所述获取与所述预设结构中的索引信息及操作时间对应的恢复日志文件,包括:The method according to claim 3 or 4, wherein the obtaining a recovery log file corresponding to the index information and the operation time in the preset structure comprises:
    依次读取所述第一恢复日志文件及与所述待恢复数据标识相对应的第二恢复日志文件,并将当前读取的恢复日志文件的索引信息依次与预设结构中的索引信息进行比对; And sequentially reading the first recovery log file and the second recovery log file corresponding to the to-be-recovered data identifier, and sequentially comparing the index information of the currently read recovery log file with the index information in the preset structure. Correct;
    若所述预设结构中存在与当前读取的恢复日志文件的索引信息相同的索引信息,则比较当前读取的恢复日志文件的操作时间与所述预设结构中对应当前读取的恢复日志文件的索引信息的操作时间;If the index information of the recovery log file that is currently read is the same as the index information of the currently read recovery log file, compare the operation time of the currently read recovery log file with the currently read recovery log in the preset structure. The operation time of the index information of the file;
    若所述预设结构中存在与当前读取的恢复日志文件的操作时间相同的对应当前读取的恢复日志文件的索引信息的操作时间,则将当前读取的恢复日志文件添加到筛选出的恢复日志文件中,并读取下一个恢复日志文件;If the operation time of the index information corresponding to the currently read recovery log file is the same as the operation time of the currently read recovery log file in the preset structure, the currently read recovery log file is added to the filtered Restore the log file and read the next recovery log file;
    以此类推,直至比对完最后一个恢复日志文件,得到所述预设结构中的每个索引信息对应的恢复日志文件。And so on, until the last recovery log file is compared, the recovery log file corresponding to each index information in the preset structure is obtained.
  6. 一种恢复数据的方法,其特征在于,所述方法应用于存储系统的主服务器,所述存储系统包括所述主服务器和从服务器,所述主服务器和所述从服务器均用于存储相同数据,所述主服务器为第一个成功存储数据的服务器,所述方法包括:A method for restoring data, the method being applied to a primary server of a storage system, the storage system including the primary server and a secondary server, the primary server and the secondary server are both configured to store the same data The primary server is the first server that successfully stores data, and the method includes:
    每个从服务器接收所述主服务器发送的日志获取请求,所述日志获取请求中携带待恢复数据标识;Receiving, by the server, a log obtaining request sent by the primary server, where the log obtaining request carries a data identifier to be restored;
    根据所述日志获取请求向所述主服务器返回第一恢复日志文件,使所述主服务器根据所述第一恢复日志文件及所述主服务器生成的第二恢复日志文件恢复所述待恢复数据;Returning, to the primary server, a first recovery log file according to the log obtaining request, and causing the primary server to recover the to-be-recovered data according to the first recovery log file and the second recovery log file generated by the primary server;
    接收所述主服务器发送的筛选出的恢复日志文件,并根据所述筛选出的恢复日志文件所记录的操作信息对待恢复数据进行操作;Receiving the filtered recovery log file sent by the primary server, and operating the restored data according to the operation information recorded by the filtered recovery log file;
    其中,所述第一恢复日志文件及所述第二恢复日志文件均记录了所述待恢复数据标识所标识的待恢复数据的位置信息及操作信息。The first recovery log file and the second recovery log file respectively record location information and operation information of the to-be-recovered data identified by the to-be-recovered data identifier.
  7. 根据权利要求6所述的方法,其特征在于,所述根据所述日志获取请求向所述主服务器返回第一恢复日志文件之前,还包括:The method according to claim 6, wherein before the returning the first recovery log file to the primary server according to the log obtaining request, the method further includes:
    接收并存储客户端发送的数据,并向所述客户端返回包含所述数据的识别标识的第二写入状态信息,所述第二写入状态信息包括写入成功信息或写入失败信息;Receiving and storing data sent by the client, and returning, to the client, second write status information including an identification identifier of the data, where the second write status information includes write success information or write failure information;
    接收所述客户端发送的总写入状态信息,所述总写入状态信息包括所述从服务器向所述客户端返回的第二写入状态信息及所述主服务器向所述客户端返回的第一写入状态信息; Receiving total write status information sent by the client, where the total write status information includes the second write status information returned from the server to the client, and the return of the primary server to the client First write status information;
    如果所述客户端发送的总写入状态信息中包含写入失败信息,则确定所述客户端发送的数据为待恢复数据,并生成记录所述待恢复数据的位置信息及操作信息的第一恢复日志文件。If the total write status information sent by the client includes the write failure information, determining that the data sent by the client is the data to be restored, and generating the first location information and the operation information for recording the data to be restored. Restore the log file.
  8. 一种恢复数据的服务器,其特征在于,所述服务器为应用于存储系统的主服务器,所述存储系统包括所述主服务器和从服务器,所述主服务器和所述从服务器均用于存储相同数据,所述主服务器为第一个成功存储数据的服务器,所述服务器包括:A server for recovering data, characterized in that the server is a primary server applied to a storage system, the storage system includes the primary server and a secondary server, and the primary server and the secondary server are both used to store the same Data, the primary server is the first server to successfully store data, and the server includes:
    第一发送模块,用于当所述存储系统中的任意一个服务器存储数据失败时,向所述存储系统中的每个从服务器发送日志获取请求,所述日志获取请求中携带待恢复数据标识;a first sending module, configured to send a log obtaining request to each of the slave servers in the storage system when the storage of the data in the storage system fails, where the log obtaining request carries the data identifier to be restored;
    第一接收模块,用于接收各个从服务器根据所述日志获取请求返回的第一恢复日志文件,每个第一恢复日志文件记录了所述待恢复数据标识所标识的待恢复数据的位置信息及操作信息;a first receiving module, configured to receive a first recovery log file returned by each slave server according to the log obtaining request, where each first recovery log file records location information of the to-be-recovered data identified by the to-be-recovered data identifier and Operational information;
    恢复模块,用于根据所有所述第一恢复日志文件及第二恢复日志文件所记录的操作信息中的最新操作信息对待恢复数据进行操作,所述待恢复数据根据所述待恢复数据的位置信息查找得到,所述第二恢复日志文件由所述主服务器生成,且记录了所述待恢复数据标识所标识的待恢复数据的位置信息及操作信息。a recovery module, configured to perform, according to the latest operation information in the operation information recorded by the first recovery log file and the second recovery log file, the data to be restored according to the location information of the data to be restored The second recovery log file is generated by the primary server, and the location information and operation information of the to-be-recovered data identified by the to-be-recovered data identifier are recorded.
  9. 根据权利要求8所述的服务器,其特征在于,所述服务器,还包括:The server according to claim 8, wherein the server further comprises:
    存储模块,用于接收并存储客户端发送的数据;a storage module, configured to receive and store data sent by the client;
    返回模块,用于向所述客户端返回包含所述数据的识别标识的第一写入状态信息,所述第一写入状态信息包括写入成功信息或写入失败信息;a returning module, configured to return, to the client, first write state information that includes an identifier of the data, where the first write state information includes write success information or write failure information;
    第二接收模块,用于接收所述客户端发送的总写入状态信息,所述总写入状态信息包括所述主服务器向所述客户端返回的第一写入状态信息及每个从服务器向所述客户端返回的第二写入状态信息;a second receiving module, configured to receive total write status information sent by the client, where the total write status information includes first write status information returned by the primary server to the client, and each slave server Second write status information returned to the client;
    生成模块,用于当所述客户端发送的总写入状态信息中包含写入失败信息时,确定所述客户端发送的数据为待恢复数据,并生成记录所述待恢复数据的位置信息及操作信息的第二恢复日志文件。 a generating module, configured to: when the total write status information sent by the client includes the write failure information, determine that the data sent by the client is the data to be restored, and generate location information that records the to-be-recovered data and The second recovery log file of the operation information.
  10. 根据权利要求8所述的服务器,其特征在于,所述恢复模块,包括:The server according to claim 8, wherein the recovery module comprises:
    第一读取单元,用于依次读取每个所述第一恢复日志文件及第二恢复日志文件;a first reading unit, configured to sequentially read each of the first recovery log file and the second recovery log file;
    判断单元,用于判断当前读取的恢复日志文件的索引信息是否在预设结构中,所述索引信息包括恢复日志文件标识、偏移量信息及数据长度信息,所述预设结构用于存储索引信息及操作时间;a determining unit, configured to determine whether the index information of the currently read recovery log file is in a preset structure, where the index information includes a recovery log file identifier, offset information, and data length information, where the preset structure is used for storing Index information and operation time;
    添加单元,用于在当前读取的恢复日志文件的索引信息未在所述预设结构中时,将当前读取的恢复日志文件的索引信息及操作时间添加到所述预设结构中;An adding unit, configured to add index information and an operation time of the currently read recovery log file to the preset structure when the index information of the currently read recovery log file is not in the preset structure;
    第二读取单元,用于继续读取下一个恢复日志文件;a second reading unit, configured to continue to read the next recovery log file;
    处理单元,用于按照处理当前读取的恢复日志文件的方式处理读取的下一个恢复日志文件,直至处理完最后一个恢复日志文件,得到存储有无重复索引信息及操作时间的预设结构;a processing unit, configured to process the read next recovery log file in a manner of processing the currently read recovery log file, until the last recovery log file is processed, to obtain a preset structure for storing the duplicate index information and the operation time;
    获取单元,用于获取与所述预设结构中的索引信息及操作时间对应的恢复日志文件,并将与所述预设结构中的索引信息及操作时间对应的恢复日志文件作为筛选出的恢复日志文件;An obtaining unit, configured to acquire a recovery log file corresponding to the index information and the operation time in the preset structure, and use the recovery log file corresponding to the index information and the operation time in the preset structure as the filtered recovery Log file
    恢复单元,用于根据筛选出的恢复日志文件中的操作信息对待恢复数据进行操作。A recovery unit, configured to operate on the restored data according to the operation information in the filtered recovery log file.
  11. 根据权利要求10所述的服务器,其特征在于,所述恢复模块,还包括:The server according to claim 10, wherein the recovery module further comprises:
    比较单元,用于在当前读取的恢复日志文件的索引信息在预设结构中时,将当前读取的恢复日志文件的操作时间与所述预设结构中对应当前读取的恢复日志文件的索引信息的操作时间进行比较;a comparison unit, configured to: when the index information of the currently read recovery log file is in the preset structure, the operation time of the currently read recovery log file and the correspondingly read recovery log file in the preset structure The operation time of the index information is compared;
    替换单元,用于在当前读取的恢复日志文件的操作时间晚于预设结构中对应当前读取的恢复日志文件的索引信息的操作时间时,将当前读取的恢复日志文件的操作时间替换预设结构中与当前读取的恢复日志文件的索引信息相对应的操作时间;a replacement unit, configured to replace the operation time of the currently read recovery log file when the operation time of the currently read recovery log file is later than the operation time of the index information corresponding to the currently read recovery log file in the preset structure The operation time in the preset structure corresponding to the index information of the currently read recovery log file;
    所述第二读取单元,还用于执行继续读取下一个恢复日志文件的步骤。 The second reading unit is further configured to perform the step of continuing to read the next recovery log file.
  12. 根据权利要求10或11所述的服务器,其特征在于,所述获取单元,包括:The server according to claim 10 or 11, wherein the obtaining unit comprises:
    第一读取子单元,用于依次读取所述第一恢复日志文件及与所述待恢复数据标识相对应的第二恢复日志文件;a first reading subunit, configured to sequentially read the first recovery log file and a second recovery log file corresponding to the to-be-recovered data identifier;
    比对子单元,用于将当前读取的恢复日志文件的索引信息依次与预设结构中的索引信息进行比对;The comparison subunit is configured to compare the index information of the currently read recovery log file with the index information in the preset structure;
    比较子单元,用于当所述预设结构中存在与当前读取的恢复日志文件的索引信息相同的索引信息时,比较当前读取的恢复日志文件的操作时间与所述预设结构中对应当前读取的恢复日志文件的索引信息的操作时间;a comparison subunit, configured to: when the index information of the recovery log file currently read is the same as the index information of the currently read recovery log file, compare the operation time of the currently read recovery log file with the preset structure The operation time of the index information of the currently read recovery log file;
    添加子单元,用于当所述预设结构中存在与当前读取的恢复日志文件的操作时间相同的对应当前读取的恢复日志文件的索引信息的操作时间时,将当前读取的恢复日志文件添加到筛选出的恢复日志文件中;Adding a subunit, configured to: when the operation time of the index information corresponding to the currently read recovery log file is the same as the operation time of the currently read recovery log file in the preset structure, the currently read recovery log The file is added to the filtered recovery log file;
    第二读取子单元,用于读取下一个恢复日志文件;以此类推,直至比对完最后一个恢复日志文件,得到所述预设结构中的每个索引信息对应的恢复日志文件。The second read subunit is configured to read the next recovery log file; and so on, until the last recovery log file is compared, and the recovery log file corresponding to each index information in the preset structure is obtained.
  13. 一种恢复数据的服务器,其特征在于,所述服务器为应用于存储系统的从服务器,所述存储系统包括主服务器和所述从服务器,所述主服务器和所述从服务器均用于存储相同数据,所述主服务器为第一个成功存储数据的服务器,所述服务器包括:A server for recovering data, characterized in that the server is a slave server applied to a storage system, the storage system includes a master server and the slave server, and the master server and the slave server are both used to store the same Data, the primary server is the first server to successfully store data, and the server includes:
    第一接收模块,用于接收所述主服务器发送的日志获取请求,所述日志获取请求中携带待恢复数据标识;a first receiving module, configured to receive a log obtaining request sent by the primary server, where the log obtaining request carries a data identifier to be restored;
    第一返回模块,用于根据所述日志获取请求向所述主服务器返回第一恢复日志文件,使所述主服务器根据所述第一恢复日志文件及所述主服务器生成的第二恢复日志文件恢复所述待恢复数据;a first returning module, configured to return a first recovery log file to the primary server according to the log obtaining request, so that the primary server generates a second recovery log file according to the first recovery log file and the primary server Recovering the data to be recovered;
    第二接收模块,用于接收所述主服务器发送的筛选出的恢复日志文件;a second receiving module, configured to receive the filtered recovery log file sent by the primary server;
    恢复模块,用于根据所述筛选出的恢复日志文件所记录的操作信息对待恢复数据进行操作;a recovery module, configured to perform operation on the restored data according to the operation information recorded by the filtered recovery log file;
    其中,所述第一恢复日志文件及所述第二恢复日志文件均记录了所述待恢复数据标识所标识的待恢复数据的位置信息及操作信息。 The first recovery log file and the second recovery log file respectively record location information and operation information of the to-be-recovered data identified by the to-be-recovered data identifier.
  14. 根据权利要求13所述的服务器,其特征在于,所述服务器,还包括:The server according to claim 13, wherein the server further comprises:
    存储模块,用于接收并存储客户端发送的数据;a storage module, configured to receive and store data sent by the client;
    第二返回模块,用于向所述客户端返回包含所述数据的识别标识的第二写入状态信息,所述第二写入状态信息包括写入成功信息或写入失败信息;a second returning module, configured to return, to the client, second write state information that includes an identifier of the data, where the second write state information includes write success information or write failure information;
    第三接收模块,用于接收所述客户端发送的总写入状态信息,所述总写入状态信息包括所述从服务器向所述客户端返回的第二写入状态信息及所述主服务器向所述客户端返回的第一写入状态信息;a third receiving module, configured to receive total write status information sent by the client, where the total write status information includes the second write status information returned from the server to the client, and the primary server First write status information returned to the client;
    生成模块,用于当所述客户端发送的总写入状态信息中包含写入失败信息时,确定所述客户端发送的数据为待恢复数据,并生成记录所述待恢复数据的位置信息及操作信息的第一恢复日志文件。a generating module, configured to: when the total write status information sent by the client includes the write failure information, determine that the data sent by the client is the data to be restored, and generate location information that records the to-be-recovered data and The first recovery log file for operational information.
  15. 一种恢复数据的系统,其特征在于,所述系统包括:主服务器和至少一个从服务器;A system for recovering data, characterized in that the system comprises: a primary server and at least one secondary server;
    其中,所述主服务器如所述权利要求8至12中任一项权利要求所述的服务器,所述从服务器如所述权利要求13至14中任一项权利要求所述的服务器。 The server according to any one of claims 8 to 12, wherein the slave server is a server according to any one of claims 13 to 14.
PCT/CN2014/088962 2013-12-31 2014-10-20 Method, server and system for data recovery WO2015101084A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201310754520.7A CN103761161B (en) 2013-12-31 2013-12-31 Recover the method for data, server and system
CN201310754520.7 2013-12-31

Publications (1)

Publication Number Publication Date
WO2015101084A1 true WO2015101084A1 (en) 2015-07-09

Family

ID=50528403

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/088962 WO2015101084A1 (en) 2013-12-31 2014-10-20 Method, server and system for data recovery

Country Status (2)

Country Link
CN (1) CN103761161B (en)
WO (1) WO2015101084A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170212856A1 (en) * 2015-04-30 2017-07-27 Hewlett Packard Enterprise Development Lp Peripheral device server access
CN109901799A (en) * 2019-02-28 2019-06-18 新华三信息安全技术有限公司 A kind of log reading/writing method and device
CN111611258A (en) * 2020-05-27 2020-09-01 杭州海康威视系统技术有限公司 Stream data recovery method and storage device

Families Citing this family (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103761161B (en) * 2013-12-31 2017-01-04 华为技术有限公司 Recover the method for data, server and system
CN104536852B (en) * 2014-12-31 2017-01-25 华为技术有限公司 Data recovery method and device
CN105426273B (en) * 2015-12-30 2018-08-10 联想(北京)有限公司 Restore the method and server of physical memory cell data
CN107220142B (en) * 2016-03-22 2020-10-09 阿里巴巴集团控股有限公司 Method and device for executing data recovery operation
CN107528872B (en) 2016-06-22 2020-07-24 杭州海康威视数字技术股份有限公司 Data recovery method and device and cloud storage system
CN106776130B (en) * 2016-11-30 2020-07-28 华为技术有限公司 Log recovery method, storage device and storage node
CN109947730B (en) * 2017-07-25 2024-02-02 中兴通讯股份有限公司 Metadata recovery method, device, distributed file system and readable storage medium
CN109960601B (en) * 2017-12-26 2023-03-24 航天信息股份有限公司 Service data recovery method and device and electronic equipment
CN109978290A (en) * 2017-12-27 2019-07-05 中国移动通信集团广东有限公司 A kind of operation flow backspacing processing method of extensive makeup, flow engine and operation system
CN108599982B (en) * 2018-03-14 2021-02-12 华为技术有限公司 Data recovery method and related equipment
CN111488238B (en) * 2020-06-24 2020-09-18 南京鹏云网络科技有限公司 Block storage node data restoration method and storage medium
CN111680010B (en) * 2020-08-14 2020-12-22 北京东方通软件有限公司 Log system design method suitable for JavaEE application server
CN116266175A (en) * 2021-12-16 2023-06-20 华为技术有限公司 Data recovery method and device

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7676502B2 (en) * 2006-05-22 2010-03-09 Inmage Systems, Inc. Recovery point data view shift through a direction-agnostic roll algorithm
CN102523105A (en) * 2011-11-30 2012-06-27 广东电子工业研究院有限公司 Failure recovery method of data storage and applied data distribution framework thereof
CN103324553A (en) * 2013-06-21 2013-09-25 华为技术有限公司 Data recovery method, system and device
CN103761161A (en) * 2013-12-31 2014-04-30 华为技术有限公司 Method, server and system for data recovery

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7043504B1 (en) * 2000-04-10 2006-05-09 International Business Machines Corporation System and method for parallel primary and secondary backup reading in recovery of multiple shared database data sets
US8074107B2 (en) * 2009-10-26 2011-12-06 Amazon Technologies, Inc. Failover and recovery for replicated data instances
CN103345470B (en) * 2013-05-31 2016-05-25 深圳市沃信科技有限公司 A kind of database disaster recovery method, system and server

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7676502B2 (en) * 2006-05-22 2010-03-09 Inmage Systems, Inc. Recovery point data view shift through a direction-agnostic roll algorithm
CN102523105A (en) * 2011-11-30 2012-06-27 广东电子工业研究院有限公司 Failure recovery method of data storage and applied data distribution framework thereof
CN103324553A (en) * 2013-06-21 2013-09-25 华为技术有限公司 Data recovery method, system and device
CN103761161A (en) * 2013-12-31 2014-04-30 华为技术有限公司 Method, server and system for data recovery

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170212856A1 (en) * 2015-04-30 2017-07-27 Hewlett Packard Enterprise Development Lp Peripheral device server access
US10318459B2 (en) * 2015-04-30 2019-06-11 Hewlett Packard Enterprise Development Lp Peripheral device server access
CN109901799A (en) * 2019-02-28 2019-06-18 新华三信息安全技术有限公司 A kind of log reading/writing method and device
CN111611258A (en) * 2020-05-27 2020-09-01 杭州海康威视系统技术有限公司 Stream data recovery method and storage device
CN111611258B (en) * 2020-05-27 2023-09-19 杭州海康威视系统技术有限公司 Stream data recovery method and storage device

Also Published As

Publication number Publication date
CN103761161B (en) 2017-01-04
CN103761161A (en) 2014-04-30

Similar Documents

Publication Publication Date Title
WO2015101084A1 (en) Method, server and system for data recovery
JP6522812B2 (en) Fast Crash Recovery for Distributed Database Systems
JP6538780B2 (en) System-wide checkpoint avoidance for distributed database systems
US8689047B2 (en) Virtual disk replication using log files
US10831741B2 (en) Log-shipping data replication with early log record fetching
US20150213100A1 (en) Data synchronization method and system
CA2893304C (en) Data storage method, data storage apparatus, and storage device
US10853157B2 (en) Compact binary event log generation
US9223797B2 (en) Reparse point replication
WO2008119292A1 (en) Method, device and system for realizing backup of stored data
CN103516736A (en) Data recovery method of distributed cache system and a data recovery device of distributed cache system
US11748215B2 (en) Log management method, server, and database system
WO2021208400A1 (en) Backup recovery system and method for modern application
CN106528338B (en) Remote data copying method, storage device and storage system
US11797397B2 (en) Hybrid NVRAM logging in filesystem namespace
US20180121531A1 (en) Data Updating Method, Device, and Related System
CN112380067A (en) Metadata-based big data backup system and method under Hadoop environment
WO2013091183A1 (en) Method and device for key-value pair operation
CN113672436B (en) Disaster recovery backup method, device, equipment and storage medium
WO2019109257A1 (en) Log management method, server and database system
CN111522688A (en) Data backup method and device for distributed system
US20230214301A1 (en) Copy Data Management System and Method for Modern Application
CN111026764B (en) Data storage method and device, electronic product and storage medium
CN112416885A (en) Real-time file synchronization method
CN118277336A (en) Metadata management method, metadata management device, and computer 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: 14876674

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: 14876674

Country of ref document: EP

Kind code of ref document: A1