Data migration method and device
By writing only on the target side and using the key value space to record the written data, the problem of insufficient storage space on the source side during data migration of NAS storage devices is solved, the migration success rate and efficiency are improved, and the user experience is improved.
Patent Information
- Application Number
- CN202310363486.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-31
- Publication Date
- 2024-10-01
AI Technical Summary
During the data migration process of the NAS storage device, the target side performs double writing when receiving the write command, which causes the source side to increase the storage space occupied, may cause the migration to fail, and the data migration efficiency is low.
The single write method is used to perform write operations on the target side instead of the source side. The written data is recorded through the key value space and data is migrated based on the effective length of the file to avoid repeated migration.
It improves the success rate and efficiency of data migration, reduces source storage space occupation, reduces business interruption caused by migration, and improves user experience.
Smart Images

Figure CN118733554A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing, and more specifically, to a data migration method, apparatus, computing device, computer program product, and computer-readable storage medium. Background Art
[0002] Network attached storage (NAS) services are widely used in various fields. When a NAS storage device needs to be replaced, the data in the old NAS storage device (source end) can be migrated to the new NAS storage device (target end), and the new NAS storage device provides NAS services. In the takeover first solution, the target end takes over the source end first, and the data migration is performed in the background.
[0003] During the data migration process, if the target side receives a write instruction to modify data, the write instruction will be executed on both the source side and the target side. The data written on the source side according to the write instruction will occupy additional storage space on the source side. When the storage space on the source side is insufficient, data migration may fail. Summary of the invention
[0004] The present application provides a data migration method and device, which can save storage space on the source side, thereby improving the success rate of data migration.
[0005] In a first aspect, a data migration method is provided, the method being used to migrate data of a first file at a source end to a second file at a target end, the method comprising: the target end receiving a write instruction from a client, the write instruction being used to write first data of a first key range in the first file, the first key range comprising at least one key; the target end writing the first data of the first key range in the second file according to the write instruction, and updating the key value space of the second file; the target end migrating the data of the first file to the second file according to the key value space and the effective length of the first file.
[0006] In the embodiment of the present application, when the target end receives a write instruction during the data migration process, a "single write" is performed, that is, a write operation is performed on the target end, and a write operation is not performed on the source end. In this way, no additional storage space of the source end is occupied, and migration failure caused by insufficient storage space on the source end is avoided, thereby improving the success rate of data migration. On the other hand, by recording the keys that have been written through the key value space and considering the effective length of the file during data migration, repeated migration of the same data is avoided, thereby improving the efficiency of data migration.
[0007] In combination with the first aspect, in certain implementations of the first aspect, the method also includes: the target end receives a read instruction from the client, the read instruction is used to read data in a second key range of the first file; the target end determines valid data in the second key range based on the key value space; and the target end sends the valid data to the client.
[0008] During the data migration process, read instructions from the client can also be received. The method provided in the embodiment of the present application can determine the valid data that the client wants to read based on the key value space, thereby reducing business interruptions caused by migration and improving user experience.
[0009] In combination with the first aspect, in certain implementations of the first aspect, the target end determines the valid data of the second key range based on the key value space, including: when the key value space includes records of each key in the second key range, the target end determines that the data in the second key range of the second file is the valid data.
[0010] During the data migration process, read instructions from the client can also be received. The method provided in the embodiment of the present application can determine the valid data that the client wants to read based on the key value space. When all the keys corresponding to the reading range indicated by the read instruction are recorded, these data can be read on the target end with a fast reading speed, thereby improving the user experience.
[0011] In combination with the first aspect, in certain implementations of the first aspect, the target end determines the valid data of the second key range based on the key value space, including: when the key value space includes records of some keys in the second key range, the target end obtains the second data of the first file based on the effective length and the key value space; the target end merges the second data and the data corresponding to the some keys in the second key range of the second file to determine the valid data.
[0012] During the data migration process, a read instruction from the client may also be received. When part of the data that the client wishes to read has been written on the target end, and the other part is on the source end, the method provided in the embodiment of the present application may obtain the data on the source end through the effective length and key value space, and merge the data on the source end with the data on the target end to determine the effective data that the client wishes to read.
[0013] In combination with the first aspect, in certain implementations of the first aspect, the target end obtains the second data of the first file based on the effective length and the key value space, including: when the maximum value of the second key range is less than or equal to the effective length, obtaining the data corresponding to the key in the second key range of the first file that has no record in the key value space as the second data; or when the effective length falls within the second key range, obtaining the data corresponding to the key in the second key range of the first file that is within the effective length and has no record in the key value space as the second data.
[0014] During the data migration process, a read instruction from the client may also be received. When part of the data that the client wishes to read has been written on the target end, and the other part is on the source end, the method provided in the embodiment of the present application may obtain the data on the source end based on the relationship between the second key range and the effective length, and merge the data on the source end with the data on the target end to determine the effective data that the client wishes to read.
[0015] In combination with the first aspect, in some implementations of the first aspect, the method further includes: the target end receives metadata of the first file; and the target end creates the second file according to the metadata.
[0016] In combination with the first aspect, in certain implementations of the first aspect, the target end migrates the data of the first file to the second file based on the key value space and the effective length of the first file, including: the target end migrates the data corresponding to the keys in the first file that are within the effective length and have no records in the key value space to the second file.
[0017] In the embodiment of the present application, when migrating data, the target end will not repeatedly migrate data already written on the target end to the target end, nor will it migrate data exceeding the effective length to the target end. The method provided by the embodiment of the present application avoids repeated migration and improves the efficiency of data migration.
[0018] In combination with the first aspect, in certain implementations of the first aspect, the method also includes: the target end receives a truncation instruction, the truncation instruction is used to truncate the first file from a first length to a second length, and the second length is smaller than the first length; the target end truncates the second file to the second length according to the truncation instruction, and modifies the effective length of the first file from the first length to the second length.
[0019] The target end may also receive a truncation instruction during data migration. The method provided in the embodiment of the present application can execute the truncation instruction only on the target end, and not on the source end, when the target end receives the truncation instruction, thereby saving overhead. On the other hand, the method provided in the embodiment of the present application can also modify the effective length of the source end file, so that even if the source end file is not truncated, the data that the client wants to discard will not be migrated in the subsequent synchronization process, thereby improving the user experience.
[0020] In a second aspect, an embodiment of the present application provides a data migration device, which includes a module for implementing the first aspect or any possible implementation method of the first aspect.
[0021] In a third aspect, a computing device is provided, including a processor and a memory, wherein the processor is used to execute instructions stored in the memory so that the computing device executes the data migration method of the first aspect or any possible implementation of the first aspect.
[0022] According to a fourth aspect, a computer program product comprising instructions is provided. When the instructions are executed by a computing device, the computing device executes the data migration method according to the first aspect or any possible implementation of the first aspect.
[0023] In a fifth aspect, a computer-readable storage medium is provided, comprising computer program instructions. When the computer program instructions are executed by a computing device, the computing device executes the data migration method of the first aspect or any possible implementation of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 It is a schematic diagram of a system architecture.
[0025] Figure 2 It is a schematic flow chart of a data migration method provided in an embodiment of the present application.
[0026] Figure 3 It is a schematic block diagram of a data migration device provided in an embodiment of the present application.
[0027] Figure 4 An architectural diagram of a computing device provided in an embodiment of the application. DETAILED DESCRIPTION
[0028] The technical solution in this application will be described below in conjunction with the accompanying drawings.
[0029] The present application will present various aspects, embodiments or features around a system that may include multiple devices, components, modules, etc. It should be understood and appreciated that each system may include additional devices, components, modules, etc., and / or may not include all of the devices, components, modules, etc. discussed in conjunction with the figures. In addition, combinations of these schemes may also be used.
[0030] In addition, in the embodiments of the present application, words such as "exemplary" and "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "exemplary" in the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of the word "exemplary" is intended to present concepts in a concrete way.
[0031] The network architecture and business scenarios described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. A person of ordinary skill in the art can appreciate that with the evolution of the network architecture and the emergence of new business scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0032] References to "one embodiment" or "some embodiments" etc. described in this specification mean that a particular feature, structure or characteristic described in conjunction with the embodiment is included in one or more embodiments of the present application. Thus, the phrases "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear at different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0033] Figure 1 A schematic diagram of a system architecture is shown. In the system architecture 100, data migration 140 is to migrate data from the source end 110 to the target end 120. During the continuous process of data migration 140, a non-stop method is generally adopted, that is, a read instruction or a write instruction from the client 130 can be received. For example, the client 130 sends a write instruction 150 to the target end 120, and the write instruction 150 hopes to modify a file in the source end 110. In the relevant technical solution, a "double write" method is adopted, that is, the write instruction 150 is executed at both the source end 110 and the target end 120.
[0034] However, when the write instruction 150 writes data to the source end 110, it may occupy additional storage space of the source end 110. There are many reasons for the target end 120 to take over the source end 110, one of which is that the storage space of the source end 110 is insufficient, affecting normal use. The "double write" solution will further occupy the storage space of the source end 110, and when the remaining storage space is insufficient, it may cause data migration failure.
[0035] Figure 2 A data migration method 200 provided in an embodiment of the present application is shown. The method 200 adopts a "single write" approach, and after receiving a write instruction, a write operation is performed only on the target end, which can improve the success rate of data migration.
[0036] Figure 2 The method 200 shown can be used to migrate data of a first file at a source end to a second file at a target end. Figure 1 The data of the first file of the source end 110 is migrated to the second file of the target end 120.
[0037] S210, the target end receives a write instruction from the client, where the write instruction is used to write first data in a first key range in the first file, where the first key range includes at least one key.
[0038] It should be noted that before S210, the target end has taken over the source end. That is to say, although the data migration is still in progress when S210 is executed, the source end is invisible to the user. This application does not limit the extent of data migration execution. For example, when S210 is executed, part of the data in the second file has been migrated. For another example, when S210 is executed, no data has been migrated in the second file.
[0039] It is understandable that the source end may have more than one file, and the target end may have more than one file. When S210 is executed, other files on the source end may have completed migration, that is, files other than the second file on the target end may have been consistent with the data on the source end. When S210 is executed, other files on the source end may also be in the process of data migration.
[0040] In some embodiments, the write instruction may include an offset, a length, and data. Thus, after receiving the write instruction, the target end may start the write operation from the offset position in the write instruction until the number of bits written meets the length in the write instruction, and the key range corresponding to the address range between the start and stop may be referred to as the first key range. The written data may be referred to as the first data.
[0041] The first file is at the source end, and the second file is at the target end. The second file corresponds to the first file, and the corresponding relationship can be reflected in that the metadata of the first file and the second file are the same, for example, the file names of the first file and the second file can be the same.
[0042] Metadata can also be called intermediate data or relay data. Metadata can be data that describes data, such as information describing the properties of data. For example, the metadata of a file can describe the file's storage location, historical data, unique identifier (ID), valid size, modification time, etc.
[0043] In other words, due to the corresponding relationship between the second file and the first file, the user may not be able to perceive the difference between the second file and the first file, and the write instruction that can be executed in the first file can also be executed in the second file.
[0044] A key can be a key in a key-value (KV) store or a key used to find data in a record table. For example, you can maintain a record table with keys that are constants and values that are pointers to addresses.
[0045] S220: The target end writes the first data in the first key range in the second file according to the write instruction, and updates the key value space of the second file.
[0046] Due to the correspondence between the second file and the first file, the user may not be able to perceive the difference between the second file and the first file, and the write instruction that can be executed in the first file can also be executed in the second file. Therefore, the write instruction can write the first data of the first key range in the second file.
[0047] The key value space can be used to record the keys written when the write instruction is executed. In some embodiments, only the written keys are recorded in the key value space, and the keys not recorded are equivalent to not being written. In other embodiments, the key value space records all the keys, the written keys have a write mark, and the keys without a write mark are equivalent to not being written.
[0048] S230: The target end migrates the data of the first file to the second file according to the key value space and the effective length of the first file.
[0049] The data corresponding to the keys recorded in the key-value space have been written into the second file, and migrating only the unwritten data can improve the efficiency of data migration.
[0050] Data exceeding the valid length of the first file is not valid data and may not be migrated to the second file. For example, the valid length of the first file can be obtained from metadata, such as r_valid_size. For example, the valid length can be 2MB, 150KB, etc., and the present application does not limit the specific value of the valid length.
[0051] In some embodiments, the target end migrates the data of the first file to the second file based on the key value space and the effective length of the first file, including: the target end migrates the data corresponding to the keys in the first file that are within the effective length and have no records in the key value space to the second file.
[0052] For example, the address range from 0 to the valid length can be traversed. If the keys corresponding to some addresses in the address range have records, these addresses are skipped, or the data stored at these addresses are not migrated to the target end. If the keys corresponding to another part of the addresses in the address range have no records, the data stored at these addresses are migrated to the target end.
[0053] For example, the data of the source file can be obtained through the file handle, thereby realizing data migration. For example, the data of the source file can also be obtained through the file path, thereby realizing data migration.
[0054] In the embodiment of the present application, when migrating data, the target end will not repeatedly migrate data already written on the target end to the target end, nor will it migrate data exceeding the effective length to the target end. The method provided by the embodiment of the present application avoids repeated migration and improves the efficiency of data migration.
[0055] In the embodiment of the present application, when the target end receives a write instruction during the data migration process, a "single write" is performed, that is, a write operation is performed on the target end, and a write operation is not performed on the source end. In this way, no additional storage space of the source end is occupied, and migration failure caused by insufficient storage space on the source end is avoided, thereby improving the success rate of data migration. On the other hand, by recording the keys that have been written through the key value space and considering the effective length of the file during data migration, repeated migration of the same data is avoided, thereby improving the efficiency of data migration.
[0056] Optionally, the method also includes: the target end receives a read instruction from the client, the read instruction is used to read data in a second key range of the first file; the target end determines valid data in the second key range based on the key value space; and the target end sends the valid data to the client.
[0057] During the data migration process, users may want to perform not only write operations but also read operations.
[0058] It should be noted that the target end may receive the read instruction from the client before the first file is migrated, that is, before S230. The target end may also receive the read instruction from the client after S230, that is, after the first file has been migrated. However, the target end receives the read instruction from the client while the data is being migrated, that is, some files are still being migrated at this time.
[0059] For example, a read instruction may include an offset and a length. The read instruction may indicate that a read operation is to be performed from the offset address until the read operation reaches a position defined by the length.
[0060] During the data migration process, read instructions from the client can also be received. The method provided in the embodiment of the present application can determine the valid data that the client wants to read based on the key value space, thereby reducing business interruptions caused by migration and improving user experience.
[0061] Optionally, the target end determines valid data of the second key range based on the key value space, including: when the key value space includes records of each key in the second key range, the target end determines that the data in the second key range of the second file is the valid data.
[0062] The above situation can be understood as the addresses corresponding to the keys in the second key range have been written with data, for example, by writing instructions or by data migration. Another possibility of the above situation is that the data in the first file have all been migrated to the second file.
[0063] In the case where the key value space includes records of each key in the second key range, the target end can read data locally, that is, in the second file of the target end, and these data are the data that the client wants to read.
[0064] During the data migration process, read instructions from the client can also be received. The method provided in the embodiment of the present application can determine the valid data that the client wants to read based on the key value space. When all the keys corresponding to the reading range indicated by the read instruction are recorded, these data can be read on the target end with a fast reading speed, thereby improving the user experience.
[0065] Optionally, the target end determines the valid data of the second key range based on the key value space, including: when the key value space includes records of some keys in the second key range, the target end obtains the second data of the first file based on the valid length and the key value space; the target end merges the second data and the data corresponding to the some keys in the second key range of the second file to determine the valid data.
[0066] The above situation can be understood as data has been written into addresses corresponding to some keys in the second key range. For example, the written data may be written through a write instruction or through data migration.
[0067] In the case where the key value space includes records of some keys in the second key range, data corresponding to the recorded keys can be obtained from the target end. Data corresponding to unrecorded keys are not stored on the target end but on the source end, and therefore need to be obtained on the source end.
[0068] When obtaining data corresponding to an unrecorded key at the source end, the effective length may be considered. Data within the effective length is data of the first file, and data exceeding the effective length may not be data of the first file.
[0069] During the data migration process, a read instruction from the client may also be received. When part of the data that the client wishes to read has been written on the target end, and the other part is on the source end, the method provided in the embodiment of the present application may obtain the data on the source end through the effective length and key value space, and merge the data on the source end with the data on the target end to determine the effective data that the client wishes to read.
[0070] Optionally, the target end obtains the second data of the first file based on the effective length and the key value space, including: when the maximum value of the second key range is less than or equal to the effective length, obtaining the data corresponding to the key in the second key range of the first file that has no record in the key value space as the second data; or when the effective length falls within the second key range, obtaining the data corresponding to the key in the second key range of the first file that is within the effective length and has no record in the key value space as the second data.
[0071] Assume that the value of the effective length is RVS, and the second key range is (R1, R2).
[0072] For example, the case where the maximum value of the second key range is less than or equal to the effective length can also be understood as R2 being less than or equal to RVS. In this case, the data of (R1, R2) is the data of the first file, and the data corresponding to the key that is not recorded in the key value space can be used as the second data, excluding the data that has been written, that is, the data corresponding to the key recorded in the key value space.
[0073] For example, the situation where the effective length falls within the second key range can also be understood as R1 being less than or equal to RVS, and RVS being less than or equal to R2. In this case, although the data within the range (RVS, R2) is the range that the client wants to read, the data of the first file may not be included in the range, so the data within the range (RVS, R2) may not be read. In some embodiments, the data within the range (RVS, R2) can all be written as 0, so that the length of the effective data can match the length of the data that the client wants to read. For example, the data within the range (R1, RVS) is within the effective length, and the data corresponding to the key that is within the range (R1, RVS) and has no record in the key value space can be used as the second data.
[0074] In other embodiments, the minimum value of the second key range may be greater than or equal to the effective length, that is, R1 is greater than or equal to RVS. In this case, the data in the range (R1, R2) may not be the data of the first file, so the data in the range (R1, R2) may not be read. In some implementations, the data in the range (R1, R2) may all be written as 0, so that the length of the effective data can match the length of data that the client wants to read.
[0075] During the data migration process, a read instruction from the client may also be received. When part of the data that the client wishes to read has been written on the target end, and the other part is on the source end, the method provided in the embodiment of the present application may obtain the data on the source end based on the relationship between the second key range and the effective length, and merge the data on the source end with the data on the target end to determine the effective data that the client wishes to read.
[0076] Optionally, the method further includes: the target end receiving metadata of the first file; and the target end creating the second file according to the metadata.
[0077] In some embodiments, the target end receives the metadata of the first file before S210, that is, the second file is created first, and then the write instruction from the client is received.
[0078] In other embodiments, the target end receives the metadata of the first file after S210, that is, the target end receives the write instruction first and then creates the second file. In this case, before the target end receives the metadata of the first file, the target end also sends an instruction to the source end, and the instruction is used to obtain the metadata of the first file. In other words, after receiving the write instruction, the target end recognizes that the second file has not been created on the target end, so it obtains the metadata of the first file on the source end and then creates the second file.
[0079] In some embodiments, data migration can also be divided into two phases. Metadata migration is performed in the first phase, and data migration is performed in the second phase, which are described separately below.
[0080] In the first stage, the metadata can be fully migrated, that is, the first stage ends only after all the metadata on the source side is migrated to the target side, and then the second stage is executed.
[0081] In the first stage, the target side can create a directory or file based on the metadata, and record the unique identifier (ID) of the target side's file in the log to be migrated. The target side can maintain information such as the effective length of the source side's file, the file handle, or the file path. In the first stage, if the target side receives a write instruction, it can perform "double write", that is, write data on both the source side and the target side; it can also first determine whether the file has been created. If the file has not been created, it will first obtain the metadata of the file to be written on the source side and create the file, and then perform a "single write" operation, that is, only write data on the target side.
[0082] When the full migration of metadata is completed, in some embodiments, a single write mark can be set on the target end file, and the single write mark is used to indicate that if a write instruction is received next, only the write operation is performed on the target end according to the write instruction, and no write operation is required on the source end. In other embodiments, the single write mark may not be set on the target end file, and the second stage is directly entered.
[0083] In the second stage, if the target end receives a write instruction, a write operation is performed on the target end only according to the write instruction, and there is no need to perform a write operation on the source end.
[0084] In the second stage, the migration process in the background of the target end can read the log to be migrated and perform data migration. Specifically, the target end file can be determined based on the unique identifier in the log to be migrated, and the data of the file can be obtained on the source end based on the file handle or file path, thereby realizing data migration. When the data migration is completed, the source end can be offline.
[0085] Optionally, the method also includes: the target end receives a truncation instruction, which is used to truncate the first file from a first length to a second length, and the second length is smaller than the first length; the target end truncates the second file to the second length according to the truncation instruction, and modifies the effective length of the first file from the first length to the second length.
[0086] The truncate instruction can be used to "truncate" a file. For example, if a file is 2MB in size, the truncate instruction can be used to truncate the file to 3MB. It can be understood that the bits contained in the newly added 1MB at the end of the file can be all 0s. The truncate instruction can also be used to "truncate" a file. For example, a 2MB file can be truncated to 1MB, which is equivalent to discarding the 1MB of data at the end of the file.
[0087] It is understandable that the truncation instruction may be issued by the client, that is, the client wishes to truncate the first file. If the "double write" solution is adopted, the stage instruction needs to be executed on the target end and the stage instruction needs to be executed on the source end, which increases the overhead.
[0088] The target end may also receive a truncation instruction during data migration. The method provided in the embodiment of the present application can execute the truncation instruction only on the target end, and not on the source end, when the target end receives the truncation instruction, thereby saving overhead. On the other hand, the method provided in the embodiment of the present application can also modify the effective length of the source end file, so that even if the source end file is not truncated, the data that the client wants to discard will not be migrated in the subsequent synchronization process, thereby improving the user experience.
[0089] Combined with the above Figure 2 The method embodiments of the present application are described in detail. The device embodiments of the present application are described below. The device embodiments correspond to the method embodiments, so the parts not described in detail can refer to the previous method embodiments. The device can implement any possible implementation of the above method.
[0090] The present application also provides a data migration device 300, such as Figure 3 As shown, the device 300 is used to migrate data of a first file at a source end to a second file at a target end, and the device 300 includes: a receiving module 310, used to receive a write instruction from a client, the write instruction is used to write first data of a first key range in the first file, the first key range includes at least one key; a writing module 320, used to write the first data of the first key range in the second file according to the write instruction, and update the key value space of the second file; a migration module 330, used to migrate the data of the first file to the second file according to the key value space and the effective length of the first file.
[0091] The receiving module 310, the writing module 320 and the migration module 330 can all be implemented by software or by hardware. For example, the implementation of the receiving module 310 is described below by taking the receiving module 310 as an example. Similarly, the implementation of the writing module 320 and the migration module 330 can refer to the implementation of the receiving module 310.
[0092] As an example of a software functional unit, the receiving module 310 may include code running on a computing instance. The computing instance may include at least one of a physical host (computing device), a virtual machine, and a container. Furthermore, the computing instance may be one or more.
[0093] As an example of a hardware functional unit, the receiving module 310 may include at least one computing device, such as a server, etc. Alternatively, the processing module may also be a device implemented using an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). The PLD may be a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL) or any combination thereof.
[0094] The present application also provides a computing device 400. Figure 4 As shown, computing device 400 includes: bus 402, processor 404, memory 406 and communication interface 408. Processor 404, memory 406 and communication interface 408 communicate through bus 402. Computing device 400 can be a server or a terminal device. It should be understood that the present application does not limit the number of processors and memories in computing device 400.
[0095] The bus 402 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 The bus 402 is represented by only one line, but it does not mean that there is only one bus or one type of bus. The bus 402 may include a path for transmitting information between various components of the computing device 400 (eg, the memory 406, the processor 404, and the communication interface 408).
[0096] The processor 404 may include any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0097] The memory 406 may include a volatile memory, such as a random access memory (RAM). The memory 406 may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD), or a solid state drive (SSD).
[0098] The memory 406 stores executable program codes, and the processor 404 executes the executable program codes to respectively implement the functions of the aforementioned receiving module 310, writing module 320 and migration module 330, thereby implementing the data migration method. That is, the memory 406 stores instructions for executing the data migration method.
[0099] The communication interface 408 uses a transceiver module such as, but not limited to, a network interface card or a transceiver to implement communication between the computing device 400 and other devices or a communication network.
[0100] The embodiment of the present application also provides a computer program product including instructions. The computer program product may be software or a program product including instructions that can be run on a computing device or stored in any available medium. When the computer program product is run on at least one computing device, the at least one computing device executes the above-mentioned data migration method.
[0101] The embodiment of the present application also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium that can be stored by the computing device or a data storage device such as a data center containing one or more available media. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk). The computer-readable storage medium includes instructions that instruct the computing device to perform the above-mentioned data migration method.
[0102] The above are only specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A data migration method, characterized in that: The method is used to migrate data of a first file at a source end to a second file at a target end, and the method comprises: The target end receives a write instruction from the client, the write instruction is used to write first data of a first key range in the first file, the first key range includes at least one key; The target end writes the first data in the first key range in the second file according to the write instruction, and updates the key value space of the second file; The target end migrates the data of the first file to the second file according to the key value space and the effective length of the first file.
2. The method according to claim 1, characterized in that Also includes: The target end receives a read instruction from the client, where the read instruction is used to read data in a second key range of the first file; The target end determines valid data of the second key range according to the key value space; The target end sends the valid data to the client end.
3. The method according to claim 2, characterized in that The target end determines valid data of the second key range according to the key value space, including: In a case where the key value space includes records for each key in the second key range, the target determines that the data of the second key range of the second file is the valid data.
4. The method according to claim 2 or 3, characterized in that: The target end determines valid data of the second key range according to the key value space, including: In a case where the key value space includes records of some keys in the second key range, the target end obtains the second data of the first file according to the effective length and the key value space; The target end merges the second data with data corresponding to some keys in the second key range of the second file to determine the valid data.
5. The method according to claim 4, characterized in that The target end obtains the second data of the first file according to the effective length and the key value space, including: When the maximum value of the second key range is less than or equal to the effective length, obtaining data corresponding to keys in the second key range of the first file that have no records in the key value space as the second data; or In the case that the effective length falls within the second key range, data corresponding to a key in the second key range of the first file that is within the effective length and has no record in the key value space is obtained as the second data.
6. The method according to any one of claims 1 to 5, characterized in that Also includes: The target end receives metadata of the first file; The target end creates the second file according to the metadata.
7. The method according to any one of claims 1 to 6, characterized in that The target end migrates data of the first file to the second file according to the key value space and the effective length of the first file, including: The target end migrates data in the first file that is within the effective length and corresponds to the key that has no record in the key value space to the second file.
8. The method according to any one of claims 1 to 7, characterized in that Also includes: The target end receives a truncation instruction, wherein the truncation instruction is used to truncate the first file from a first length to a second length, wherein the second length is smaller than the first length; The target end truncates the second file to the second length according to the truncation instruction, and modifies the effective length of the first file from the first length to the second length.
9. A data migration device, characterized in that: The device is used to migrate data of a first file at a source end to a second file at a target end, and the device includes: A receiving module, configured to receive a write instruction from a client, wherein the write instruction is used to write first data of a first key range in the first file, wherein the first key range includes at least one key; a writing module, configured to write the first data in the first key range in the second file according to the writing instruction, and update the key value space of the second file; A migration module is used to migrate the data of the first file to the second file according to the key value space and the effective length of the first file.
10. The device according to claim 9, characterized in that The receiving module is further used to receive a read instruction from the client, wherein the read instruction is used to read data in a second key range of the first file; Wherein, the device further comprises: A processing module, used for determining valid data in the second key range according to the key value space; A sending module is used to send the valid data to the client.
11. The device according to claim 10, characterized in that The processing module is specifically used for: In a case where the key value space includes records of the respective keys in the second key range, it is determined that the data of the second key range of the second file is the valid data.
12. The device according to claim 9 or 10, characterized in that The processing module is specifically used for: In a case where the key value space includes records of some keys in the second key range, acquiring second data of the first file according to the effective length and the key value space; The second data and data corresponding to some keys in the second key range of the second file are merged to determine the valid data.
13. The device according to claim 12, characterized in that The processing module is specifically used for: When the maximum value of the second key range is less than or equal to the effective length, obtaining data corresponding to keys in the second key range of the first file that have no records in the key value space as the second data; or In the case that the effective length falls within the second key range, data corresponding to a key in the second key range of the first file that is within the effective length and has no record in the key value space is obtained as the second data.
14. The device according to any one of claims 9 to 13, characterized in that The receiving module is also used for the target end to receive the metadata of the first file; wherein the device also includes A creation module is used to create the second file according to the metadata.
15. The device according to any one of claims 9 to 14, characterized in that The migration module is specifically used for: Migrate data corresponding to keys in the first file that are within the effective length and have no record in the key value space to the second file.
16. The device according to any one of claims 9 to 15, characterized in that The receiving module is further used to receive a truncation instruction, wherein the truncation instruction is used to truncate the first file from a first length to a second length, wherein the second length is smaller than the first length; The processing module is further configured to truncate the second file to the second length according to the truncation instruction, and modify the effective length of the first file from the first length to the second length.
17. A computing device, characterized in that The method comprises a processor and a memory, wherein the processor is configured to execute instructions stored in the memory so that the computing device executes the method according to any one of claims 1 to 8.
18. A computer program product comprising instructions, characterized in that When the instructions are executed by a computing device, the computing device is caused to perform the method according to any one of claims 1 to 8.
19. A computer-readable storage medium, characterized in that: The method comprises computer program instructions, and when the computer program instructions are executed by a computing device, the computing device performs the method as claimed in any one of claims 1 to 8.
