WO2023179077A1 - 一种数据一致性检测和修复的方法、装置及介质 - Google Patents

一种数据一致性检测和修复的方法、装置及介质 Download PDF

Info

Publication number
WO2023179077A1
WO2023179077A1 PCT/CN2022/135108 CN2022135108W WO2023179077A1 WO 2023179077 A1 WO2023179077 A1 WO 2023179077A1 CN 2022135108 W CN2022135108 W CN 2022135108W WO 2023179077 A1 WO2023179077 A1 WO 2023179077A1
Authority
WO
WIPO (PCT)
Prior art keywords
file
data
repaired
repair
data object
Prior art date
Application number
PCT/CN2022/135108
Other languages
English (en)
French (fr)
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 WO2023179077A1 publication Critical patent/WO2023179077A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems

Definitions

  • the present application relates to the field of storage technology, and in particular to a method, device and non-volatile computer-readable storage medium for data consistency detection and repair.
  • SATA hard disk Serial Advanced Technology Attachment hard disk
  • FC Fiber Channel
  • firmware issues such as disk arrays (Redundant Arrays of Independent Disks, RAID) controller, disk controller, etc.
  • software problems such as operating system kernel problems, local file system problems, network system problems, general block layer problems, IO (Input/Output, input/output) scheduling layer problems, etc.
  • operation Dimension factors when extreme situations occur, maintenance operations on the distributed system may be incorrect.
  • the purpose of this application is to provide a data consistency detection and repair method, device and non-volatile computer-readable storage medium for consistency detection and repair of data.
  • this application provides a method for data consistency detection and repair, including:
  • the current file is determined to be the file to be repaired
  • comparing the current file with the original file to determine whether the current file is consistent with the original file includes:
  • obtaining the data object of the file to be repaired includes:
  • the original files stored in the storage pool include:
  • the PG placement group is mapped to the OSD disk of the storage pool through the crushmap algorithm.
  • the OSD disk of the storage pool contains multiple copy data mapped by each PG placement group.
  • repairing the data object to be repaired based on the copy data of the data object of the original file includes:
  • the data object to be repaired is repaired based on the copy data of the data object of the original file, it also includes:
  • the data object to be repaired is repaired according to the copy data corresponding to the data object to be repaired, it also includes:
  • this application also provides a device for data consistency detection and repair, including:
  • the first acquisition module is set to acquire the current file and the original file corresponding to the current file
  • the first comparison module is set to compare the current file with the original file to determine whether the current file is consistent with the original file; if the current file is inconsistent with the original file, trigger the determination module; if the current file is consistent with the original file, end ;
  • Determination module set to determine the current file as the file to be repaired
  • the second acquisition module is set to acquire the data object of the file to be repaired
  • the second comparison module is configured to compare the data object of the file to be repaired with the data object of the original file and determine the data object to be repaired;
  • the repair module is configured to repair the data object to be repaired based on the copy data of the data object of the original file, and return the steps of obtaining the current file and the original file corresponding to the current file.
  • this application also provides a device for data consistency detection and repair, including:
  • a memory configured to store a computer program
  • the processor is configured to implement the steps of the above-mentioned data consistency detection and repair method when executing the computer program.
  • this application also provides a non-volatile computer-readable storage medium.
  • a computer program is stored on the computer-readable storage medium.
  • the computer program is executed by the processor, the above-mentioned data consistency detection and repair are realized. Method steps.
  • the data consistency detection and repair method provided by this application includes: obtaining the current file and the original file corresponding to the current file; comparing the current file with the original file to determine whether the current file is consistent with the original file; if the current file is consistent with the original file, If the file is inconsistent with the original file, determine that the current file is the file to be repaired; obtain the data object of the file to be repaired; compare the data object of the file to be repaired with the data object of the original file and determine the data object to be repaired; according to the original file Use the copy data of the data object to repair the data object to be repaired, and return to the steps of obtaining the current file and the original file corresponding to the current file; if the current file is consistent with the original file, it ends.
  • the method of this application does not need to attach verification information to the entire IO path in the process of achieving data consistency, and is therefore more complex. It is easy to achieve data consistency; secondly, compared with the method of directly dividing files into multiple data objects, this method first determines whether the files are consistent, and then only divides the files to be repaired into multiple data objects, without the need for data consistency. The file is divided into multiple data objects, thus reducing the time to determine the data objects to be repaired, making the process of data consistency detection and repair relatively simple, and improving the efficiency of data consistency detection and repair.
  • this application also provides a device and a non-volatile computer-readable storage medium for data consistency detection and repair, which correspond to the above-mentioned data consistency detection and repair method and have the same effect as above.
  • Figure 1 is a data storage flow chart based on a distributed storage system provided by an embodiment of the present application
  • Figure 2 is a flow chart of a data consistency detection and repair method provided by an embodiment of the present application
  • Figure 3 is a structural diagram of a device for data consistency detection and repair provided by an embodiment of the present application.
  • Figure 4 is a structural diagram of a device for data consistency detection and repair provided by another embodiment of the present application.
  • Figure 5 is a schematic diagram of an application scenario for data consistency detection and repair provided by an embodiment of the present application.
  • the core of this application is to provide a data consistency detection and repair method, device and non-volatile computer-readable storage medium for consistency detection and repair of data.
  • a distributed storage system usually consists of a storage server and multiple clients. Its essence is to evenly distribute a large number of files to multiple storage servers.
  • Distributed storage systems have been widely used in production environments and have the characteristics of high scalability, high availability, and high reliability.
  • distributed object storage systems can be used in a variety of scenarios. Driven by the commercial model, The requirements for data reliability of distributed storage systems are getting higher and higher.
  • Figure 1 is a data storage flow chart based on a distributed storage system provided by an embodiment of the present application.
  • the distributed storage system mainly includes: file data 1, data object 2, PG (Placement group, placement group) 3, disk 4, of which data object 2, PG placement group 3, and disk 4 are stored in in the storage pool.
  • the client of the distributed storage system stores the file data to be stored in the underlying disk 4 as object instances.
  • Disk 4 is a daemon that stores data in a distributed storage system. The role of the disk 4 daemon is to handle IO operations on storage devices.
  • the distributed storage system designs PG placement group 3 to effectively manage massive data objects 2, and maps PG placement group 3 to disk 4.
  • Disk 4 is usually an object storage device (OSD) and is set as a process to return specific data in response to client requests.
  • OSD object storage device
  • the method for the distributed storage system client to store files in the storage system is as follows:
  • the distributed storage client first specifies the object name to be stored in the storage pool of the distributed storage system
  • the crushmap algorithm performs hash calculation on the object name to obtain the specific PG id.
  • the setting of PG num is determined by the number of OSD disks;
  • the data object is stored in the directory of the PG placement group.
  • the data object consists of three elements: data, xattr, and omap.
  • Data saves the data of the data object
  • xattr saves the extended attributes of the data object.
  • Each object file can set a file. Attribute, this attribute is a key/value value, but it is limited by the file system. The number of key/value pairs and the size of each value are limited. If the key/value of the object to be set cannot be stored in the file Among the extended attributes, there is another way to save omap.
  • Omap is saved in the database levelDB of key/value pair;
  • the data objects in the PG placement group will be mapped to multiple OSD disks, such as three copies.
  • a PG placement group contains three OSD disks, and each OSD disk The data object information carried is completely consistent. The above process serves as the principle basis for data consistency detection and repair in this application.
  • OSD disk uses a unified namespace in the distributed storage system to slice the client's file data, stipulates that the size of each data object is a preset value, and performs data object detection and repair processing based on the slice size.
  • the data object consists of a globally unique inode number (specified in hexadecimal), relative file offset, object type (snapshot or non-snapshot), object hash value, the id of the storage pool to which it belongs, and the osd number.
  • examples of data objects stored in the OSD disk are as follows:
  • 10000226acd the inode number of the file, globally unique
  • the object is in the head directory, not a snapshot, or snap if it is a snapshot;
  • This application detects the consistency of data based on the distributed storage system and repairs the data based on the copy redundancy mechanism of the distributed storage system when data inconsistency is detected.
  • Figure 2 is a flow chart of a data consistency detection and repair method provided by an embodiment of the present application. As shown in Figure 2, the method includes:
  • the consistency test of data is based on whether the data of the current file is consistent with the original file corresponding to the current file. Therefore, first obtain the current file and the original file corresponding to the current file.
  • the specific contents of the two files obtained are not limited here, but the objects obtained for comparison must be Consistent, such as obtaining file attributes for both files. Since obtaining the current file and the original file corresponding to the current file is used to determine whether the data of the two files are consistent, you can also obtain the check values of the two files separately through the verification tool, thereby judging the two files based on the check values. Whether the data in the file is consistent.
  • verification tools mainly include hash algorithms, MD5 Message-Digest Algorithm (MD5), etc.
  • MD5 Message-Digest Algorithm MD5 Message-Digest Algorithm
  • the specific verification tools used are not limited in this application. For example, when judging whether the data of two files are consistent based on the MD5 value, it is necessary to obtain the MD5 value of the current file and the MD5 value of the original file corresponding to the current file.
  • step S11 Compare the current file with the original file to determine whether the current file is consistent with the original file; if the current file is inconsistent with the original file, proceed to step S12; if the current file is consistent with the original file, end.
  • the current file and the original file corresponding to the current file are obtained, and then it can be judged whether the data is consistent based on the current file and the original file corresponding to the current file.
  • the comparison object used to determine whether the data of two files are consistent you can make a judgment based on the specific contents of the two files. When the specific contents of the two files are exactly the same, confirm that the data of the two files are consistent; you can also make a judgment based on the specific contents of the two files and the attributes of the files at the same time.
  • the files to be repaired are identified in the above steps.
  • this embodiment divides the file to be repaired into multiple data objects, and determines whether the data has changed one by one. First, confirm that the client accesses the damaged file path. Through the file path, find out the inode information of the file and convert it to hexadecimal. Calculate the size of the file. It is known that the size of each data object is the preset value for segmentation. Count how many data objects a file has.
  • the 11-i command uses the 11-i command to obtain the inode number and file size of the file, calculate the underlying data object name prefix based on the inode number, and obtain the maximum suffix of the underlying data object name based on the file size.
  • the inode of the file is 2199080746415.
  • Execute printf′′%x ⁇ n′′2199080746415 to get the underlying data object name prefix is 200036d3daf.
  • the number of data objects is 5130 and the data object name suffix is Starting from 0, the suffix ranges from 00000000 to 00001409, where 1409 is the hexadecimal version of 5129.
  • the files in the PG placement group directory will be migrated according to the process of storing files in the storage system and the data object storage process. However, the move will cause the expansion of the data object files in the PG placement group directory. If the attribute is missing, an error will occur when reading the data object in the PG placement group directory, and it will be reported that the data object does not exist.
  • step S15 Repair the data object to be repaired according to the copy data of the data object of the original file, and return to step S10.
  • the distributed storage system records the Map information of each PG placement group in different replica data.
  • the replica OSD id of the OSD disk of the lost data object can be obtained.
  • the information of the lost data object can be restored based on the OSD disk of the replica.
  • the data consistency detection and repair method includes: obtaining the current file and the original file corresponding to the current file; comparing the current file with the original file to determine whether the current file is consistent with the original file; if the current file If it is inconsistent with the original file, the current file is determined to be the file to be repaired; the data object of the file to be repaired is obtained; the data object of the file to be repaired is compared with the data object of the original file and the data object to be repaired is determined; according to the data object of the original file The copy data of the data object repairs the data object to be repaired, and returns to the steps of obtaining the current file and the original file corresponding to the current file; if the current file is consistent with the original file, it ends.
  • the method of this embodiment does not need to attach verification information to the entire IO path in the process of achieving data consistency. Therefore, It is easier to achieve data consistency; secondly, compared with the method of directly dividing files into multiple data objects, this method first determines whether the files are consistent, and then only divides the files to be repaired into multiple data objects, without the need for data consistency. The file is divided into multiple data objects, thus reducing the time to determine the data objects to be repaired, making the process of data consistency detection and repair relatively simple, and improving the efficiency of data consistency detection and repair.
  • a verification tool is used to make the determination.
  • An optional implementation is to compare the current file with the original file to determine whether the current file is consistent with the original file, including:
  • the two MD5 values when When the two MD5 values are the same, it means that the data of the two files are consistent; when the two MD values are not the same, it means that the data of the two files are inconsistent, and the current file is determined to be the file to be repaired.
  • the data consistency verification based on the MD5 value provided in this embodiment can obtain data consistency results more accurately, comprehensively, and quickly.
  • the file to be repaired is divided into multiple data objects, and the damaged data object is determined by traversing each data object.
  • obtaining the data object of the file to be repaired includes:
  • the client accesses the damaged file path.
  • Find out the inode information of the file through the path of the file convert it to hexadecimal, calculate the size of the file, and set the size of each data object to the preset value.
  • This default value splits the file and calculates how many data objects the file has. It should be noted that this application does not limit the setting of the default value.
  • the default value can be 4MB; for 6FS distributed storage, the default value can be 64MB; for HDFS distributed storage, the default value can be 128MB. In this embodiment, the default value is 4M.
  • This embodiment provides that the file is divided into multiple data objects, and the damaged data object is determined by traversing each data object, thereby accurately locating the location of the data damage.
  • the storage of original files in the storage pool includes:
  • the PG placement group is mapped to the OSD disk of the storage pool through the crushmap algorithm.
  • the OSD disk of the storage pool contains multiple copy data mapped by each PG placement group.
  • the distributed storage method provided by this embodiment can, on the one hand, set up a PG placement group in the storage pool to avoid the tight coupling between the client and the underlying OSD disk; on the other hand, the crushmap algorithm can ensure that Data objects are evenly distributed among OSD disks.
  • common data inconsistencies include damage to stored data, loss of xattr extended attributes, etc.
  • the specific repair process is as follows.
  • the data object to be repaired based on the copy data of the data object of the original file includes:
  • the distribution of the data object is located in the distributed storage system.
  • the distributed storage system records the Map information of different copy data of each PG placement group.
  • the copy number of the OSD disk of the lost data object that is, the OSD id
  • the lost data object can be recovered according to the OSD disk of the copy. information, first obtain the information of the copy data and save it, then copy the saved object information to the corresponding node, and finally modify the header part of the attr file and set it to the OSD disk number of the currently lost data object, and re-store the data object information. , complete the data repair.
  • the repair process is as follows:
  • the OSD of the lost object lists the attribute information of the copy OSD under the same group of PGs;
  • the data repair method provided in this embodiment solves the problem of data inconsistency caused by the loss of the xattr extended attribute, making the business IO as correct as possible and ensuring the availability of the data.
  • an optional implementation method is that after repairing the data object to be repaired based on the copy data of the data object of the original file, it also includes:
  • the checking tool can be designed through pseudo code and added to the Linux background crontab task to achieve scheduled detection.
  • the detection process through pseudocode is as follows: first enter the path of the file to be repaired, find the path of the file to be analyzed, and compare the information of the data object in the storage pool.
  • This embodiment provides an automated repair tool.
  • the automated repair tool can handle the data inconsistency in a timely manner, thereby making the business IO as correct as possible and ensuring the availability of the data.
  • the consistency of data is detected and repaired.
  • the data repair situation in order to allow users to intuitively understand the data repair situation, as an optional method, after repairing the data object to be repaired based on the copy data corresponding to the data object to be repaired, it also includes:
  • prompt information is output to prompt the user to complete the data repair.
  • the specific content, method, time, etc. of the information used to prompt the completion of repair there are no restrictions on the specific content, method, time, etc. of the information used to prompt the completion of repair, as long as it can prompt the completion of data repair.
  • This embodiment provides that after the data repair is completed, prompt information is output, so that the user can intuitively understand the data repair situation.
  • the method of data consistency detection and repair is described in detail.
  • the present application also provides a corresponding embodiment of a device for data consistency detection and repair. It should be noted that this application describes the embodiments of the device part from two perspectives, one is based on the perspective of functional modules, and the other is based on the perspective of hardware.
  • Figure 3 is a structural diagram of a device for data consistency detection and repair provided by an embodiment of the present application. This embodiment is based on the perspective of functional modules, including:
  • the first acquisition module 10 is configured to acquire the current file and the original file corresponding to the current file;
  • the first comparison module 11 is configured to compare the current file with the original file to determine whether the current file is consistent with the original file; if the current file is inconsistent with the original file, trigger the determination module 12; if the current file is consistent with the original file, then ends;
  • the determination module 12 is configured to determine that the current file is the file to be repaired
  • the second acquisition module 13 is configured to acquire the data object of the file to be repaired
  • the second comparison module 14 is configured to compare the data object of the file to be repaired with the data object of the original file and determine the data object to be repaired;
  • the repair module 15 is configured to repair the data object to be repaired based on the copy data of the data object of the original file, and return to the step of obtaining the current file and the original file corresponding to the current file.
  • the device for data consistency detection and repair obtaineds the current file and the original file corresponding to the current file through the first acquisition module; and compares the current file with the original file through the first comparison module to determine the current file. Whether it is consistent with the original file; if the current file is inconsistent with the original file, the determination module is triggered to determine that the current file is the file to be repaired; the data object of the file to be repaired is obtained through the second acquisition module; the file to be repaired is obtained through the second comparison module Compare the data object with the data object of the original file and determine the data object to be repaired; use the repair module to repair the data object to be repaired based on the copy data of the data object of the original file.
  • this device does not need to attach verification information to the entire IO path in the process of achieving data consistency, so it is easier to implement.
  • the data is consistent; secondly, compared to directly dividing the files into multiple data objects, this device first determines whether the files are consistent, and then only divides the files to be repaired into multiple data objects. There is no need to divide files with consistent data into Multiple data objects, thus reducing the time to determine the data objects to be repaired, making the process of data consistency detection and repair relatively simple, and improving the efficiency of data consistency detection and repair.
  • Figure 4 is a structural diagram of a device for data consistency detection and repair provided by another embodiment of the present application. This embodiment is based on the hardware perspective. As shown in Figure 4, the device for data consistency detection and repair includes:
  • Memory 20 configured to store computer programs
  • the processor 21 is configured to implement the steps of the data consistency detection and repair method mentioned in the above embodiment when executing the computer program.
  • the device for data consistency detection and repair provided in this embodiment may include but is not limited to smartphones, tablet computers, notebook computers or desktop computers.
  • the processor 21 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc.
  • the processor 21 can adopt at least one hardware form among a digital signal processor (Digital Signal Processor, DSP), a field-programmable gate array (Field-Programmable Gate Array, FPGA), and a programmable logic array (Programmable Logic Array, PLA). to fulfill.
  • the processor 21 may also include a main processor and a co-processor.
  • the main processor is a processor configured to process data in a wake-up state, also called a central processing unit (Central Processing Unit, CPU); the co-processor is A low-power processor configured to process data in standby mode.
  • CPU Central Processing Unit
  • the processor 21 may be integrated with a graphics processor (Graphics Processing Unit, GPU), and the GPU is configured to be responsible for rendering and drawing content that needs to be displayed on the display screen.
  • the processor 21 may also include an artificial intelligence (Artificial Intelligence, AI) processor, which is configured to process computing operations related to machine learning.
  • AI Artificial Intelligence
  • Memory 20 may include one or more computer-readable storage media, which may be non-transitory.
  • the memory 20 may also include high-speed random access memory, and non-volatile memory, such as one or more magnetic disk storage devices, flash memory storage devices.
  • the memory 20 is at least configured to store the following computer program 201. After the computer program is loaded and executed by the processor 21, the relevant steps of the data consistency detection and repair method disclosed in any of the foregoing embodiments can be implemented.
  • the resources stored in the memory 20 may also include the operating system 202, data 203, etc., and the storage method may be short-term storage or permanent storage.
  • the operating system 202 may include Windows, Unix, Linux, etc.
  • Data 203 may include but is not limited to data involved in the above-mentioned data consistency detection and repair methods, etc.
  • the device for data consistency detection and repair may also include a display screen 22 , an input and output interface 23 , a communication interface 24 , a power supply 25 and a communication bus 26 .
  • Figure 4 does not constitute a limitation on the device for data consistency detection and repair, and may include more or fewer components than shown in the figure.
  • the device for data consistency detection and repair provided by the embodiment of the present application includes a memory and a processor.
  • the processor executes the program stored in the memory, the following method can be implemented:
  • the method of data consistency detection and repair has the same effect as above.
  • this application also provides a corresponding embodiment of a non-volatile computer-readable storage medium.
  • the computer program is stored on the computer-readable storage medium.
  • the steps recorded in the above method embodiments are implemented.
  • the methods in the above embodiments are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium.
  • the technical solution of the present application is essentially or contributes to the existing technology, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium , execute all or part of the steps of the methods of various embodiments of this application.
  • the aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM), random access memory (Random Access Memory, RAM), magnetic disk or optical disk and other media that can store program code. .
  • the computer-readable storage medium provided by this application includes the above-mentioned data consistency detection and repair methods, and the effect is the same as above.
  • Figure 5 is a data consistency detection and repair method provided by an embodiment of the present application.
  • Application scenario diagram As shown in Figure 5, the process includes:
  • the data consistency detection and repair method does not require the entire IO to achieve data consistency. Verification information is attached to the path, so it is easier to achieve data consistency; secondly, compared to directly dividing the file into multiple data objects, this method first determines whether the file is consistent, and then only divides the file to be repaired into multiple Data objects do not need to divide files with consistent data into multiple data objects, thus reducing the time to determine the data objects to be repaired, making the process of data consistency detection and repair relatively simple, and improving the efficiency of data consistency detection and repair. efficiency.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本申请公开了一种数据一致性检测和修复的方法、装置及非易失性计算机可读存储介质,涉及存储技术领域。该方法对文件进行一致性检测,在检测到文件不一致时,对文件进行修复。在修复过程中获取待修复文件的数据对象并确定待修复的数据对象;然后根据数据对象对应的副本数据将待修复的数据对象进行修复。由此可见,该方法在实现数据一致性的过程中不需要在整个IO路径上附上校验信息,因此较容易实现数据一致;其次,先判断文件是否一致,然后只将待修复的文件分为多个数据对象,不需要对数据一致的文件分为多个数据对象,因此减少了确定待修复的数据对象的时间,使得数据一致性检测和修复的过程相对简单,提高了数据一致性检测和修复的效率。

