A method for data replication based on logical volumes

By using a logical volume-based data replication method, which utilizes replication cache call functions and linear or stripe mapping mechanisms, logical volume data is converted into disk data shards. This solves the application unavailability problem caused by differences in the number and names of disks in LVM scenarios, and achieves accurate replication and normal use of logical volumes.

CN116088765BActive Publication Date: 2026-01-09GUIZHOU AISU SHUZHI INFORMATION TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310103652.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-13
Publication Date
2026-01-09
Estimated Expiration
2043-02-13

AI Technical Summary

Technical Problem

In Logical Volume Management (LVM) scenarios, the difference in the number and names of disks between production machines and disaster recovery machines can cause applications to be unusable on disaster recovery machines.

Method used

A data replication method based on logical volumes is provided. By determining the target disk corresponding to the logical volume to be replicated in the production machine, the data is replicated using the replication cache call function, and the data is converted into disk data fragments using a linear or striped mapping mechanism and written to the disk of the disaster recovery machine.

Benefits of technology

It achieves accurate replication of production machine logical volumes under the original layout, avoiding application unavailability issues caused by changes in the number and names of disks on the disaster recovery machine and the production machine, and ensuring that the replicated data can be used normally on the disaster recovery machine.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116088765B_ABST
    Figure CN116088765B_ABST
Patent Text Reader

Abstract

The application discloses a data replication method based on a logical volume. The method comprises the following steps: determining a replication cache calling function according to a target disk corresponding to a logical volume to be replicated in a production machine; replicating the logical volume to be replicated by using the replication cache calling function to obtain replication data; determining disk data fragments corresponding to the replication data based on a linear mapping mechanism or a strip mapping mechanism, and writing the disk data fragments into a disk of a disaster recovery machine. The technical scheme of the embodiment of the application can replicate data of a specified disk, solves the problem that a traditional replication mode does not support partial logical volume data replication, and converts the replication data of the logical volume into disk data fragments, so that the disk data fragments are replicated to an underlying disk of a logical volume of the disaster recovery machine, thereby avoiding the problem that partial applications are unavailable due to changes in the number and names of the disks of the disaster recovery machine and the production machine.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of data backup, and particularly relates to a data replication method based on a logical volume. BACKGROUND

[0002] With the continuous development of information technology, the value of data is increasingly prominent. Data damage or loss occurs due to various subjective or objective reasons, which brings great loss to enterprises and users, and data protection becomes extremely important.

[0003] At present, the continuous data protection (CDP) technology is a popular data protection scheme with good recovery time objective (RTO) and recovery point objective (RPO) effects. The continuous data protection generally has two implementation modes, one is file-based continuous data protection, and the other is block-based continuous data protection. The file-based continuous data protection is generally used for specific application protection, such as database replication, and the block-based continuous data protection is generally used for whole machine protection, such as host replication.

[0004] However, in the scene of the logical volume management (LVM), when the number and names of disks between a production machine and a disaster recovery machine are different, some applications cannot be used on the disaster recovery machine in the block-based continuous data protection mode. SUMMARY

[0005] The present application provides a data replication method to solve the problem that some applications cannot be used on a disaster recovery machine due to the difference in the number and names of disks between a production machine and a disaster recovery machine.

[0006] In a first aspect, the present application provides a data replication method based on a logical volume, comprising:

[0007] determining a replication cache calling function according to a target disk corresponding to a to-be-replicated logical volume in a production machine;

[0008] replicating the to-be-replicated logical volume by using the replication cache calling function to obtain replication data;

[0009] determining disk data fragments corresponding to the replication data based on a linear mapping mechanism or a strip mapping mechanism, and writing the disk data fragments into disks of a disaster recovery machine

[0010] The application provides a logical volume-based data replication scheme, which comprises the following steps: determining a target disk corresponding to a logical volume to be replicated in a production machine, determining a replication cache calling function according to the target disk, replicating the logical volume to be replicated by using the replication cache calling function to obtain replication data, determining disk data fragments corresponding to the replication data based on a linear mapping mechanism or a strip mapping mechanism, and writing the disk data fragments into a disk of a disaster recovery machine.

