CN113535331A - Data migration method and device - Google Patents

Data migration method and device Download PDF

Info

Publication number
CN113535331A
CN113535331A CN202110871800.0A CN202110871800A CN113535331A CN 113535331 A CN113535331 A CN 113535331A CN 202110871800 A CN202110871800 A CN 202110871800A CN 113535331 A CN113535331 A CN 113535331A
Authority
CN
China
Prior art keywords
virtual machine
data block
disk
data
source
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.)
Granted
Application number
CN202110871800.0A
Other languages
Chinese (zh)
Other versions
CN113535331B (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

Images

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

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the application discloses a data migration method and device. The method and the device can stop migrating data from the source disk to the destination disk when a data migration stop event is detected in the process of data migration of the source virtual machine, and sends the location information of the data block in the source disk with the first flag set (i.e. dirty data in the source disk that is not migrated to the destination disk) to the destination virtual machine, so that after the target virtual machine takes over the service of the source virtual machine and receives the service writing instruction, if the data block with the first mark set exists in the data block associated with the service writing instruction, determining the data block with the first mark 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 position information and writing the target data block into a destination disk, the dirty data which is not migrated in the source disk is further migrated, and the problem that the data in the source disk cannot be completely migrated is avoided.

Description

Data migration method and device
Technical Field
The present application 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 traffic on the virtual machine is busy at the moment, data is always written in a disk of the virtual machine, and the data cannot be migrated all the time, so that the migration time is long.
If the data in the virtual machine cannot be migrated all the time, the virtual machine needs to be completely suspended, and then the data which is not migrated is migrated completely by using the time delay of suspending the virtual machine, but due to the limitation of network bandwidth, the data which is not migrated may not be migrated completely within the time delay of suspending the virtual machine, so that the virtual machine cannot complete the migration of all the data.
Disclosure of Invention
The application discloses a data migration method and device, which are used for avoiding the situation that data of a virtual machine cannot be completely migrated when business is busy.
According to a first aspect of the embodiments of the present application, there is provided a data migration method, which is applied to a virtual machine, and includes:
if the virtual machine is a source virtual machine, migrating 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 during data migration, stopping migrating the data from the source disk to the destination disk when a data migration stop event is detected, and sending position information of a data block provided with a first mark in the source disk to the destination virtual machine, wherein the first mark is used for representing dirty data;
if the virtual machine is a destination virtual machine, receiving position 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 is present in a data block associated with the service writing instruction, determining the data block with the first mark 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 position information and writing the target data block to a target position in a target disk, wherein the target 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 by removing the first mark from the data block in the target position in the source disk by the source virtual machine.
According to a second aspect of the embodiments of the present application, there is provided a data migration apparatus, which is applied to a virtual machine, and includes:
a location information sending unit, configured to migrate, if the virtual machine is a source virtual machine, 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 during data migration, and when a data migration stop event is detected, stop migrating the data from the source disk to the destination disk, 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 indicate dirty data;
a target data block obtaining unit, configured to receive, if the virtual machine is a target virtual machine, location information sent by a source virtual machine, and after taking over a service of the source virtual machine and when a service write instruction is received, if the data block with the first mark set exists in the data block associated with the service writing instruction, determining the data block with the first mark 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 position information and writing the target data block to a target position in the target disk, wherein the destination disk stores the data blocks migrated from the source disk according to the same storage structure mode as the source disk, the target data block is obtained by the source virtual machine removing a first mark from the data block in the target position in the source disk.
The technical scheme provided by the embodiment of the application can have the following beneficial effects:
as can be seen from the foregoing technical solutions, in the process of performing data migration by a source virtual machine, when a data migration stop event is detected, the method provided in the present application may stop migrating data from a source disk to a destination disk, and send location information of a data block with a first flag set in the source disk (that is, dirty data that is not migrated in the destination disk in the source disk) to the destination virtual machine, so that when the destination virtual machine takes over a service of the source virtual machine and receives a service write instruction, if it is determined that a data block with the first flag set exists in a data block associated with the service write instruction, the data block with the first flag set in the data block associated with the service write instruction is determined as a target data block, and a target data block is obtained from the source virtual machine according to the location information and written in the destination disk, so as to further migrate dirty data that is not migrated in the source disk, and the data in the source disk cannot be completely migrated is avoided.
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 present specification and together with the description, serve to explain the principles of the specification.
FIG. 1 is a flowchart of a method for implementing data migration according to an embodiment of the present application;
FIG. 2 is a schematic structural 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 flowchart of another method for implementing data migration according to 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 the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the 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 and all possible combinations of one or more of the associated listed items.
It is to be understood that although the terms first, second, third, etc. may be used herein to describe various information, such information should not be limited to these terms. These terms are only used to distinguish one type of information from another. For example, first information may also be referred to as second information, and similarly, second information may also be referred to as first information, without departing from the scope of the present application. The word "if" as used herein may be interpreted as "at … …" or "when … …" or "in response to a determination", depending on the context.
In order to make the technical solutions provided in the embodiments of the present application better understood and make the above objects, features and advantages of the embodiments of the present application more comprehensible, 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 an embodiment, the flow illustrated in fig. 1 may be applied to a virtual machine, which may be a source virtual machine performing data migration.
As shown in fig. 1, the process may include the following steps:
step 101, when data migration is performed, migrating data from a source disk associated with the virtual machine to a destination disk currently mounted by the virtual machine and associated with a destination virtual machine.
In a specific implementation, migrating data from the source disk to the destination disk may be performed when a virtual machine migration instruction is triggered, where the virtual machine migration instruction specifies a flow of operations that the virtual machine migration needs to perform, and the virtual machine migration instruction is performed when the source virtual machine is in a running state and the destination virtual machine is in a suspended running state.
According to the virtual machine migration instruction, when a source virtual machine is triggered to migrate data in a source disk to a destination disk, a Network Block Device (NBD) protocol is based on to mount the destination disk of the destination virtual machine on the source virtual machine, 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 may be further performed, such as starting to execute the migration of data from the source disk to the destination disk. As for how to mount the destination disk to the source virtual machine, reference may be made to related technologies, which are not described herein again.
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, and details are not described here again.
Step 102, when detecting a data migration stop event, stopping migrating data from the source disk to the destination disk, and sending 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 indicate dirty data.
As an embodiment, when a source virtual machine detects a data migration stop event, the source virtual machine suspends operation, stops migrating data from a source disk to a destination disk currently mounted on the source virtual machine, and notifies the destination virtual machine to start operating, so that the destination virtual machine takes over a service of the source virtual machine.
In specific implementation, when a source virtual machine detects a data migration stop event, after the source virtual machine stops migrating data from a source disk to a destination disk currently mounted by the source virtual machine, data blocks with first marks set still exist in the source virtual machine, and the data blocks with the first marks set still have to be migrated to the destination disk. Therefore, in this embodiment of the present application, after stopping data migration, the source virtual machine needs to send location information of a data block in the source disk, to which the first flag is set, to the destination virtual machine to notify the destination virtual machine of a location of a data block in the source disk that has not been migrated to the destination virtual machine.
Illustratively, the location information at least includes a location of the data block in the source disk and a first flag that is set for the data block.
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, data is migrated from a source disk associated with the source virtual machine to a destination disk associated with a destination virtual machine, and when a data migration stop event is detected, the migration of data from the source disk to the destination disk is stopped, and location information of a data block in a source disk of the destination virtual machine, where the data block in which a first flag is set is a dirty data block, and indicates that the data block in the source disk is not migrated to the destination disk, so as to notify the destination virtual machine of the dirty data in a source disk that is not migrated to the destination disk currently.
The above examples are merely for convenience of understanding, and the embodiments of the present application are not particularly limited.
How the data migration of the source virtual machine is performed will be described in detail below with reference to fig. 2 and 3:
as an embodiment, before the data migration of the source virtual machine, the following steps need to be further performed: setting a first mark for all data blocks in a source disk so as to dirty all the data blocks in the source disk, and sending a global bitmap of each data block in the source disk, which is set with the first mark, to a destination virtual machine.
It should be noted that, in this embodiment, the first flag is set for the data block in the source disk, and the first flag may be set according to the data block divided when the data is written in the source disk, or the data in the source disk may be re-divided according to actual requirements, and the divided data block is set after the division is completed. For example, the storage structure of each data block in the source disk can refer to fig. 2.
As an embodiment, a global bitmap sent by the virtual machine to the target virtual machine records a storage structure of a data block in a source disk and whether the data block is set with a first flag, positions of bits in the global bitmap correspond to positions of data blocks in the source disk in the disk one to one, and values of the bits are used for identifying whether the data block is set with the first flag.
In this embodiment, a 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 the first flag is not set for the data block corresponding to the bit.
For example, the global bitmap may be implemented by using a data structure bitmap (bitmap), when a bit in the global bitmap takes a value of 1, the data block corresponding to the bit is set with a first flag, that is, the data block corresponding to the bit is dirty, and when the bit takes a value of 0, the data block corresponding to the bit is not set with the first flag, that is, the data block corresponding to the bit is not dirty. Based on the global bitmap realized by the bitmap, in this embodiment, the global bitmap obtained after setting the first flag for all the data blocks in the source disk can 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 flag for 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 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 in the source disk, for which the first flag is set. For each data block to be migrated, which is set with the first mark, in the process of migrating the data block, the set first mark of the data block is removed first, and then the data block from which the first mark is removed is migrated to the destination disk. When the first mark set in 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 data block with the first mark removed is migrated to the destination disk, and the migration can be realized by copying the data block with the first mark removed and then sending the copied data block to the destination disk.
Meanwhile, since the source virtual machine and the destination virtual machine each store one same global bitmap, in order to ensure synchronization of the contents of the global bitmaps stored in the source virtual machine and the destination virtual machine, so that the destination virtual machine can judge whether all data blocks in the source virtual machine are migrated to the destination disk according to the global bitmaps stored in the destination virtual machine, in the process of migrating the data blocks, the destination virtual machine needs to be notified to update the value of the bit corresponding to the migrated data block in the global bitmap 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, the data blocks in the source disk may be migrated to the destination disk in order of address size. For example, sequentially migrating data block 1 to data block 9 shown in fig. 2, when data block 1 needs to be migrated, the first flag of data block 1 may be removed first, so that the value of the bit corresponding to data block 1 in the global bitmap stored by 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 data block 1 in the global bitmap stored by the destination virtual machine from 1 to 0. As shown in fig. 3, the global bitmap saved in the source virtual machine and the destination virtual machine at this time is updated from the global bitmap a to the global bitmap b.
As an embodiment, in the process of migrating the data blocks, since the source virtual machine is still in operation, if the source virtual machine receives a data write instruction and a data block associated with the data write instruction is to be updated, for a data block in the source disk, which is set with the first flag, and a data block from which the first flag is removed due to being migrated, the following steps are performed:
when a 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 flag, the first flag is set for the data block, a target virtual machine is informed 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, and if the data block corresponding to the data writing instruction is set with the first flag, the set first flag of the data block is maintained.
For example, if the data block 4 in fig. 2 is migrated according to the address size order, and at this time, the data block 1, the data block 2, and the data block 3 have all been migrated to the destination disk, the values of the bits in the global bitmap corresponding to the data block 1, the data block 2, and the data block 3 are all 0 at this time, and if a data write instruction for the data block 2 is received at this time, the source virtual machine will reset the first flag to the data block 2, 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 by the destination virtual machine to be 1.
However, if a data write command for the data block 6 is received at this time, since the data block 6 has not been migrated to the destination disk at this time, and the value of the bit in the global bitmap corresponding to the data block 6 is 1, the first flag set for the data block can be maintained, and it is not necessary to update the global bitmaps in the source virtual machine and the destination virtual machine.
Further, in this embodiment of the application, if it is determined that the data migration condition of the current source virtual machine meets the preset iteration condition, after updating the data block for each data write instruction, it is required to detect whether a data migration stop event occurs in the current source virtual machine according to the data block in which the first flag is set in the source disk.
In an embodiment of the present application, the preset iteration condition at least includes: each data block in the source disk, to which the first flag is initially set, is migrated to the destination disk, that is, the data migration stop event in this embodiment occurs after it is determined that each data block in the source disk has been migrated once.
Optionally, when the number of the data blocks in the source disk, for which the first flag is set, is greater than or equal to a set threshold, it is determined that a data migration stop event occurs in the current source virtual machine, and otherwise, it is determined that a data migration stop event does not occur in the current source virtual machine. When the number of the data blocks in the source disk, to which the first flag is set, is greater than or equal to the set threshold, this indicates that the data blocks are updated frequently and limited by the network bandwidth, and if data migration is continued, the data blocks in the source disk, to which the data blocks are updated, need to be migrated all the time, but the migration speed may be lower than the data block update speed, and at this time, migration continues, and the time required for migration is long, so this embodiment needs to stop data migration in this case.
For example, when it is determined that 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 data block migration rate of the source virtual machine, the threshold value may be determined by using the maximum value of the number of data blocks that can be completely migrated by using the current network bandwidth. Meanwhile, for convenience of application, in this embodiment, the set threshold may be determined by setting a ratio of the maximum number of the data blocks that can be migrated through the network bandwidth to the total number of the data blocks in the source disk.
For example, it is determined that each data block, to which the first flag is initially set, in the source disk is migrated to the destination disk, and the determination may be performed by recording the number of times of migration of each data block, and for each data block to be migrated, to which the first flag is set, after the data block is migrated to the destination disk, updating the number of times of migration corresponding to the data block, and if it is detected that the number of times of migration corresponding to all data blocks in the source disk is greater than 0, determining that each data block, to which the first flag is initially set, in the source disk is migrated to the destination disk.
Optionally, in this embodiment, when migrating each data block in the source disk 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 the source virtual machine may determine that each data block, in the source disk, to which the first flag is initially set, is migrated to the destination disk when detecting that all data blocks in the source disk are set with the second flag.
Meanwhile, it should be noted that, when a data migration stop event is detected, the operation of the source virtual machine needs to be suspended, at this time, there are situations that a data block with a first flag set has not yet been migrated to the destination disk in the source disk, and the source virtual machine may have not yet been notified to update the value of the bit in the global bitmap, so in this embodiment, it is necessary that the source virtual machine sends 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 to fig. 4, fig. 4 is a flowchart of another data migration method according to an embodiment of the present disclosure. As an embodiment, the flow illustrated 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 write instruction, determining whether a data block with a first flag set exists in a data block associated with the service write instruction.
As an embodiment, before the source virtual machine migrates data in the source disk to a destination disk associated with the destination virtual machine, the source virtual machine sends a global bitmap, in the source disk, of each data block to which the first flag is set, to the destination virtual machine.
After receiving the global bitmap, when receiving the data block migrated from the source disk, the destination virtual machine stores the data block according to the storage structure indicated by the global bitmap, 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 that the data block with the first flag is present in the data block associated with the service write instruction in this step 401, this 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 a value of the bit from a second value to the first value.
Further, based on the updated global bitmap, it may be determined whether a data block with a first flag set exists in the data block associated with the service write instruction by looking up a bit corresponding to the data block associated with the service write instruction in the global bitmap. And if the value of the searched bit is the first value, determining the data block corresponding to the bit as the data block in which the first mark is set in the target disk.
Step 402, if it is determined that the data block associated with the service write instruction has the data block with the first flag set, determining the data block with the first flag set in the data block associated with the service write instruction as a target data block, and obtaining the target data block from the source virtual machine according to the location information and writing the target data block to a target location in the target disk.
In this embodiment of the present application, the destination disk stores the data block migrated from the source disk in the same storage structure as the source disk, and the target data block is obtained by removing, by the source virtual machine, the first flag from the data block in the source disk at the target position.
As an embodiment, the destination virtual machine may send, to the source virtual machine, an instruction to acquire the data block at the target location, so as to trigger the source virtual machine to find the data block at the target location, enable the source virtual machine to remove the first tag of the data block, and send the data block from which the first tag is removed as the target data block to the destination virtual machine.
As an embodiment, 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 bit corresponding to the target location 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 detecting that the values of all the bits in the global bitmap are the second values, the destination virtual machine may control the source virtual machine to be turned off or destroyed. Therefore, even if all data blocks in the source disk are not migrated to the destination disk due to busy traffic on the source virtual machine, migration of all data blocks on the source virtual machine can be further completed based on the traffic write instruction received by the destination virtual machine.
The flow shown in fig. 4 is completed.
As can be seen from the flow shown in fig. 4, in this embodiment of the application, when a service write instruction is received and it is determined that a data block with a first flag set exists in the data block associated with the service write instruction (i.e., a data block that is not migrated from the source disk to the destination disk), the destination virtual machine may obtain the data block with the first flag set, which 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 that is 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 the apparatus provided in the embodiments 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 includes:
a location information sending unit 501, configured to migrate, if the virtual machine is a source virtual machine, 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 during data migration, and when a data migration stop event is detected, stop migrating the data from the source disk to the destination disk, 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 indicate dirty data;
a target data block obtaining unit 502, configured to receive, if the virtual machine is a destination virtual machine, 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, if the data block with the first mark set exists in the data block associated with the service writing instruction, determining the data block with the first mark 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 position information and writing the target data block to a target position in the target disk, wherein the destination disk stores the data blocks migrated from the source disk according to the same storage structure mode as the source disk, the target data block is obtained by the source virtual machine removing a first mark from the data block in the target position in the source disk.
Optionally, the apparatus further comprises:
a global bitmap sending unit, configured to set a first flag for all data blocks in a source disk before data migration if the virtual machine is a source virtual machine, and send a global bitmap of each data block in the source disk, to which the first flag is set, to a destination virtual machine;
the migrating, by the source virtual machine through the location information sending unit 501, data from the source disk associated with the source virtual machine to the destination disk currently mounted on the source virtual machine and associated with the destination virtual machine includes:
and for each data block to be migrated, which is set with the first mark, removing the set first mark of the data block, migrating the data block from which the first mark is removed to a destination disk, and notifying the destination virtual machine to update the value of the bit corresponding to the migrated data block in the global bitmap, so that the destination 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 set with the first mark, and the second value is used for indicating that the corresponding data block is not set 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, the first mark is set for the data block, and a target virtual machine is informed 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 mark of the data block;
and when the current preset iteration condition is met, detecting whether a data migration stop event occurs currently according to the data block in which the first mark is set in the source disk.
Optionally, the preset iteration condition at least includes: all data blocks in the source disk, which are initially set with the first marks, are migrated to the destination disk;
the detecting whether a data migration stop event occurs in the current source virtual machine according to the data block in which the first flag is set in the source disk includes:
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 a data migration stop event occurs in the current source virtual machine, otherwise, determining that no data migration stop event occurs in the current source virtual machine.
Optionally, the apparatus further comprises:
a global bitmap updating unit, configured to determine, before determining that a data block with a first flag is set in a data block associated with the service write instruction, if the virtual machine is a source virtual machine, a data block with a first flag set in a destination disk according to the location information, find a bit corresponding to the data block in an obtained global bitmap, and update a value of the bit from a second value to a first value;
the determining, by the target virtual machine through the target data block obtaining unit 502, that there is a data block with a first flag set in the data block associated with the service write instruction includes:
and searching a bit corresponding to the data block associated with the service writing instruction in the global bitmap, and if the value of the searched bit is a first value, determining that the data block corresponding to the bit is a data block with a first mark set in a 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 a bit corresponding to the target position in the global bitmap, and updating the value of the searched bit from a first value to a second value.
Optionally, the global bitmap updating unit is further configured to: and when the values of all the bits in the global bitmap of the destination virtual machine are the second values, controlling the source virtual machine to be closed or destroyed.
Thus, the structure of the embodiment of the apparatus shown in FIG. 5 is completed.
The above description is only exemplary of the present application and should not be taken as limiting the present application, as any modification, equivalent replacement, or improvement made within the spirit and principle of the present application should be included in the scope of protection of the present application.

Claims (10)

1. A data migration method is applied to a virtual machine and comprises the following steps:
if the virtual machine is a source virtual machine, migrating 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 during data migration, stopping migrating the data from the source disk to the destination disk when a data migration stop event is detected, and sending position information of a data block provided with a first mark in the source disk to the destination virtual machine, wherein the first mark is used for representing dirty data;
if the virtual machine is a destination virtual machine, receiving position 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 is present in a data block associated with the service writing instruction, determining the data block with the first mark 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 position information and writing the target data block to a target position in a target disk, wherein the target 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 by removing the first mark from the data block in the target position in the source disk by the source virtual machine.
2. The method of claim 1, wherein the source virtual machine further performs the following steps prior to performing the data migration: setting first marks for all data blocks in a source disk, and sending a global bitmap of each data block in the source disk, to which the first marks are set, to a target virtual machine;
the method for migrating data from a source disk associated with the virtual machine to a target disk currently mounted by the virtual machine and associated with a target virtual machine includes:
and for each data block to be migrated, which is set with the first mark, removing the set first mark of the data block, migrating the data block from which the first mark is removed to a destination disk, and notifying the destination virtual machine to update the value of the bit corresponding to the migrated data block in the global bitmap, so that the destination 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 set with the first mark, and the second value is used for indicating that the corresponding data block is not set with the first mark.
3. The method of claim 2, wherein the source virtual machine further performs the following steps in performing the data migration:
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, the first mark is set for the data block, and a target virtual machine is informed 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 mark of the data block;
and when the current preset iteration condition is met, detecting whether a data migration stop event occurs currently according to the data block in which the first mark is set in the source disk.
4. The method according to claim 3, wherein the preset iteration condition comprises at least: all data blocks in the source disk, which are initially set with the first marks, are migrated to the destination disk;
the detecting whether a data migration stop event occurs in the current source virtual machine according to the data block in which the first flag is set in the source disk includes:
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 a data migration stop event occurs in the current source virtual machine, otherwise, determining that no data migration stop event occurs in the current source virtual machine.
5. The method according to claim 2, wherein the following steps are further performed before the destination virtual machine determines that there is a data block with the first flag set in the data block associated with the service writing instruction:
determining a data block in a target disk, which is provided with a first mark, according to the position information, finding 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 a data block with a first flag set exists in the data blocks associated with the service writing instruction, and the method includes:
and searching a bit corresponding to the data block associated with the service writing instruction in the global bitmap, and if the value of the searched bit is a first value, determining that the data block corresponding to the bit is a data block with a first mark set in a 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 the target data block to the target location in the destination disk, further performing the following steps: and searching a bit corresponding to the target position in the global bitmap, and updating the value of the searched bit from a first value to a second value.
7. The method of claim 5 or 6, further comprising:
and when the values of all the bits in the global bitmap of the destination virtual machine are the second values, controlling the source virtual machine to be closed or destroyed.
8. A data migration device is applied to a virtual machine and comprises the following components:
a location information sending unit, configured to migrate, if the virtual machine is a source virtual machine, 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 during data migration, and when a data migration stop event is detected, stop migrating the data from the source disk to the destination disk, 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 indicate dirty data;
a target data block obtaining unit, configured to receive, if the virtual machine is a target virtual machine, location information sent by a source virtual machine, and after taking over a service of the source virtual machine and when a service write instruction is received, if the data block with the first mark set exists in the data block associated with the service writing instruction, determining the data block with the first mark 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 position information and writing the target data block to a target position in the target disk, wherein the destination disk stores the data blocks migrated from the source disk according to the same storage structure mode as the source disk, the target data block is obtained by the source virtual machine removing a first mark from the data block in the target position in the source disk.
9. The apparatus of claim 8, further comprising:
a global bitmap sending unit, configured to set a first flag for all data blocks in a source disk before data migration if the virtual machine is a source virtual machine, and send a global bitmap of each data block in the source disk, to which the first flag is set, to a destination virtual machine;
the method for migrating data from a source disk associated with the virtual machine to a target disk currently mounted on the virtual machine and associated with a target virtual machine by the source virtual machine through a position information sending unit includes:
and for each data block to be migrated, which is set with the first mark, removing the set first mark of the data block, migrating the data block from which the first mark is removed to a destination disk, and notifying the destination virtual machine to update the value of the bit corresponding to the migrated data block in the global bitmap, so that the destination 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 set with the first mark, and the second value is used for indicating that the corresponding data block is not set with the first mark.
10. The apparatus of claim 9, further comprising:
a global bitmap updating unit, configured to determine, before determining that a data block with a first flag is set in a data block associated with the service write instruction, if the virtual machine is a destination virtual machine, the data block with the first flag set in a destination disk according to the location information, find a bit corresponding to the data block in an obtained global bitmap, and update a value of the bit from a second value to a first value;
the target virtual machine determines, by a target data block obtaining unit, that a data block with a first flag set exists in a data block associated with the service write instruction, and includes:
and searching a bit corresponding to the data block associated with the service writing instruction in the global bitmap, and if the value of the searched bit is a first value, determining that the data block corresponding to the bit is a data block with a first mark set in a 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 true CN113535331A (en) 2021-10-22
CN113535331B 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)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024113543A1 (en) * 2022-11-30 2024-06-06 苏州元脑智能科技有限公司 Data processing method, system, and apparatus, non-volatile readable storage medium, and electronic device