Description

一种数据一致性检测和修复的方法、装置及介质
相关申请的交叉引用
本申请要求于2022年3月25日提交中国专利局,申请号为202210298447.6,申请名称为“一种数据一致性检测和修复的方法、装置及介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及存储技术领域,特别是涉及一种数据一致性检测和修复的方法、装置及非易失性计算机可读存储介质。
背景技术
随着云计算、数字化转型,产生的数据量呈指数级增长,因此,对海量数据存储有新的技术要求。为了满足海量数据的存储需求,当前技术背景下出现了分布式存储技术。但是分布式存储系统的架构复杂,当集群节点越多,不同的集群节点出现故障的概率就越高,造成数据损坏的因素,主要有硬件错误,如内存、中央处理器(Central Processing Unit,CPU)、网卡等;数据传输过程中的信噪干扰,如SATA硬盘(Serial Advanced Technology Attachment hard disk)、光纤通道(Fiber Channel,FC)等协议;固件问题,如磁盘阵列(Redundant Arrays of Independent Disks,RAID)控制器、磁盘控制器等;软件问题,如操作系统的内核问题、本地文件系统问题,网络系统问题、通用块层问题、IO(Input/Output,输入/输出)调度层问题等;运维因素,当出现极端情况,对分布式系统进行维护操作错误。
以上因素均会造成数据的损坏,导致分布式集群系统数据不一致,业务IO出错,出现数据不可用现象,进而使得数据的可靠性降低。目前,一般采用端到端的数据校验实现数据的一致性,但是需要在整个IO路径上附上校验信息,由于在整个IO路径上附上校验信息存在一定的难度,因此实现数据一致性的过程较为复杂。
由此可见,如何对数据进行一致性检测和修复,是本领域技术人员亟待解决的问题。
发明内容
本申请的目的是提供一种数据一致性检测和修复的方法、装置及非易失性计算机可读存储介质,用于对数据进行一致性检测和修复。
为解决上述技术问题,本申请提供一种数据一致性检测和修复的方法,包括:
获取当前文件以及当前文件对应的原始文件;
将当前文件与原始文件进行比对以便确定当前文件与原始文件是否一致;
若当前文件与原始文件不一致,则确定当前文件为待修复文件;
获取待修复文件的数据对象;
将待修复文件的数据对象与原始文件的数据对象进行比对并确定待修复的数据对象;
根据原始文件的数据对象的副本数据将待修复的数据对象进行修复,并返回获取当前文件以及当前文件对应的原始文件的步骤;
若当前文件与原始文件一致,则结束。
可选地,将当前文件与原始文件进行比对以便确定当前文件与原始文件是否一致包括:
获取原始文件的第一MD5值以及获取当前文件的第二MD5值;
在第一MD5值与第二MD5值不相同的情况下,进入确定当前文件为待修复文件的步骤。
可选地,获取待修复文件的数据对象包括:
获取待修复文件的大小以及设置各数据对象的大小为预设值;
根据待修复文件的大小以及预设值将待修复的文件分为多个数据对象;
获取待修复文件的各数据对象。
可选地,原始文件在存储池中存放包括:
将原始文件分为多个数据对象并获取原始文件的数据对象;
在存储池中设置PG归置组;
将原始文件的数据对象存储至PG归置组;
通过crushmap算法将PG归置组映射至存储池的OSD磁盘,其中,存储池的OSD磁盘中包含各PG归置组映射的多个副本数据。
可选地,在检测到是xattr扩展属性丢失导致数据不一致的情况下,根据原始文件的数据对象的副本数据将待修复的数据对象进行修复包括:
根据各PG归置组在存储池的OSD磁盘中的映射信息查询待修复的数据对象的副本编号;
获取待修复的数据对象对应的PG归置组映射的副本数据;其中,PG归置组映射的副本数据为原始文件的数据对象的副本数据;
将PG归置组映射的副本数据复制到待修复的数据对象对应的节点;
将xattr文件的头部部分修改为待修复的数据对象的副本编号;
重新储存待修复的数据对象以完成数据的修复。
可选地,在根据原始文件的数据对象的副本数据将待修复的数据对象进行修复之后,还包括:
设置自动化修复工具;
将自动化修复工具添加至后台任务中。
可选地,在根据待修复的数据对象对应的副本数据将待修复的数据对象进行修复之后,还包括:
输出用于提示完成修复的信息。
为了解决上述技术问题,本申请还提供一种数据一致性检测和修复的装置,包括:
第一获取模块,设置为获取当前文件以及当前文件对应的原始文件;
第一比对模块,设置为将当前文件与原始文件进行比对以便确定当前文件与原始文件是否一致;若当前文件与原始文件不一致,则触发确定模块;若当前文件与原始文件一致,则结束;
确定模块,设置为确定当前文件为待修复文件;
第二获取模块,设置为获取待修复文件的数据对象;
第二比对模块,设置为将待修复文件的数据对象与原始文件的数据对象进行比对并确定待修复的数据对象;
修复模块,设置为根据原始文件的数据对象的副本数据将待修复的数据对象进行修复,并返回获取当前文件以及当前文件对应的原始文件的步骤。
为了解决上述技术问题,本申请还提供一种数据一致性检测和修复的装置,包括:
存储器,设置为存储计算机程序;
处理器,设置为执行计算机程序时实现上述的数据一致性检测和修复的方法的步骤。
为了解决上述技术问题,本申请还提供一种非易失性计算机可读存储介质,计算机可读存储介质上存储有计算机程序,计算机程序被处理器执行时实现上述的数据一致性检测和修复的方法的步骤。
本申请所提供的数据一致性检测和修复的方法,该方法包括:获取当前文件以及当前文件对应的原始文件;将当前文件与原始文件进行比对以便确定当前文件与原始文件是否一致;若当前文件与原始文件不一致,则确定当前文件为待修复文件;获取待修复文件的数据 对象;将待修复文件的数据对象与原始文件的数据对象进行比对并确定待修复的数据对象;根据原始文件的数据对象的副本数据将待修复的数据对象进行修复,并返回获取当前文件以及当前文件对应的原始文件的步骤;若当前文件与原始文件一致,则结束。由此可见,相比于目前的通过端到端数据校验实现数据一致性的方法,本申请的方法在实现数据一致性的过程中不需要在整个IO路径上附上校验信息,因此较容易实现数据一致;其次,相比于直接将文件分为多个数据对象的方法,该方法先判断文件是否一致,然后只将待修复的文件分为多个数据对象,不需要对数据一致的文件分为多个数据对象,因此减少了确定待修复的数据对象的时间,使得数据一致性检测和修复的过程相对简单,提高了数据一致性检测和修复的效率。
此外,本申请还提供一种数据一致性检测和修复的装置、非易失性计算机可读存储介质,与上述的数据一致性检测和修复的方法相对应,效果同上。
附图说明
为了更清楚地说明本申请实施例,下面将对实施例中所需要使用的附图做简单的介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1为本申请实施例提供的一种基于分布式存储系统的数据存储流程图;
图2为本申请实施例提供的一种数据一致性检测和修复的方法的流程图;
图3为本申请的一实施例提供的一种数据一致性检测和修复的装置的结构图;
图4为本申请另一实施例提供的一种数据一致性检测和修复的装置的结构图;
图5为本申请实施例提供的一种数据一致性检测和修复的应用场景示意图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下,所获得的所有其他实施例,都属于本申请保护范围。
本申请的核心是提供一种数据一致性检测和修复的方法、装置及非易失性计算机可读存储介质,用于对数据进行一致性检测和修复。
随着云计算、数字化转型,产生的数据量呈指数级增长,因此,对海量数据存储有新的 技术要求。传统存储虽然技术成熟、性能良好、可用性高等优点,但面对海量数据,其缺点也越来越明显,如扩展性差、成本高、存在单点故障和性能瓶颈等。为了克服上述缺点,满足海量数据的存储需求,当前技术背景下出现了分布式存储技术。分布式存储系统,通常包括存储服务器,以及多个客户端组成,其本质是将大量的文件,均匀分布到多个存储服务器上。分布式存储系统已经普遍应用于生成环境中,具有高扩展性,高可用性,高可靠性的特点,与此同时,分布式对象存储系统能够应用于多种场景,在商业化模式的推动下,对分布式存储系统的数据可靠性要求越来越高。
图1为本申请实施例提供的一种基于分布式存储系统的数据存储流程图。如图1所示,分布式存储系统主要包括:文件数据1、数据对象2、PG(Placement group,归置组)3、磁盘4,其中数据对象2、PG归置组3、磁盘4存放在存储池中。分布式存储系统的客户端将所要存储的文件数据,均以对象实例存储在底层磁盘4中。磁盘4是分布式存储系统的存储数据的守护进程,磁盘4守护进程的作用是处理存储设备上的IO操作。文件数据1被分片为数据对象2后,分布式存储系统设计了PG归置组3对海量数据对象2进行有效管理,并将PG归置组3映射到磁盘4中。由于随着数据量的增加,在集群扩容,动态均衡过程中,会导致磁盘4管理数据对象2过多而崩溃的问题,因此,设置PG归置组3用来避免客户端与底层磁盘4之间的紧耦合。磁盘4通常为存储对象的设备(Object Storage Device,OSD),设置为响应客户端请求返回具体数据的进程。
可选地,分布式存储系统客户端将文件存入存储系统中的方法流程如下:
a)分布式存储客户端首先指定存入分布式存储系统存储池pool,对象名;
b)crushmap算法将对象名进行hash计算得出具体的PG id,PG num的设置根据OSD磁盘的数量决定;
c)切片后的数据对象存储入PG归置组中后,在OSD磁盘中进程以目录的形式进行存储实例化;
d)数据对象存储在PG归置组的目录中,数据对象由三要素组成data,xattr,omap,其中data保存数据对象的数据,xattr保存数据对象的扩展属性,每个对象文件都可以设置文件的属性,这个属性是一个key/value值,但是受到文件系统的限制,key/value对的个数和每个value的大小都进行了限制,如果要设置的对象的key/value不能存储在文件的扩展属性中,还存在另外一种方式保存omap,omap保存到了key/vaule值对的数据库levelDB中;
e)最后,根据分布式存储系统冗余策略,在PG归置组中的数据对象会映射到多 个OSD磁盘当中,例如三副本,一个PG归置组包含三个OSD磁盘,每个OSD磁盘承载的数据对象信息完全一致,以上流程作为本申请数据一致性检测和修复的原理依据。
其中,OSD磁盘在分布式存储系统中使用统一的命名空间,将客户端的文件数据,进行切片,规定每个数据对象大小为预设值,依据该切片大小进行数据对象检测和修复处理。数据对象由全局唯一的inode号(规定十六进制),相对文件的偏移量,对象类型(快照snap或非快照),对象Hash值,所属存储池的id和第几个osd组成。可选地,存储在OSD磁盘中的数据对象示例如下:
10000226acd.00000002_head_84325100_5;
10000226acd:文件的inode号,全局唯一;
00000002:相对于文件的偏移;
head:对象在head目录下,非快照,如果是快照则为snap;
84325100:对象的哈希值,文件夹的目录分层id;
5:数据池编号pool id。
本申请基于分布式存储系统对数据的一致性进行检测以及在检测到数据不一致的情况下,根据分布式存储系统副本冗余机制对数据进行修复。
为了使本技术领域的人员更好地理解本申请方案,下面结合附图和具体实施方式对本申请作进一步的详细说明。图2为本申请实施例提供的一种数据一致性检测和修复的方法的流程图,如图2所示,该方法包括:
S10:获取当前文件以及当前文件对应的原始文件。
对数据的一致性检测是针对当前文件与当前文件对应的原始文件相比,数据是否一致。因此先分别获取当前文件以及当前文件对应的原始文件。在获取两个文件时,可以分别获取两个文件的具体内容、文件的属性、文件的类型等,此处对于获取的两个文件的具体的内容不作限定,但是获取的用来比较的对象要一致,如对两个文件均获取文件的属性。由于获取当前文件以及当前文件对应的原始文件是用来判断两个文件的数据是否一致,因此,也可以通过校验工具分别获取两个文件的校验值,从而根据校验值来判断两个文件的数据是否一致。当前常用的校验工具主要由哈希算法、MD5信息摘要算法(MD5 Message-Digest Algorithm,MD5)等,本申请中对于使用的具体的校验工具不作限定。如当根据MD5值判断两个文件的数据是否一致时,需要分别获取当前文件的MD5值以及当前文件对应的原始文件的MD5值。
S11:将当前文件与原始文件进行比对以便确定当前文件与原始文件是否一致;若当前 文件与原始文件不一致,则进入步骤S12;若当前文件与原始文件一致,则结束。
在上述步骤中获取了当前文件以及当前文件对应的原始文件,进而可以根据当前文件以及当前文件对应的原始文件来判断数据是否一致。此处对于用来判断两个文件数据是否一致的比较对象不作限定。如上述步骤中,可以根据两个文件的具体内容进行判断,当两个文件的具体内容完全相同时,确认两个文件的数据一致;也可以同时根据两个文件的具体内容、文件的属性进行判断,当两个文件的具体内容完全相同、文件的属性完全相同,确认两个文件的数据一致;当两个文件的MD5值相同时,确认两个文件的数据一致。当两个文件的数据一致时,说明数据未发生的损坏,因此不需要对数据进行修复;当两个文件的数据不一致时,说明数据发生了损坏。当数据发生损坏后,若不对数据进行修复,则可能会导致业务IO出错,出现数据不可用的现象,因此对于数据不一致的情况,需要对数据进行修复。
S12:确定当前文件为待修复文件。
在判断出当前文件与当前文件对应的原始文件不一致时,确认当前文件是待修复的文件。
S13:获取待修复文件的数据对象。
上述步骤中确定了待修复文件。在实施中,为了确定数据损坏的具体位置,以及针对损坏的数据进行准确地修复,本实施例将待修复文件分为多个数据对象,逐个数据对象判断数据是否发生了变化。首先确认客户端访问损坏的文件路径,通过文件路径,查出文件的inode信息,并转换为十六进制,计算该文件的大小,已知每个数据对象大小为预设值进行切分,计算出文件拥有多少个数据对象。可选地,在文件路径下,使用11-i命令获取到该文件的inode号及文件大小,通过inode号计算底层数据对象名前缀,根据文件大小获取底层数据对象名后缀最大值。假设文件的inode为2199080746415,执行printf″%x\n″2199080746415得出底层数据对象名前缀为200036d3daf,使用文件大小除以4M,得到5129.233,则得到数据对象个数为5130个,数据对象名后缀从0开始,则后缀范围为00000000到00001409,其中1409是5129的十六进制。
S14:将待修复文件的数据对象与原始文件的数据对象进行比对并确定待修复的数据对象。
在存储池中,扫描遍历每个数据对象,当以“No such file or directory”为标志,当出现该标志时,则表示该数据对象已存坏。如:损坏的对象示例,inodeID(十六进制):
error stat-ing存储池名称/inodeID.对象ID:No such file or directory。
如分布式集群容量将近写满的状态下,曾多次写满了几个OSD磁盘,容量到100%,会 导致该OSD磁盘进程down掉,无法启动;为了使该OSD磁盘启动,并且在不删除原有数据的情况下,依据文件存入存储系统中的流程,数据对象存储过程,将PG归置组目录下的文件进行迁移,但是移动会导致该PG归置组目录下数据对象文件扩展属性丢失,则读取该PG归置组目录下数据对象会出错,报该数据对象不存在。
S15:根据原始文件的数据对象的副本数据将待修复的数据对象进行修复,并返回步骤S10。
为了使业务IO尽可能地不出错以及数据可读,对上述步骤中确定的待修复的数据对象进行修复。分布式存储系统记录了每个PG归置组在不同副本数据的Map信息,经过查询可以获取丢失数据对象的OSD磁盘的副本OSD id,根据副本的OSD磁盘可以恢复丢失数据对象的信息。可选地,首先获取副本数据的信息并进行保存,然后将保存的数据对象信息复制到对应的节点上。
本实施例所提供的数据一致性检测和修复的方法,包括:获取当前文件以及当前文件对应的原始文件;将当前文件与原始文件进行比对以便确定当前文件与原始文件是否一致;若当前文件与原始文件不一致,则确定当前文件为待修复文件;获取待修复文件的数据对象;将待修复文件的数据对象与原始文件的数据对象进行比对并确定待修复的数据对象;根据原始文件的数据对象的副本数据将待修复的数据对象进行修复,并返回获取当前文件以及当前文件对应的原始文件的步骤;若当前文件与原始文件一致,则结束。由此可见,相比于目前的通过端到端数据校验实现数据一致性的方法,本实施例的方法在实现数据一致性的过程中不需要在整个IO路径上附上校验信息,因此较容易实现数据一致;其次,相比于直接将文件分为多个数据对象的方法,该方法先判断文件是否一致,然后只将待修复的文件分为多个数据对象,不需要对数据一致的文件分为多个数据对象,因此减少了确定待修复的数据对象的时间,使得数据一致性检测和修复的过程相对简单,提高了数据一致性检测和修复的效率。
在实施中,为了能够快速地判断出当前文件与当前文件对应的原始文件的数据是否一致,采用校验工具来进行判断。可选地实施方式是,将当前文件与原始文件进行比对以便确定当前文件与原始文件是否一致包括:
获取原始文件的第一MD5值以及获取当前文件的第二MD5值;
在第一MD5值与第二MD5值不相同的情况下,进入确定当前文件为待修复文件的步骤。
上述实施例中列举出可以根据文件的具体内容、文件的属性、文件的类型等或采用校验 工具来判断两个文件的数据是否一致。在采用校验工具时,直接在命令行键入文件校验和完整性验证程序信息即可获得校验值,因此相比于直接根据文件的具体内容、文件的属性、文件的类型来判断数据一致性较全面以及较方便快速。本实施例对于使用的具体的校验工具不作限定。可选地,采用MD5值进行数据一致性的校验。在计算文件的MD5值时,在命令行键入如下命令:FCIV-md5-sha1 path\filename.ext便可以获取到文件的MD5值。先获取当前文件对应的原始文件的MD5值,将该MD5值定义为第一MD5值,然后获取当前文件的MD5值,将该MD5值定义为第二MD5值,当比较两个MD5值,当两个MD5值相同时,说明两个文件的数据一致;当两个MD值不相同时,则说明两个文件的数据不一致,确定当前文件为待修复的文件。
本实施例所提供的根据MD5值进行数据一致性的校验,能够较为准确、全面、快速地得到数据一致性的结果。
为了准确地定位数据损坏的位置,在实施中,将待修复文件分为多个数据对象,通过遍历每个数据对象来确定损坏的数据对象。可选地实施方式,获取待修复文件的数据对象包括:
获取待修复文件的大小以及设置各数据对象的大小为预设值;
根据待修复文件的大小以及预设值将待修复的文件分为多个数据对象;
获取待修复文件的各数据对象。
首先确认客户端访问损坏的文件路径,通过该文件的路径,查出该文件的inode信息,并转换为十六进制,计算该文件的大小,设置各数据对象的大小为预设值,根据该预设值对该文件进行切分,计算出该文件拥有多少个数据对象。需要说明的是,本申请对于预设值的设定不作限定。对于Ceph分布式存储,预设值可以为4MB;对于6FS分布式存储,预设值可以为64MB;对于HDFS分布式存储,预设值可以为128MB。本实施例中选取预设值为4M。
本实施例所提供的将文件分为多个数据对象,通过遍历每个数据对象来确定损坏的数据对象,进而准确地定位到数据损坏的位置。
本申请基于分布式存储系统对数据的一致性检测和修复,可选地实施方式,原始文件在存储池中存放包括:
将原始文件分为多个数据对象并获取原始文件的数据对象;
在存储池中设置PG归置组;
将原始文件的数据对象存储至PG归置组;
通过crushmap算法将PG归置组映射至存储池的OSD磁盘,其中,存储池的OSD磁盘中包含各PG归置组映射的多个副本数据。
原始文件在存储池中存放的过程如图1所示。上文中已对分布式存储系统作了详细描述,此处不再赘述。
本实施例所提供的分布式存储方式,一方面,在存储池中设置PG归置组,能够避免客户端与底层OSD磁盘之间的紧耦合;另一方面,通过crushmap算法能够尽可能地保证数据对象均匀分布在各OSD磁盘中。
在实施中,常见的数据不一致的情况有存储数据data损坏、xattr扩展属性丢失等。当因xattr扩展属性丢失而导致数据不一致时,具体的修复过程如下。在检测到是xattr扩展属性丢失导致数据不一致的情况下,根据原始文件的数据对象的副本数据将待修复的数据对象进行修复包括:
根据各PG归置组在存储池的OSD磁盘中的映射信息查询待修复的数据对象的副本编号;
获取待修复的数据对象对应的PG归置组映射的副本数据;其中,PG归置组映射的副本数据为原始文件的数据对象的副本数据;
将PG归置组映射的副本数据复制到待修复的数据对象对应的节点;
将xattr文件的头部部分修改为待修复的数据对象的副本编号;
重新储存待修复的数据对象以完成数据的修复。
在确定待修复的数据对象即丢失的数据对象之后,在分布式存储系统中定位数据对象的分布情况。分布式存储系统中记录了每个PG归置组在不同副本数据的Map信息,经过查询可以获取丢失的数据对象的OSD磁盘的副本编号即OSD id,根据副本的OSD磁盘可以恢复丢失的数据对象的信息,首先获取副本数据的信息并进行保存,然后将保存的对象信息复制到对应的节点,最后修改attr文件的头部部分设置为当前丢失的数据对象的OSD磁盘编号,重新存储数据对象信息,完成数据的修复。可选地,修复过程如下:
a)丢失对象的OSD,列举同组PG下的副本OSD属性信息;
attr-l PG对象目录
/3.3d3_head/200036d3db5.00000f7d_head_CEAF8FD3_3
b)导出同组PG下的副本OSD属性信息;
getfattr-d PG对象目录
/3.3d3_head/200036d3db5.00000f7d_head_CEAF8FD3_3>保存文件.txt
c)修改“保存文件.txt”设置为当前丢失对象信息的OSD编号;
d)复制到丢失对象的OSD所属节点:
e)通过“setfattr-restore保存文件.txt”命令进行扩展属性恢复。
本实施例所提供的数据修复的方法,解决了因xattr扩展属性丢失而导致数据不一致的问题,使得业务IO尽可能地正确以及确保数据的可用性。
在上述实施例的基础上,为了实现对数据一致性的定时检测,可选地实施方式是,在根据原始文件的数据对象的副本数据将待修复的数据对象进行修复之后,还包括:
设置自动化修复工具;
将自动化修复工具添加至后台任务中。
在实施中,可以通过伪代码设计检查工具,并添加到Linux后台crontab任务中,可实现定时检测。通过伪代码实现检测的过程如下:先输入要修复的文件路径,找到要分析的文件的路径;在存储池中比对数据对象的信息。
本实施例所提供的通过设置自动化修复工具,在检测到数据不一致的情况下,通过自动化修复工具能够及时地对数据不一致的情况进行处理,从而使得业务IO尽可能地正确以及确保数据的可用性。
上述实施例中对数据的一致性进行了检测以及修复。在实施中,为了能够使用户直观了解到数据的修复情况,作为可选地方式,在根据待修复的数据对象对应的副本数据将待修复的数据对象进行修复之后,还包括:
输出用于提示完成修复的信息。
在对数据修复完成之后,输出提示信息用来提示用户完成数据的修复。本实施例中对于用于提示完成修复的信息的具体内容、方式、时间等不作限定,只要能提示完成数据的修复即可。
本实施例所提供的在完成数据修复之后,输出提示信息,使得用户能够直观了解到数据的修复情况。
在上述实施例中,对于数据一致性检测和修复的方法进行了详细描述,本申请还提供一 种数据一致性检测和修复的装置对应的实施例。需要说明的是,本申请从两个角度对装置部分的实施例进行描述,一种是基于功能模块的角度,另一种是基于硬件的角度。
图3为本申请的一实施例提供的一种数据一致性检测和修复的装置的结构图。本实施例基于功能模块的角度,包括:
第一获取模块10,设置为获取当前文件以及当前文件对应的原始文件;
第一比对模块11,设置为将当前文件与原始文件进行比对以便确定当前文件与原始文件是否一致;若当前文件与原始文件不一致,则触发确定模块12;若当前文件与原始文件一致,则结束;
确定模块12,设置为确定当前文件为待修复文件;
第二获取模块13,设置为获取待修复文件的数据对象;
第二比对模块14,设置为将待修复文件的数据对象与原始文件的数据对象进行比对并确定待修复的数据对象;
修复模块15,设置为根据原始文件的数据对象的副本数据将待修复的数据对象进行修复,并返回获取当前文件以及当前文件对应的原始文件的步骤。
由于装置部分的实施例与方法部分的实施例相互对应,因此装置部分的实施例请参见方法部分的实施例的描述,这里暂不赘述。
本实施例所提供的数据一致性检测和修复的装置,通过第一获取模块获取当前文件以及当前文件对应的原始文件;通过第一比对模块将当前文件与原始文件进行比对以便确定当前文件与原始文件是否一致;若当前文件与原始文件不一致,则触发确定模块来确定当前文件为待修复文件;通过第二获取模块获取待修复文件的数据对象;通过第二比对模块将待修复文件的数据对象与原始文件的数据对象进行比对并确定待修复的数据对象;通过修复模块来根据原始文件的数据对象的副本数据将待修复的数据对象进行修复。由此可见,相比于目前的通过端到端数据校验实现数据一致性的方法,该装置在实现数据一致性的过程中不需要在整个IO路径上附上校验信息,因此较容易实现数据一致;其次,相比于直接将文件分为多个数据对象,该装置中先判断文件是否一致,然后只将待修复的文件分为多个数据对象,不需要对数据一致的文件分为多个数据对象,因此减少了确定待修复的数据对象的时间,使得数据一致性检测和修复的过程相对简单,提高了数据一致性检测和修复的效率。
图4为本申请另一实施例提供的一种数据一致性检测和修复的装置的结构图。本实施例 基于硬件角度,如图4所示,数据一致性检测和修复的装置包括:
存储器20,设置为存储计算机程序;
处理器21,设置为执行计算机程序时实现如上述实施例中所提到的数据一致性检测和修复的方法的步骤。
本实施例提供的数据一致性检测和修复的装置可以包括但不限于智能手机、平板电脑、笔记本电脑或台式电脑等。
其中,处理器21可以包括一个或多个处理核心,比如4核心处理器、8核心处理器等。处理器21可以采用数字信号处理器(Digital Signal Processor,DSP)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)、可编程逻辑阵列(Programmable Logic Array,PLA)中的至少一种硬件形式来实现。处理器21也可以包括主处理器和协处理器,主处理器是设置为对在唤醒状态下的数据进行处理的处理器,也称中央处理器(Central Processing Unit,CPU);协处理器是设置为对在待机状态下的数据进行处理的低功耗处理器。在一些实施例中,处理器21可以集成有图形处理器(Graphics Processing Unit,GPU),GPU设置为负责显示屏所需要显示的内容的渲染和绘制。一些实施例中,处理器21还可以包括人工智能(Artificial Intelligence,AI)处理器,该AI处理器设置为处理有关机器学习的计算操作。
存储器20可以包括一个或多个计算机可读存储介质,该计算机可读存储介质可以是非暂态的。存储器20还可包括高速随机存取存储器,以及非易失性存储器,比如一个或多个磁盘存储设备、闪存存储设备。本实施例中,存储器20至少设置为存储以下计算机程序201,其中,该计算机程序被处理器21加载并执行之后,能够实现前述任一实施例公开的数据一致性检测和修复的方法的相关步骤。另外,存储器20所存储的资源还可以包括操作系统202和数据203等,存储方式可以是短暂存储或者永久存储。其中,操作系统202可以包括Windows、Unix、Linux等。数据203可以包括但不限于上述所提到的数据一致性检测和修复的方法所涉及到的数据等。
在一些实施例中,数据一致性检测和修复的装置还可包括有显示屏22、输入输出接口23、通信接口24、电源25以及通信总线26。
本领域技术人员可以理解,图4中示出的结构并不构成对数据一致性检测和修复的装置的限定,可以包括比图示更多或更少的组件。
本申请实施例提供的数据一致性检测和修复的装置,包括存储器和处理器,处理器在执行存储器存储的程序时,能够实现如下方法:数据一致性检测和修复的方法,效果同上。
最后,本申请还提供一种非易失性计算机可读存储介质对应的实施例。计算机可读存储介质上存储有计算机程序,计算机程序被处理器执行时实现如上述方法实施例中记载的步骤。
可以理解的是,如果上述实施例中的方法以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,执行本申请各个实施例方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。
本申请提供的计算机可读存储介质包括上述提到的数据一致性检测和修复的方法,效果同上。
为了使本领域的技术人员更好的理解本申请的技术方案,下面结合附图5对上述本申请作进一步的详细说明,图5为本申请实施例提供的一种数据一致性检测和修复的应用场景示意图。如图5所示,该过程包括:
S16:文件一致性校验;
S17:判断文件MD5值是否变化;若文件MD5值有变化,则进入步骤S18,若文件MD5值无变化,则进入步骤S25;
S18:确认数据损坏;
S19:计算文件大小和inode并转换;
S20:遍历存储池;
S21:找到丢失对象;
S22:PG归置组副本对象;
S23:修复数据;
S24:重新存储损坏的数据;
S25:数据正常。
由此可见,相比于目前的通过端到端数据校验实现数据一致性的方法,本实施例所提供的数据一致性检测和修复的方法在实现数据一致性的过程中不需要在整个IO路径上附上校 验信息,因此较容易实现数据一致;其次,相比于直接将文件分为多个数据对象,该方法中先判断文件是否一致,然后只将待修复的文件分为多个数据对象,不需要对数据一致的文件分为多个数据对象,因此减少了确定待修复的数据对象的时间,使得数据一致性检测和修复的过程相对简单,提高了数据一致性检测和修复的效率。
以上对本申请所提供的一种数据一致性检测和修复的方法、装置及非易失性计算机可读存储介质进行了详细介绍。说明书中各个实施例采用递进的方式描述,每个实施例重点说明的都是与其他实施例的不同之处,各个实施例之间相同相似部分互相参见即可。对于实施例公开的装置而言,由于其与实施例公开的方法相对应,所以描述的比较简单,相关之处参见方法部分说明即可。应当指出,对于本技术领域的普通技术人员来说,在不脱离本申请原理的前提下,还可以对本申请进行若干改进和修饰,这些改进和修饰也落入本申请权利要求的保护范围内。
还需要说明的是,在本说明书中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括上述要素的过程、方法、物品或者设备中还存在另外的相同要素。

Claims (20)

  1. 一种数据一致性检测和修复的方法,包括:
    获取当前文件以及当前所述文件对应的原始文件;
    将当前所述文件与所述原始文件进行比对以便确定当前所述文件与所述原始文件是否一致;
    若所述文件与所述原始文件不一致,则确定当前所述文件为待修复文件;
    获取待修复文件的数据对象;
    将所述待修复文件的数据对象与所述原始文件的数据对象进行比对并确定待修复的数据对象;
    根据所述原始文件的数据对象的副本数据将所述待修复的数据对象进行修复,并返回所述获取当前文件以及当前所述文件对应的原始文件的步骤;
    若所述文件与所述原始文件一致,则结束。
  2. 根据权利要求1所述的数据一致性检测和修复的方法,其中,所述将当前所述文件与所述原始文件进行比对以便确定当前所述文件与所述原始文件是否一致包括:
    获取所述原始文件的第一MD5值以及获取当前所述文件的第二MD5值;
    在所述第一MD5值与所述第二MD5值不相同的情况下,进入所述确定当前所述文件为待修复文件的步骤。
  3. 根据权利要求2所述的数据一致性检测和修复的方法,其中,所述获取待修复文件的数据对象包括:
    获取所述待修复文件的大小以及设置各所述数据对象的大小为预设值;
    根据所述待修复文件的大小以及所述预设值将所述待修复的文件分为多个数据对象;
    获取所述待修复文件的各所述数据对象。
  4. 根据权利要求1所述的数据一致性检测和修复的方法,其中,所述原始文件在存储池中存放包括:
    将所述原始文件分为多个数据对象并获取所述原始文件的数据对象;
    在所述存储池中设置PG归置组;
    将所述原始文件的数据对象存储至所述PG归置组;
    通过crushmap算法将所述PG归置组映射至所述存储池的OSD磁盘,其中,所述存储池的OSD磁盘中包含各所述PG归置组映射的多个副本数据。
  5. 根据权利要求4所述的数据一致性检测和修复的方法,其中,在检测到是xattr 扩展属性丢失导致数据不一致的情况下,所述根据所述原始文件的数据对象的副本数据将所述待修复的数据对象进行修复包括:
    根据各所述PG归置组在所述存储池的OSD磁盘中的映射信息查询所述待修复的数据对象的副本编号;
    获取所述待修复的数据对象对应的PG归置组映射的副本数据;其中,所述PG归置组映射的副本数据为所述原始文件的数据对象的副本数据;
    将所述PG归置组映射的副本数据复制到所述待修复的数据对象对应的节点;
    将xattr文件的头部部分修改为所述待修复的数据对象的副本编号;
    重新储存所述待修复的数据对象以完成数据的修复。
  6. 根据权利要求5所述的数据一致性检测和修复的方法,其中,在所述根据所述原始文件的数据对象的副本数据将所述待修复的数据对象进行修复之后,还包括:
    设置自动化修复工具;
    将所述自动化修复工具添加至后台任务中。
  7. 根据权利要求1至6任意一项所述的数据一致性检测和修复的方法,其中,在所述根据所述待修复的数据对象对应的副本数据将所述待修复的数据对象进行修复之后,还包括:
    输出用于提示完成修复的信息。
  8. 根据权利要求1所述的数据一致性检测和修复的方法,其中,所述将当前所述文件与所述原始文件进行比对以便确定当前所述文件与所述原始文件是否一致包括:
    获取所述原始文件的信息以及获取当前所述文件的信息,其中,所述原始文件的信息包括以下至少之一:所述原始文件中的内容、所述原始文件的属性、所述原始文件的类型,当前所述文件的信息包括以下至少之一:当前所述文件中的内容、当前所述文件的属性、当前所述文件的类型;
    对所述原始文件的信息与当前所述文件的信息进行对应比较,并在确定比较结果为不相同的情况下,进入所述确定当前所述文件为待修复文件的步骤。
  9. 根据权利要求1所述的数据一致性检测和修复的方法,其中,所述将当前所述文件与所述原始文件进行比对以便确定当前所述文件与所述原始文件是否一致包括:
    获取所述原始文件的哈希值以及获取当前所述文件的哈希值;
    在所述原始文件的哈希值与当前所述文件的哈希值不相同的情况下,进入所述确定当前所述文件为待修复文件的步骤。
  10. 根据权利要求3所述的数据一致性检测和修复的方法,其中,将所述待修复文 件的数据对象与所述原始文件的数据对象进行比对并确定待修复的数据对象包括:
    针对所述待修复文件的多个所述数据对象,逐个与所述原始文件的数据对象进行比对并确定待修复的数据对象。
  11. 根据权利要求1所述的数据一致性检测和修复的方法,其中,根据所述原始文件的数据对象的副本数据将所述待修复的数据对象进行修复包括:
    保存所述原始文件的数据对象的副本数据;
    将保存的所述副本数据复制到所述待修复的数据对象对应的节点上。
  12. 根据权利要求3所述的数据一致性检测和修复的方法,其中,根据所述待修复文件的大小以及所述预设值将所述待修复的文件分为多个数据对象包括:
    根据所述待修复文件的大小以及所述预设值对所述待修复的文件进行切分,以将所述待修复的文件分为多个数据对象,其中,按照不同的存储格式存储的所述待修复文件所对应的所述预设值是不同的。
  13. 根据权利要求6所述的数据一致性检测和修复的方法,其中,
    设置所述自动化修复工具包括:设置伪代码设计检查工具;
    将所述自动化修复工具添加至后台任务中包括:将所述伪代码设计检查工具添加到所述后台任务中。
  14. 根据权利要求13所述的数据一致性检测和修复的方法,其中,将所述伪代码设计检查工具添加到所述后台任务中包括:
    将所述伪代码设计检查工具添加到Linux后台crontab任务中。
  15. 根据权利要求13所述的数据一致性检测和修复的方法,其中,所述伪代码设计检查工具的检测过程包括:
    在所述伪代码设计检查工具中输入要修复的文件路径,找到要分析的文件的路径;
    在存储池中比对基于要分析的文件的路径所确定出的数据对象的信息。
  16. 一种数据一致性检测和修复的装置,包括:
    第一获取模块,设置为获取当前文件以及当前所述文件对应的原始文件;
    第一比对模块,设置为将当前所述文件与所述原始文件进行比对以便确定当前所述文件与所述原始文件是否一致;若所述文件与所述原始文件不一致,则触发确定模块;若所述文件与所述原始文件一致,则结束;
    所述确定模块,设置为确定当前所述文件为待修复文件;
    第二获取模块,设置为获取待修复文件的数据对象;
    第二比对模块,设置为将所述待修复文件的数据对象与所述原始文件的数据对象进 行比对并确定待修复的数据对象;
    修复模块,设置为根据所述原始文件的数据对象的副本数据将所述待修复的数据对象进行修复,并返回所述获取当前文件以及当前所述文件对应的原始文件的步骤。
  17. 根据权利要求16所述的数据一致性检测和修复的装置,其中,所述第一比对模块用于:
    获取所述原始文件的第一MD5值以及获取当前所述文件的第二MD5值;
    在所述第一MD5值与所述第二MD5值不相同的情况下,进入所述确定当前所述文件为待修复文件的步骤。
  18. 一种数据一致性检测和修复的装置,包括:
    存储器,设置为存储计算机程序;
    处理器,设置为执行所述计算机程序时实现如权利要求1至15任一项所述的数据一致性检测和修复的方法的步骤。
  19. 根据权利要求18所述的数据一致性检测和修复的装置,其中,还包括:
    显示屏、输入输出接口、通信接口、电源以及通信总线;
    所述存储器、所述处理器、所述显示屏、所述输入输出接口、所述通信接口以及所述电源均与所述通信总线连接。
  20. 一种非易失性计算机可读存储介质,所述计算机可读存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现如权利要求1至15任一项所述的数据一致性检测和修复的方法的步骤。