[0011] It should be understood that the content described in this part is not intended to identify the key or important features of the application, nor is it used to limit the scope of the application. Other features of the application will become apparent from the following description. BRIEF DESCRIPTION OF DRAWINGS

[0012] In order to more clearly illustrate the technical solutions in the embodiments of the application, the following will briefly introduce the drawings needed to be used in the embodiment description. Obviously, the drawings in the following description are only some embodiments of the application, and other drawings can be obtained by those skilled in the art without creative labor on the basis of these drawings.

[0013] Figure 1 is a flow chart of a logical volume-based data replication method according to the first embodiment of the application;

[0014] Figure 2 is a replication schematic diagram according to the first embodiment of the application;

[0015] Figure 3 is a flow chart of a logical volume-based data replication method according to the second embodiment of the application;

[0016] Figure 4 is a schematic diagram of a replication logical volume according to the second embodiment of the application;

[0017] Figure 5 is a linear mapping schematic diagram according to the second embodiment of the application;

[0018] Figure 6 is a flow chart of a logical volume-based data replication method according to the third embodiment of the application;

[0019] Figure 7 is a strip mapping schematic diagram according to the third embodiment of the present application. DETAILED DESCRIPTION

[0020] In order to make the personnel in the technical field better understand the present application scheme, the technical scheme in the embodiments of the present application will be described clearly and completely below in combination with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, not all. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor should belong to the scope of protection of the present application.

[0021] It should be noted that the terms "first", "second" and the like in the specification and claims of the present application and the above-described drawings are used to distinguish similar objects, and do not necessarily indicate a specific order or a chronological sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. In the description of the present application, "a plurality of" means two or more, unless otherwise specified. The association relationship of "and / or" described between the associated objects indicates that there can be three relationships, for example, A and / or B can represent: A exists alone, A and B exist together, and B exists alone. The character " / " generally represents an "or" relationship between the associated objects. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device that includes a series of steps or units does not have to be limited to those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to the process, method, product or device.

[0022] Embodiment one

[0023] Figure 1 A flowchart of a logical volume-based data replication method is provided for the first embodiment of the present application. The present embodiment can be applicable to the case of replicating data in a logical volume. The method can be executed by a logical volume-based data replication device, which can be realized in the form of hardware and / or software. The logical volume-based data replication device can be configured in an electronic device, which can be composed of two or more physical entities or one physical entity.

[0024] As shown in Figure 1 , the logical volume-based data replication method provided by the first embodiment of the present application specifically includes the following steps:

[0025] S101, determining a replication cache calling function according to a target disk corresponding to a logical volume to be replicated in a production machine.

[0026] In the embodiment, a plurality of logical volumes can be generated by a logical volume management (LVM) in a host arranged with the LVM, and the logical volumes can be denoted as Lv-1, Lv-2, …, Lv-n, etc. Figure 2 For a replication schematic diagram, generally, the name and / or quantity of a disk in a production machine is different from that in a disaster recovery machine, such as Figure 2 As shown, the production machine contains two disks, and the disaster recovery machine contains five disks. The production machine can be understood as a host containing a logical volume to be replicated, and the disk containing data in the logical volume to be replicated is a target disk, such as a disk containing data of a logical volume 1 (Lv-1). According to parameter information of the disk 1, such as a block device identifier, data corresponding to the block device number for replication and cache can be determined, and an IO (input / output) submission function, such as an io_filter_make_request function, is called, which is a replication cache calling function.

[0027] S102, replicating the logical volume to be replicated by using the replication cache calling function to obtain replication data.

[0028] In the embodiment, the replication cache calling function can be used to replicate data in the logical volume to be replicated, and cache and call a specified function, such as a make_request_fn function, to obtain replication data of the logical volume to be replicated.

[0029] S103, determining disk data fragments corresponding to the replication data based on a linear mapping mechanism or a strip mapping mechanism, and writing the disk data fragments into a disk of a disaster recovery machine.

[0030] In the embodiment, the linear mapping mechanism or the strip mapping mechanism can be used to convert the replication data into a format of data fragments stored in an underlying disk, such as converting replication data of a logical volume 5 (lv-5) into a format of data fragments in a disk 1 of the disaster recovery machine to obtain disk data fragments, and finally writing the disk data fragments into a disk of the disaster recovery machine, so as to complete replication of data in the logical volume to be replicated in the production machine. Specifically, the linear mapping mechanism or the strip mapping mechanism is used to convert the replication data, which can be determined and configured in the production machine according to disk capacity and replication efficiency, etc.

[0031] The method for data replication based on a logical volume provided by the embodiment of the present application comprises the following steps: determining a target disk corresponding to a logical volume to be replicated in a production machine, determining a replication cache calling function according to the target disk, replicating the logical volume to be replicated by using the replication cache calling function, obtaining replication data, determining disk data fragments corresponding to the replication data based on a linear mapping mechanism or a strip mapping mechanism, and writing the disk data fragments into a disk of a disaster recovery machine. The technical scheme of the embodiment of the present application can replicate data of a specified disk by determining the target disk corresponding to the logical volume to be replicated in the production machine, solve the problem that a traditional replication method can only replicate an entire disk and does not support partial logical volume data replication, and realize replication of the logical volume of the production machine under an original layout by converting the replication data of the logical volume into disk data fragments and replicating the disk data fragments to the underlying disk of the logical volume of the disaster recovery machine, thereby avoiding the problem that some applications cannot be used due to changes in the number and names of the disks of the disaster recovery machine and the production machine.

[0032] Embodiment two

[0033] Figure 3 The flowchart of the method for data replication based on a logical volume provided by the embodiment two of the present application is given. The technical scheme of the embodiment of the present application is further optimized on the basis of the above-mentioned optional technical schemes, and a specific way of replicating data in a logical volume is given.

[0034] Optionally, the step of determining a replication cache calling function according to a target disk corresponding to a logical volume to be replicated in a production machine comprises the following steps: determining a block device identifier of the target disk corresponding to the logical volume to be replicated in the production machine, and determining a replication cache calling function of a block device of the target disk according to the block device identifier. This setting has the advantage that the mapping relationship between the underlying disk of the logical volume to be replicated and the replication cache calling function is accurately established by determining the block device identifier, thereby ensuring the accuracy of replicating data in a specified logical volume.

[0035] Optionally, before the step of replicating the logical volume to be replicated by using the replication cache calling function to obtain replication data, the method further comprises the following steps: determining a current application submission function of the block device of the target disk according to the block device identifier, replacing the application submission function with the replication cache calling function, wherein the replication cache calling function is used for replicating and caching data, and calling the application submission function. This setting has the advantage that the current application submission function is replaced, and the data in the logical volume to be replicated can be replicated and cached on the basis of realizing the functions of the original application submission function.

[0036] Optionally, the linear mapping mechanism is used to determine a linear mapping table, and the replication data is converted into data shards according to the linear mapping table, so as to obtain the disk data shards of the target disk. In this way, the data space in the logical volume to be replicated is mapped to the disk of the disaster recovery machine by using the linear mapping mechanism, so that the data shards corresponding to the disk of the disaster recovery machine can be obtained, and it is ensured that the application corresponding to the replication data can be normally used after being written into the disaster recovery machine.

[0037] As shown in Figure 3 The embodiment two of the present application provides a logical volume-based data replication method, which specifically includes the following steps:

[0038] S201, determining the block device identifier of the target disk corresponding to the logical volume to be replicated in the production machine, and determining the replication cache calling function of the block device of the target disk according to the block device identifier.

[0039] Specifically, the management module and the data grabbing module can be configured in the production machine. After the replication starts, the management module can be used to instruct the data grabbing module to initialize and send relevant parameters, such as the name and storage path of the target disk corresponding to the logical volume to be replicated in the production machine, to the data grabbing module. After receiving the initialization instruction and the relevant parameters, the data grabbing module can determine the block device identifier and the block device kernel data structure of the target disk according to the relevant parameters, and then generate the corresponding replication cache calling function for copying and caching the data in the logical volume to be replicated and calling the specified function. The data grabbing module is equivalent to a Linux driver (which can be called iofilter), which mainly realizes the grabbing of the IO data of the disk (i.e., the block device), that is, the replication.

[0040] S202, determining the current application submission function of the block device of the target disk according to the block device identifier, and replacing the application submission function with the replication cache calling function, wherein the replication cache calling function is used to copy and cache data and call the application submission function.

[0041] Specifically, the data grabbing module can also replace the IO submission function of the block device corresponding to the block device identifier, that is, the current application submission function, with the replication cache calling function. For example, make_request_fn is replaced with io_filter_make_request.

[0042] S203, replicating the logical volume to be replicated by using the replication cache calling function to obtain replication data.

[0043] Specifically, the data conversion module can call the replication cache call function to copy the logical volume to be copied in order to obtain the copied data.

[0044] S204. A linear mapping table is determined using a linear mapping mechanism, and the copied data is converted into data fragments according to the linear mapping table to obtain disk data fragments of the target disk.

[0045] Specifically, a data conversion module can be configured in the production machine, which can use a linear mapping mechanism to determine a linear mapping table. Figure 4 This is a schematic diagram of a replicated logical volume, such as... Figure 4 As shown, the data conversion module converts the copied data obtained by the data capture module into data slices corresponding to the underlying disk, i.e., disk data shards.

[0046] For example, Figure 5 This is a schematic diagram of a linear mapping, such as... Figure 5 As shown, if the data space occupied by logical volume 1 (denoted as lv-1) is mapped to disk 1 and disk 2 of the disaster recovery machine, the linear mapping table can be represented as follows:

[0047]

[0048]

[0049] Here, "devPath:disk1" and "devPath:disk2" represent the disk paths, and "length:5GB" and "length:2GB" represent the disk capacities. The data conversion module can convert copied data into data fragments based on the disk path and disk capacity, as shown below:

[0050]

[0051]

[0052] S205. Write the disk data into the disk of the disaster recovery machine in fragments.

[0053] The logical volume-based data replication method provided by the embodiment of the present application accurately establishes the mapping relationship between the underlying disk of the logical volume to be replicated and the replication cache calling function by determining the block device identifier, ensures the accuracy of replicating the data in the specified logical volume, and by replacing the current application submission function, can also replicate and cache the data in the logical volume to be replicated on the basis of realizing the function of the original application submission function, and finally maps the data occupation space in the logical volume to be replicated to the disk of the disaster recovery machine by using the linear mapping mechanism, obtains the data shard corresponding to the disk of the disaster recovery machine, ensures that the application corresponding to the replicated data can be normally used after being written into the disaster recovery machine, and avoids the problem that part of the application cannot be used due to the change of the number and name of the disk of the disaster recovery machine and the production machine.

[0054] Embodiment three

[0055] Figure 6 The flowchart of the logical volume-based data replication method provided by the second embodiment of the present application is further optimized on the basis of the above-mentioned optional technical solutions, and the specific way of replicating the data in the logical volume is given.

[0056] Optionally, the logical volume-based data replication method comprises the following steps of: determining the block device identifier of the target disk corresponding to the logical volume to be replicated in the production machine, and determining the replication cache calling function of the block device of the target disk according to the block device identifier.

[0057] Optionally, after the linear mapping mechanism or the strip mapping mechanism is used to determine the disk data shard corresponding to the replicated data and the disk data shard is written into the disk of the disaster recovery machine, the method further comprises the following step of: if the replication of the logical volume to be replicated is stopped, the replication cache calling function of the block device of the target disk is replaced by the application submission function.

[0058] As shown in Figure 6 The logical volume-based data replication method provided by the third embodiment of the present application specifically comprises the following steps:

[0059] S301, determining the block device identifier of the target disk corresponding to the logical volume to be replicated in the production machine, and determining the replication cache calling function of the block device of the target disk according to the block device identifier.

[0060] S302, determining a current application submission function of the block device of the target disk according to the block device identifier, replacing the application submission function with a replication cache calling function, wherein the replication cache calling function is used for replicating and caching data, and calling the application submission function.

[0061] S303, replicating the logical volume to be replicated by using the replication cache calling function to obtain replication data.

[0062] S304, determining a strip mapping table by using a strip mapping mechanism, and converting the replication data into data fragments according to the strip mapping table to obtain disk data fragments of the target disk.

[0063] Exemplarily, Figure 7 As shown in a strip mapping schematic diagram, Figure 7 If the data occupied space of a logical volume 2 (denoted as lv-2) is mapped to a disk 1 and a disk 2 of a disaster recovery machine, S1, S2, S3, … in the figure represent data blocks in the disks, the strip mapping table can be represented as follows:

[0064]

[0065]

[0066] Wherein, “offset:0” represents a disk offset. The data conversion module can convert the replication data into data fragments according to the disk path and the disk offset, and the specific manner can be represented as follows:

[0067]

[0068]

[0069] S305, writing the disk data fragments into the disks of the disaster recovery machine.

[0070] S306, judging whether to stop replicating the logical volume to be replicated, if yes, executing step 307, and if no, executing step 301.

[0071] S307, replacing the replication cache calling function of the block device of the target disk with the application submission function, and ending the replication.

[0072] Specifically, in addition to instructing the data grabbing module to initialize and start grabbing data, the management module can also instruct the data grabbing module to stop grabbing data, and instruct the data grabbing module to replace the replication cache calling function of the block device of the target disk with the application submission function.

[0073] Optionally, further comprising: based on a netlink network connection communication mechanism, instructing to stop the replication operation on the to-be-replicated logical volume by using a stop replication instruction.

[0074] Specifically, the management module, the data grabbing module and the data conversion module can communicate by using the netlink network connection communication mechanism of the Linux operating system, for example, the management module instructs the data grabbing module to stop grabbing data, that is, sends a stop replication instruction to the data grabbing module to instruct the data grabbing module to stop the replication operation on the to-be-replicated logical volume.

[0075] The logical volume-based data replication method provided by the embodiment of the application maps the data occupied space in the to-be-replicated logical volume to the disks of the disaster recovery machine by using the strip mapping mechanism, can obtain the data shards corresponding to the disks of the disaster recovery machine, guarantees that the application corresponding to the replicated data can be normally used after being written into the disaster recovery machine, improves the replication efficiency, and restores the function of the block device of the target disk to the application submission function after stopping the replication operation, guarantees the normal progress of the replication task in the production machine, realizes the replication of the logical volume of the production machine under the original layout, and avoids the problem that some applications cannot be used due to the change of the number and name of the disks of the disaster recovery machine and the production machine.

Claims

1. A method of data replication based on a logical volume, characterized by, The method comprises the following steps: determining a replication cache calling function according to a target disk corresponding to a logical volume to be replicated in a production machine; replicating the logical volume to be replicated by using the replication cache calling function to obtain replication data; determining disk data fragments corresponding to the replication data based on a linear mapping mechanism or a strip mapping mechanism, and writing the disk data fragments into a disk of a disaster recovery machine; wherein the step of determining the replication cache calling function according to the target disk corresponding to the logical volume to be replicated in the production machine comprises: determining a block device identifier of the target disk corresponding to the logical volume to be replicated in the production machine, and determining a replication cache calling function of a block device of the target disk according to the block device identifier; before the step of replicating the logical volume to be replicated by using the replication cache calling function to obtain replication data, the method further comprises: determining a current application submission function of the block device of the target disk according to the block device identifier, and replacing the application submission function with the replication cache calling function, wherein the replication cache calling function is used for replicating and caching data, and calling the application submission function.

2. The method of claim 1, wherein, the step of determining the disk data fragments corresponding to the replication data based on the linear mapping mechanism comprises: determining a linear mapping table by using the linear mapping mechanism, and converting the replication data into data fragments according to the linear mapping table to obtain disk data fragments of the target disk.

3. The method of claim 1, wherein, the step of determining the disk data fragments corresponding to the replication data based on the strip mapping mechanism comprises: determining a strip mapping table by using the strip mapping mechanism, and converting the replication data into data fragments according to the strip mapping table to obtain disk data fragments of the target disk.

4. The method of claim 1, wherein, after the step of determining the disk data fragments corresponding to the replication data based on the linear mapping mechanism or the strip mapping mechanism, and writing the disk data fragments into the disk of the disaster recovery machine, the method further comprises: if the replication of the logical volume to be replicated is stopped, the replication cache calling function of the block device of the target disk is replaced with the application submission function.

5. The method of claim 4, wherein, the method further comprises: indicating to stop the replication operation of the logical volume to be replicated by using a stop replication instruction based on a netlink network connection communication mechanism.

Citation Information

Patent Citations

  • Method and device for cloning logical volume in disk and disk

    CN106326039A

  • Rapid remote recovery method and system for continuous data protection

    CN111045864A