Citations (4)

* 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
US20120137098A1 (en) * 2010-11-29 2012-05-31 Huawei Technologies Co., Ltd. Virtual storage migration method, virtual storage migration system and virtual machine monitor
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

Patent Citations (4)

* 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
US20120137098A1 (en) * 2010-11-29 2012-05-31 Huawei Technologies Co., Ltd. Virtual storage migration method, virtual storage migration system and virtual machine monitor
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
焦术进;白静;: "基于写时重定向的虚拟机磁盘迁移技术", 电视技术, no. 23, 2 December 2013 (2013-12-02) *
王科;丁倩梅;余万;: "基于COW双写的虚拟机磁盘全量迁移关键技术", 现代信息科技, no. 15, 10 August 2020 (2020-08-10) *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024113543A1 (en) * 2022-11-30 2024-06-06 苏州元脑智能科技有限公司 Data processing method, system, and apparatus, non-volatile readable storage medium, and electronic device

Also Published As

Publication number Publication date
CN113535331B (en) 2024-02-27

Similar Documents

Publication Publication Date Title
EP2821925B1 (en) Distributed data processing method and apparatus
EP3306477B1 (en) Storage device and block storage method based on the storage device
EP3502877A1 (en) Data loading method and device
US20080040539A1 (en) Method and system for writing and reading application data
CN109324878A (en) A kind of control method and relevant device of process CPU usage
CN114003349B (en) Virtual machine migration method and equipment
CN103532731A (en) method and device for preventing network configuration of virtual machine from losing
CN111198845B (en) Data migration method, readable storage medium and computing device
CN105574217A (en) Data synchronization method and device of distributed relational database
CN113535331A (en) Data migration method and device
EP1855187A2 (en) Computer system for managing number of writes for storage medium and control method therefor
CN108255576A (en) Live migration of virtual machine abnormality eliminating method, device and storage medium
US20200310924A1 (en) Database replication with continue and tape-type-override functions
CN103729301B (en) Data processing method and device
US20080109607A1 (en) Method, system and article for managing memory
CN111124256B (en) Method, apparatus and computer program product for managing storage
CN114201458B (en) Information updating method, micro-service system and computer readable storage medium
CN101308472B (en) Mirrored volume initial synchronization method and control device
US9372700B2 (en) Network boot system
KR20160113483A (en) Apparatus and Method for updating a snapshot image
US10809939B2 (en) Disk synchronization
JP2008129967A (en) Volume transition program and method
CN112527325A (en) Deployment method and system applied to super-fusion architecture
CN109344011A (en) A kind of data back up method and device
CN113986128B (en) LUN data copying method and device

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