PCT/CN2022/135108 2022-03-25 2022-11-29 一种数据一致性检测和修复的方法、装置及介质 WO2023179077A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210298447.6 2022-03-25
CN202210298447.6A CN114416665B (zh) 2022-03-25 2022-03-25 一种数据一致性检测和修复的方法、装置及介质

Publications (1)

Publication Number Publication Date
WO2023179077A1 true WO2023179077A1 (zh) 2023-09-28

Family

ID=81264493

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/135108 WO2023179077A1 (zh) 2022-03-25 2022-11-29 一种数据一致性检测和修复的方法、装置及介质

Country Status (2)

Country Link
CN (1) CN114416665B (zh)
WO (1) WO2023179077A1 (zh)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114416665B (zh) * 2022-03-25 2022-06-10 苏州浪潮智能科技有限公司 一种数据一致性检测和修复的方法、装置及介质
CN115729477A (zh) * 2023-01-09 2023-03-03 苏州浪潮智能科技有限公司 分布式存储io路径数据写入、读取方法、装置和设备

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104111937A (zh) * 2013-04-18 2014-10-22 中兴通讯股份有限公司 主、备数据库及其数据一致性检测、修复方法和装置
US20170344597A1 (en) * 2016-05-24 2017-11-30 Vmware, Inc. Distributed file system consistency check
CN107948334A (zh) * 2018-01-09 2018-04-20 无锡华云数据技术服务有限公司 基于分布式存储系统的数据处理方法
CN112463444A (zh) * 2020-11-18 2021-03-09 苏州浪潮智能科技有限公司 一种数据不一致修复方法及相关装置
CN114416665A (zh) * 2022-03-25 2022-04-29 苏州浪潮智能科技有限公司 一种数据一致性检测和修复的方法、装置及介质

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105160253B (zh) * 2015-09-29 2018-11-09 网易(杭州)网络有限公司 修复客户端程序的方法、装置、系统及服务器
US10599634B2 (en) * 2016-06-19 2020-03-24 Qualcomm Incorporated Signaling which version information to use on byte-range file repair
CN113806119A (zh) * 2020-06-17 2021-12-17 浙江宇视科技有限公司 存储卡处理方法、装置、设备及存储介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104111937A (zh) * 2013-04-18 2014-10-22 中兴通讯股份有限公司 主、备数据库及其数据一致性检测、修复方法和装置
US20170344597A1 (en) * 2016-05-24 2017-11-30 Vmware, Inc. Distributed file system consistency check
CN107948334A (zh) * 2018-01-09 2018-04-20 无锡华云数据技术服务有限公司 基于分布式存储系统的数据处理方法
CN112463444A (zh) * 2020-11-18 2021-03-09 苏州浪潮智能科技有限公司 一种数据不一致修复方法及相关装置
CN114416665A (zh) * 2022-03-25 2022-04-29 苏州浪潮智能科技有限公司 一种数据一致性检测和修复的方法、装置及介质

Also Published As

Publication number Publication date
CN114416665A (zh) 2022-04-29
CN114416665B (zh) 2022-06-10

Similar Documents

Publication Publication Date Title
US11153380B2 (en) Continuous backup of data in a distributed data store
WO2023179077A1 (zh) 一种数据一致性检测和修复的方法、装置及介质
US20230031079A1 (en) Resynchronization to a synchronous replication relationship
US20220006755A1 (en) Load balancing for ip failover
US11068503B2 (en) File system operation handling during cutover and steady state
US11593016B2 (en) Serializing execution of replication operations
US11782783B2 (en) Method and apparatus to neutralize replication error and retain primary and secondary synchronization during synchronous replication
US9727273B1 (en) Scalable clusterwide de-duplication
US11221785B2 (en) Managing replication state for deleted objects
WO2021057108A1 (zh) 一种读数据方法、写数据方法及服务器
US9984139B1 (en) Publish session framework for datastore operation records
US11409711B2 (en) Barriers for dependent operations among sharded data stores
US20230081436A1 (en) Dependency aware parallel splitting of operations
US11822520B2 (en) Freeing pages within persistent memory
US10896152B2 (en) Method, apparatus and computer program product for managing data storage
US11544007B2 (en) Forwarding operations to bypass persistent memory
US11663166B2 (en) Post-processing global deduplication algorithm for scaled-out deduplication file system
US11940954B2 (en) Methods for ensuring correctness of file system analytics and devices thereof
US10852994B2 (en) Metadata compaction
US11138229B2 (en) Dependency aware improvements to support parallel replay or parallel replication of operations which are directed to a common inode
US11740976B2 (en) Crash-consistent clone generation in a distributed file system
CN111459928B (zh) 应用于集群范围内数据备份场景的数据去重方法及应用
US11720551B1 (en) Method and system for streaming data from portable storage devices

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

Country of ref document: EP

Kind code of ref document: A1