Data replication method and device and electronic equipment
By creating multiple replica LUNs for source LUNs in storage devices and using full replication and time stamp management methods, the problem of the inability to retrieve source LUN historical data in the prior art is solved, and high availability and reliable recovery of data are achieved.
Patent Information
- Application Number
- CN202411977675.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-04-25
AI Technical Summary
The existing one-to-one data replication scheme cannot retrieve historical data in the event of a disaster in the source LUN, affecting the availability of data.
Using a one-to-many data replication scheme, by creating multiple replica LUNs in the storage device corresponding to the source LUN, and when it is determined to enable data replication, select the replica LUN with the available state as the main state from the current replica LUN list as the target LUN, and perform full replication. After the copy is completed, modify the available status and timestamp values of the target LUN to cycle through multiple replica LUNs and save data from multiple historical moments.
When a disaster occurs in the source LUN, data from multiple historical moments can be retrieved through multiple replica LUNs to improve data availability, and data recovery can still be carried out in the event of a disaster of replica LUNs to improve the reliability of data recovery.
Smart Images

Figure CN119883740A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a data replication method, device and electronic device. Background Art
[0002] With the advent of the big data era, the amount of data is increasing, and data protection is becoming more and more important. Replication is one of the common means of data protection, and it is also a common solution for dealing with "hard disasters" and "soft disasters". The so-called hard disaster, also known as "hard" disaster, usually refers to the physical damage or unreadable production data due to factors such as disk array (Redundant Arrays of Independent Disks, RAID) failure, earthquake, fire, etc. The so-called soft disaster usually refers to the situation where data is logically damaged due to viruses, misoperation, software bugs, etc.
[0003] At present, in actual applications, a logical unit number (LUN) is usually created on a storage device to write data generated by a front-end application server. This LUN can be called a source LUN. The so-called LUN refers to an independent and available storage space created based on RAID. Then a one-to-one replication scheme is adopted, that is, through replication technology, a replica LUN is created for the source LUN to replicate the data in the source LUN. The source LUN and the replica LUN are physically independent, so that when a hard disaster occurs to the source LUN, the data in the replica LUN can be used for data recovery. However, with the above one-to-one replication scheme, when a disaster such as a hard disaster or a soft disaster occurs to the source LUN, the historical data of the source LUN before the disaster cannot be retrieved using only one replica LUN, thereby affecting the availability of data. Summary of the invention
[0004] In view of this, the present application provides a data replication method, device and electronic device to improve the availability of data.
[0005] An embodiment of the present application provides a data replication method, which is applied to a storage device, wherein the storage device includes a source LUN to be replicated; the method includes:
[0006] When it is determined to start a replication of data in the storage space corresponding to the source LUN, a replica LUN whose available status is the primary status is obtained from the current replica LUN list corresponding to the source LUN as the target LUN to which the data is replicated this time; if the available status of any replica LUN in the current replica LUN list is the primary status, it indicates that the replica LUN is currently allowed to replicate data, and if the available status of any replica LUN is the standby status, it indicates that the replica LUN is currently not allowed to replicate data;
[0007] Use full replication to copy the data in the storage space corresponding to the source LUN to the target LUN;
[0008] If there are at least two replica LUNs in the current replica LUN list, the available status of the target LUN in the current replica LUN list is changed from the primary status to the backup status, and the timestamp value corresponding to the target LUN is modified; and the available status of the replica LUN in the current replica LUN list whose available status is the backup status and whose timestamp value is the smallest is changed from the backup status to the primary status.
[0009] The embodiment of the present application further provides a data replication device, which is applied to a storage device, wherein the storage device includes a source LUN to be replicated; the device includes:
[0010] An acquisition module is used to, when determining to start a replication of data in a source LUN, obtain a replica LUN whose available state is in the primary state from the current replica LUN list corresponding to the source LUN as the target LUN to which the data is replicated this time; if the available state of any replica LUN in the current replica LUN list is in the primary state, it indicates that the replica LUN is currently allowed to replicate data, and if the available state of any replica LUN is in the standby state, it indicates that the replica LUN is currently not allowed to replicate data;
[0011] A replication module is used to replicate the data in the storage space corresponding to the source LUN to the target LUN by using a full replication method;
[0012] A modification module is used to modify the available status of the target LUN in the current copy LUN list to a standby status if there are at least two copy LUNs in the current copy LUN list, and to modify the timestamp value corresponding to the target LUN; and to modify the available status of the copy LUN in the current copy LUN list whose available status is a standby status and whose timestamp value is the smallest from a standby status to a primary status.
[0013] The present application also provides an electronic device, the electronic device comprising:
[0014] Processor; and
[0015] A computer-readable storage medium stores computer program instructions, which, when executed by a processor, cause the processor to execute the steps of the above method.
[0016] An embodiment of the present application further provides a computer-readable storage medium, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the processor executes the steps in the above method.
[0017] It can be seen from the above technical solution that in the embodiment of the present application, multiple replica LUNs are created for the source LUN for subsequent replication of data in the storage space corresponding to the source LUN. It can be seen that the present embodiment adopts a one-to-many replication scheme, that is, a replication scheme in which one source LUN corresponds to multiple replica LUNs. Based on this, when determining to start a replication of data in the storage space corresponding to the source LUN, first select a replica LUN with an available status of the master status from the current replica LUN list corresponding to the source LUN as the target LUN to which the data is replicated this time. Here, the master status indicates that the corresponding replica LUN currently allows data replication, and then the data in the storage space corresponding to the source LUN is fully replicated to the target LUN to achieve this data replication. Moreover, after completing this data replication, the availability status of the above-mentioned target LUN is also modified to a standby status indicating that the corresponding replica LUN is currently not allowed to perform data replication, and the availability status of the replica LUN with the smallest timestamp value and the standby status, that is, the replica LUN that has never performed data replication or the replica LUN with the earliest timestamp of the last data replication, is modified to the primary status. It can be seen that in this embodiment, the multiple replica LUNs corresponding to the source LUN are used cyclically in sequence, so that the historical data of the source LUN at multiple historical moments are stored on the multiple replica LUNs. When a disaster occurs to the source LUN, the historical data at multiple historical moments can be retrieved through the multiple replica LUNs, thereby improving the availability of data.
[0018] Furthermore, when a disaster occurs to one or more of the replica LUNs corresponding to the source LUN, data recovery can be performed using the replica LUNs corresponding to the source LUN except for the replica LUN that suffered the disaster, thereby avoiding the situation in which data is completely lost due to a disaster occurring to the replica LUN in a one-to-one replication solution, thereby improving the reliability of data recovery.
[0019] Furthermore, the embodiment of the present application utilizes a storage device including a source LUN to perform replication of data in the storage space corresponding to the source LUN. The replication process does not need to pass through the front-end application server, but directly reads the data locally for corresponding replication. This will not affect the normal business operation of the front-end application server and can effectively improve the efficiency of data replication. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] The accompanying drawings, which are incorporated in the specification and constitute a part of this application, illustrate embodiments consistent with the application and, together with the description, serve to explain the principles of the application.
[0021] Figure 1 A flow chart of the method provided in an embodiment of the present application.
[0022] Figure 2 Another method flow chart provided for an embodiment of the present application.
[0023] Figure 3 Another method flow chart provided for an embodiment of the present application.
[0024] Figure 4 A schematic diagram of the device structure provided in an embodiment of the present application.
[0025] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0026] In order to enable those skilled in the art to better understand the technical solutions provided by the embodiments of the present application and to make the above-mentioned purposes, features and advantages of the embodiments of the present application more obvious and understandable, the technical solutions in the embodiments of the present application are further described in detail below in conjunction with the accompanying drawings.
[0027] See also Figure 1 , Figure 1 A flowchart of a method provided in an embodiment of the present application. The method is applied to a storage device, which includes a source LUN to be copied. As an embodiment, the storage device can be an electronic device such as a computer or a server, which is not specifically limited in this embodiment.
[0028] like Figure 1 As shown, the process may include the following steps:
[0029] Step 101, when it is determined to start a replication of data in the storage space corresponding to the source LUN, a replica LUN whose available state is the primary state is obtained from the current replica LUN list corresponding to the source LUN as the target LUN to which the data is replicated this time.
[0030] In this embodiment, the source LUN refers to the LUN whose data needs to be replicated. In this embodiment, the source LUN supports the configuration of a one-to-many replication relationship, that is, the source LUN supports the configuration of multiple replica LUNs for subsequent use in replicating data in the storage space corresponding to the source LUN. Here, there is no specific limitation on the number of replica LUNs corresponding to the source LUN, for example, it can be 20 or 30.
[0031] The above-mentioned source LUN is deployed in the above-mentioned storage device. As an embodiment, the source LUN and the multiple replica LUNs corresponding to the source LUN can be deployed in the same storage device (that is, the above-mentioned storage device); or, the source LUN and the multiple replica LUNs corresponding to the source LUN can be deployed in different storage devices, in which case the multiple replica LUNs corresponding to the source LUN can be deployed in the same storage device or in different storage devices; this embodiment does not specifically limit this.
[0032] In this embodiment, a corresponding replication trigger policy can be configured in advance for the replication of data in the storage space corresponding to the source LUN based on actual needs; for example, as an embodiment, the replication trigger policy can be set for the source LUN to set a scheduled task for triggering data replication, and specifically, it can be set to trigger the replication of data in the storage space corresponding to the source LUN once at 10 pm every day, etc. Based on this, when the time reaches 10 pm every day, it is determined to start the replication of data in the storage space corresponding to the source LUN.
[0033] In this embodiment, a copy LUN list corresponding to the source LUN can be maintained in the storage device where the source LUN is located. The copy LUN list can be used to record information of each copy LUN corresponding to the source LUN, such as availability status, etc., and the information recorded in the copy LUN list can change dynamically.
[0034] In this embodiment, each replica LUN corresponding to the source LUN is used cyclically, that is, one data replication only copies the data in the storage space corresponding to the source LUN to one of the replica LUNs. Based on this, when it is determined to start a replication of the data in the storage space corresponding to the source LUN, if the available status of any replica LUN in the current replica LUN list corresponding to the source LUN is in the primary state, it indicates that the replica LUN currently allows data replication, and if the available status of any replica LUN is in the standby state, it indicates that the replica LUN currently does not allow data replication; under this premise, this embodiment can determine the replica LUN to which the data is replicated this time, that is, the above-mentioned target LUN, by the available status of each replica LUN. Specifically, the replica LUN that is currently allowed to replicate data, that is, the replica LUN whose available status is in the primary state, can be obtained from the current replica LUN list corresponding to the source LUN as the target LUN to which the data is replicated this time.
[0035] Step 102: Copy the data in the storage space corresponding to the source LUN to the target LUN by using a full copy method.
[0036] In this embodiment, after obtaining a copy LUN in the primary state from the current copy LUN list corresponding to the source LUN as the target LUN to which the data is copied this time, the data in the storage space corresponding to the source LUN can be copied to the target LUN using the full copy method, thereby realizing the copying of the data in the storage space corresponding to the source LUN this time. Among them, the full copy method refers to a copying method in which all data in the storage space corresponding to the source LUN is copied to the corresponding target LUN. During the copying process, the space in the target LUN data that has been copied corresponds to the new data, and the space that has not been copied corresponds to the old data, that is, the data in the target LUN is not the complete and consistent data of the source LUN at the time of starting the copy.
[0037] As an embodiment, in the data replication scheme proposed in this embodiment, the source LUN only supports the full replication mode. Therefore, in this embodiment, a mark can be set in advance for the source LUN to indicate that the source LUN only supports the full replication mode. For example, when the mark value corresponding to the mark is 1, it can be indicated that the source LUN only supports the full replication mode. At this time, the source LUN does not need to record data differences. In other words, when the source LUN processes the write IO request transmitted by the front-end application server, it does not need to record the data difference in real time. This can effectively reduce the operation of the source LUN in the IO processing process and improve the IO processing performance of the source LUN. Based on this, only when the mark corresponding to the source LUN indicates that the source LUN only supports the full replication mode, will the data replication scheme provided by this embodiment be triggered in the subsequent data replication.
[0038] When the tag value corresponding to the tag is other values such as 0, it may indicate that the source LUN supports conventional replication methods such as incremental replication. At this time, it indicates that there is no need to use the data replication scheme proposed in this embodiment to replicate data, but conventional replication methods such as incremental replication can be used for data replication.
[0039] In this embodiment, the current replica LUN list also records the timestamp value of each replica LUN corresponding to the source LUN; wherein, the timestamp value corresponding to any replica LUN in the current replica LUN list that is determined as the target LUN and has a timestamp value of a specified value is used to indicate that the replica LUN is currently being replicated, which can indicate that the data in the replica LUN is not the complete and consistent data of the source LUN at the time of starting this replication, and cannot be used to restore the data of the source LUN. Here, the specified value is pre-configured based on actual needs, such as the specified value can be configured as 0, etc.; based on this, the non-specified value refers to non-zero values such as 1, 2, 3, etc.
[0040] Based on the above description, as an embodiment, in order to indicate the available status of the replica LUN, after this embodiment obtains a replica LUN with an available status of primary status from the current replica LUN list corresponding to the source LUN as the target LUN to which the data is copied this time, it means that the current data replication corresponding to the source LUN will use the target LUN for data replication. At this time, the data in the target LUN can be marked as incomplete and cannot be used to restore the data of the source LUN by modifying the timestamp value of the target LUN; specifically, for example, if the timestamp value corresponding to the target LUN in the current replica LUN list is a non-specified value, the timestamp value corresponding to the target LUN in the current replica LUN list is modified from the non-specified value to the specified value; if the timestamp value corresponding to the target LUN in the current replica LUN list is a specified value, the timestamp value corresponding to the target LUN continues to be maintained as the specified value.
[0041] Step 103, if there are at least two replica LUNs in the current replica LUN list, the available status of the target LUN in the current replica LUN list is changed from the primary status to the backup status, and the timestamp value corresponding to the target LUN is modified; and the available status of the replica LUN in the current replica LUN list whose available status is the backup status and whose timestamp value is the smallest is changed from the backup status to the primary status.
[0042] In this embodiment, the timestamp value corresponding to any replica LUN in the current replica LUN list whose timestamp value is not the specified value is used to indicate the timestamp when the replica LUN was last replicated. The timestamp value corresponding to any replica LUN in the current replica LUN list that is not the target LUN and whose timestamp value is the specified value is used to indicate that the replica LUN has never been replicated, that is, the data of the source LUN is not saved in the replica LUN and cannot be used to restore the data of the source LUN.
[0043] As described above, in this embodiment, for the replication of data in the storage space corresponding to the source LUN, the replica LUNs corresponding to the source LUN are used cyclically, and only one of the replica LUNs will be used for one data replication; based on this, in this embodiment, for any replica LUN whose timestamp value is a non-specified value in the current replica LUN list, the smaller the timestamp value of the replica LUN, the earlier the last time the data replication was performed on the replica LUN, and correspondingly, the larger the timestamp value of the replica LUN, the later the last time the data replication was performed on the replica LUN. And, as described above, in this embodiment, the timestamp value is not represented by the time on the storage device, but by the numerical values 0, 1, 2, etc., so as to avoid the situation where the order of cyclic use of the replica LUNs corresponding to the source LUN is incorrect due to the modifiable time on the storage device.
[0044] For example, assuming that the timestamp values corresponding to replica LUN1 and replica LUN2 are 1 and 2 respectively, and 1 is less than 2, then the time when data replication was last performed on replica LUN1 (such as the starting time) is earlier than the time when data replication was last performed on replica LUN2 (such as the starting time); for example, when the replication of data in the storage space corresponding to the source LUN is triggered once every night at 8 o'clock, the starting time of the last data replication performed on replica LUN1 was 8 o'clock yesterday evening, and the starting time of the last data replication performed on replica LUN2 was 8 o'clock this evening.
[0045] In this embodiment, after the data replication is completed, if there are at least two replica LUNs (including the target LUN) in the current replica LUN list, the target LUN has been used in this data replication. Based on the scheme of cyclically using replica LUNs in this embodiment, the replica LUN used for the next data replication is another replica LUN that is not the target LUN. Then the available state of the target LUN in the current replica LUN list can be changed from the primary state to the standby state, and the timestamp value corresponding to the target LUN can be modified. In addition, in order to ensure the selection of the target LUN during the next data replication, the available state of the replica LUN in the current replica LUN list that is in the standby state and has the smallest timestamp value needs to be changed from the standby state to the primary state, so that when the next data replication is triggered, the replica LUN that is in the primary state and has the smallest timestamp value is selected as the target LUN.
[0046] In this embodiment, after the completion of this data replication, the timestamp of the last data replication executed on the target LUN, that is, the timestamp value of the target LUN, needs to change accordingly. At this time, the timestamp value corresponding to the target LUN needs to be modified, and the modified timestamp value of the target LUN is the largest to indicate that the target LUN is the latest copy LUN that has completed data replication. Based on this, as an embodiment, the above modification of the timestamp value corresponding to the target LUN can be implemented as follows: modifying the timestamp value corresponding to the target LUN according to the sum of the largest timestamp value in the current copy LUN list and the set value; here, the set value can be, for example, 1, etc., and this is not specifically limited here.
[0047] It should be noted that, as an embodiment, after completing this data replication, if there is only a target LUN in the current replica LUN list, then in order to ensure the normal operation of the next data replication, it is necessary to continue to maintain the available status corresponding to the target LUN in the current replica LUN list as the primary status, so that the target LUN can continue to be used for data replication during the next data replication.
[0048] So far, completed Figure 1 The process shown.
[0049] pass Figure 1It can be seen from the process shown that in the embodiment of the present application, multiple replica LUNs are created for the source LUN for subsequent replication of data in the storage space corresponding to the source LUN. It can be seen that the present embodiment adopts a one-to-many replication scheme, that is, a replication scheme in which one source LUN corresponds to multiple replica LUNs. Based on this, when determining to start a replication of data in the storage space corresponding to the source LUN, first select a replica LUN with an available status of the master status from the current replica LUN list corresponding to the source LUN as the target LUN to which the data is replicated this time. Here, the master status indicates that the corresponding replica LUN currently allows data replication, and then the data in the storage space corresponding to the source LUN is fully copied to the target LUN to achieve this data replication. Moreover, after completing this data replication, the availability status of the above-mentioned target LUN is also modified to a standby status indicating that the corresponding replica LUN is currently not allowed to perform data replication, and the availability status of the replica LUN with the smallest timestamp value and the standby status, that is, the replica LUN that has never performed data replication or the replica LUN with the earliest timestamp of the last data replication, is modified to the primary status. It can be seen that in this embodiment, the multiple replica LUNs corresponding to the source LUN are used cyclically in sequence, so that the historical data of the source LUN at multiple historical moments are stored on the multiple replica LUNs. When a disaster occurs to the source LUN, the historical data at multiple historical moments can be retrieved through the multiple replica LUNs, thereby improving the availability of data.
[0050] Furthermore, when a disaster occurs to one or more of the replica LUNs corresponding to the source LUN, data recovery can be performed using the replica LUNs corresponding to the source LUN except for the replica LUN that suffered the disaster, thereby avoiding the situation in which data is completely lost due to a disaster occurring to the replica LUN in a one-to-one replication solution, thereby improving the reliability of data recovery.
[0051] Furthermore, the embodiment of the present application utilizes a storage device including a source LUN to perform replication of data in the storage space corresponding to the source LUN. The replication process does not need to pass through the front-end application server, but directly reads the data locally for corresponding replication. This will not affect the normal business operation of the front-end application server and can effectively improve the efficiency of data replication.
[0052] The following is a further description of the replica LUN in this embodiment:
[0053] In this embodiment, the replica LUN corresponding to the source LUN supports configuration, for example, at least one LUN can be added as the replica LUN corresponding to the source LUN, and at least one LUN can be removed from the replica LUN corresponding to the source LUN. The following is an example of how to add at least one LUN as the replica LUN corresponding to the source LUN:
[0054] First, before describing how to add at least one LUN as a replica LUN corresponding to a source LUN, the replica LUN list maintained by the above storage device is described:
[0055] In this embodiment, the information recorded in the replica LUN list corresponding to the source LUN maintained by the above storage device is not specifically limited. For example, as shown in Table 1, the replica LUN list may include the device identifier (such as the IP address of the storage device), the replica LUN identifier (such as the replica LUN name), the available status, and the timestamp value of the storage device to which each replica LUN corresponding to the source LUN belongs. It should be noted that, initially, the timestamp value of each replica LUN in the replica LUN list is 0 (i.e., the above-mentioned specified value) to indicate that the replica LUN has never been replicated.
[0056] Table 1: Example 1 of a replica LUN list
[0057]
[0058] Afterwards, as an embodiment, when an addition instruction is received indicating the addition of at least one LUN to be added as a replica LUN corresponding to the source LUN, for each LUN to be added, the LUN to be added, the available status of the LUN to be added, and the timestamp value of the LUN to be added are added to the current replica LUN list; wherein, if there is a replica LUN in the current replica LUN list that meets the set conditions, the available status of the LUN to be added is a standby status, and the timestamp value of the LUN to be added is a specified value; otherwise, the available status of the LUN to be added is a primary status, and the timestamp value of the LUN to be added is a specified value. Here, the above-mentioned set conditions are any of the following conditions: the available status is a standby status and the timestamp value is a specified value, the timestamp value is a non-specified value and the timestamp value is the smallest, and the available status is a primary status.
[0059] In this embodiment, the above-mentioned adding instruction may be, for example, an instruction manually triggered by relevant management personnel based on actual needs, and this embodiment does not make any specific limitation.
[0060] Exemplarily, it is assumed that the replica LUNs in the current replica LUN list corresponding to the source LUN are arranged in a specified order, where the specified order may be, for example, the order of the replica LUN names, such as LUN A1, LUN A2, LUN A3, LUNA4, ..., LUN An, where n is greater than 1. Initially, the available state of LUN A1 is the primary state, and the available states of the other replica LUNs except LUN A1 in the current replica LUN list are all in the standby state; the timestamp value of each replica LUN in the current replica LUN list is 0 to indicate that the corresponding replica LUN has never been replicated.
[0061] Based on the above description, see Figure 2 As shown, when receiving an addition instruction indicating to add LUN Ax as a replica LUN corresponding to the source LUN, how to process the LUN Ax may include the following steps in specific implementation:
[0062] Step 201 , searching in the current copy LUN list corresponding to the source LUN whether there is a copy LUN in the master state in the available state, if yes, executing step 202 , otherwise executing step 203 .
[0063] Step 202: determine the record corresponding to the replica LUN found in the current replica LUN list as the target record, and insert a record corresponding to LUN Ax whose available state is the standby state and whose timestamp value is 0 after the target record.
[0064] In this embodiment, if at least one replica LUN is found whose available state is standby state and whose timestamp value is 0, the record corresponding to the replica LUN with the highest LUN name in the replica LUNs found in the current replica LUN list is determined as the target record. As shown in Table 2, the record corresponding to LUN A3 ("127.0.0.1, LUN A3, standby state, 0") is the found target record. At this time, the IP address of the storage device to which the LUN Ax to be added belongs, the replica LUN name, the available state, and the timestamp value can be added as a new record to the current replica LUN list, wherein the available state of LUN Ax is standby state and the timestamp value is 0; as shown in Table 3, the record corresponding to LUN Ax ("127.0.0.1, LUN Ax, standby state, 0") can be inserted before the target record.
[0065] Table 2: Example 2 of replica LUN list
[0066]
[0067] Table 3: Example 3 of replica LUN list
[0068]
[0069] Step 203 , searching in the current copy LUN list whether there is a copy LUN with a timestamp value other than 0, if yes, executing step 204 , otherwise executing step 205 .
[0070] Step 204: determine the record corresponding to the replica LUN with a non-zero timestamp value and the smallest timestamp value in the previous replica LUN list as the target record, and insert a record corresponding to LUN Ax with an available state of standby and a timestamp value of 0 before the target record.
[0071] In this embodiment, if at least one replica LUN with a timestamp value other than 0 is found, the record corresponding to the replica LUN with a timestamp value other than 0 and the smallest timestamp value in the previous replica LUN list (that is, the replica LUN with the earliest timestamp when data replication was last performed) is determined as the target record, as shown in Table 4, the record corresponding to LUN A1 ("127.0.0.1, LUN A1, standby state, 1") is the found target record. At this time, as described above, the record corresponding to the LUN Ax to be added can be added to the current replica LUN list, where the available state of LUN Ax is standby state and the timestamp value is 0; as shown in Table 5, the record corresponding to LUN Ax ("127.0.0.1, LUN Ax, standby state, 0") can be inserted before the target record.
[0072] Table 4: Example 4 of replica LUN list
[0073]
[0074] Table 5: Example 5 of replica LUN list
[0075]
[0076] Step 205, when there is a replica LUN in the current replica LUN list whose available status is the primary status, determine the record corresponding to the replica LUN in the current replica LUN list as the target record, and insert a record corresponding to LUN Ax whose available status is the backup status and whose timestamp value is 0 before the target record; otherwise, add the record corresponding to LUN Ax whose available status is the primary status and whose timestamp value is 0 to the current replica LUN list.
[0077] In this embodiment, if a replica LUN with a timestamp value other than 0 is not found, then the current replica LUN list is searched for a replica LUN with an available status of primary status; if a replica LUN with an available status of primary status is found, then this actually means that the current replica LUN list only contains a replica LUN with an available status of primary status, and then the record corresponding to the replica LUN in the current replica LUN list is determined as the target record, as shown in Table 6, the record corresponding to LUN A1 ("127.0.0.1, LUN A1, primary status, 0") is the target record found. At this time, the record corresponding to the LUNAx to be added can be added to the current replica LUN list, where the available status of LUN Ax is the standby status and the timestamp value is 0; as shown in Table 7, the record corresponding to LUN Ax ("127.0.0.1, LUN Ax, standby status, 0") can be inserted before the target record.
[0078] Table 6: Example 6 of replica LUN list
[0079]
[0080] Table 7: Example of replica LUN list 7
[0081]
[0082] If no replica LUN with the available status of the primary state is found, it actually means that the current replica LUN list is an empty list. Then, the record corresponding to the LUN Ax to be added can be added to the current replica LUN list as the first record in the current replica LUN list, wherein the available status of LUN Ax is the primary state and the timestamp value is 0. As shown in Table 8, the record corresponding to LUN Ax is "127.0.0.1, LUN Ax, primary state, 0".
[0083] Table 8: Example of replica LUN list 8
[0084]
[0085] This completes the above description of how to add at least one LUN as a replica LUN corresponding to a source LUN. The following describes how to remove at least one LUN from a replica LUN corresponding to a source LUN:
[0086] In this embodiment, as an embodiment, when a removal instruction indicating the removal of at least one replica LUN in the replica LUN corresponding to the source LUN is received, the removal instruction includes at least one LUN to be removed, and for each LUN to be removed, the LUN to be removed is removed from the current replica LUN list, as well as the available state and timestamp value of the LUN to be removed. Here, this embodiment does not specifically limit the triggering method of the removal instruction. For example, similar to the above-mentioned addition instruction, it can be an instruction manually triggered by relevant management personnel based on actual needs.
[0087] Among them, when there are at least two copy LUNs in the current copy LUN list, and the available status of the LUN to be removed in the current copy LUN list is the primary status, the available status of the copy LUN in the current copy LUN list whose available status is the backup status and whose timestamp value is the smallest is changed from the backup status to the primary status to ensure the selection of the target LUN during the next data replication, thereby ensuring the normal operation of the next data replication.
[0088] For example, see Figure 3 As shown, when receiving an instruction to remove the copy LUN Ax corresponding to the source LUN, how to process LUN Ax may include the following steps in specific implementation:
[0089] Step 301 , when the current copy LUN list corresponding to the source LUN includes a copy LUN, check whether the current copy LUN list corresponding to the source LUN includes only a record corresponding to one copy LUN, if yes, execute step 302 , otherwise, execute step 303 .
[0090] Step 302: directly remove the record corresponding to LUN Ax.
[0091] In this embodiment, if the current copy LUN list corresponding to the source LUN includes only one record, that is, a record corresponding to LUN Ax, the record corresponding to LUN Ax is directly removed.
[0092] Step 303, when the available state of LUN Ax is the active state, the available state of the next record of the record corresponding to LUN Ax in the current replica LUN list is modified to the active state, and then the record corresponding to LUN Ax is removed; when the available state of LUN Ax is the standby state, the record corresponding to LUN Ax is directly removed.
[0093] In this embodiment, if the current replica LUN list includes records corresponding to multiple replica LUNs, when the available status of LUNAx is the primary status, the available status of the next record corresponding to LUN Ax in the current replica LUN list (that is, the record corresponding to the replica LUN whose available status is the backup status and has the smallest timestamp value) is modified to the primary status to ensure the normal operation of the next data replication, and then the record corresponding to LUN Ax is removed; when the available status of LUN Ax is the backup status, the record corresponding to LUN Ax is directly removed.
[0094] It should be noted that, if the record corresponding to the above LUN Ax is the last record in the current copy LUN list, the next record of the record corresponding to LUN Ax may be the first record in the current copy LUN list.
[0095] This completes the above description of how to remove at least one LUN from the copy LUN corresponding to the source LUN.
[0096] At this point, the description of the method provided in the embodiment of the present application is completed. The following is a description of the device provided in the embodiment of the present application:
[0097] See also Figure 4 , Figure 4 The present invention provides a schematic diagram of a data replication device. The device is applied to a storage device, and the storage device includes a source LUN to be replicated. Figure 4 As shown, the device 400 includes an acquisition module 401, a copy module 402 and a modification module 403;
[0098] The obtaining module 401 is used to obtain a copy LUN whose available state is the primary state from the current copy LUN list corresponding to the source LUN as the target LUN to which the data is copied when it is determined to start a copy of the data in the source LUN; if the available state of any copy LUN in the current copy LUN list is the primary state, it indicates that the copy LUN is currently allowed to copy data, and if the available state of any copy LUN is the standby state, it indicates that the copy LUN is currently not allowed to copy data;
[0099] A copy module 402 is used to copy the data in the storage space corresponding to the source LUN to the target LUN by using a full copy method;
[0100] Modification module 403 is used to modify the available status of the target LUN in the current copy LUN list to a standby status if there are at least two copy LUNs in the current copy LUN list, and to modify the timestamp value corresponding to the target LUN; and to modify the available status of the copy LUN in the current copy LUN list whose available status is a standby status and whose timestamp value is the smallest from a standby status to a primary status.
[0101] As an embodiment, after obtaining a copy LUN in the active state from the current copy LUN list corresponding to the source LUN as the target LUN to which the data is copied, the modification module 403 is further configured to:
[0102] If the timestamp value corresponding to the target LUN in the current replica LUN list is a non-specified value, the timestamp value corresponding to the target LUN in the current replica LUN list is modified from the non-specified value to the specified value; if the timestamp value corresponding to the target LUN in the current replica LUN list is a specified value, the timestamp value corresponding to the target LUN continues to maintain the specified value;
[0103] Among them, the timestamp value corresponding to any replica LUN in the current replica LUN list whose timestamp value is not a specified value is used to indicate the timestamp when data replication was last performed on the replica LUN; the timestamp value corresponding to any replica LUN in the current replica LUN list that is determined as a target LUN and whose timestamp value is a specified value is used to indicate that data replication is currently being performed on the replica LUN; the timestamp value corresponding to any replica LUN in the current replica LUN list that is not a target LUN and whose timestamp value is a specified value is used to indicate that data replication has never been performed on the replica LUN.
[0104] As an embodiment, the modification module 403 is further used to:
[0105] After the data in the storage space corresponding to the source LUN is copied to the target LUN by using the full copy method, if only the target LUN exists in the current copy LUN list, the available state corresponding to the target LUN in the current copy LUN list is maintained as the primary state.
[0106] As an embodiment, modifying the timestamp value corresponding to the target LUN includes:
[0107] Modify the timestamp value corresponding to the target LUN based on the sum of the largest timestamp value in the current replica LUN list and the set value.
[0108] As an embodiment, the device further comprises:
[0109] An adding module, configured to, upon receiving an adding instruction indicating to add at least one LUN to be added as a replica LUN corresponding to a source LUN, add, for each LUN to be added, the LUN to be added, the available status of the LUN to be added, and the timestamp value of the LUN to be added to a current replica LUN list;
[0110] Among them, if there is a replica LUN that meets the set conditions in the current replica LUN list, the available state of the LUN to be added is the standby state, and the timestamp value of the LUN to be added is the specified value; otherwise, the available state of the LUN to be added is the primary state, and the timestamp value of the LUN to be added is the specified value; the set condition is any one of the following conditions: the available state is the standby state and the timestamp value is the specified value, the timestamp value is a non-specified value and the timestamp value is the smallest, and the available state is the primary state.
[0111] As an embodiment, the device further comprises:
[0112] A removal module, configured to, upon receiving a removal instruction indicating removal of at least one replica LUN among the replica LUNs corresponding to the source LUN, wherein the removal instruction includes at least one LUN to be removed, remove the LUN to be removed from the current replica LUN list, as well as the available status and timestamp value of the LUN to be removed for each LUN to be removed;
[0113] Among them, when there are at least two copy LUNs in the current copy LUN list and the available status of the LUN to be removed in the current copy LUN list is the primary status, the available status corresponding to the copy LUN in the current copy LUN list whose available status is the backup status and whose timestamp value is the smallest is changed from the backup status to the primary status.
[0114] So far, completed Figure 4 Structural description of the device shown.
[0115] The implementation process of the functions and effects of each module in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, which will not be repeated here.
[0116] For the device embodiment, since it basically corresponds to the method embodiment, the relevant parts can refer to the partial description of the method embodiment. The device embodiment described above is only schematic, wherein the modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present application scheme. A person of ordinary skill in the art can understand and implement it without paying creative labor.
[0117] See also Figure 5 , is a schematic diagram of the hardware structure of an electronic device provided by an exemplary embodiment of the present application. The electronic device may include a processor 501, a communication interface 502, a computer-readable storage medium 503 and a communication bus 504. The processor 501, the communication interface 502 and the computer-readable storage medium 503 communicate with each other through the communication bus 504. Among them, computer program instructions are stored on the computer-readable storage medium 503; the processor 501 can execute the steps of the method described in the above embodiment by executing the computer program instructions stored on the computer-readable storage medium 503. The electronic device may also include other hardware according to the actual function of the electronic device, which will not be described in detail.
[0118] Correspondingly, an embodiment of the present application further provides a computer-readable storage medium, on which a number of computer program instructions are stored. When the computer program instructions are executed by a processor, the method disclosed in the above example of the present application can be implemented.
[0119] Exemplarily, the computer-readable storage medium may be any electronic, magnetic, optical or other physical storage device that may contain or store information, such as executable instructions, data, etc. For example, the computer-readable storage medium may be: RAM (Radom Access Memory), volatile memory, non-volatile memory, flash memory, storage drive (such as hard disk drive), solid state drive, any type of storage disk (such as optical disk, DVD, etc.), or similar storage medium, or a combination thereof. The processor and memory may be supplemented by or incorporated into a dedicated logic circuit.
[0120] The above are only preferred embodiments of the present application and are not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the scope of protection of the present application.
Claims
1. A data replication method, characterized in that: The method is applied to a storage device, wherein the storage device includes a source logical unit number LUN to be copied; the method includes: When it is determined to start a replication of data in the storage space corresponding to the source LUN, a replica LUN whose available status is the primary status is obtained from the current replica LUN list corresponding to the source LUN as the target LUN to which the data is replicated this time; if the available status of any replica LUN in the current replica LUN list is the primary status, it indicates that the replica LUN is currently allowed to replicate data, and if the available status of any replica LUN is the standby status, it indicates that the replica LUN is currently not allowed to replicate data; Use full replication to copy the data in the storage space corresponding to the source LUN to the target LUN; If there are at least two replica LUNs in the current replica LUN list, the available status of the target LUN in the current replica LUN list is changed from the primary status to the backup status, and the timestamp value corresponding to the target LUN is modified; and the available status of the replica LUN in the current replica LUN list whose available status is the backup status and whose timestamp value is the smallest is changed from the backup status to the primary status.
2. The method according to claim 1, characterized in that After obtaining a copy LUN in an available state and in a primary state from the current copy LUN list corresponding to the source LUN as a target LUN to which the data is copied, the method further includes: If the timestamp value corresponding to the target LUN in the current copy LUN list is a non-specified value, the timestamp value corresponding to the target LUN in the current copy LUN list is modified from the non-specified value to the specified value; if the timestamp value corresponding to the target LUN in the current copy LUN list is a specified value, the timestamp value corresponding to the target LUN continues to be maintained at the specified value; Among them, the timestamp value corresponding to any replica LUN in the current replica LUN list whose timestamp value is not a specified value is used to indicate the timestamp when data replication was last performed on the replica LUN; the timestamp value corresponding to any replica LUN in the current replica LUN list that is determined as a target LUN and whose timestamp value is a specified value is used to indicate that data replication is currently being performed on the replica LUN; the timestamp value corresponding to any replica LUN in the current replica LUN list that is not a target LUN and whose timestamp value is a specified value is used to indicate that data replication has never been performed on the replica LUN.
3. The method according to claim 1, characterized in that: After copying the data in the storage space corresponding to the source LUN to the target LUN by using the full copy method, the method further includes: If only the target LUN exists in the current replica LUN list, the available state corresponding to the target LUN in the current replica LUN list continues to be maintained as the primary state.
4. The method according to claim 1, characterized in that: The modifying the timestamp value corresponding to the target LUN includes: The timestamp value corresponding to the target LUN is modified according to the sum of the largest timestamp value in the current copy LUN list and the set value.
5. The method according to claim 1, characterized in that The method further comprises: When receiving an addition instruction indicating to add at least one LUN to be added as a replica LUN corresponding to the source LUN, for each LUN to be added, adding the LUN to be added, the available status of the LUN to be added, and the timestamp value of the LUN to be added to the current replica LUN list; Among them, if there is a replica LUN that meets the set conditions in the current replica LUN list, the available state of the LUN to be added is the standby state, and the timestamp value of the LUN to be added is the specified value; otherwise, the available state of the LUN to be added is the primary state, and the timestamp value of the LUN to be added is the specified value; the set conditions are any of the following conditions: the available state is the standby state and the timestamp value is the specified value, the timestamp value is a non-specified value and the timestamp value is the smallest, and the available state is the primary state.
6. The method according to claim 1, characterized in that The method further comprises: When a removal instruction indicating removal of at least one of the replica LUNs corresponding to the source LUN is received, the removal instruction includes at least one LUN to be removed, and for each LUN to be removed, the LUN to be removed, and the available status and timestamp value of the LUN to be removed are removed from the current replica LUN list; Among them, when there are at least two copy LUNs in the current copy LUN list and the available status of the LUN to be removed in the current copy LUN list is the primary status, the available status corresponding to the copy LUN in the current copy LUN list whose available status is the backup status and whose timestamp value is the smallest is changed from the backup status to the primary status.
7. A data replication device, characterized in that: The device is applied to a storage device, wherein the storage device includes a source logical unit number LUN to be copied; The device includes: An acquisition module is used to, when determining to start a replication of data in a source LUN, obtain a replica LUN whose available state is a primary state from a current replica LUN list corresponding to the source LUN as a target LUN to which the data is replicated this time; if the available state of any replica LUN in the current replica LUN list is a primary state, it indicates that the replica LUN currently allows data replication, and if the available state of any replica LUN is a standby state, it indicates that the replica LUN currently does not allow data replication; A replication module is used to replicate the data in the storage space corresponding to the source LUN to the target LUN by using a full replication method; A modification module is used to modify the available status of the target LUN in the current copy LUN list to a standby status if there are at least two copy LUNs in the current copy LUN list, and to modify the timestamp value corresponding to the target LUN; and to modify the available status of the copy LUN in the current copy LUN list whose available status is a standby status and whose timestamp value is the smallest from a standby status to a primary status.
8. The device according to claim 7, characterized in that After obtaining a copy LUN in the primary state from the current copy LUN list corresponding to the source LUN as the target LUN to which the data is copied, the modification module is further used to: if the timestamp value corresponding to the target LUN in the current copy LUN list is a non-specified value, modify the timestamp value corresponding to the target LUN in the current copy LUN list from the non-specified value to the specified value; If the timestamp value corresponding to the target LUN in the current copy LUN list is a specified value, the timestamp value corresponding to the target LUN continues to be maintained at the specified value; wherein, the timestamp value corresponding to any copy LUN in the current copy LUN list whose timestamp value is not a specified value is used to indicate the timestamp when the copy LUN was last replicated; the timestamp value corresponding to any copy LUN in the current copy LUN list that is determined to be a target LUN and whose timestamp value is a specified value is used to indicate that the copy LUN is currently being replicated; the timestamp value corresponding to any copy LUN in the current copy LUN list that is not a target LUN and whose timestamp value is a specified value is used to indicate that the copy LUN has never been replicated; and / or, After the data in the storage space corresponding to the source LUN is copied to the target LUN by full copy, the modification module is further used to: if only the target LUN exists in the current copy LUN list, continue to maintain the available state corresponding to the target LUN in the current copy LUN list as the primary state; and / or, The modifying of the timestamp value corresponding to the target LUN comprises: modifying the timestamp value corresponding to the target LUN according to the sum of the largest timestamp value in the current replica LUN list and the set value; and / or, The device further includes: an adding module, which is used for, when receiving an adding instruction indicating to add at least one LUN to be added as a replica LUN corresponding to the source LUN, for each LUN to be added, adding the LUN to be added, the available state of the LUN to be added, and the timestamp value of the LUN to be added to the current replica LUN list; wherein, if there is a replica LUN that meets the set condition in the current replica LUN list, the available state of the LUN to be added is a standby state, and the timestamp value of the LUN to be added is a specified value; otherwise, the available state of the LUN to be added is an active state, and the timestamp value of the LUN to be added is a specified value; the set condition is any one of the following conditions: the available state is a standby state and the timestamp value is a specified value, the timestamp value is a non-specified value and the timestamp value is the smallest, and the available state is an active state; and / or, The device further includes: a removal module, which is used for, when receiving a removal instruction instructing to remove at least one of the replica LUNs corresponding to the source LUN, the removal instruction includes at least one LUN to be removed, and for each LUN to be removed, removing the LUN to be removed, as well as the available status and timestamp value of the LUN to be removed from the current replica LUN list; wherein, when there are at least two replica LUNs in the current replica LUN list, and the available status of the LUN to be removed in the current replica LUN list is the primary status, the available status corresponding to the replica LUN in the current replica LUN list whose available status is the standby status and whose timestamp value is the smallest is changed from the standby status to the primary status.
9. An electronic device, characterized in that: The electronic device includes: Processor; and A computer-readable storage medium, wherein computer program instructions are stored in the computer-readable storage medium, and when the computer program instructions are executed by the processor, the processor executes the steps in any one of the methods of claims 1 to 6.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions, which, when executed by a processor, enable the processor to perform the steps of any one of the methods of claims 1 to 6.