Virtual disk migration method, device, equipment and readable storage medium

文档序号:1627684 发布日期:2020-01-14 浏览:6次 中文

阅读说明:本技术 一种虚拟磁盘迁移方法、装置、设备及可读存储介质 (Virtual disk migration method, device, equipment and readable storage medium ) 是由 冯振 颜秉珩 王理想 杨锋 于 2019-09-05 设计创作,主要内容包括:本申请公开了一种虚拟磁盘迁移方法,包括:若簇中发生数据变更,则将簇在二值表中的标签更新为第一目标值;将簇中的数据拷贝至第二数据中心,并将第一目标值更新为第二目标值;若接收到将虚拟机迁移至第二数据中心的指令,则控制虚拟机停止运行,在二值表中查询第一目标值,并将查询到的第一目标值对应的簇中的数据迁移至第二数据中心。本申请基于二值表预先将部分数据拷贝至第二数据中心,在迁移虚拟机时,只需迁移另外一部分数据,从而降低了数据迁移量和迁移时间,提高了虚拟磁盘和虚拟机的迁移效率。相应地,本申请公开的一种虚拟磁盘迁移装置、设备及可读存储介质,也同样具有上述技术效果。(The application discloses a virtual disk migration method, which comprises the following steps: if the data in the cluster is changed, updating the label of the cluster in the binary table to a first target value; copying the data in the cluster to a second data center, and updating the first target value to a second target value; and if an instruction for migrating the virtual machine to the second data center is received, controlling the virtual machine to stop running, inquiring the first target value in the binary table, and migrating the data in the cluster corresponding to the inquired first target value to the second data center. According to the method and the device, part of data is copied to the second data center in advance based on the binary table, and when the virtual machine is migrated, only the other part of data needs to be migrated, so that the data migration amount and the migration time are reduced, and the migration efficiency of the virtual disk and the virtual machine is improved. Accordingly, the virtual disk migration apparatus, the device and the readable storage medium disclosed by the application also have the technical effects.)

1. A virtual disk migration method is applied to a first data center, and a source virtual disk corresponding to a virtual machine running in the first data center is divided into a plurality of clusters, and includes:

if the data in the cluster is changed, updating the label of the cluster in a binary table to a first target value; copying the data in the cluster to a second data center, and updating the first target value to a second target value;

and if an instruction for migrating the virtual machine to the second data center is received, controlling the virtual machine to stop running, inquiring the first target value in the two-value table, and migrating the data in the cluster corresponding to the inquired first target value to the second data center.

2. The virtual disk migration method according to claim 1, wherein the second data center is a disaster recovery center of the first data center;

if a corresponding backup virtual disk is set for the disaster recovery virtual disk in the second data center, the copying the data in the cluster to the second data center includes: copying the data in the cluster to the backup virtual disk; the disaster recovery virtual disk is arranged in the second data center and used for performing disaster recovery on the data in the source virtual disk;

correspondingly, the migrating the queried data in the cluster corresponding to the first target value to the second data center includes: and migrating the inquired data in the cluster corresponding to the first target value to the backup virtual disk.

3. The virtual disk migration method according to claim 2, wherein after the migrating the queried data in the cluster corresponding to the first target value to the backup virtual disk, the method further comprises:

and the second data center controls the virtual machine to run based on the backup virtual disk.

4. The virtual disk migration method according to claim 3, wherein before controlling the virtual machine to run based on the backup virtual disk, the method further comprises:

and migrating the memory resources of the virtual machine to the backup virtual disk.

5. The virtual disk migration method according to claim 2, wherein the migrating the queried data in the cluster corresponding to the first target value to the second data center includes:

and migrating the queried data in the cluster corresponding to the first target value to the disaster recovery virtual disk.

6. The virtual disk migration method according to any one of claims 2 to 5, wherein the step of initializing the binary table includes:

calculating the difference value between the backup virtual disk and the source virtual disk;

and determining the difference value as an initial label of each cluster in the source virtual disk in the binary table.

7. The virtual disk migration method according to claim 1, wherein the copying the data in the cluster to a second data center includes:

and if the data copying time point is reached, the step of copying the data in the cluster to a second data center is executed.

8. A virtual disk migration apparatus, applied to a first data center, where a source virtual disk corresponding to a virtual machine running in the first data center is divided into a plurality of clusters, includes:

the copying module is used for updating the label of the cluster in the binary table to a first target value if the data in the cluster is changed; copying the data in the cluster to a second data center, and updating the first target value to a second target value;

and the migration module is used for controlling the virtual machine to stop running if an instruction for migrating the virtual machine to the second data center is received, inquiring the first target value in the binary table, and migrating the data in the cluster corresponding to the inquired first target value to the second data center.

9. A virtual disk migration apparatus, comprising:

a memory for storing a computer program;

a processor for executing the computer program to implement the virtual disk migration method of any of claims 1 to 7.

10. A readable storage medium storing a computer program, wherein the computer program when executed by a processor implements the virtual disk migration method of any one of claims 1 to 7.

Technical Field

The present application relates to the field of computer technologies, and in particular, to a virtual disk migration method, apparatus, device, and readable storage medium.

Background

In the prior art, a source end is generally provided with a backup disk, and the backup disk is used for backing up data in a virtual disk corresponding to a virtual machine running at the source end. When the virtual machine at the source end needs to be migrated to the destination end, all data in the backup disk is directly migrated to the destination end, so that migration of the virtual disk corresponding to the virtual machine is completed, and migration of the virtual machine is realized accordingly. Therefore, the existing migration method needs to migrate all the data in the backup disk to the destination end at one time, so that the volume of the migrated data is large, the migration time is prolonged, and the migration efficiency of the virtual disk and the virtual machine is reduced.

Therefore, how to improve the migration efficiency of the virtual disk is a problem to be solved by those skilled in the art.

Disclosure of Invention

In view of the above, an object of the present application is to provide a virtual disk migration method, apparatus, device and readable storage medium, so as to improve the migration efficiency of a virtual disk. The specific scheme is as follows:

in a first aspect, the present application provides a virtual disk migration method, which is applied to a first data center, where a source virtual disk corresponding to a virtual machine running in the first data center is divided into a plurality of clusters, and the method includes:

if the data in the cluster is changed, updating the label of the cluster in the binary table to a first target value; copying the data in the cluster to a second data center, and updating the first target value to a second target value;

and if an instruction for migrating the virtual machine to the second data center is received, controlling the virtual machine to stop running, inquiring the first target value in the binary table, and migrating the data in the cluster corresponding to the inquired first target value to the second data center.

Preferably, the second data center is a disaster recovery center of the first data center; if a corresponding backup virtual disk is set for the disaster recovery virtual disk in the second data center, copying the data in the cluster to the second data center, including: copying the data in the cluster to a backup virtual disk; the disaster recovery virtual disk is arranged in the second data center and used for carrying out disaster recovery on the data in the source virtual disk; correspondingly, migrating the queried data in the cluster corresponding to the first target value to a second data center, including: and migrating the data in the cluster corresponding to the inquired first target value to a backup virtual disk.

Preferably, after migrating the queried data in the cluster corresponding to the first target value to the backup virtual disk, the method further includes:

and the second data center controls the virtual machine to run based on the backup virtual disk.

Preferably, before the controlling virtual machine runs based on the backup virtual disk, the method further includes:

and migrating the memory resources of the virtual machine to the backup virtual disk.

Preferably, migrating the queried data in the cluster corresponding to the first target value to the second data center, including:

and migrating the data in the cluster corresponding to the inquired first target value to the disaster recovery virtual disk.

Preferably, the initializing step of the binary table comprises:

calculating the difference value between the backup virtual disk and the source virtual disk;

and determining the difference value as an initial label of each cluster in the source virtual disk in the binary table.

Preferably, copying the data in the cluster to a second data center includes:

and if the data copying time point is reached, copying the data in the cluster to a second data center.

In a second aspect, the present application provides a virtual disk migration apparatus, which is applied to a first data center, where a source virtual disk corresponding to a virtual machine running in the first data center is divided into a plurality of clusters, and the apparatus includes:

the copying module is used for updating the label of the cluster in the binary table to a first target value if the data in the cluster is changed; copying the data in the cluster to a second data center, and updating the first target value to a second target value;

and the migration module is used for controlling the virtual machine to stop running if an instruction for migrating the virtual machine to the second data center is received, inquiring the first target value in the binary table, and migrating the data in the cluster corresponding to the inquired first target value to the second data center.

In a third aspect, the present application provides a virtual disk migration apparatus, including:

a memory for storing a computer program;

and the processor is used for executing the computer program to realize the virtual disk migration method disclosed in the foregoing.

In a fourth aspect, the present application provides a readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the virtual disk migration method disclosed in the foregoing.

According to the above scheme, the present application provides a virtual disk migration method, which is applied to a first data center, where a source virtual disk corresponding to a virtual machine running in the first data center is divided into a plurality of clusters, and the method includes: if the data in the cluster is changed, updating the label of the cluster in the binary table to a first target value; copying the data in the cluster to a second data center, and updating the first target value to a second target value; and if an instruction for migrating the virtual machine to the second data center is received, controlling the virtual machine to stop running, inquiring the first target value in the binary table, and migrating the data in the cluster corresponding to the inquired first target value to the second data center.

It can be seen that, before migrating the virtual machine to the second data center, the method marks data in the virtual disk with a binary table to distinguish between updated data and non-updated data. Wherein the first target value is used for marking data to be updated; the second target value is used to mark that the data has not been updated or that an update has occurred but has been copied. According to the method and the device, part of data in the virtual disk corresponding to the virtual machine is copied to the second data center in advance based on the binary table, so that only uncopyed data in the virtual disk need to be migrated when the virtual machine is migrated, the data migration amount and the migration time are reduced, and the migration efficiency of the virtual disk and the virtual machine is improved. And when the virtual machine is migrated, the migrated data is data which is not updated all the time in the virtual disk and/or data which is updated but not copied to the second data center.

Accordingly, the virtual disk migration apparatus, the device and the readable storage medium provided by the application also have the technical effects.

Drawings

In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, it is obvious that the drawings in the following description are only embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.

Fig. 1 is a flowchart of a first virtual disk migration method disclosed in the present application;

FIG. 2 is a flowchart of a second virtual disk migration method disclosed in the present application;

FIG. 3 is a schematic diagram of a virtual disk migration system according to the present disclosure;

FIG. 4 is a schematic diagram of a virtual disk migration apparatus according to the present disclosure;

fig. 5 is a schematic diagram of a virtual disk migration apparatus disclosed in the present application.

Detailed Description

The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.

At present, the existing migration method needs to migrate all the data in the backup disk to the destination end at one time, so the volume of the migrated data is large, which prolongs the migration time and reduces the migration efficiency of the virtual disk and the virtual machine. Therefore, the virtual disk migration scheme is provided, and the virtual disk migration efficiency can be improved.

Referring to fig. 1, an embodiment of the present application discloses a first virtual disk migration method, which is applied to a first data center, where a source virtual disk corresponding to a virtual machine running in the first data center is divided into a plurality of clusters, and the method includes:

s101, if data change occurs in the cluster, updating the label of the cluster in the binary table to a first target value;

specifically, when data in a certain cluster in the virtual disk changes, a label of the cluster in the binary table is updated to a first target value, and the first target value is used for marking the updated data.

S102, copying the data in the cluster to a second data center, and updating the first target value to a second target value;

further, the data in the cluster having such a label of the first target value is copied to the second data center, i.e., the updated data is copied to the second data center, while the first target value is updated to a second target value, which is used to mark the non-updated data and/or the updated but copied data.

S103, receiving an instruction for migrating the virtual machine to a second data center;

and S104, controlling the virtual machine to stop running, inquiring the first target value in the binary table, and migrating the data in the cluster corresponding to the inquired first target value to a second data center.

When an instruction for migrating the virtual machine to a second data center is received, querying a first target value in a two-value table, wherein data in a cluster corresponding to the queried first target value comprises: non-updated data, updated but copied data, and data that has not yet been copied updated, i.e., another portion of data that needs to be migrated. Therefore, the part of data is migrated to the second data center, that is, the migration of all data in the virtual disk is completed.

In one embodiment, the step of initializing the binary table comprises: calculating the difference value between the backup virtual disk and the source virtual disk; and determining the difference value as an initial label of each cluster in the source virtual disk in the binary table.

Specifically, the backup virtual disk is also divided into a plurality of clusters, and the clusters in the backup virtual disk correspond to the clusters in the source virtual disk one to one, so that the difference between the backup virtual disk and the source virtual disk is: and backing up the corresponding difference value of each cluster in the virtual disk and each cluster in the source virtual disk. When the data stored in a certain cluster in the backup virtual disk is consistent with the data stored in the corresponding cluster in the virtual disk, the difference between the two can be recorded as "0", otherwise, the difference is recorded as "1". Wherein "0" is the second target value, and "1" is the first target value. Therefore, the label of the cluster in the source virtual disk in the binary table is consistent with the label of the corresponding cluster in the backup virtual disk in the binary table.

It should be noted that, a data copy cycle may be set, and when the data copy time point is reached, the data in the cluster having the label of the first target value is copied to the second data center. That is, the data is copied in batches within a preset time period.

It can be seen that, in the embodiment, before migrating the virtual machine to the second data center, the data in the virtual disk is marked by using the binary table, so as to distinguish between updated data and non-updated data. Wherein the first target value is used for marking data to be updated; the second target value is used to mark that the data has not been updated or that an update has occurred but has been copied. According to the method and the device, part of data in the virtual disk corresponding to the virtual machine is copied to the second data center in advance based on the binary table, so that only uncopyed data in the virtual disk need to be migrated when the virtual machine is migrated, the data migration amount and the migration time are reduced, and the migration efficiency of the virtual disk and the virtual machine is improved.

Referring to fig. 2, an embodiment of the present application discloses a second virtual disk migration method, which is applied to a first data center, where a source virtual disk corresponding to a virtual machine running in the first data center is divided into a plurality of clusters; the second data center is a disaster recovery center of the first data center; the disaster recovery virtual disk is arranged in the second data center and used for carrying out disaster recovery on data in the source virtual disk, and the method comprises the following steps:

s201, if data change occurs in the cluster, updating the label of the cluster in the binary table to a first target value;

s202, copying the data in the cluster to a backup virtual disk in a second data center, and updating the first target value to a second target value;

s203, receiving an instruction for migrating the virtual machine to a second data center;

s204, controlling the virtual machine to stop running, inquiring the first target value in the binary table, and migrating the data in the cluster corresponding to the inquired first target value to the backup virtual disk so that the second data center controls the virtual machine to run based on the backup virtual disk.

In a specific embodiment, before controlling the virtual machine to run based on the backup virtual disk, the method further includes: and migrating the memory resources of the virtual machine to the backup virtual disk. The backup virtual disk is a backup disk of the disaster backup virtual disk.

The step of migrating the data in the cluster corresponding to the inquired first target value to a second data center includes: and migrating the data in the cluster corresponding to the inquired first target value to the disaster recovery virtual disk. That is, when the virtual machine is migrated, the remaining data to be migrated is migrated to the disaster recovery virtual disk, and then the data in the disaster recovery virtual disk is migrated to the backup virtual disk, so that the backup virtual disk stores all the data in the active virtual disk. In this case, the backup virtual disk and the disaster recovery virtual disk store the same data, so that when data in the disaster recovery virtual disk is migrated to the backup virtual disk, only data not in the backup virtual disk is migrated to the backup virtual disk. The data not in the backup virtual disk is: the residual data that needs to be migrated when the virtual machine is migrated.

It should be noted that, implementation steps in this embodiment are the same as or similar to those in the above embodiments, and may be referred to each other when necessary, and are not described again in this embodiment.

As can be seen from the above, in this embodiment, before migrating the virtual machine to the second data center, the data in the virtual disk is marked by using the binary table, so as to distinguish between the updated data and the non-updated data. Wherein the first target value is used for marking data to be updated; the second target value is used to mark that the data has not been updated or that an update has occurred but has been copied. According to the method and the device, part of data in the virtual disk corresponding to the virtual machine is copied to the second data center in advance based on the binary table, so that only uncopyed data in the virtual disk need to be migrated when the virtual machine is migrated, the data migration amount and the migration time are reduced, and the migration efficiency of the virtual disk and the virtual machine is improved.

Referring to fig. 3, an embodiment of the present application discloses a virtual disk migration system, including: data center a (i.e., a first data center) and data center B (i.e., a second data center), where data center a has a plurality of source virtual disks, and each source virtual disk is divided into a plurality of clusters.

The data center B is a disaster backup center of the data center a, and the data center B is provided with a disaster backup virtual disk corresponding to the source virtual disk and a backup disk of the disaster backup virtual disk, i.e., a target virtual disk.

In fig. 3, it is necessary to perform 1) timing data disaster recovery, 2) copy, and 3) storage migration, specifically referring to the following processes:

specifically, the data in the source virtual disk can be copied to the disaster recovery virtual disk at 24 points every day at regular time, and a backup disk-target virtual disk of the disaster recovery virtual disk is further established, then in the next day, the data center a maintains a binary table, and if the data in a certain cluster in the virtual disk in the data center a changes, the cluster is marked as 1 (i.e., a first target value) in the binary table; otherwise, the cluster is marked as 0 (i.e., the second target value) in the binary table. For the cluster marked as 1, the data in the cluster is timely copied to the backup virtual disk of the data center B (i.e., the target virtual disk in fig. 3), and after the copying is completed, the cluster is marked as 0.

If the data center a triggers the virtual machine migration process on the second day, the data center a controls the virtual machine to be migrated to stop running, and queries the cluster marked with 1 in the binary table, and then migrates the data in the cluster marked with 1 to the target virtual disk in the data center B, at this time, all the data in the source virtual disk corresponding to the current virtual machine will be stored in the target virtual disk. At this time, the data in the disaster recovery virtual disk is already stored in the target virtual disk, so that the data therein can be cleared to perform disaster recovery on the data in another source virtual disk at 24 o' clock in the next day.

Further, the data center B migrates the memory resource of the virtual machine corresponding to the source virtual disk in time, and completes the migration of the virtual machine.

It should be noted that the implementation steps in this embodiment are the same as or similar to those in the above embodiments, and therefore, the description of this embodiment is omitted here. If necessary, the reference may be made to each other, and the description of this embodiment is omitted.

When the virtual disk is migrated, the virtual disk does not need to be copied in full, so that the migration time of the virtual machine is reduced, and the migration efficiency of the virtual disk and the virtual machine is improved.

In the following, a virtual disk migration apparatus provided in an embodiment of the present application is introduced, and a virtual disk migration apparatus described below and a virtual disk migration method described above may refer to each other.

Referring to fig. 4, an embodiment of the present application discloses a virtual disk migration apparatus, which is applied to a first data center, where a source virtual disk corresponding to a virtual machine running in the first data center is divided into a plurality of clusters, and the virtual disk migration apparatus includes:

a copy module 401, configured to update a tag of a cluster in a binary table to a first target value if data change occurs in the cluster; copying the data in the cluster to a second data center, and updating the first target value to a second target value;

the migration module 402 is configured to, if an instruction to migrate the virtual machine to the second data center is received, control the virtual machine to stop running, query the first target value in the binary table, and migrate data in a cluster corresponding to the queried first target value to the second data center.

In one embodiment, the second data center is a disaster recovery center of the first data center; if the corresponding backup virtual disk is set for the disaster backup virtual disk in the second data center, then

The copy module is specifically configured to:

copying the data in the cluster to a backup virtual disk; the disaster recovery virtual disk is arranged in the second data center and used for carrying out disaster recovery on the data in the source virtual disk;

accordingly, the migration module is specifically configured to:

and migrating the data in the cluster corresponding to the inquired first target value to a backup virtual disk.

In a specific embodiment, the method further comprises the following steps:

and the second data center migrates the memory resource of the virtual machine to the backup virtual disk and controls the virtual machine to run based on the backup virtual disk.

In a specific embodiment, the migration module is specifically configured to:

and migrating the data in the cluster corresponding to the inquired first target value to the disaster recovery virtual disk.

In a specific embodiment, the virtual disk migration apparatus further includes: a binary table initialization module, the binary table initialization module comprising:

the computing unit is used for computing the difference value between the backup virtual disk and the source virtual disk;

and the determining unit is used for determining the difference value as an initial label of each cluster in the source virtual disk in the binary table.

In one embodiment, the copy module is specifically configured to:

and if the data copying time point is reached, copying the data in the cluster to a second data center.

For more specific working processes of each module and unit in this embodiment, reference may be made to corresponding contents disclosed in the foregoing embodiments, and details are not described here again.

Therefore, the embodiment provides a virtual disk migration device, and the device can reduce data migration volume and migration time and improve the migration efficiency of the virtual disk and the virtual machine.

In the following, a virtual disk migration device provided in an embodiment of the present application is introduced, and a virtual disk migration device described below and a virtual disk migration method and apparatus described above may refer to each other.

Referring to fig. 5, an embodiment of the present application discloses a virtual disk migration apparatus, including:

a memory 501 for storing a computer program;

a processor 502 for executing the computer program to implement the method disclosed in any of the embodiments above.

In the following, a readable storage medium provided by an embodiment of the present application is introduced, and a readable storage medium described below and a virtual disk migration method, apparatus, and device described above may be referred to each other.

A readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the virtual disk migration method disclosed in the foregoing embodiments. For the specific steps of the method, reference may be made to the corresponding contents disclosed in the foregoing embodiments, which are not described herein again.

References in this application to "first," "second," "third," "fourth," etc., if any, are intended to distinguish between similar elements and not necessarily to describe a particular order or sequence. It will be appreciated that the data so used may be interchanged under appropriate circumstances such that the embodiments described herein may be practiced otherwise than as specifically illustrated or described herein. Furthermore, the terms "comprises" and "comprising," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, or apparatus.

It should be noted that the descriptions in this application referring to "first", "second", etc. are for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one such feature. In addition, technical solutions between various embodiments may be combined with each other, but must be realized by a person skilled in the art, and when the technical solutions are contradictory or cannot be realized, such a combination should not be considered to exist, and is not within the protection scope of the present application.

The embodiments are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same or similar parts among the embodiments are referred to each other.

The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of readable storage medium known in the art.

The principle and the implementation of the present application are explained herein by applying specific examples, and the above description of the embodiments is only used to help understand the method and the core idea of the present application; meanwhile, for a person skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.

12页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种存储空间管理方法、系统、电子设备及存储介质

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类