Disclosure of Invention
Embodiments of the present invention provide a method, an apparatus, a system, and a computer-readable storage medium for repairing a mirror volume of a storage system, which can keep data of two volumes in a mirror volume consistent during a use process, and improve consistency, integrity, and reliability of data backup.
In order to solve the foregoing technical problem, an embodiment of the present invention provides a method for repairing a mirror volume of a storage system, where the method includes:
detecting the states of two volumes in the mirror volume, and determining a normal volume and an abnormal volume when the state of one volume is abnormal;
dividing a normal volume into N first areas according to a preset dividing mode, dividing an abnormal volume into N second areas, wherein each first area corresponds to each second area one by one, and N is not less than 2;
judging whether the data in each first area is consistent with the data in the corresponding second area, and if not, covering the data in the target second area with the data in the target first area; and respectively taking the first area with inconsistent data and the corresponding second area as the target first area and the target second area.
Optionally, the determining whether the data in each first region is consistent with the data in the corresponding second region, and if not, the process of covering the data in the target second region with the data in the target first region includes:
judging whether the data in the current first area is consistent with the data in the corresponding second area;
if not, taking the current first area as a target first area, taking the second area as a target second area, and covering data in the corresponding target second area by adopting the data in the target first area;
if so, taking the next first area as the current first area, and returning to execute the step of judging whether the data in the current first area is consistent with the data in the corresponding second area until all the first areas are judged.
Optionally, the process of determining whether the data in each first area is consistent with the data in the corresponding second area is as follows:
comparing the MD5 value of each of the first regions with the MD5 value of the corresponding second region;
and judging whether the MD5 value of each first area is equal to the MD5 value of the corresponding second area, if so, the data of the first area is consistent with the data of the corresponding second area, and if not, the data of the first area is inconsistent with the data of the corresponding second area.
Optionally, the method further includes:
and recording the address information of the target first area and the address information of the target second area.
Optionally, the first area and the second area are both sector areas.
The embodiment of the invention correspondingly provides a mirror image volume repairing device of a storage system, which comprises:
the detection module is used for detecting the states of two volumes in the mirror volume, and when the state of one volume is abnormal, the normal volume and the abnormal volume are determined;
the system comprises a dividing module, a judging module and a judging module, wherein the dividing module is used for dividing a normal volume into N first areas according to a preset dividing mode, dividing an abnormal volume into N second areas, and enabling the first areas and the second areas to correspond one to one, wherein N is not less than 2;
the judging module is used for judging whether the data in each first area is consistent with the data in the corresponding second area or not, and if not, the repairing module is triggered;
the repair module is used for covering the data in the target second area by adopting the data in the target first area; and respectively taking the first area with inconsistent data and the corresponding second area as the target first area and the target second area.
Optionally, the determining module includes:
a comparison unit for comparing the MD5 value of each first region with the MD5 value of the corresponding second region;
and the judging unit is used for judging whether the MD5 value of each first area is equal to the MD5 value of the corresponding second area, and if not, triggering the repairing module.
Optionally, the method further includes:
and the recording module is used for recording the address information of the target first area and the address information of the target second area.
An embodiment of the present invention further provides a system for repairing a mirror volume of a storage system, including:
a memory for storing a computer program;
and a processor, configured to implement the steps of the mirror volume repair method of the storage system when executing the computer program.
An embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the mirror volume repair method of the storage system are implemented.
The embodiment of the invention provides a method, a device and a system for repairing a mirror image volume of a storage system and a computer readable storage medium, wherein the method comprises the following steps: detecting the states of two volumes in the mirror volume, and determining a normal volume and an abnormal volume when the state of one volume is abnormal; dividing the normal volume into N first areas according to a preset dividing mode, dividing the abnormal volume into N second areas, wherein each first area corresponds to each second area one by one, and N is not less than 2; judging whether the data in each first area is consistent with the data in the corresponding second area, and if not, covering the data in the target second area by adopting the data in the target first area; and respectively taking the first area with inconsistent data and the corresponding second area as a target first area and a target second area.
It can be seen that in the present application, the running states of two volumes in the mirror volume are detected to determine a normal volume and an abnormal volume, and the normal volume and the abnormal volume are both divided into N areas, then the data in each first area in the normal volume is compared with the data in the corresponding second area in the abnormal volume, and when the data in the two areas are inconsistent, the data in the target first area in the normal volume is adopted to cover the data in the corresponding target second area in the abnormal volume, so that the data in the abnormal volume is repaired, the data in the two volumes in the mirror volume is kept consistent, and the consistency, integrity and reliability of data backup are improved.
Detailed Description
The embodiment of the invention provides a method, a device and a system for repairing a mirror image volume of a storage system and a computer readable storage medium, which can keep the data of two volumes in the mirror image volume consistent in the using process and improve the consistency, integrity and reliability of data backup.
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Referring to fig. 1, fig. 1 is a flowchart illustrating a method for repairing a mirror volume of a storage system according to an embodiment of the present invention. The method comprises the following steps:
s110: detecting the states of two volumes in the mirror volume, and determining a normal volume and an abnormal volume when the state of one volume is abnormal;
it should be noted that, the data of the two volumes in the mirror volume are kept synchronized in real time, and when performing a write operation, data may be written into the two volumes at the same time, but there may be a difference in the data of the two volumes due to a media error or the like, and at this time, it is necessary to determine the difference data and repair the corresponding data in the volume in which the error occurs by using the data in the volume in which no problem occurs.
Specifically, the state of the two volumes can be detected, and when one of the volumes is abnormal and the other volume is not abnormal, the two volumes are marked to determine the normal volume and the abnormal volume, so that when the data in the abnormal volume is determined to be abnormal later, the data in the normal volume is adopted to repair the data in the abnormal volume.
S120: dividing the normal volume into N first areas according to a preset dividing mode, dividing the abnormal volume into N second areas, wherein each first area corresponds to each second area one by one, and N is not less than 2;
specifically, after the normal volume and the abnormal volume are determined, the normal volume and the abnormal volume may be divided into a plurality of regions, wherein the normal volume is divided into a plurality of first regions, the abnormal volume is divided into a plurality of second regions in the same manner, the number of the first regions and the number of the second regions are the same, and the position, the size and the shape of each first region and the corresponding second region are also correspondingly the same. The first area and the second area are in the shape of sectors, that is, the normal roll and the abnormal roll are divided into a plurality of sector areas, as shown in fig. 2.
S130: judging whether the data in each first area is consistent with the data in the corresponding second area, if not, entering S140;
it can be understood that, by performing comparative analysis on the data in each first region in the normal volume and the data in the corresponding second region in the abnormal volume, it can be determined whether the data in the first region is consistent with the data in the corresponding second region, and when a certain first region is inconsistent with the data in the corresponding second region, it is indicated that a difference occurs in the data in the second region in the abnormal volume, at this time, the first region may be taken as a target first region, and the corresponding second region may be taken as a target second region.
S140: covering data in a target second area with data in a target first area; and respectively taking the first area with inconsistent data and the corresponding second area as a target first area and a target second area.
Specifically, since the data in the normal volume is correct data, the data in the target second area may be overwritten by the data in the target first area, so as to repair the data in the target second area.
The method has the advantages that the comparison speed can be increased by dividing the normal volume and the abnormal volume into the plurality of regions, the method is favorable for accurately determining which data in the abnormal volume goes wrong, and after the abnormal target second region is determined, the abnormal data in the abnormal volume can be repaired by only covering the data in the target second region by the data in the corresponding target first region, the data copy amount is small, and the repairing speed is high.
Further, in the above S130 and S140, determining whether the data in each first area is consistent with the data in the corresponding second area, and if not, the process of overwriting the data in the target second area with the data in the target first area includes:
judging whether the data in the current first area is consistent with the data in the corresponding second area;
if not, taking the current first area as a target first area, taking the second area as a target second area, and covering the data in the corresponding target second area by adopting the data in the target first area;
if so, taking the next first area as the current first area, and returning to execute the step of judging whether the data in the current first area is consistent with the data in the corresponding second area until all the first areas are judged.
It can be understood that after the areas are divided, the comparative analysis of the data in the current first area and the corresponding second area in the abnormal volume may be started from any position, if the data in the current first area and the corresponding second area are consistent, it is continuously determined whether the data in the next first area and the corresponding second area are consistent, if the data in the current first area and the corresponding second area are inconsistent, the data in the current first area (target first area) is used to overlay the data in the corresponding second area (target second area), and then it is continuously determined whether the data in the next first area and the corresponding second area are consistent until all the areas are compared.
Of course, in specific implementation, after comparing the data in the first area and the corresponding second area, when the data are inconsistent, the address information of the target first area and the corresponding target second area is recorded, and after all the first areas and the corresponding second areas are compared, according to the recorded address information of the target first area and the corresponding target second area where the data are inconsistent, the data in the corresponding target second area are overlaid one by one or simultaneously by using the data in the corresponding target first area, so as to repair the data in the corresponding target second area.
Further, the process of determining whether the data in each first area is consistent with the data in the corresponding second area is as follows:
comparing the MD5 value of each first region with the MD5 value of the corresponding second region;
and judging whether the MD5 value of each first area is equal to the MD5 value of the corresponding second area, if so, the data of the first area is consistent with the data of the corresponding second area, and if not, the data of the first area is inconsistent with the data of the corresponding second area.
Specifically, in order to accurately and quickly determine whether the data in the first region is consistent with the data in the corresponding second region, the MD5 values of the first region and the corresponding second region may be compared, where the MD5 value may accurately reflect the data information in the corresponding region, if the data in the two regions are consistent, the MD5 values are the same, and if the data in the two regions are inconsistent, the MD5 values are different, so as to quickly determine the first region and the corresponding second region where the data are inconsistent.
Further, the method further comprises:
address information of the target first area and address information of the target second area are recorded.
It should be noted that, in order to facilitate the administrator to manage and maintain the mirror volume, in this embodiment, the address information of the target first area and the corresponding target second area where the data are inconsistent may be recorded, so that the administrator can maintain the mirror volume according to the address information.
Furthermore, the first area and the second area in the application are both fan-shaped areas, so that the data copy amount during the repair of the fan-shaped areas can be reduced to a certain extent, and the data repair speed is increased, wherein the specific size of the fan-shaped areas can be determined according to actual needs.
Of course, the first region and the second region in this application may also have other specific shapes, and this application is not limited specifically.
It can be seen that in the present application, the running states of two volumes in the mirror volume are detected to determine a normal volume and an abnormal volume, and the normal volume and the abnormal volume are both divided into N areas, then the data in each first area in the normal volume is compared with the data in the corresponding second area in the abnormal volume, and when the data in the two areas are inconsistent, the data in the target first area in the normal volume is adopted to cover the data in the corresponding target second area in the abnormal volume, so that the data in the abnormal volume is repaired, the data in the two volumes in the mirror volume is kept consistent, and the consistency, integrity and reliability of data backup are improved.
On the basis of the foregoing embodiments, embodiments of the present invention correspondingly provide a mirror volume repair apparatus for a storage system, and refer to fig. 3 specifically. The device includes:
the detection module 31 is configured to detect states of two volumes in the mirror volume, and when a state of one of the volumes is abnormal, determine a normal volume and an abnormal volume;
the dividing module 32 is configured to divide the normal volume into N first regions according to a preset dividing manner, and divide the abnormal volume into N second regions, where each first region corresponds to each second region one to one, and N is not less than 2;
a judging module 33, configured to judge whether data in each first region is consistent with data in a corresponding second region, and if not, trigger the repairing module 34;
a repair module 34 for overwriting data in the target second region with data in the target first region; and respectively taking the first area with inconsistent data and the corresponding second area as a target first area and a target second area.
Further, the determining module 33 includes:
a comparison unit for comparing the MD5 value of each first region with the MD5 value of the corresponding second region;
and the judging unit is used for judging whether the MD5 value of each first area is equal to the MD5 value of the corresponding second area, and if not, the repairing module 34 is triggered.
Further, the apparatus further comprises:
and the recording module is used for recording the address information of the target first area and the address information of the target second area.
It should be noted that the mirror volume repair apparatus of the storage system provided in this embodiment has the same beneficial effects as the mirror volume repair method of the storage system provided in the foregoing embodiment, and for a specific description of the mirror volume repair method of the storage system related in this embodiment, please refer to the foregoing embodiment, which is not described herein again.
On the basis of the above embodiment, an embodiment of the present invention further provides a system for repairing a mirror volume of a storage system, where the system includes:
a memory for storing a computer program;
and the processor is used for implementing the steps of the mirror volume repair method of the storage system when executing the computer program.
For example, the processor in this embodiment is configured to detect states of two volumes in a mirror volume, and when a state of one of the volumes is abnormal, determine a normal volume and an abnormal volume; dividing the normal volume into N first areas according to a preset dividing mode, dividing the abnormal volume into N second areas, wherein each first area corresponds to each second area one by one, and N is not less than 2; judging whether the data in each first area is consistent with the data in the corresponding second area, and if not, covering the data in the target second area by adopting the data in the target first area; and respectively taking the first area with inconsistent data and the corresponding second area as a target first area and a target second area.
On the basis of the foregoing embodiments, an embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when executed by a processor, the computer program implements the steps of the mirror volume repair method of the storage system.
The computer-readable storage medium may include: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The embodiments in the present description are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description.
It is further noted that, in the present specification, relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.