CN113535331B - Data migration method and device - Google Patents

Data migration method and device Download PDF

Info

Publication number
CN113535331B
CN113535331B CN202110871800.0A CN202110871800A CN113535331B CN 113535331 B CN113535331 B CN 113535331B CN 202110871800 A CN202110871800 A CN 202110871800A CN 113535331 B CN113535331 B CN 113535331B
Authority
CN
China
Prior art keywords
virtual machine
data block
target
data
disk
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110871800.0A
Other languages
Chinese (zh)
Other versions
CN113535331A (en
Inventor
高亮
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
New H3C Big Data Technologies Co Ltd
Original Assignee
New H3C Big Data Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by New H3C Big Data Technologies Co Ltd filed Critical New H3C Big Data Technologies Co Ltd
Priority to CN202110871800.0A priority Critical patent/CN113535331B/en
Publication of CN113535331A publication Critical patent/CN113535331A/en
Application granted granted Critical
Publication of CN113535331B publication Critical patent/CN113535331B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/4557Distribution of virtual machine instances; Migration and load balancing

Abstract

The embodiment of the application discloses a data migration method and device. According to the method and the device, when a data migration stopping event is detected in a data migration process of a source virtual machine, migration data from a source disk to a target disk is stopped, position information of a data block with a first mark in the source disk (namely dirty data which is not migrated to the target disk in the source disk) is sent to the target virtual machine, so that after the target virtual machine takes over service of the source virtual machine and receives a service writing instruction, if the data block with the first mark is determined to exist in the data block associated with the service writing instruction, the data block with the first mark in the data block associated with the service writing instruction is determined to be a target data block, and the target data block is obtained from the source virtual machine and written into the target disk according to the position information, so that the dirty data which is not migrated in the source disk is further migrated, and the situation that all data in the source disk cannot be migrated is avoided.

Description

Data migration method and device
Technical Field
The present invention relates to the field of communications, and in particular, to a data migration method and apparatus.
Background
In the process of migrating data in a virtual machine, if the virtual machine is running and the service on the virtual machine is busy at this time, there will be data in a disk of the virtual machine at all times in writing, and the data will not be migrated all the time, resulting in long migration time.
If the data in the virtual machine is not completely migrated, the virtual machine needs to be completely paused, and then the data which is not completely migrated is migrated by utilizing the time delay of pausing the virtual machine, but the data which is not completely migrated can not be completely migrated within the time delay of pausing the virtual machine due to the limitation of network bandwidth.
Disclosure of Invention
The application discloses a data migration method and device, which are used for avoiding that data of a virtual machine cannot be completely migrated when a service is busy.
According to a first aspect of embodiments of the present application, there is provided a data migration method, which is applied to a virtual machine, including:
if the virtual machine is a source virtual machine, when data migration is carried out, migrating data from a source disk associated with the virtual machine to a target disk associated with a target virtual machine currently mounted on the virtual machine, and when a data migration stopping event is detected, stopping migrating the data from the source disk to the target disk, and sending position information of a data block with a first mark to the target virtual machine, wherein the first mark is used for representing dirty data;
and if the virtual machine is the destination virtual machine, receiving the position information sent by the source virtual machine, after taking over the service of the source virtual machine and receiving a service writing instruction, if the data block with the first mark is determined to exist in the data block associated with the service writing instruction, determining the data block with the first mark in the data block associated with the service writing instruction as a target data block, and obtaining the target data block from the source virtual machine according to the position information and writing the target data block into a target position in the destination disk, wherein the destination disk stores the data block migrated from the source disk in the same storage structure mode as the source disk, and the target data block is obtained after the source virtual machine removes the first mark from the data block in the target position in the source disk.
According to a second aspect of embodiments of the present application, there is provided a data migration apparatus, which is applied to a virtual machine, including:
the position information sending unit is used for migrating data from a source disk associated with the virtual machine to a target disk associated with a target virtual machine currently mounted on the virtual machine when the virtual machine is a source virtual machine and stopping migrating the data from the source disk to the target disk when a data migration stopping event is detected, and sending the position information of a data block with a first mark to the target virtual machine, wherein the first mark is used for representing dirty data;
the target data block obtaining unit is configured to, if the virtual machine is a target virtual machine, receive location information sent by a source virtual machine, and after taking over a service of the source virtual machine and receiving a service writing instruction, if it is determined that a data block with a first mark set in a data block associated with the service writing instruction exists, determine the data block with the first mark set in the data block associated with the service writing instruction as a target data block, obtain the target data block from the source virtual machine according to the location information and write the target data block into a target location in the target disk, where the target disk stores the data block migrated from the source disk in a storage structure mode identical to that of the source disk, and the target data block is obtained after the source virtual machine removes the first mark from the data block located in the target location in the source disk.
The technical scheme provided by the embodiment of the application can comprise the following beneficial effects:
according to the technical scheme, in the process of data migration of the source virtual machine, when a data migration stopping event is detected, migration of data from the source disk to the target disk is stopped, and position information of the data block with the first mark in the source disk (namely dirty data which is not migrated to the target disk in the source disk) is sent to the target virtual machine, so that after the target virtual machine takes over service of the source virtual machine and receives a service writing instruction, if it is determined that the data block with the first mark exists in the data block associated with the service writing instruction, the data block with the first mark in the data block associated with the service writing instruction is determined to be a target data block, and the target data block is obtained from the source virtual machine and written into the target disk according to the position information, so that migration of dirty data which is not migrated in the source disk is further avoided, and the data in the source disk cannot be completely migrated.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the application.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the specification and together with the description, serve to explain the principles of the specification.
FIG. 1 is a flow chart of a method for implementing data migration according to an embodiment of the present application;
FIG. 2 is a schematic diagram of a data block in a disk according to an embodiment of the present application;
FIG. 3 is a schematic diagram of a global bitmap provided by an embodiment of the present application;
FIG. 4 is a flow chart of another method for implementing data migration provided by an embodiment of the present application;
fig. 5 is a schematic diagram of an apparatus for implementing data migration according to an embodiment of the present application.
Detailed Description
Reference will now be made in detail to exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, the same numbers in different drawings refer to the same or similar elements, unless otherwise indicated. The implementations described in the following exemplary examples are not representative of all implementations consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with some aspects of the present application as detailed in the accompanying claims.
The terminology used in the present application is for the purpose of describing particular embodiments only and is not intended to be limiting of the present application. As used in this application and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein refers to and encompasses any or all possible combinations of one or more of the associated listed items.
It should be understood that although the terms first, second, third, etc. may be used herein to describe various information, these information should not be limited by these terms. These terms are only used to distinguish one type of information from another. For example, a first message may also be referred to as a second message, and similarly, a second message may also be referred to as a first message, without departing from the scope of the present application. The word "if" as used herein may be interpreted as "at … …" or "at … …" or "responsive to a determination", depending on the context.
In order to better understand the technical solutions provided by the embodiments of the present application and make the above objects, features and advantages of the embodiments of the present application more obvious, the technical solutions in the embodiments of the present application are described in further detail below with reference to the accompanying drawings.
Referring to fig. 1, fig. 1 is a flowchart of a method for data migration according to an embodiment of the present application. As one embodiment, the flow shown in fig. 1 may be applied to a virtual machine, which may be a source virtual machine that performs data migration.
As shown in fig. 1, the process may include the steps of:
and step 101, when data migration is performed, migrating data from a source disk associated with the virtual machine to a target disk currently mounted on the virtual machine and associated with the target virtual machine.
In particular implementations, migrating data from the source disk to the destination disk may be performed upon triggering a virtual machine migration instruction that specifies a flow of operations that need to be performed by the virtual machine migration, where the virtual machine migration instruction is performed with the source virtual machine in a running state and the destination virtual machine in a suspended running state.
According to the virtual machine migration instruction, when the source virtual machine is triggered to migrate data in a source disk to a destination disk, the destination disk of the destination virtual machine is mounted on the source virtual machine based on an NBD protocol (network block device, network block storage) so that the source virtual machine can find and access the destination disk. After the source virtual machine determines that the destination disk is mounted, a next operation specified by the virtual machine migration instruction, such as starting to perform migration of data from the source disk to the destination disk, may be further performed. As to how to mount the destination disk on the source virtual machine, reference may be made to the related art, and details are not repeated here.
As to how the source virtual machine performs data migration in this embodiment, details will be described after the flow shown in fig. 1 is introduced, which is not repeated here.
And 102, stopping migrating data from the source disk to the destination disk when a data migration stopping event is detected, and sending the position information of the data block with the first mark to the destination virtual machine, wherein the first mark is used for representing dirty data.
As one embodiment, when the source virtual machine detects a data migration stopping event, the source virtual machine will pause operation, stop migrating data from the source disk to a destination disk currently mounted by the source virtual machine, and inform the destination virtual machine to start operation, so that the destination virtual machine takes over the service of the source virtual machine.
When the source virtual machine detects a data migration stopping event, after stopping migrating data from the source disk to a target disk currently mounted on the source virtual machine, the source virtual machine also has data blocks with the first marks set therein, and the data blocks with the first marks set therein are not yet available to be migrated to the target disk. Therefore, in the embodiment of the present application, after stopping data migration, the source virtual machine needs to send, to the destination virtual machine, location information of the data block in the source disk, where the first flag is set, so as to notify the destination virtual machine that the location of the data block in the source disk has not yet been migrated to the destination virtual machine.
Illustratively, the location information includes at least a location of the data block in the source disk, and a first flag to which the data block is set.
Thus, the flow shown in fig. 1 is completed.
As can be seen from the flow shown in fig. 1, in the embodiment of the present application, when a source virtual machine performs data migration, migration data from an associated source disk to a destination disk associated with a destination virtual machine, and when a data migration stop event is detected, migration data from the source disk to the destination disk is stopped, and location information of a data block in the source disk, where the location information is set in the destination virtual machine, of the data block in the source disk, where the data block in the source disk is a dirty data block, indicates that the data block in the source disk is not migrated to the destination disk, so as to notify the destination virtual machine that the dirty data in the source disk is not migrated to the destination disk.
The above examples are merely for ease of understanding, and the embodiments of the present application are not particularly limited.
How the source virtual machine performs data migration will be described in detail below in conjunction with fig. 2 and 3:
as an embodiment, before the source virtual machine performs data migration, the following steps are further performed: and setting a first mark for all the data blocks in the source disk, marking the dirty of all the data blocks in the source disk, and sending the global bitmap of each data block with the first mark in the source disk to the destination virtual machine.
It should be noted that, in this embodiment, the first flag is set for the data block in the source disk, which may be set according to the data block divided when writing data in the source disk, or may be set after the data block is completed by re-partitioning the data in the source disk according to the actual requirement. For example, reference may be made to fig. 2 for a storage structure of data blocks in a source disk.
As one embodiment, the global bitmap sent to the target virtual machine by the virtual machine records the storage structure of the data blocks in the source disk and whether the data blocks are set with the first marks, the positions of bits in the global bitmap correspond to the positions of the data blocks in the source disk one by one, and the values of the bits are used for identifying whether the data blocks are set with the first marks.
In this embodiment, the value of a bit in the global bitmap may be a first value or a second value, where the first value is used to indicate that a first flag is set for a data block corresponding to the bit, and the second value is used to indicate that a first flag is not set for the data block corresponding to the bit.
For example, the global bitmap may be implemented using a data structure bitmap (bitmap), where when the value of a bit in the global bitmap is 1, it indicates that a data block corresponding to the bit is set to a first flag, that is, the data block corresponding to the bit is marked dirty, and when the value of the bit is 0, it indicates that the data block corresponding to the bit is not set to the first flag, that is, the data block corresponding to the bit is not marked dirty. Based on the global bitmap implemented by the bitmap, in this embodiment, the global bitmap obtained after setting the first marks on all the data blocks in the source disk may refer to the global bitmap a in fig. 3, and the values of all the bits in the global bitmap obtained after setting the first marks on all the data blocks in the source disk are all 1.
The following describes a specific migration process of a data block in a source disk:
based on the above description of the global bitmap, in the embodiment of the present application, after setting the first flag for all the data blocks in the source disk and sending the global bitmap to the destination virtual machine, the source virtual machine will start to migrate the data blocks with the first flag set in the source disk. For each data block to be migrated, which is provided with a first mark, in the process of migrating the data block, the first mark of the data block, which is provided with the first mark, is removed first, and then the data block, from which the first mark is removed, is migrated to a destination disk. When the first mark set by the data block is removed, the bit value corresponding to the data block in the global bitmap of the source virtual machine is updated, and the bit value is updated from the first value to the second value. The migration of the data block from which the first mark is removed to the destination disk may be achieved by copying the data block from which the first mark is removed and then sending the copied data block to the destination disk.
Meanwhile, as the source virtual machine and the destination virtual machine each store the same global bitmap, in order to ensure the synchronization of the global bitmap contents stored in the source virtual machine and the destination virtual machine, so that the destination virtual machine can judge whether the data blocks in the source virtual machine are migrated to the destination disk according to the global bitmaps stored in the source virtual machine and the destination virtual machine, in the process of migrating the data blocks, the destination virtual machine is also required to be informed of updating the value of the bit corresponding to the migrated data block in the global bitmaps stored in the destination virtual machine, so that the destination virtual machine updates the value of the bit from the first value to the second value.
For example, data blocks in the source disk may be migrated to the destination disk in address size order. For example, when the data block 1 needs to be migrated, the first flag of the data block 1 may be removed first, so that the value of the bit corresponding to the data block 1 in the global bitmap stored in the source virtual machine is updated from 1 to 0, and the destination virtual machine is notified to update the value of the bit corresponding to the data block 1 in the global bitmap stored in the destination virtual machine from 1 to 0. At this time, the global bitmap stored in the source virtual machine and the destination virtual machine is updated from the global bitmap a to the global bitmap b, as shown in fig. 3.
As one embodiment, in the process of migrating the data blocks, since the source virtual machine is still running, if the source virtual machine receives a data writing instruction, and the data blocks associated with the data writing instruction will be updated, the following steps will be performed for the data block in the source disk, where the first flag is set, and the data block in which the first flag is removed due to being migrated:
when the source virtual machine receives a data writing instruction, if a data block corresponding to the data writing instruction in a source disk is not set with a first mark, the first mark is set for the data block, the destination virtual machine is informed to update the value of a bit corresponding to the data block in a global bitmap of the destination virtual machine, so that the destination virtual machine updates the value of the bit from a second value to a first value, and if the data block corresponding to the data writing instruction is set with the first mark, the set first mark of the data block is maintained.
For example, if the data block 4 in fig. 2 is migrated according to the address size order, where all of the data block 1, the data block 2 and the data block 3 have been migrated to the destination disk, then the values of the bits in the global bitmaps corresponding to the data block 1, the data block 2 and the data block 3 are all 0, if the data writing instruction for the data block 2 is received at this time, the source virtual machine will set the first flag on the data block 2 again, update the value of the bit in the global bitmap corresponding to the data block 2 in the source virtual machine to be 1, and notify the destination virtual machine to update the value of the bit corresponding to the data block 2 in the global bitmap stored in the destination virtual machine to be 1.
If the data writing instruction for the data block 6 is received at this time, since the data block 6 is not migrated to the destination disk at this time, the bit value in the global bitmap corresponding to the data block 6 is 1, so that the first flag set for the data block can be maintained, and the global bitmaps in the source virtual machine and the destination virtual machine do not need to be updated.
Further, in the embodiment of the present application, if it is determined that the current source virtual machine data migration condition meets a preset iteration condition, after updating the data block for each data writing instruction, it is required to detect whether a data migration stopping event occurs in the current source virtual machine according to the data block in the source disk, where the first flag is set.
In this embodiment of the present application, the preset iteration conditions at least include: each data block in the source disk, to which the first flag is initially set, is migrated to the destination disk, i.e., the data migration stop event in this embodiment occurs after determining that each data block in the source disk has been migrated once.
Optionally, when the number of the data blocks with the first marks set in the source disk is greater than or equal to a set threshold, determining that a data migration stopping event occurs in the current source virtual machine, otherwise, determining that a data migration stopping event does not occur in the current source virtual machine. When the number of the data blocks with the first flag set in the source disk is greater than or equal to the set threshold, it indicates that the data blocks are updated more frequently, and limited by the network bandwidth, if the data migration is continued, the data blocks with the update in the source disk need to be migrated all the time, but the migration speed may be less than the data block update speed, and the migration is continued at this time, so that the time required for the migration is long, and therefore, in this embodiment, the data migration needs to be stopped in this case.
For example, when it is determined that the data blocks in the source disk are frequently updated according to the network bandwidth and the update frequency of the data blocks is greater than the migration data block number rate of the source virtual machine, the maximum number of data blocks that can be migrated to the current network bandwidth is used to determine the threshold. Meanwhile, for convenience of application, in this embodiment, the set threshold may be determined by setting a ratio of the maximum value of the number of data blocks that can be migrated by the network bandwidth to the total number of data blocks in the source disk.
In an exemplary embodiment, it is determined that each data block in the source disk, to which the first flag is initially set, is migrated to the destination disk, by recording the migration times of each data block, determining, for each data block to be migrated, that the first flag is set, updating the migration times corresponding to the data block after the data block is migrated to the destination disk, and if it is detected that the migration times corresponding to all the data blocks in the source disk are greater than 0, determining that each data block in the source disk, to which the first flag is initially set, is migrated to the destination disk.
Optionally, in this embodiment, when each data block in the source disk is migrated to the destination disk for the first time, a second flag may be set for the migrated data block, where the second flag indicates that the data block has been migrated once, so that, when detecting that all data blocks in the source disk are set with the second flag, the source virtual machine may determine that each data block in the source disk, where the first flag is initially set, is migrated to the destination disk.
Meanwhile, it should be noted that, when the data migration stop event is detected, the source virtual machine needs to be suspended, at this time, there are situations that the data block with the first flag set in the source disk is not yet available to be migrated to the destination disk, and the source virtual machine may not be available to notify the destination virtual machine to update the value of the bit in the global bitmap, so in this embodiment, the source virtual machine needs to send the location information of the data block with the first flag set in the source disk to the destination virtual machine after stopping migrating data from the source disk to the destination disk.
Referring now to fig. 4, fig. 4 is a flowchart illustrating another method for data migration according to an embodiment of the present application. As one embodiment, the flow shown in fig. 4 may be applied to a virtual machine, which may be a destination virtual machine for data migration.
Step 401, receiving location information sent by a source virtual machine, and after taking over a service of the source virtual machine and when receiving a service writing instruction, determining whether a data block with a first flag set exists in a data block associated with the service writing instruction.
As one embodiment, before the source virtual machine migrates the data in the source disk to the destination disk associated with the destination virtual machine, the source virtual machine sends the global bitmap of the data blocks in the source disk with the first flag set to the destination virtual machine.
After receiving the global bitmap, the destination virtual machine stores the data block according to the storage structure indicated by the global bitmap when receiving the data block migrated from the source disk, so as to achieve that the storage structure of the data block in the destination disk is consistent with the storage structure of the data block in the source disk.
Optionally, before determining in the step 401 that the data block with the first flag set in the data block associated with the service writing instruction exists, the embodiment may determine, according to the location information, the data block with the first flag set in the destination disk, find a bit corresponding to the data block in the global bitmap obtained by the destination virtual machine, and update the value of the bit from the second value to the first value.
Further, based on the updated global bitmap, whether the data block with the first flag set exists in the data block associated with the service writing instruction can be determined by searching bits corresponding to the data block associated with the service writing instruction in the global bitmap. If the value of the searched bit is the first value, determining the data block corresponding to the bit as the data block with the first mark set in the target disk.
Step 402, if it is determined that the data block with the first flag set in the data block associated with the service writing instruction exists, determining the data block with the first flag set in the data block associated with the service writing instruction as a target data block, obtaining the target data block from the source virtual machine according to the location information, and writing the target data block into the target location in the target disk.
In this embodiment of the present invention, the destination disk stores the data block migrated from the source disk in the same storage structure manner as the source disk, and the target data block is obtained by removing the first mark from the data block located in the target position in the source disk by the source virtual machine.
As one embodiment, the destination virtual machine may trigger the source virtual machine to find the data block located at the target location by sending an instruction to the source virtual machine to acquire the data block located at the target location, and cause the source virtual machine to remove the first tag of the data block, and send the data block with the first tag removed to the destination virtual machine as the target data block.
As an embodiment, after the destination virtual machine obtains the target data block from the source virtual machine and writes the target data block into the target position in the destination disk, the bit corresponding to the target position may be searched in the global bitmap of the destination virtual machine, and the value of the searched bit is updated from the first value to the second value.
Further, when the destination virtual machine detects that the values of all bits in the global bitmap are the second values, the source virtual machine can be controlled to be turned off or destroyed. Therefore, even if the data blocks in the source disk are not completely migrated to the destination disk due to busy service on the source virtual machine, the migration of all the data blocks on the source virtual machine can be further completed based on the service writing instruction received by the destination virtual machine.
Thus, the flow shown in fig. 4 is completed.
As can be seen from the flow shown in fig. 4, in this embodiment of the present application, the destination virtual machine may receive the location information indicating the data block in the source disk, when a service write instruction is received and it is determined that the data block in which the first flag is set exists in the data block associated with the service write instruction (i.e., the data block not migrated from the source disk to the destination disk), and obtain the data block in which the first flag is associated with the service write instruction from the source disk according to the location information, so that after the source disk stops migrating data to the destination disk, the data block not migrated from the source disk to the destination disk may be further sent to the destination virtual machine, thereby implementing migration of all data on the source virtual machine.
The method provided by the embodiment of the application is described above. The following describes a device provided in an embodiment of the present application:
referring to fig. 5, fig. 5 is a schematic diagram of an apparatus for implementing data migration according to an embodiment of the present application, where the embodiment of the apparatus is applied to a virtual machine. The device comprises:
a location information sending unit 501, configured to, if the present virtual machine is a source virtual machine, migrate data from a source disk associated with the present virtual machine to a destination disk associated with a destination virtual machine currently mounted on the present virtual machine when performing data migration, stop migrating data from the source disk to the destination disk when detecting a data migration stop event, and send location information of a data block in the source disk, where a first flag is set, to the destination virtual machine, where the first flag is used to represent dirty data;
the target data block obtaining unit 502 is configured to, if the virtual machine is a target virtual machine, receive location information sent by a source virtual machine, and after taking over a service of the source virtual machine and receiving a service writing instruction, determine, as a target data block, a data block in which a first flag is set in a data block associated with the service writing instruction if it is determined that the data block in which the first flag is set is in a data block associated with the service writing instruction, obtain, according to the location information, the target data block from the source virtual machine and write the target data block into a target location in the target disk, where the target disk stores, in the same storage structure manner as the source disk, a data block migrated from the source disk, and the target data block is obtained after the source virtual machine removes the first flag from the data block in the target location in the source disk.
Optionally, the apparatus further comprises:
the global bitmap sending unit is used for setting a first mark for all data blocks in the source disk before data migration if the virtual machine is the source virtual machine, and sending the global bitmap of each data block with the first mark in the source disk to the target virtual machine;
the source virtual machine migrates data from a source disk associated with the virtual machine to a destination disk associated with a destination virtual machine currently mounted on the virtual machine through the location information sending unit 501, and includes:
for each data block to be migrated, which is provided with a first mark, removing the first mark of the data block, migrating the data block with the first mark removed to a target disk, and informing a target virtual machine to update the value of a bit corresponding to the migrated data block in a global bitmap, so that the target virtual machine updates the value of the bit from a first value to a second value, wherein the first value is used for indicating that the corresponding data block is provided with the first mark, and the second value is used for indicating that the corresponding data block is not provided with the first mark.
Optionally, the source virtual machine further performs the following steps in the data migration process through the location information sending unit 501:
when a data writing instruction is received, if a data block corresponding to the data writing instruction in a source disk is not provided with a first mark, setting the first mark on the data block, and informing a target virtual machine to update the value of a bit corresponding to the data block in a global bitmap so that the target virtual machine updates the value of the bit from a second value to a first value; otherwise, maintaining the first flag of the data block set;
and when the fact that the preset iteration condition is met currently is determined, detecting whether a data migration stopping event occurs currently according to the data block with the first mark set in the source disk.
Optionally, the preset iteration condition at least includes: each data block in the source disk, which is initially set with a first mark, is migrated to the destination disk;
the detecting whether the data migration stopping event occurs in the current source virtual machine according to the data block with the first mark set in the source disk comprises the following steps:
and when the number of the data blocks with the first marks set in the source disk is larger than or equal to a set threshold value, determining that the data migration stopping event occurs in the current source virtual machine, otherwise, determining that the data migration stopping event does not occur in the current source virtual machine.
Optionally, the apparatus further comprises:
the global bitmap updating unit is used for determining the data block with the first mark in the target disk according to the position information before determining that the data block with the first mark is in the data block associated with the service writing instruction if the virtual machine is the source virtual machine, searching the bit corresponding to the data block in the obtained global bitmap, and updating the value of the bit from the second value to the first value;
the target virtual machine determines, through the target data block obtaining unit 502, that there is a data block with a first flag set in the data blocks associated with the service write instruction, including:
and searching bit positions corresponding to the data blocks associated with the service writing instructions in the global bitmap, and if the value of the searched bit positions is a first value, determining the data block corresponding to the bit position as the data block with the first mark in the target disk.
Optionally, after the destination virtual machine obtains the target data block from the source virtual machine and writes the target data block to the target location in the destination disk, the global bitmap updating unit is further configured to: and searching bit positions corresponding to the target positions in the global bitmap, and updating the value of the searched bit positions from a first value to a second value.
Optionally, the global bitmap updating unit is further configured to: and when the value of all bits in the global bitmap is the second value, the destination virtual machine controls the source virtual machine to be closed or destroyed.
This completes the block diagram of the embodiment of the apparatus shown in fig. 5.
The foregoing description of the preferred embodiments of the present invention is not intended to limit the invention to the precise form disclosed, and any modifications, equivalents, improvements and alternatives falling within the spirit and principles of the present invention are intended to be included within the scope of the present invention.

Claims (10)

1. A data migration method, wherein the method is applied to a virtual machine, and comprises:
if the virtual machine is a source virtual machine, when data migration is carried out, migrating data from a source disk associated with the virtual machine to a target disk associated with a target virtual machine currently mounted on the virtual machine, and when a data migration stopping event is detected, stopping migrating the data from the source disk to the target disk, and sending position information of a data block with a first mark to the target virtual machine, wherein the first mark is used for representing dirty data;
and if the virtual machine is the destination virtual machine, receiving the position information sent by the source virtual machine, after taking over the service of the source virtual machine and receiving a service writing instruction, if the data block with the first mark is determined to exist in the data block associated with the service writing instruction, determining the data block with the first mark in the data block associated with the service writing instruction as a target data block, and obtaining the target data block from the source virtual machine according to the position information and writing the target data block into a target position in the destination disk, wherein the destination disk stores the data block migrated from the source disk in the same storage structure mode as the source disk, and the target data block is obtained after the source virtual machine removes the first mark from the data block in the target position in the source disk.
2. The method of claim 1, wherein the source virtual machine further performs the following steps prior to data migration: setting a first mark for all data blocks in a source disk, and sending a global bitmap of each data block with the first mark in the source disk to a target virtual machine;
the source virtual machine migrates data from a source disk associated with the virtual machine to a destination disk associated with a destination virtual machine currently mounted by the virtual machine, and the source virtual machine comprises:
for each data block to be migrated, which is provided with a first mark, removing the first mark of the data block, migrating the data block with the first mark removed to a target disk, and informing a target virtual machine to update the value of a bit corresponding to the migrated data block in a global bitmap, so that the target virtual machine updates the value of the bit from a first value to a second value, wherein the first value is used for indicating that the corresponding data block is provided with the first mark, and the second value is used for indicating that the corresponding data block is not provided with the first mark.
3. The method of claim 2, wherein the source virtual machine further performs the following steps in the data migration process:
when a data writing instruction is received, if a data block corresponding to the data writing instruction in a source disk is not provided with a first mark, setting the first mark on the data block, and informing a target virtual machine to update the value of a bit corresponding to the data block in a global bitmap so that the target virtual machine updates the value of the bit from a second value to a first value; otherwise, maintaining the first flag of the data block set;
and when the fact that the preset iteration condition is met currently is determined, detecting whether a data migration stopping event occurs currently according to the data block with the first mark set in the source disk.
4. A method according to claim 3, wherein the predetermined iteration conditions comprise at least: each data block in the source disk, which is initially set with a first mark, is migrated to the destination disk;
the detecting whether the data migration stopping event occurs in the current source virtual machine according to the data block with the first mark set in the source disk comprises the following steps:
and when the number of the data blocks with the first marks set in the source disk is larger than or equal to a set threshold value, determining that the data migration stopping event occurs in the current source virtual machine, otherwise, determining that the data migration stopping event does not occur in the current source virtual machine.
5. The method of claim 2, wherein the destination virtual machine further performs the following steps before determining that there is a data block with the first flag set in the data block associated with the traffic write instruction:
determining a data block with a first mark in a target disk according to the position information, searching a bit corresponding to the data block in the obtained global bitmap, and updating the value of the bit from a second value to a first value;
the destination virtual machine determines that the data block with the first mark set exists in the data blocks associated with the service writing instruction, and the method comprises the following steps:
and searching bit positions corresponding to the data blocks associated with the service writing instructions in the global bitmap, and if the value of the searched bit positions is a first value, determining the data block corresponding to the bit position as the data block with the first mark in the target disk.
6. The method of claim 5, wherein after the destination virtual machine obtains the target data block from the source virtual machine and writes to the target location in the destination disk, further performing the steps of: and searching bit positions corresponding to the target positions in the global bitmap, and updating the value of the searched bit positions from a first value to a second value.
7. The method according to claim 5 or 6, characterized in that the method further comprises:
and when the value of all bits in the global bitmap is the second value, the destination virtual machine controls the source virtual machine to be closed or destroyed.
8. A data migration apparatus, the apparatus being applied to a virtual machine, comprising:
the position information sending unit is used for migrating data from a source disk associated with the virtual machine to a target disk associated with a target virtual machine currently mounted on the virtual machine when the virtual machine is a source virtual machine and stopping migrating the data from the source disk to the target disk when a data migration stopping event is detected, and sending the position information of a data block with a first mark to the target virtual machine, wherein the first mark is used for representing dirty data;
the target data block obtaining unit is configured to, if the virtual machine is a target virtual machine, receive location information sent by a source virtual machine, and after taking over a service of the source virtual machine and receiving a service writing instruction, if it is determined that a data block with a first mark set in a data block associated with the service writing instruction exists, determine the data block with the first mark set in the data block associated with the service writing instruction as a target data block, obtain the target data block from the source virtual machine according to the location information and write the target data block into a target location in the target disk, where the target disk stores the data block migrated from the source disk in a storage structure mode identical to that of the source disk, and the target data block is obtained after the source virtual machine removes the first mark from the data block located in the target location in the source disk.
9. The apparatus of claim 8, wherein the apparatus further comprises:
the global bitmap sending unit is used for setting a first mark for all data blocks in the source disk before data migration if the virtual machine is the source virtual machine, and sending the global bitmap of each data block with the first mark in the source disk to the target virtual machine;
the source virtual machine migrates data from a source disk associated with the virtual machine to a destination disk associated with a destination virtual machine currently mounted on the virtual machine through a position information sending unit, and the method comprises the following steps:
for each data block to be migrated, which is provided with a first mark, removing the first mark of the data block, migrating the data block with the first mark removed to a target disk, and informing a target virtual machine to update the value of a bit corresponding to the migrated data block in a global bitmap, so that the target virtual machine updates the value of the bit from a first value to a second value, wherein the first value is used for indicating that the corresponding data block is provided with the first mark, and the second value is used for indicating that the corresponding data block is not provided with the first mark.
10. The apparatus of claim 9, wherein the apparatus further comprises:
the global bitmap updating unit is used for determining the data block with the first mark in the target disk according to the position information before determining that the data block with the first mark is in the data block associated with the service writing instruction if the virtual machine is the target virtual machine, searching the bit corresponding to the data block in the obtained global bitmap, and updating the value of the bit from the second value to the first value;
the target virtual machine determines, through a target data block acquisition unit, that a data block with a first flag set in the data blocks associated with the service writing instruction exists, including:
and searching bit positions corresponding to the data blocks associated with the service writing instructions in the global bitmap, and if the value of the searched bit positions is a first value, determining the data block corresponding to the bit position as the data block with the first mark in the target disk.
CN202110871800.0A 2021-07-30 2021-07-30 Data migration method and device Active CN113535331B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110871800.0A CN113535331B (en) 2021-07-30 2021-07-30 Data migration method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110871800.0A CN113535331B (en) 2021-07-30 2021-07-30 Data migration method and device

Publications (2)

Publication Number Publication Date
CN113535331A CN113535331A (en) 2021-10-22
CN113535331B true CN113535331B (en) 2024-02-27

Family

ID=78121554

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110871800.0A Active CN113535331B (en) 2021-07-30 2021-07-30 Data migration method and device

Country Status (1)

Country Link
CN (1) CN113535331B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102081552A (en) * 2009-12-01 2011-06-01 华为技术有限公司 Method, device and system for transferring from physical machine to virtual machine on line
CN111506386A (en) * 2020-02-27 2020-08-07 平安科技(深圳)有限公司 Virtual machine online migration method, device, equipment and computer readable storage medium
CN112527452A (en) * 2020-12-03 2021-03-19 北京浪潮数据技术有限公司 Virtual machine migration method, device and medium across OpenStack

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102073462B (en) * 2010-11-29 2013-04-17 华为技术有限公司 Virtual storage migration method and system and virtual machine monitor

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102081552A (en) * 2009-12-01 2011-06-01 华为技术有限公司 Method, device and system for transferring from physical machine to virtual machine on line
CN111506386A (en) * 2020-02-27 2020-08-07 平安科技(深圳)有限公司 Virtual machine online migration method, device, equipment and computer readable storage medium
CN112527452A (en) * 2020-12-03 2021-03-19 北京浪潮数据技术有限公司 Virtual machine migration method, device and medium across OpenStack

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
基于COW双写的虚拟机磁盘全量迁移关键技术;王科;丁倩梅;余万;;现代信息科技;20200810(第15期);全文 *
基于写时重定向的虚拟机磁盘迁移技术;焦术进;白静;;电视技术;20131202(第23期);全文 *

Also Published As

Publication number Publication date
CN113535331A (en) 2021-10-22

Similar Documents

Publication Publication Date Title
CN108733761B (en) Data processing method, device and system
EP3306477B1 (en) Storage device and block storage method based on the storage device
CN107817950B (en) Data processing method and device
CN109407976B (en) Distributed storage method and distributed storage device
US20170371810A1 (en) Data Transmission Method and System
CN109324878A (en) A kind of control method and relevant device of process CPU usage
CN105138481A (en) Stored data processing method and apparatus and system
CN113535331B (en) Data migration method and device
US9442656B2 (en) Efficient use of metadata accompanying file writing to media
CN104134027A (en) Sequence flow recognition method and sequence flow recognition device
CN108664208B (en) File additional writing operation method and device based on FLASH memory
CN110795282B (en) Data rollback method, device, equipment and storage medium
US9535796B2 (en) Method, apparatus and computer for data operation
CN114201458B (en) Information updating method, micro-service system and computer readable storage medium
KR102142675B1 (en) Apparatus for controlling eeprom and method for writing data using same
CN111124256B (en) Method, apparatus and computer program product for managing storage
JP2006350633A (en) Data management method and data management system
CN115328851A (en) Data protection method, device, equipment and medium
CN110825542A (en) Method, device and system for detecting fault disk in distributed system
CN110049149B (en) MAC address learning method and device and distributed equipment
CN111597149B (en) Data cleaning method and device for database
JP6005826B2 (en) Car navigation system and data updating method for car navigation system
CN102591792B (en) Storage method for memory data
JP5855781B2 (en) Car navigation system
CN107577433B (en) Storage medium and file data migration method, device and equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant