Virtual machine migration method, system and equipment
By creating the overlay file of the first disk of the virtual machine on the destination host, the second virtual machine can be turned on before data migration, solving the problem of long business interruption caused by virtual machine migration in the prior art, achieving a more efficient migration process and better service continuity.
Patent Information
- Application Number
- CN202411687518.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-22
- Publication Date
- 2025-03-04
AI Technical Summary
Existing cross-cloud virtual machine migration methods cause long service interruption times, especially when the data volume is large or the network bandwidth is limited. Traditional migration methods require virtual machines to be shut down to complete data synchronization, resulting in uncontrollable service interruption times.
By creating an overlay file for the first disk of the virtual machine on the destination host, the second virtual machine can be turned on before data migration, thereby shortening the waiting time for the destination host to take over the virtual machine and reducing the business interruption time.
It achieves shortening business interruption time during virtual machine migration, improves migration efficiency, and ensures service continuity.
Smart Images

Figure CN119557048A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of virtual machine technology, and in particular to a virtual machine migration method, system, and device. Background Art
[0002] In a cloud computing environment, cross-cloud virtual machine migration technology is critical to enterprises, as it enables enterprises to flexibly transfer workloads between different cloud service providers based on factors such as cost-effectiveness, performance requirements, and geographic location.
[0003] However, existing cross-cloud VM migration methods often result in significant service interruptions during implementation. Cold migration, as a traditional migration technique, involves shutting down the VM during the entire migration process, resulting in unacceptably long business interruptions. Warm migration techniques, although they allow partial data migration while the VM is running, still require downtime to complete the synchronization of incremental data at the end of the migration, which is still a problem for applications that have strict requirements for service continuity. Moreover, in traditional migration methods, the target platform must wait until the entire data set is copied and verified before starting the VM, which results in a longer process when the amount of data to be migrated is large or the network bandwidth is limited, and the business interruption time is even more uncontrollable. Summary of the invention
[0004] The embodiments of the present application provide a virtual machine migration method, system, and device, which can solve the problem of long service interruption time caused by virtual machine migration in the prior art.
[0005] In order to achieve the above purpose, the embodiment of the present application adopts the following technical solution:
[0006] In a first aspect, an embodiment of the present application provides a virtual machine migration method, the method comprising: obtaining a migration request, the migration request being used to migrate a first virtual machine running on a source host to a destination host, the first virtual machine mounting a first disk; based on the migration request, creating a second virtual machine, and establishing a mapping relationship between the destination host and the first disk, so that the destination host can access the first disk; based on the first disk, creating an overlay file of the first disk on the destination host; mounting the overlay file of the first disk on the second virtual machine, and performing a power-on operation on the second virtual machine; migrating data from the first disk to the second disk of the destination host; and merging the second disk and the overlay file.
[0007] Based on this solution, by creating an overlay file of the first disk on the destination host, the second virtual machine can mount the overlay file and start the second virtual machine before data migration. In this way, the waiting time for the destination host to take over the virtual machine can be shortened, thereby reducing the interruption time of the service.
[0008] In one possible implementation, establishing a mapping relationship between the destination host and the first disk includes: establishing a mapping relationship with the first disk through an access protocol supported by the first host and the virtual machine platform where the second virtual machine is located, the first host being used to establish a mapping relationship with the first disk through an access protocol supported by the virtual machine platform where the first virtual machine is located and configuring the first disk based on the access protocol supported by the virtual machine platform where the second virtual machine is located.
[0009] Based on this solution, by using the migration agent in the first host as an intermediary, the destination host can mount the first disk of the first virtual machine; in this way, the data transfer efficiency can be improved and the compatibility between the source end and the destination end can be enhanced.
[0010] In another possible implementation, the access protocol supported by the virtual machine platform where the second virtual machine is located is the ISCSI protocol.
[0011] Based on this solution, the access and mounting of the first disk is achieved by using the standard ISCSI protocol.
[0012] In another possible implementation, creating the overlay file of the first disk on the destination host based on the first disk includes: creating a file in qcow2 format on the destination host based on the first disk as a basic image file; and using the file in qcow2 format as the overlay file of the first disk.
[0013] Based on this solution, by taking the first disk mounted on the destination host as the basic image, a file in qcow2 format is created as an overlay file; in this way, the action of creating an overlay layer on the basic image can be realized, thereby realizing the creation of the overlay layer conveniently and quickly.
[0014] In another possible implementation, the merging of the second disk and the overlay file includes: writing the data in the second disk into the overlay file; or, writing the data in the overlay file into the second disk; or, redirecting the base image file referenced by the overlay file to the second disk.
[0015] Based on this solution, by writing the second disk and the overlay file to each other, or redirecting the base image referenced by the overlay file to the second disk, the migrated original data and the newly added data can be merged to achieve the effect of migration completion.
[0016] In another possible implementation, after the power-on operation is performed on the second virtual machine, the method further includes: if the second virtual machine has a data write operation request, writing the data corresponding to the data write operation request into the overlay file; and / or, if the second virtual machine has a data read operation request, if the target data corresponding to the data read operation request exists in the overlay file, reading the target data from the overlay file; if the target data does not exist in the overlay file, reading the target data from the first disk.
[0017] Based on this solution, when there is a data write operation request in the second virtual machine, the data corresponding to the data write operation request is written to the overlay file, thereby avoiding modification of the first disk.
[0018] In a second aspect, an embodiment of the present application provides another virtual machine migration method, the method comprising: obtaining a migration request, the migration request being used to migrate a first virtual machine running on a source host to a destination host, the first virtual machine mounting a first disk; based on the migration request, instructing the destination host to: create a second virtual machine, and establish a mapping relationship with the first disk, so that the destination host can access the first disk; create an overlay file of the first disk based on the first disk; mount the overlay file of the first disk on the second virtual machine, and perform a power-on operation on the second virtual machine; after the data of the first disk is migrated to the second disk of the destination host, merge the second disk and the overlay file.
[0019] Based on this solution, by creating an overlay file of the first disk on the destination host, the second virtual machine can mount the overlay file and start the second virtual machine before data migration. In this way, the waiting time for the destination host to take over the virtual machine can be shortened, thereby reducing the interruption time of the service.
[0020] In one possible implementation, the instructing the destination host to establish a mapping relationship with the first disk includes: establishing a mapping relationship between the first host and the first disk through an access protocol supported by the virtual machine platform where the first virtual machine is located; configuring the first disk based on the access protocol supported by the virtual machine platform where the second virtual machine is located; and instructing the destination host to establish a mapping relationship with the first disk through an access protocol supported by the virtual machine platform where the second virtual machine is located.
[0021] Based on this solution, by using the migration agent in the first host as an intermediary, the destination host can mount the first disk of the first virtual machine; in this way, the data transfer efficiency can be improved and the compatibility between the source end and the destination end can be enhanced.
[0022] In another possible implementation, the mapping relationship between the first host and the first disk is established through the access protocol supported by the virtual machine platform where the first virtual machine is located, including: obtaining the platform type corresponding to the virtual machine platform where the first virtual machine is located, and the storage type corresponding to the first disk; based on the platform type and the storage type, determining the access protocol supported by the virtual machine platform where the first virtual machine is located; based on the access protocol, establishing a mapping relationship between the first host and the first disk.
[0023] Based on this solution, the migration agent is used as an intermediary to establish a connection with the source host according to the platform type of the virtual machine platform where the first virtual machine is located and the storage type of the first disk, so that the disk to be migrated on the source host is mounted on the migration agent, and then the disk to be migrated can be mounted on the destination host through the migration agent.
[0024] In yet another possible implementation, the access protocol supported by the virtual machine platform where the second virtual machine is located is the ISCSI protocol.
[0025] Based on this solution, the access and mounting of the first disk is achieved by using the standard ISCSI protocol.
[0026] In another possible implementation, the instructing the destination host to create an overlay file of the first disk based on the first disk includes: instructing the destination host to create a file in qcow2 format on the destination host based on the first disk as a basic image file; and instructing the destination host to use the file in qcow2 format as the overlay file of the first disk.
[0027] Based on this solution, by taking the first disk mounted on the destination host as the basic image, a file in qcow2 format is created as an overlay file; in this way, the action of creating an overlay layer on the basic image can be realized, thereby realizing the creation of the overlay layer conveniently and quickly.
[0028] In another possible implementation, the instructing the destination host to merge the second disk and the overlay file includes: instructing the destination host to write the data in the second disk into the overlay file; or, instructing the destination host to write the data in the overlay file into the second disk; or, instructing the destination host to redirect the base image file referenced by the overlay file to the second disk.
[0029] Based on this solution, by writing the second disk and the overlay file to each other, or redirecting the base image referenced by the overlay file to the second disk, the migrated original data and the newly added data can be merged to achieve the effect of migration completion.
[0030] In a third aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program, and the computer program is used to execute the virtual machine migration method provided in the first aspect above, or the virtual machine migration method provided in the second aspect above.
[0031] In a fourth aspect, an embodiment of the present application provides a computing device, which includes: a processor; a memory for storing processor executable instructions; a processor, configured to read executable instructions from the memory and execute the instructions to implement the following steps: obtaining a migration request, wherein the migration request is used to migrate a first virtual machine running on a source host to a destination host, wherein the first virtual machine mounts a first disk; based on the migration request, creating a second virtual machine, and establishing a mapping relationship between the destination host and the first disk so that the destination host can access the first disk; creating an overlay file of the first disk on the destination host based on the first disk; mounting the overlay file of the first disk on the second virtual machine, and performing a power-on operation on the second virtual machine; migrating data from the first disk to the second disk of the destination host; and merging the second disk and the overlay file.
[0032] In a fifth aspect, an embodiment of the present application provides another computing device, which includes: a processor; a memory for storing processor executable instructions; a processor, configured to read executable instructions from the memory, and execute the instructions to implement the following steps: obtaining a migration request, wherein the migration request is used to migrate a first virtual machine running on a source host to a destination host, wherein the first virtual machine mounts a first disk; based on the migration request, instructing the destination host to create a second virtual machine, and instructing the destination host to establish a mapping relationship with the first disk so that the destination host can access the first disk; instructing the destination host to create an overlay file of the first disk based on the first disk; instructing the destination host to mount the overlay file of the first disk on the second virtual machine, and instructing the destination host to perform a power-on operation on the second virtual machine; migrating data from the first disk to the second disk of the destination host; and instructing the destination host to merge the second disk and the overlay file.
[0033] In a sixth aspect, an embodiment of the present application provides another computing device, which includes: a processor; a memory for storing processor executable instructions; a processor, for reading executable instructions from the memory, and executing the instructions to implement the following steps: creating a second virtual machine, establishing a mapping relationship with a first disk to access the first disk, the first disk being located on a source host, and the first virtual machine on the source host mounting the first disk; creating an overlay file of the first disk based on the first disk; mounting the overlay file of the first disk on the second virtual machine, and performing a power-on operation on the second virtual machine; after the data of the first disk is migrated to the second disk, merging the second disk and the overlay file.
[0034] In a possible implementation, the processor is further configured to obtain a migration request, where the migration request is used to migrate a first virtual machine running on a source host to a destination host, where the first virtual machine mounts a first disk.
[0035] In the seventh aspect, an embodiment of the present application provides a virtual machine migration system, which includes: a migration management module, used to obtain a migration request, the migration request is used to migrate a first virtual machine running on a source host to a destination host, the first virtual machine mounts a first disk; based on the migration request, a second virtual machine is created, and a mapping relationship between the destination host and the first disk is established, so that the destination host can access the first disk; based on the first disk, an overlay file of the first disk is created on the destination host; the overlay file of the first disk is mounted on the second virtual machine, and the second virtual machine is powered on; the data of the first disk is migrated to the second disk of the destination host; the second disk and the overlay file are merged; a migration agent module, used to establish a mapping relationship with the first disk through an access protocol supported by the virtual machine platform where the first virtual machine is located, and configure the first disk based on the access protocol supported by the virtual machine platform where the second virtual machine is located, so that the migration management module can establish a mapping relationship between the destination host and the first disk.
[0036] In an eighth aspect, an embodiment of the present application provides a computer program product. When instructions in the computer program product are executed by a processor, the virtual machine migration method provided in the first aspect or the virtual machine migration method provided in the second aspect is executed. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 A schematic diagram of a network system provided in an embodiment of the present application.
[0038] Figure 2 A flowchart of a virtual machine migration method provided in an embodiment of the present application.
[0039] Figure 3 A flowchart of another virtual machine migration method provided in an embodiment of the present application.
[0040] Figure 4 A flowchart of another virtual machine migration method provided in an embodiment of the present application.
[0041] Figure 5 A flowchart of another virtual machine migration method provided in an embodiment of the present application.
[0042] Fig. 6A A schematic diagram of a virtual machine migration process provided by the prior art.
[0043] Figure 6B A schematic diagram of a virtual machine migration process provided in an embodiment of the present application.
[0044] Figure 7 A flowchart of another virtual machine migration method provided in an embodiment of the present application.
[0045] Figure 8 A schematic diagram of the structure of a virtual machine migration device provided in an embodiment of the present application.
[0046] Fig. 9 A schematic diagram of the structure of another virtual machine migration device provided in an embodiment of the present application.
[0047] Fig.10 A schematic diagram of the structure of a computing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0048] The technical solution in the embodiment of the present application will be described below in conjunction with the drawings in the embodiment of the present application. In order to facilitate the clear description of the technical solution in the embodiment of the present application, the first, second, etc. descriptions appearing in the embodiment of the present application are only used for illustration and distinction of the description objects, and there is no order, nor does it represent a special limitation on the number of devices in the embodiment of the present application, and cannot constitute any limitation on the embodiment of the present application.
[0049] First, the relevant technical terms in the embodiments of the present application are explained:
[0050] Virtual Manufacturing (VM): A virtual machine is a complete computer system that is simulated by software and has complete hardware system functions and runs in a completely isolated environment.
[0051] Cross-platform migration: Cross-platform migration refers to migrating a virtual machine running on a certain hardware or software platform to another hardware or software platform.
[0052] Overlay technology: A data storage method in which newly written data is placed in an overlay layer on top of the original data, rather than being written directly to the original data layer. In other words, overlay technology is a technology that stacks multiple file layers together to add new content to the data or modify the original content without changing the underlying data. In virtualization and storage systems, this technology is used to implement functions such as rapid deployment, snapshots, backup, and recovery of virtual machines.
[0053] qcow2 file: qcow2 is a virtual disk file format that supports copy-on-write and is widely used in virtualization scenarios. It can be used as an overlay file of a disk, acting as an overlay layer in overlay technology, recording all write operations that have occurred since creation.
[0054] ISCSI (Internet Small Computer System Interface) protocol: an IP network-based storage network protocol used to connect storage devices and servers.
[0055] Background data migration: The data transfer process that is performed invisible to the user, usually refers to the data migration work that continues after the virtual machine has started running on the destination host.
[0056] The embodiment of the present application provides a virtual machine migration method, which creates an overlay file of a first disk on a destination host, so that a second virtual machine of the destination host can mount the overlay file and start the second virtual machine before data migration. In this way, the waiting time for the destination host to take over the virtual machine can be shortened, thereby reducing the interruption time of the service.
[0057] The virtual machine migration method provided in the embodiment of the present application can be applied to Figure 1 In the network system shown, the network system includes: a source host 101 , a destination host 102 and a virtual machine migration system 103 , wherein the virtual machine migration system 103 includes a migration management module 1031 and a migration agent (Agent) 1032 .
[0058] The source host 101 runs a first virtual machine to be migrated, the first virtual machine has at least one first disk mounted thereon, and the first virtual machine needs to be migrated to the destination host 102. The source host 101 or the destination host 102 may be a computing device with processing, storage, and transceiver capabilities.
[0059] For example, the computing device may be a blade server, a high-density server, a rack server, or a whole cabinet server, etc. The computing device may be an X86 server, an ARM server, or a graphics processing unit (GPU) server in terms of processor architecture. Of course, the computing device may also be an electronic device such as a personal computer (PC), a tablet computer, etc., and the embodiments of the present application do not limit this.
[0060] It should be noted that the source host 101 and the destination host 102 in the embodiment of the present application are two independent computing devices, such as two different servers.
[0061] It should be understood that the source host 101 may include one virtual machine or multiple virtual machines. The embodiment of the present application does not limit the number of virtual machines running in the source host 101, and does not limit the number of first disks mounted on each virtual machine.
[0062] The migration management module 1031 in the virtual machine migration system 103 is mainly responsible for executing the cross-platform migration task of the virtual machine in the source host 101. It can notify the migration agent 1032 to establish connections with the source host 101 and the destination host 102, and manage the entire virtual machine migration process.
[0063] The migration agent 1032 in the virtual machine migration system 103 is mainly responsible for adapting the storage access protocol of the source host 101 and establishing a connection with the first disk on the source host 101; and providing the disk on the source host 101 to the destination host 102 through the storage protocol adapted by the destination host. For example, the migration agent 1032 can provide the disk on the source host 101 to the destination host 102 through the standard storage protocol ISCSI. The migration agent 1032 can be a virtual machine or a computing device.
[0064] Furthermore, the migration management module 1031 and the migration agent 1032 may be deployed on different computing devices or on the same computing device. When the migration agent 1032 and the migration management module 1031 are deployed on the same computing device, the migration agent 1032 and the migration management module 1031 may be two virtual machines running on the computing device.
[0065] Figure 1The dashed line in the figure represents the data flow of the migration, and the solid line represents the communication flow. Exemplarily, in the migration process, the embodiment of the present application uses the migration agent 1032 as an intermediary to transmit the first disk data of the first virtual machine running on the source host 101 to the destination host 102 in real time. The migration agent 1032 is responsible for adapting the network connection method with the source host 101, and providing the disk of the virtual machine running on the source host 101 to the outside in a way accessible to the destination host 102 (such as ISCSI). The migration management module 1031 has a network communication connection with the source host 101, the destination host 102 and the migration agent 1032.
[0066] It should be noted that the virtual machine migration system 103 can be deployed on the destination host 102 or on other independent computing devices, and the embodiment of the present application does not limit this.
[0067] The network system described in the embodiment of the present application is intended to more clearly illustrate the technical solution of the embodiment of the present application, and does not constitute a limitation on the technical solution provided in the embodiment of the present application. A person of ordinary skill in the art can appreciate that with the evolution of the system architecture, the technical solution provided in the embodiment of the present application is also applicable to similar technical problems.
[0068] Figure 2 A flow chart of a virtual machine migration method provided in an embodiment of the present application. This embodiment can be applied in Figure 1 The destination host 102 is shown in FIG. 1 , and the migration management module 1031 is deployed on the destination host 102, and the migration agent 1032 is deployed on the first host. The first host and the destination host 102 are different computing devices, and the first host and the source host 101 are also different computing devices. Figure 2 As shown, the method includes the following steps S201-S206.
[0069] Step S201: Obtain a migration request, where the migration request is used to migrate a first virtual machine running on a source host to a destination host, and the first virtual machine mounts a first disk.
[0070] For example, Figure 1 As shown, the migration management module 1031 in the destination host 102 can obtain a virtual machine migration request initiated by a user, and the virtual machine migration request is used to migrate the first virtual machine running on the source host 101 to the destination host 102. The first virtual machine can be any virtual machine running on the source host 101, and the first virtual machine can mount one first disk or multiple first disks. At the same time, the first virtual machine can also be called a source virtual machine.
[0071] Step S202: based on the migration request, create a second virtual machine, and establish a mapping relationship between the destination host and the first disk, so that the destination host can access the first disk.
[0072] For example, Figure 1 As shown, after receiving the virtual machine migration request, the migration management module 1031 in the destination host 102 can create a second virtual machine on the destination host 102 as the migrated virtual machine; and the configuration of the second virtual machine is the same as that of the first virtual machine, and the second virtual machine can also be called the destination virtual machine. The configuration of the virtual machine includes but is not limited to: processor, memory, storage, network interface, virtualization management software, security measures and backup, etc.
[0073] In some examples, the migration management module 1031 may establish a mapping relationship between the destination host 102 and the first disk after creating the second virtual machine, so that the destination host can access the first disk. For example, the migration management module may mount the first disk on the destination host, so that the destination host can access the first disk.
[0074] It should be noted that the first virtual machine to be migrated includes at least one first disk. When the disk data in each first disk is migrated, the migration of the first virtual machine is completed.
[0075] Step S203: Create an overlay file of the first disk on the destination host based on the first disk.
[0076] Exemplarily, the migration management module 1031 can check the status of the first virtual machine, wait and confirm whether the first virtual machine on the source host is in a shut down state, to avoid asynchronization of the newly added data. Therefore, when the first virtual machine is in a shut down state, the migration management module 1031 can create an overlay file (i.e., an overlay layer) of the first disk on the destination host 102 based on the first disk accessible to the destination host 102. This is a fast operation that can be completed in seconds, and the overlay file can record all write operations that have occurred since its creation. For example, the first disk mounted on the destination host can be used as the base image file to create an overlay file of the first disk on the destination host.
[0077] Step S204: mount the overlay file of the first disk on the second virtual machine, and start the second virtual machine.
[0078] Exemplarily, after successfully creating the overlay file of the first disk on the destination host 102, the overlay file of the first disk may be mounted on the second virtual machine. After the second virtual machine successfully mounts the overlay file of the first disk, the second virtual machine may be powered on.
[0079] In some examples, after the second virtual machine on the destination host 102 mounts the overlay file, the second virtual machine can be powered on based on the overlay file, and the service is restored. For example, after the second virtual machine on the destination host mounts the overlay file (i.e., the overlay file), the power-on operation of the second virtual machine can be performed.
[0080] In some examples, the migration management module 1031 can mount the overlay file of the first disk on the second virtual machine, so that the second virtual machine can perform a boot operation and then perform read and write operations based on the overlay file. For example, if the second virtual machine has a request to write data, the data is directly written to the overlay file. If the second virtual machine has a request to read data, the target data is read from the overlay file first. If the target data does not exist in the overlay, the target data is read from the base image (such as the first disk mounted on the destination host). For example, the base image is the first disk mounted on the destination host and is only used to read data. The qcow2 image file created with the first disk as the base image is an implementation of overlay, and all data is written to the qcow2 image file. The qcow2 image file is in the upper layer of the base image. When reading data, the qcow2 image file is read first. If there is no base image in the qcow2 image file, the base image is read again. If there is data in the qcow2 image file, it is returned directly.
[0081] In some examples, after the second virtual machine of the destination host 102 mounts the overlay file (i.e., the overlay file), all I / O (input / output) in the second virtual machine is in the overlay file. Because both reading and writing are in the overlay file, the power-on operation of the second virtual machine can be directly executed. Among them, for the second virtual machine, it is to read and write disk data, and the underlying implementation is to read and write overlay files. That is, the overlay file is equivalent to a disk file. In other words, the entity of the overlay layer is a file, which will intercept all write operations. For example, after creating an overlay layer of the first disk on the destination host, all write operations are in the overlay layer, not in the first disk, so as to avoid damaging the data in the first disk. After the second virtual machine on the destination host mounts the overlay layer, the written data is all in the overlay layer and saved on the destination host.
[0082] Step S205: Migrate the data of the first disk to the second disk of the destination host.
[0083] Exemplarily, after the second virtual machine mounts the overlay file of the first disk and boots successfully, the migration management module 1031 in the destination host 102 can silently migrate the disk data of the first disk to the second disk of the second virtual machine in the background.
[0084] In some examples, step S204 and step S205 may be performed in parallel, which is not limited in the embodiments of the present application.
[0085] Step S206: Merge the second disk and the cover layer file.
[0086] Exemplarily, after the disk data migration is completed, the migration management module 1031 can merge the second disk and the overlay file to complete the migration task of the virtual machine. For example, when the first virtual machine is in a shutdown state, the migration management module 1031 can migrate the data of the first disk in the first virtual machine to the second disk of the second virtual machine. Furthermore, when the disk data migration of the first disk is completed, the overlay layer can be merged with the second disk. Alternatively, when the disk data migration of the first disk is completed, the base image referenced by the overlay layer can be redirected to the second disk to complete the data integration process, thereby realizing the migration task of the virtual machine.
[0087] In some examples, for merging the overlay layer and the second disk (i.e., data flattening operation), the data of the base image can be read and written to the overlay file. The data in the overlay file can also be written to the base image, which is the first disk of the first virtual machine.
[0088] In some examples, to redirect the base image referenced by the overlay layer to the second disk, the path of the first disk may be directly replaced with the path of the base image of the second disk.
[0089] Exemplarily, when the data in the second disk and the data in the overlay file are successfully merged, it indicates that the virtual machine migration is completed. At this time, the data of the first virtual machine on the source host 101 has been successfully migrated to the second virtual machine of the destination host 102, and the business has been restored on the second virtual machine. Further, the migration management module 1031 in the destination host 102 unmounts the first disk mounted on the destination host 102, and sends a message of the completion of the virtual machine migration to the migration agent 1032 in the first host, so that the migration agent can unmount the first disk. At the same time, after the cross-platform virtual machine migration task is completed, the migration management module 1031 can notify the user of the corresponding migration result. In this way, the entire migration task of the first virtual machine can be completed when the original data and the newly added data after the migration are successfully merged. In addition, since the second virtual machine has been started and run on the destination host, the business can continue unaffected during the background data migration process, thereby ensuring business continuity. In addition, the method makes full use of the resources of the destination host and does not cause waste of resources while waiting for the completion of data migration.
[0090] The virtual machine migration method provided in the embodiment of the present application creates an overlay file of the first disk on the destination host, so that the second virtual machine can mount the overlay file and then start the second virtual machine before data migration. In this way, the waiting time for the destination host to take over the virtual machine can be shortened, thereby reducing the interruption time of the service.
[0091] like Figure 3 As shown in the above Figure 2 Based on the illustrated embodiment, step S202 may include the following steps S2021 and S2022.
[0092] Step S2021: Create a second virtual machine based on the migration request.
[0093] For example, Figure 1 As shown, the migration management module 1031 in the destination host 102 can create a second virtual machine on the destination host based on the migration request, so that the disk data on the first virtual machine can be migrated to the second virtual machine, thereby realizing the migration task of the virtual machine.
[0094] Step S2022: establish a mapping relationship with the first disk through the access protocol supported by the first host and the virtual machine platform where the second virtual machine is located. The first host is used to establish a mapping relationship with the first disk through the access protocol supported by the virtual machine platform where the first virtual machine is located and configure the first disk based on the access protocol supported by the virtual machine platform where the second virtual machine is located.
[0095] Exemplarily, after obtaining the migration request, the migration management module 1031 on the destination host 102 may send the migration request to the migration agent 1032 on the first host. Further, the migration agent 1032 on the first host may establish a mapping relationship with the first disk through the access protocol supported by the virtual machine platform where the first virtual machine is located, and configure the first disk based on the access protocol supported by the virtual machine platform where the second virtual machine is located, so that the destination host 102 can establish a mapping relationship with the first disk through the migration agent 1032 on the first host and the access protocol supported by the virtual machine platform where the second virtual machine is located.
[0096] In some examples, after receiving the migration request sent by the migration management module 1031 on the destination host 102, the migration agent 1032 on the first host may establish a connection with the source host 101 based on the migration request, such as the migration agent 1032 establishing a connection with the source platform corresponding to the source host 101. The migration agent 1032 may establish a connection with the source platform after performing operations such as authentication through the network. Further, the migration agent 1032 mounts the first disk of the first virtual machine to prepare for data transfer.
[0097] In some examples, after the migration agent 1032 mounts the first disk of the first virtual machine through the access protocol supported by the virtual machine platform where the first virtual machine is located, the ISCSI Server may be configured to provide a block service, and the first disk may be mounted on the block service, thereby providing the first disk to the virtual machine platform in the destination host 102. Furthermore, the migration management module 1031 on the destination host 102 establishes a mapping relationship with the first disk through the access protocol supported by the virtual machine platform where the second virtual machine is located, for example, the destination host mounts the first disk through the access protocol supported by the virtual machine platform where the second virtual machine is located.
[0098] In some examples, if the destination host 102 successfully mounts the first disk of the first virtual machine through the access protocol supported by the first host and the virtual machine platform where the second virtual machine is located, the migration management module 1031 on the destination host can notify the user that the first virtual machine on the source host 101 is about to be shut down and the service will be interrupted. Furthermore, when the migration management module 1031 detects that the first virtual machine is in a completely shut down state, it can create an overlay file based on the first disk mounted on the destination host, and control the second virtual machine to mount the overlay file to enable the second virtual machine to start up.
[0099] The virtual machine migration method provided in the embodiment of the present application uses a migration agent as an intermediary to enable the destination host to mount the first disk of the first virtual machine; in this way, the data transfer efficiency can be improved and the compatibility between the source end and the destination end can be enhanced.
[0100] In some embodiments, the access protocol supported by the virtual machine platform where the second virtual machine is located is the ISCSI protocol.
[0101] In some embodiments, creating an overlay file of the first disk on the destination host based on the first disk includes: creating a qcow2 format file on the destination host based on the first disk as the base image file; and using the qcow2 format file as the overlay file of the first disk.
[0102] For example, taking an implementation of overlay, i.e., a file in qcow2 format, as an example, the first disk mounted on the destination host can be used as the base image to create a file in qcow2 format on the destination host. The advantage of a file in qcow2 format is that it has a directional function, and a file in qcow2 format can realize the action of creating an overlay layer on the base image. The created file in qcow2 format is the overlay file of the first disk.
[0103] In some embodiments, merging the second disk and the overlay file includes: writing data in the second disk to the overlay file; or, writing data in the overlay file to the second disk; or, redirecting the base image file referenced by the overlay file to the second disk.
[0104] Exemplarily, merging the data in the second disk with the data in the overlay file may include multiple implementations, such as writing the data in the second disk into the overlay file, and writing the data in the overlay file into the second disk. Of course, the base image file referenced by the overlay file may also be redirected from the original first disk to the second disk of the second virtual machine.
[0105] It should be noted that those skilled in the art may select a corresponding data merging method according to actual application requirements, and the embodiments of the present application do not limit this.
[0106] In some embodiments, after the power-on operation is performed on the second virtual machine, it also includes: if the second virtual machine has a data write operation request, writing the data corresponding to the data write operation request into the overlay file; and / or, if the second virtual machine has a data read operation request, if there is target data corresponding to the data read operation request in the overlay file, reading the target data from the overlay file; if the target data does not exist in the overlay file, reading the target data from the first disk.
[0107] Exemplarily, after the second virtual machine is powered on, the second virtual machine can run normally. At this time, the second virtual machine may have a request to read or write data. Furthermore, if there is a data write operation request, the data corresponding to the data write operation request is written into the overlay file to avoid modifying the data of the source disk (i.e., the first disk). If there is a data read operation request, first determine whether there is target data corresponding to the data read operation request in the overlay file. If there is target data corresponding to the data read operation request, read the target data from the overlay file; if the target data does not exist in the overlay file, read the data from the mounted first disk.
[0108] Figure 4 1 is a flowchart of a virtual machine migration method provided in an embodiment of the present application. This embodiment can be applied to a first host, and the migration management module 1031 and the migration agent 1032 are both deployed on the first host. The first host and the source host 101 are different computing devices, and the first host and the destination host 102 are also different computing devices. Figure 4 As shown, the method includes the following steps S401-S406.
[0109] Step S401: Obtain a migration request, where the migration request is used to migrate a first virtual machine running on a source host to a destination host, and the first virtual machine mounts a first disk.
[0110] For example, Figure 1 As shown, the migration management module 1031 in the first host can obtain a virtual machine migration request initiated by a user, and the virtual machine migration request is used to migrate the first virtual machine running on the source host 101 to the destination host 102. The first virtual machine can be any virtual machine running on the source host 101, and the first virtual machine can mount one first disk or multiple first disks. At the same time, the first virtual machine can also be called a source virtual machine.
[0111] Step S402: Based on the migration request, instruct the destination host to create a second virtual machine, and instruct the destination host to establish a mapping relationship with the first disk, so that the destination host can access the first disk.
[0112] For example, Figure 1 As shown, after the migration management module 1031 in the first host obtains the migration request of the virtual machine, it can communicate with the destination host 102 to instruct the destination host 102 to create a second virtual machine and instruct the destination host 102 to establish a mapping relationship with the first disk so that the destination host 102 can access the first disk.
[0113] It is understandable that the specific implementation manner of the destination host creating the second virtual machine and the destination host establishing the mapping relationship with the first disk can refer to the implementation manner of the aforementioned step S202, which will not be repeated here.
[0114] Step S403: instruct the destination host to create an overlay file of the first disk based on the first disk.
[0115] Exemplarily, after the destination host 102 establishes a mapping relationship with the first disk and can access the first disk, the migration management module 1031 in the first host can instruct the destination host 102 to create an overlay file of the first disk based on the first disk. It can be understood that the specific implementation method of the destination host creating the overlay file of the first disk based on the first disk can refer to the implementation method of the aforementioned step S203, which will not be repeated here.
[0116] Step S404: instruct the destination host to mount the overlay file of the first disk on the second virtual machine, and instruct the destination host to perform a power-on operation on the second virtual machine.
[0117] For example, after the overlay file is created, the migration management module 1031 in the first host may instruct the destination host 102 to mount the overlay file on the second virtual machine, and instruct the destination host 102 to boot up the second virtual machine.
[0118] It is understandable that the specific implementation manner in which the destination host mounts the overlay file of the first disk on the second virtual machine and the destination host boots up the second virtual machine can refer to the implementation manner of the aforementioned step S204, which will not be repeated here.
[0119] Step S405: Migrate the data of the first disk to the second disk of the destination host.
[0120] Exemplarily, after the second virtual machine is powered on, the migration management module 1031 in the first host migrates the data of the first disk to the second disk of the destination host. It is understandable that the specific implementation of migrating the data of the first disk to the second disk of the destination host can refer to the implementation of the aforementioned step S205, which will not be repeated here.
[0121] Step S406: instruct the destination host to merge the second disk and the overlay layer file.
[0122] Exemplarily, after the disk data migration is completed, the migration management module 1031 in the first host may instruct the destination host 102 to merge the data in the second disk and the overlay file.
[0123] It is understandable that the specific implementation method of the destination host merging the second disk and the overlay layer file can refer to the implementation method of the aforementioned step S206, which will not be repeated here.
[0124] The virtual machine migration method provided in the embodiment of the present application creates an overlay file of the first disk on the destination host, so that the second virtual machine can mount the overlay file and then start the second virtual machine before data migration. In this way, the waiting time for the destination host to take over the virtual machine can be shortened, thereby reducing the interruption time of the service.
[0125] In a possible implementation, when the first host instructs the destination host to complete steps 402, 403, 404 and step 406, it may be one instruction or multiple instructions, and this application does not impose any limitation on this.
[0126] Therefore, an embodiment of the present application further provides a virtual machine migration method, which is applied to a first host and includes:
[0127] Obtaining a migration request, wherein the migration request is used to migrate a first virtual machine running on a source host to a destination host, and the first virtual machine mounts a first disk;
[0128] Based on the migration request, instruct the destination host to: create a second virtual machine and establish a mapping relationship with the first disk so that the destination host can access the first disk; create an overlay file of the first disk based on the first disk; mount the overlay file of the first disk on the second virtual machine and power on the second virtual machine; after the data of the first disk is migrated to the second disk of the destination host, merge the second disk and the overlay file.
[0129] like Figure 5 As shown in the above Figure 4 Based on the illustrated embodiment, step S402 may include the following steps S4021 to S4024.
[0130] Step S4021: Based on the migration request, instruct the destination host to create a second virtual machine.
[0131] For example, Figure 1 As shown, the migration management module 1031 in the first host can instruct the destination host to create a second virtual machine based on the migration request. It can be understood that the specific implementation of the destination host creating the second virtual machine can refer to the implementation of the aforementioned step S2021, which will not be repeated here.
[0132] Step S4022: Establish a mapping relationship between the first host and the first disk through an access protocol supported by the virtual machine platform where the first virtual machine is located.
[0133] Exemplarily, after obtaining the migration request, the migration management module 1031 in the first host may notify the migration agent 1032 in the first host. Further, the migration agent 1032 in the first host may establish a mapping relationship between the first host and the first disk through an access protocol supported by the virtual machine platform where the first virtual machine is located, so that the migration agent 1032 can mount the first disk.
[0134] Step S4023: configure the first disk based on the access protocol supported by the virtual machine platform where the second virtual machine is located.
[0135] Exemplarily, after mounting the first disk, the migration agent 1032 in the first host can configure the first disk based on the access protocol supported by the virtual machine platform where the second virtual machine is located, so that the destination host 102 can establish a mapping relationship with the first disk through the access protocol supported by the virtual machine platform where the second virtual machine is located, thereby mounting the first disk on the destination host 102.
[0136] In some examples, the migration agent 1032 can be used as a server and the destination host 102 as a client. Then the migration agent 1032 configures the target service (such as a block service) based on a preset protocol, and mounts the first disk on the target service, so that the destination host 102 can access the first disk as a client. Among them, the preset protocol includes but is not limited to the ISCSI protocol. For example, the process of the ISCSI Server providing block services can be used as one of the implementations of the migration agent configuring the target service based on the preset protocol. Of course, there can be other implementations of the migration agent configuring the target service based on the preset protocol. The embodiment of the present application does not limit the specific implementation method of the migration agent configuring the target service based on the preset standard protocol.
[0137] In some examples, the migration agent configures the target service based on a preset protocol, and mounts the first disk on the target service so that the destination host can access the migration agent as a server as a client. In this way, the migration agent can provide the first disk to the virtual machine platform on the destination host through a storage protocol (such as ISCSI). In this way, the migration agent can adapt to different protocols to connect with the source host and the destination host, thereby improving the adaptability and compatibility of the migration.
[0138] Step S4024: instruct the destination host to establish a mapping relationship with the first disk through an access protocol supported by the virtual machine platform where the second virtual machine is located, so that the destination host can access the first disk.
[0139] Exemplarily, after the migration agent 1032 configures the first disk, the migration management module 1031 in the first host may instruct the destination host 102 to establish a mapping relationship with the first disk through the access protocol supported by the virtual machine platform where the second virtual machine is located, so that the destination host 102 can access the first disk. For example, after the migration agent configures the first disk based on the access protocol supported by the virtual machine platform where the second virtual machine is located, and as a server, provides the first disk mounted on the migration agent to the destination host through the standard protocol, the migration management module may instruct the destination host to establish a mapping relationship with the first disk as a client through the access protocol supported by the virtual machine platform where the second virtual machine is located (such as the destination host mounts the first disk through the access protocol supported by the virtual machine platform where the second virtual machine is located), so as to access the first disk.
[0140] In some examples, the destination host 102 may first perform security authentication with the migration agent 1032, such as an ID card or some specific security authentication mechanism. After the destination host 102 passes the security authentication with the migration agent 1032, the destination host 102 may mount the first disk to the destination host 102 as a client through a specified storage access protocol, so that the destination host 102 can access the data in the first disk. The specified storage access protocol refers to a pre-agreed storage access protocol. For example, the migration agent may be pre-assigned to use the SCSI protocol, and the destination host may also use the SCSI protocol.
[0141] In some examples, the migration agent acts as an intermediate platform and can be plugged with two network cards, one for the source platform and one for the destination platform. The migration agent can use the source platform network card to communicate with the source host, and use the destination platform network card to communicate with the destination host. Moreover, both the source platform network card and the destination platform network card can be 10G communications, and the transfer function of the migration agent can accelerate the data transmission speed between the source host and the destination host, so that the migration agent can improve the data transfer efficiency.
[0142] For example, if the destination host successfully mounts the first disk, the first virtual machine is shut down, and the user can no longer write data to the first disk, thus avoiding the asynchrony of the newly added data. Subsequent operations can then be performed, such as creating an overlay layer on the original first disk.
[0143] In some examples, if the destination host has mounted the first disk through the migration agent, the migration management module may send a prompt message to the user; wherein the prompt message is used to remind the user to shut down the first virtual machine on the source host; if a shutdown command input by the user is received, the first virtual machine may be shut down. Of course, the first virtual machine may also be automatically shut down directly after the user is reminded of the shutdown operation.
[0144] The virtual machine migration method provided in the embodiment of the present application uses a migration agent as an intermediary to enable the destination host to mount the first disk of the first virtual machine; thus, the data transfer efficiency can be improved, and the compatibility between the source end and the destination end can be enhanced. Moreover, regardless of the network environment of the source host and the destination host, the migration agent can effectively adapt and ensure smooth data migration, thereby enhancing compatibility.
[0145] In some embodiments, a mapping relationship between the first host and the first disk is established through an access protocol supported by the virtual machine platform where the first virtual machine is located, including: obtaining the platform type corresponding to the virtual machine platform where the first virtual machine is located, and the storage type corresponding to the first disk; based on the platform type and the storage type, determining the access protocol supported by the virtual machine platform where the first virtual machine is located; based on the access protocol, establishing a mapping relationship between the first host and the first disk.
[0146] Exemplarily, the migration agent 1032 may first establish a connection with the source host 101. After successfully establishing a connection with the source host 101, the migration agent 1032 may obtain the platform type of the virtual machine platform where the first virtual machine is located, and the storage type corresponding to the first disk. Further, the migration agent 1032 may determine the access protocol and / or access tool supported by the virtual machine platform where the first virtual machine is located based on the platform type and storage type, so that the migration agent on the first host can access the first disk of the first virtual machine based on the access protocol and / or access tool. For example, the access protocol supported by the virtual machine platform where the first virtual machine is located may be the SCSI protocol, and the corresponding access tool may be the SCSI client, which may be integrated into the migration agent. Further, the migration agent 1032 may establish a mapping relationship between the first host and the first disk based on the access protocol, so as to access the first disk. For example, the migration agent may mount the first disk in a manner specified by the virtual machine platform where the first virtual machine is located. Among them, the manner specified by the virtual machine platform of the first virtual machine may be through the NBD (Network Block Device) protocol, and of course it may also be other specified manners. The embodiments of the present application do not limit this.
[0147] In some examples, the platform type corresponding to the virtual machine platform refers to the type of manufacturer to which the virtual machine platform belongs, and different manufacturers use different types of virtual machine platforms. For example, the platform types of the virtual machine platform provided by Huawei and the virtual machine platform provided by Sangfor are different. The storage types of the virtual machine platform include, but are not limited to: VMFS (VMware Virtual Machine File System), NFS (Network File System), ISCSI, FCP (Fibre Channel Protocol), DAS (Direct-Attached Storage), etc. The storage type includes support for virtualized storage, support for non-virtualized storage, or support for file storage, etc.
[0148] In some embodiments, the access protocol supported by the virtual machine platform where the second virtual machine is located is the ISCSI protocol.
[0149] Fig. 6A is a schematic diagram of a virtual machine migration process in the prior art, such as Fig. 6A As shown, the migration process of the existing virtual machine warm migration technology is mainly divided into three stages: Stage 1 is the normal operation stage, in which the full data is migrated while the business is running normally. Stage 2 is the business interruption stage, in which the incremental data is migrated after the source virtual machine is shut down, and the destination virtual machine can be turned on only after the incremental data migration is completed. Stage 3 is the normal operation stage, that is, the stage after the virtual machine migration is completed. In general, the existing virtual machine warm migration technology allows partial data migration while the virtual machine is running, but it still needs to be shut down in the final stage of the migration to complete the synchronization of incremental data, which still poses a problem for applications that have strict requirements for service continuity. If the amount of incremental data is large and / or the network bandwidth is limited, the business interruption time will be extended indefinitely.
[0150] Figure 6B Schematic diagram of the virtual machine migration process in the embodiment of the present application, such as Figure 6B As shown, the virtual machine migration process corresponding to the virtual migration method of the embodiment of the present application is divided into three stages: Stage 1 is the normal operation stage, in which the source disk (i.e., the first disk) is transferred by the migration agent. Stage 2 is the business interruption stage. In this stage, after the source VM (i.e., the first virtual machine) is shut down, the overlay layer is created and mounted in the destination VM (i.e., the second virtual machine), and then the destination VM is powered on using the mounted overlay layer. In this process, only the creation and mounting of the overlay layer by the destination VM will cause business interruption, because the creation and mounting of the overlay layer is a fast operation that can be completed in seconds, so the business interruption time during the virtual machine migration of the embodiment of the present application will be very short. Stage 3 is the normal operation stage, in which the data in the source disk can be silently migrated in the background, and the redirection of the overlay is executed after the data migration of the source disk is completed, so that the data can be merged to complete the entire migration process of the virtual machine. It can be seen that the virtual machine migration method in the embodiment of the present application can solve the problem of long business interruption time during cross-platform virtual machine migration, and shorten the waiting time for the destination platform to take over the virtual machine.
[0151] Figure 7 A flow chart of a virtual machine migration method provided in an embodiment of the present application is shown as follows: Figure 7As shown, the method includes: 1. Network mapping is performed between the source host 101 and the migration agent 1032. The migration agent mounts the source disk of the source virtual machine on the source host through the blk client tool, so that the migration agent can access the source disk. 2. Network mapping is performed between the migration agent 1032 and the destination host 102. The migration agent provides the source disk to the destination host in a block-level access manner through a standardized storage protocol (such as iSCSI), so that the destination host can access the source disk. 3. The source virtual machine of the source host 101 is shut down. 4. Overlay is created on the destination host 102. For example, an overlay file is created on the destination host with an accessible source disk as the base image. 5. The destination virtual machine on the destination host 102 mounts the overlay to start the destination virtual machine on the destination host 102. 6. The destination virtual machine is started to restore the business. 7. Disk data migration is performed. For example, the destination disk is mounted on the destination virtual machine, and the data of the source disk accessible to the destination host is migrated to the destination disk. 8. Redirection is performed. For example, the base image referenced by the overlay is redirected to the destination disk to complete the data integration process. The migration management module 1031 is responsible for executing the cross-platform migration of the virtual machine and notifying the migration agent 1032 to establish a connection with the source host 101 and the destination host 102 .
[0152] Corresponding to the embodiment of the aforementioned virtual machine migration method, the present application also provides an embodiment of a computing device. The computing device includes a processor and a memory for storing processor executable instructions. The processor is used to read executable instructions from the memory and execute instructions to implement the following steps: obtain a migration request, the migration request is used to migrate the first virtual machine running on the source host to the destination host, and the first virtual machine mounts the first disk; based on the migration request, create a second virtual machine, and establish a mapping relationship between the destination host and the first disk so that the destination host can access the first disk; create an overlay file of the first disk on the destination host based on the first disk; mount the overlay file of the first disk on the second virtual machine, and perform a power-on operation on the second virtual machine; migrate the data of the first disk to the second disk of the destination host; merge the second disk and the overlay file.
[0153] Exemplarily, the computing device may be Figure 1 The destination host 102 in. Figure 1 The migration management module 1031 is deployed on the computing device.
[0154] Corresponding to the embodiment of the aforementioned virtual machine migration method, the present application also provides another embodiment of a computing device. The computing device includes a processor and a memory for storing processor executable instructions. The processor is used to read executable instructions from the memory and execute instructions to implement the following steps: obtain a migration request, the migration request is used to migrate the first virtual machine running on the source host to the destination host, and the first virtual machine mounts the first disk; based on the migration request, instruct the destination host to create a second virtual machine, and instruct the destination host to establish a mapping relationship with the first disk so that the destination host can access the first disk; instruct the destination host to create an overlay file of the first disk based on the first disk; instruct the destination host to mount the overlay file of the first disk on the second virtual machine, and instruct the destination host to perform a power-on operation on the second virtual machine; migrate the data of the first disk to the second disk of the destination host; instruct the destination host to merge the second disk and the overlay file.
[0155] Exemplarily, the computing device may be a first host, the first host and Figure 1 The source host 101 and the destination host 102 are shown as different computing devices. Figure 1 The migration management module 1031 and the migration agent 1032 are both deployed on the computing device.
[0156] Based on the above computing device, the present application also provides another embodiment of a computing device. The computing device includes a processor and a memory for storing processor executable instructions. The processor is used to read executable instructions from the memory and execute the instructions to implement the following steps: create a second virtual machine, establish a mapping relationship with the first disk to access the first disk, the first disk is located on the source host, and the first virtual machine on the source host mounts the first disk; create an overlay file of the first disk based on the first disk; mount the overlay file of the first disk on the second virtual machine, and perform a power-on operation on the second virtual machine; after the data of the first disk is migrated to the second disk, merge the second disk and the overlay file.
[0157] Exemplarily, the computing device may be Figure 1 The destination host 102 in.
[0158] It should be noted that the beneficial technical effects corresponding to the above-mentioned computing device exemplary embodiments can be found in the corresponding beneficial technical effects of the above-mentioned method embodiment part, which will not be repeated here.
[0159] Corresponding to the above-mentioned embodiment of the virtual machine migration method, the present application also provides an embodiment of a virtual machine migration system. Figure 1 As shown, the virtual machine migration system 103 includes a migration management module 1031 and a migration agent module 1032.
[0160] The migration management module 1031 is used to obtain a migration request, where the migration request is used to migrate a first virtual machine running on a source host to a destination host, where the first virtual machine mounts a first disk; based on the migration request, create a second virtual machine, and establish a mapping relationship between the destination host and the first disk, so that the destination host can access the first disk;
[0161] Creating an overlay file of the first disk on the destination host based on the first disk; mounting the overlay file of the first disk on the second virtual machine, and powering on the second virtual machine; migrating data of the first disk to the second disk of the destination host; and merging the second disk and the overlay file;
[0162] The migration agent module 1032 is used to establish a mapping relationship with the first disk through the access protocol supported by the virtual machine platform where the first virtual machine is located, and configure the first disk based on the access protocol supported by the virtual machine platform where the second virtual machine is located, so that the migration management module can establish a mapping relationship between the destination host and the first disk.
[0163] It should be noted that the beneficial technical effects corresponding to the exemplary embodiment of the virtual machine migration system 103 can be found in the corresponding beneficial technical effects of the method embodiment part, which will not be repeated here.
[0164] Corresponding to the aforementioned embodiment of the virtual machine migration method, the present application also provides an embodiment of a virtual machine migration device. Figure 8 A virtual machine migration device is provided in an embodiment of the present application, such as Figure 8 As shown, the virtual machine migration device 800 includes a first request acquisition unit 801 , a first migration processing unit 802 , a first service recovery unit 803 and a first data migration unit 804 .
[0165] A first request acquisition unit 801 is used to acquire a migration request, where the migration request is used to migrate a first virtual machine running on a source host to a destination host, and the first virtual machine mounts a first disk;
[0166] The first migration processing unit 802 is used to create a second virtual machine based on the migration request, and establish a mapping relationship between the destination host and the first disk so that the destination host can access the first disk;
[0167] A first business recovery unit 803, configured to create an overlay file of the first disk on a destination host based on the first disk;
[0168] The first business recovery unit 803 is further configured to mount the overlay file of the first disk on the second virtual machine and perform a startup operation on the second virtual machine;
[0169] A first data migration unit 804 is used to migrate data of the first disk to a second disk of a destination host;
[0170] The first data migration unit 804 is further used to merge the second disk and the overlay layer file.
[0171] For example, Figure 1 The migration management module 1031 in the embodiment at least includes a first request acquisition unit 801 , a first migration processing unit 802 , a first service recovery unit 803 and a first data migration unit 804 .
[0172] In one possible implementation, the first migration processing unit 802 is specifically used to create a second virtual machine based on a migration request; establish a mapping relationship with the first disk through an access protocol supported by the first host and the virtual machine platform where the second virtual machine is located, and the first host is used to establish a mapping relationship with the first disk through an access protocol supported by the virtual machine platform where the first virtual machine is located and configure the first disk based on the access protocol supported by the virtual machine platform where the second virtual machine is located.
[0173] In another possible implementation manner, the access protocol supported by the virtual machine platform where the second virtual machine is located is the ISCSI protocol.
[0174] In another possible implementation, the first business recovery unit 803 is specifically configured to create a file in qcow2 format on the destination host based on the first disk as the basic image file; and use the file in qcow2 format as the overlay file of the first disk.
[0175] In another possible implementation, the first data migration unit 804 is specifically used to write the data in the second disk into the overlay file; or, write the data in the overlay file into the second disk; or, redirect the base image file referenced by the overlay file to the second disk.
[0176] In another possible implementation, the virtual machine migration device 800 also includes a read-write processing unit, which is used to write data corresponding to the data write operation request into the overlay file if there is a data write operation request for the second virtual machine; and / or, if there is a data read operation request for the second virtual machine, read the target data from the overlay file if there is target data corresponding to the data read operation request in the overlay file; if there is no target data in the overlay file, read the target data from the first disk.
[0177] The beneficial technical effects corresponding to the exemplary embodiment of the virtual machine migration device 800 can be found in the corresponding beneficial technical effects of the method embodiment, which will not be repeated here.
[0178] Corresponding to the aforementioned embodiment of the virtual machine migration method, the present application also provides another embodiment of the virtual machine migration device. Fig. 9Another virtual machine migration device provided in an embodiment of the present application is as follows: Fig. 9 As shown, the virtual machine migration device 900 includes a second request acquisition unit 901 , a second migration processing unit 902 , a second service recovery unit 903 and a second data migration unit 904 .
[0179] A second request acquisition unit 901 is used to acquire a migration request, where the migration request is used to migrate a first virtual machine running on a source host to a destination host, where the first virtual machine mounts a first disk to run a service;
[0180] A second migration processing unit 902, configured to instruct the destination host to create a second virtual machine based on the migration request, and to instruct the destination host to establish a mapping relationship with the first disk so that the destination host can access the first disk;
[0181] A second business recovery unit 903, configured to instruct the destination host to create an overlay file of the first disk based on the first disk;
[0182] The second service recovery unit 903 is further used to instruct the destination host to mount the overlay file of the first disk on the second virtual machine, and to instruct the destination host to start the second virtual machine;
[0183] A second data migration unit 904, configured to migrate the data of the first disk to a second disk of the destination host;
[0184] The second data migration unit 904 is further configured to instruct the destination host to merge the second disk and the overlay layer file.
[0185] For example, Figure 1 The migration management module 1031 in the embodiment at least includes a second request acquisition unit 901 , a second service recovery unit 903 and a second data migration unit 904 .
[0186] In a possible implementation, the second migration processing unit 902 includes a management submodule and an agent submodule.
[0187] A management submodule, configured to instruct a destination host to create a second virtual machine based on a migration request;
[0188] An agent submodule, used to establish a mapping relationship with the first disk through an access protocol supported by the virtual machine platform where the first virtual machine is located;
[0189] The proxy submodule is further used to configure the first disk based on an access protocol supported by the virtual machine platform where the second virtual machine is located;
[0190] The management submodule is further used to instruct the destination host to establish a mapping relationship with the first disk through an access protocol supported by the virtual machine platform where the second virtual machine is located.
[0191] For example, Figure 1 The migration management module 1031 in at least includes the management submodule. Figure 1 The migration agent 1032 in at least includes the agent submodule.
[0192] In another possible implementation, the proxy sub-module is specifically used to obtain the platform type corresponding to the virtual machine platform where the first virtual machine is located, and the storage type corresponding to the first disk; based on the platform type and the storage type, determine the access protocol supported by the virtual machine platform where the first virtual machine is located; based on the access protocol, establish a mapping relationship between the first host and the first disk.
[0193] In yet another possible implementation, the access protocol supported by the virtual machine platform where the second virtual machine is located is the ISCSI protocol.
[0194] The beneficial technical effects corresponding to the exemplary embodiment of the virtual machine migration device 900 can be found in the corresponding beneficial technical effects of the method embodiment part, which will not be repeated here.
[0195] Fig.10 A schematic diagram of a computing device 100 provided in an embodiment of the present application, the computing device 100 may be Figure 1 The destination host 102 in the embodiment may also be the first host in the above method embodiment. Fig.10 As shown, the hardware entity of the computing device 100 includes: a processor 11, a communication interface 12 and a memory 13, wherein:
[0196] Processor 11 generally controls the overall operation of computing device 100 .
[0197] The communication interface 12 may enable the computing device 100 to communicate with other electronic devices or servers over a network.
[0198] The memory 13 is configured to store instructions and applications executable by the processor 11, and can also cache data to be processed or processed by the processor 11 and various modules in the computing device 100, which can be implemented through FLASH (flash memory) or RAM (Random Access Memory).
[0199] In addition to the above-mentioned methods and devices, embodiments of the present application may also provide a computer program product, including computer program instructions, which, when executed by a processor, enable the processor to execute the steps of the virtual machine migration method of various embodiments of the present application described in the above-mentioned method embodiment section.
[0200] The computer program product may be written in any combination of one or more programming languages to write program codes for performing the operations of the embodiments of the present application, including object-oriented programming languages, such as Java, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0201] In addition, an embodiment of the present application may also be a computer-readable storage medium on which computer program instructions are stored. When the computer program instructions are executed by a processor, the processor executes the steps of the virtual machine migration method of various embodiments of the present application described in the above method embodiment section.
[0202] Computer readable storage media can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium is, for example, but not limited to, a system, device or device including electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0203] The basic principles of the present application are described above in conjunction with specific embodiments. However, the advantages, strengths, effects, etc. mentioned in the present application are only examples and not limitations, and cannot be considered as being required by each embodiment of the present application. In addition, the specific details of the above embodiments are only for the purpose of illustration and ease of understanding, rather than limitation, and the above details do not limit the present application to being implemented by adopting the above specific details.
[0204] Those skilled in the art may make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
[0205] Furthermore, the above-described implementation modes are only specific implementation modes of the present application and are not intended to limit the protection scope of the present application. Any modifications, equivalent substitutions, improvements, etc. made on the basis of the technical solutions of the present application shall be included in the protection scope of the present application.
Claims
1. A virtual machine migration method, characterized in that: The method comprises: Obtain a migration request, where the migration request is used to migrate a first virtual machine running on a source host to a destination host, where the first virtual machine mounts a first disk; Based on the migration request, create a second virtual machine, and establish a mapping relationship between the destination host and the first disk, so that the destination host can access the first disk; Creating an overlay file of the first disk on the destination host based on the first disk; Mounting the overlay file of the first disk on the second virtual machine, and starting up the second virtual machine; Migrating the data of the first disk to the second disk of the destination host; The second disk and the overlay file are merged.
2. The method according to claim 1, characterized in that The establishing of a mapping relationship between the destination host and the first disk includes: A mapping relationship with the first disk is established through an access protocol supported by the first host and the virtual machine platform where the second virtual machine is located. The first host is used to establish a mapping relationship with the first disk through an access protocol supported by the virtual machine platform where the first virtual machine is located, and configure the first disk based on the access protocol supported by the virtual machine platform where the second virtual machine is located.
3. The method according to claim 2, characterized in that The access protocol supported by the virtual machine platform where the second virtual machine is located is the ISCSI protocol.
4. The method according to claim 1, characterized in that: The step of creating an overlay file of the first disk on the destination host based on the first disk includes: Using the first disk as the basic image file, create a file in qcow2 format on the destination host; The file in the qcow2 format is used as a cover layer file of the first disk.
5. The method according to claim 1, characterized in that The merging of the second disk and the cover layer file comprises: writing the data in the second disk into the overlay file; or, writing the data in the overlay file to the second disk; or, The base image file referenced by the overlay file is redirected to the second disk.
6. The method according to any one of claims 1 to 5, characterized in that After the power-on operation is performed on the second virtual machine, the method further includes: If there is a data write operation request for the second virtual machine, write the data corresponding to the data write operation request into the overlay file; and / or, If there is a data read operation request for the second virtual machine, if the target data corresponding to the data read operation request exists in the overlay file, the target data is read from the overlay file; if the target data does not exist in the overlay file, the target data is read from the first disk.
7. A virtual machine migration method, characterized in that: The method comprises: Obtain a migration request, where the migration request is used to migrate a first virtual machine running on a source host to a destination host, where the first virtual machine mounts a first disk; Based on the migration request, instruct the destination host to: Create a second virtual machine, Establishing a mapping relationship with the first disk so that the destination host can access the first disk; creating an overlay file of the first disk based on the first disk; Mounting the overlay file of the first disk on the second virtual machine, and starting up the second virtual machine; After the data on the first disk is migrated to the second disk of the destination host, the second disk and the overlay file are merged.
8. The method according to claim 7, characterized in that The establishing of a mapping relationship with the first disk includes: Establishing a mapping relationship between the first host and the first disk through an access protocol supported by the virtual machine platform where the first virtual machine is located; Configuring the first disk based on an access protocol supported by a virtual machine platform where the second virtual machine is located; Instruct the destination host to establish a mapping relationship with the first disk through an access protocol supported by the virtual machine platform where the second virtual machine is located.
9. The method according to claim 8, characterized in that The establishing a mapping relationship between the first host and the first disk through an access protocol supported by the virtual machine platform where the first virtual machine is located includes: Obtaining a platform type corresponding to the virtual machine platform where the first virtual machine is located, and a storage type corresponding to the first disk; Based on the platform type and the storage type, determining an access protocol supported by the virtual machine platform where the first virtual machine is located; Based on the access protocol, a mapping relationship between the first host and the first disk is established.
10. The method according to claim 8, characterized in that The access protocol supported by the virtual machine platform where the second virtual machine is located is the ISCSI protocol.
11. A computing device, characterized in that: The computing device comprises: processor; a memory for storing instructions executable by the processor; The processor is used to read the executable instructions from the memory and execute the instructions to implement the following steps: create a second virtual machine, establish a mapping relationship with the first disk to access the first disk, the first disk is located on a source host, and the first virtual machine on the source host mounts the first disk; create an overlay file of the first disk based on the first disk; mount the overlay file of the first disk on the second virtual machine, and perform a power-on operation on the second virtual machine; after the data of the first disk is migrated to the second disk, merge the second disk and the overlay file.
12. The computing device according to claim 11, characterized in that The computing device is also used to: A migration request is obtained, where the migration request is used to migrate a first virtual machine running on a source host to a destination host, where the first virtual machine mounts a first disk.
13. A virtual machine migration system, characterized in that: The system comprises: A migration management module, configured to obtain a migration request, wherein the migration request is used to migrate a first virtual machine running on a source host to a destination host, wherein the first virtual machine mounts a first disk; based on the migration request, create a second virtual machine, and establish a mapping relationship between the destination host and the first disk, so that the destination host can access the first disk; Creating an overlay file of the first disk on the destination host based on the first disk; mounting the overlay file of the first disk on the second virtual machine, and powering on the second virtual machine; migrating data of the first disk to the second disk of the destination host; and merging the second disk and the overlay file; A migration agent module is used to establish a mapping relationship with the first disk through an access protocol supported by the virtual machine platform where the first virtual machine is located, and configure the first disk based on the access protocol supported by the virtual machine platform where the second virtual machine is located, so that the migration management module can establish a mapping relationship between the destination host and the first disk.