Virtual machine migration method and device, computer equipment, readable storage medium and program product
By obtaining virtual machine resource data blocks and configuration information, creating matching target virtual machine disks, and writing driver information and management scripts, the complexity and compatibility issues of traditional virtual machine migration methods are solved, achieving efficient and seamless virtual machine migration and recovery.
Patent Information
- Application Number
- CN202411351728.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-26
- Publication Date
- 2025-01-14
- Estimated Expiration
- 2044-09-26
AI Technical Summary
The traditional virtual machine migration method relies on proxy plug-ins in the target virtual machine operating system, which increases operational complexity and system dependence on specific technologies, making it difficult to achieve large-scale seamless migration, especially in terms of compatibility, which affects the business. Continuity.
Generate a backup file by obtaining the resource data block of the current virtual machine, create a target virtual machine disk that matches the current virtual machine configuration information, and write driver information and management scripts to the target virtual machine disk, and create a backup of the carry-on virtual machine based on this information The target virtual machine of the file ensures compatibility and performance stability when running in the new environment.
It realizes efficient virtual machine migration and recovery, ensures data consistency and integrity, improves system automation and flexibility, achieves the purpose of seamless migration and recovery, and improves the efficiency of virtual machine migration.
Smart Images

Figure CN119311371A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of virtualization technology, and in particular to a virtual machine migration method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Art
[0002] With the development of virtualization technology, virtual machine migration has gradually become an important part of enterprise computer infrastructure management. Especially when migrating virtual machines from one platform to another, ensuring seamless system transition is a key challenge.
[0003] Traditional virtual machine migration methods usually rely on deploying proxy plug-ins in the target virtual machine operating system. Although this method can achieve migration, it increases the complexity of operations and the system's dependence on specific technologies. It is difficult to achieve large-scale seamless migration, especially in terms of compatibility. There is a greater risk, which affects business continuity. A more efficient virtual machine migration solution is urgently needed to provide more flexible migration. Summary of the invention
[0004] Based on this, it is necessary to provide a virtual machine migration method, apparatus, computer equipment, computer-readable storage medium and computer program product to address the above technical issues.
[0005] In a first aspect, the present application provides a virtual machine migration method, comprising:
[0006] Obtaining a resource data block of the current virtual machine, and generating a virtual machine backup file according to the resource data block;
[0007] Acquire configuration information of the current virtual machine, and based on the configuration information, create a target virtual machine disk that matches the configuration information of the current virtual machine;
[0008] Writing the virtual machine backup file into the target virtual machine disk, and obtaining the driver information and management script of the target virtual machine to be created, and writing the driver information and management script into the target virtual machine disk;
[0009] Based on the target virtual machine disk including the driver information and the management script, the target virtual machine carrying the virtual machine backup file is created.
[0010] In one embodiment, obtaining the resource data block of the current virtual machine includes:
[0011] Sending a request to obtain the resource data block to the agentless program interface of the current virtual machine;
[0012] If the agentless program interface responds to the request, obtaining the resource data block of the current virtual machine through the agentless program interface;
[0013] If the agentless program interface does not respond to the request, a proxy server of the current virtual machine is determined, and a resource data block of the current virtual machine is obtained through an agent program deployed on the proxy server.
[0014] In one embodiment, creating a target virtual machine disk that matches the configuration information of the current virtual machine based on the configuration information includes:
[0015] Parsing the configuration information of the current virtual machine to obtain parsed configuration information;
[0016] According to the expected configuration parameters customized by the user for the target virtual machine, the parsed configuration information is adjusted to obtain the disk configuration information in the target virtual machine;
[0017] The target virtual machine disk matching the configuration information of the current virtual machine is created according to the disk configuration information.
[0018] In one of the embodiments, writing the virtual machine backup file to the target virtual machine disk includes:
[0019] Determine a data backup host for the target virtual machine, and mount the target virtual machine disk on the data backup host;
[0020] Writing the virtual machine backup file into the data backup host;
[0021] The virtual machine backup file is written to the target virtual machine disk through the data backup host.
[0022] In one embodiment, writing the driver information to the target virtual machine disk includes:
[0023] If the operating system of the target virtual machine is a Linux system, the driver information is written to the target virtual machine disk through the data backup host of the target virtual machine;
[0024] If the operating system of the target virtual machine is Windows, determine a pre-installed image server corresponding to the target virtual machine, mount the pre-installed image server on the data backup host, and mount the target virtual machine disk on the image server;
[0025] The driver information is written into the target virtual machine disk by mounting the pre-installed image server on the backup host.
[0026] In one embodiment, writing the management script to the target virtual machine disk includes:
[0027] Writing the management script to a preset storage location of the target virtual machine disk through a disk operation tool;
[0028] After creating the target virtual machine carrying the virtual machine backup file based on the target virtual machine disk containing the driver information and the management script, the method further includes:
[0029] When the target virtual machine is not started, the files in the virtual machine backup file that are incompatible with the target virtual machine are uninstalled using the management script in the preset storage location.
[0030] In a second aspect, the present application further provides a virtual machine backup module, which is used to obtain resource data blocks of the current virtual machine and generate a virtual machine backup file according to the resource data blocks;
[0031] A target virtual machine disk creation module, used to obtain configuration information of a current virtual machine, and based on the configuration information, create a target virtual machine disk that matches the configuration information of the current virtual machine;
[0032] A backup data writing module, used to write the virtual machine backup file into the target virtual machine disk, and to obtain the driver information and management script of the target virtual machine to be created, and write the driver information and management script into the target virtual machine disk;
[0033] The target virtual machine generation module is used to create the target virtual machine carrying the virtual machine backup file based on the target virtual machine disk containing the driver information and the management script.
[0034] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0035] Obtaining a resource data block of the current virtual machine, and generating a virtual machine backup file according to the resource data block;
[0036] Acquire configuration information of the current virtual machine, and based on the configuration information, create a target virtual machine disk that matches the configuration information of the current virtual machine;
[0037] Writing the virtual machine backup file into the target virtual machine disk, and obtaining the driver information and management script of the target virtual machine to be created, and writing the driver information and management script into the target virtual machine disk;
[0038] Based on the target virtual machine disk including the driver information and the management script, the target virtual machine carrying the virtual machine backup file is created.
[0039] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the following steps are implemented:
[0040] Obtaining a resource data block of the current virtual machine, and generating a virtual machine backup file according to the resource data block;
[0041] Acquire configuration information of the current virtual machine, and based on the configuration information, create a target virtual machine disk that matches the configuration information of the current virtual machine;
[0042] Writing the virtual machine backup file into the target virtual machine disk, and obtaining the driver information and management script of the target virtual machine to be created, and writing the driver information and management script into the target virtual machine disk;
[0043] The target virtual machine carrying the virtual machine backup file is created by using the target virtual machine disk containing the driver information and the management script.
[0044] In a fifth aspect, the present application further provides a computer program product, including a computer program, which implements the following steps when executed by a processor:
[0045] Obtaining a resource data block of the current virtual machine, and generating a virtual machine backup file according to the resource data block;
[0046] Acquire configuration information of the current virtual machine, and based on the configuration information, create a target virtual machine disk that matches the configuration information of the current virtual machine;
[0047] Writing the virtual machine backup file into the target virtual machine disk, and obtaining the driver information and management script of the target virtual machine to be created, and writing the driver information and management script into the target virtual machine disk;
[0048] The target virtual machine carrying the virtual machine backup file is created by using the target virtual machine disk containing the driver information and the management script.
[0049] The above-mentioned virtual machine migration method, device, computer equipment, computer-readable storage medium and computer program product obtain the resource data block of the current virtual machine and generate a virtual machine backup file based on the resource data block; obtain the configuration information of the current virtual machine, and create a target virtual machine disk that matches the configuration information of the current virtual machine based on the configuration information; write the virtual machine backup file to the target virtual machine disk, and obtain the driver information and management script of the target virtual machine to be created, and write the driver information and management script to the target virtual machine disk; create a target virtual machine carrying the virtual machine backup file based on the target virtual machine disk containing the driver information and management script. In this application, by effectively acquiring the resource data of the virtual machine and generating a backup file for migration or recovery, the efficiency of backup is improved, and the consistency and integrity of data are ensured. The server generates a target virtual machine disk that matches the current virtual machine based on its configuration information, achieving the purpose of efficient migration and recovery, ensuring the compatibility and performance stability of the virtual machine when running in a new environment. At the same time, by writing driver information and management scripts, an automated configuration adjustment means is provided for the virtual machine in the new environment, achieving rapid startup and environmental adaptation of the virtual machine, improving system automation and flexibility, and achieving the purpose of seamless migration and recovery. Finally, based on the target virtual machine disk containing driver information and management scripts, a target virtual machine carrying a virtual machine backup file is created, ensuring that the virtual machine can be quickly deployed and started smoothly when migrating or recovering across platforms. Thus, the efficiency of virtual machine migration is significantly improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0051] FIG1 is a schematic diagram of a flow chart of a virtual machine migration method in one embodiment;
[0052] FIG2 is a schematic diagram of a process for obtaining virtual machine backup data in one embodiment;
[0053] FIG3 is a schematic diagram of a process of creating a target virtual machine disk in one embodiment;
[0054] FIG4 is a schematic diagram of a process of writing backup data in one embodiment;
[0055] FIG5 is a schematic diagram of a process of injecting a driver into a target virtual machine disk in one embodiment;
[0056] FIG6 is a schematic diagram of a process of writing a virtual machine management script in one embodiment;
[0057] FIG7 is a schematic diagram of a process of creating a target virtual machine in one embodiment;
[0058] FIG8 is a structural block diagram of a virtual machine migration device in one embodiment;
[0059] FIG. 9 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0060] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0061] In one embodiment, as shown in FIG1 , a virtual machine migration method is provided. This embodiment is illustrated by applying the method to a server. It is understandable that the method can also be applied to a terminal, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. In this embodiment, the method includes the following steps:
[0062] Step S102: Obtain resource data blocks of the current virtual machine, and generate a virtual machine backup file according to the resource data blocks.
[0063] The virtual machine resource data block is a collection of memory, storage and other system resources in the virtual machine system, which constitute the operating environment of the virtual machine. The virtual machine backup file is a file used to save the current state of the virtual machine. It contains the resource data block, virtual hard disk and configuration information of the virtual machine, with the purpose of being able to restore this data on the target virtual machine.
[0064] Exemplarily, the server establishes a connection with the virtual machine interface and first sends a request to obtain the resource data blocks of the current virtual machine. In one embodiment, the server calls the virtual machine management interface, interacts with the virtual machine through the virtual machine management interface, retrieves the memory, CPU, disk and other information of the virtual machine, and packages these data blocks in binary or standard format.
[0065] To ensure data consistency, the server can prevent data changes by locking the state of the virtual machine during execution, so that the acquired data can accurately reflect the state of the virtual machine at a specific moment. The acquired resource data blocks are stored in the local storage of the server as intermediate data to be further processed in subsequent steps.
[0066] Next, the server packages and compresses these resource data blocks to generate a virtual machine backup file. The virtual machine backup file can include multiple formats, such as Open Virtualization Format (OVF), Quick Emulation Copy Version 2 (QEMU Copy On Write version 2, QCOW2), Virtual Hard Disk v2 (VHDX), etc., which can be set according to user needs and the configuration of the target system. The virtual machine backup file can be stored on the server local disk, waiting for subsequent recovery operations.
[0067] Step S104: obtaining configuration information of the current virtual machine, and based on the configuration information, creating a target virtual machine disk that matches the configuration information of the current virtual machine.
[0068] Among them, the configuration information of the current virtual machine refers to a set of parameters in the virtualization environment. These parameters define the hardware and software configuration of the virtual machine, including but not limited to the number of CPUs, memory size, storage configuration, network interface configuration, virtual disk format and file system, etc., which can control the operating status of the virtual machine and its demand for hardware resources.
[0069] The target virtual machine disk refers to the virtual disk created by the server for the target virtual machine. It is the carrier for restoring the virtual machine backup file. It can ensure that the restored or migrated virtual machine can run normally.
[0070] Exemplarily, the server first obtains the configuration information of the current virtual machine through the application programming interface (API) or management tool of the virtualization platform. After obtaining the configuration information, the server starts to create the corresponding virtual machine disk in the storage system of the target virtual machine according to these parameters. The server customizes the target virtual machine disk according to the configuration information. In one embodiment, the server can selectively adjust the configuration information to meet the compatibility requirements between different virtualization platforms. For example, if the disk format is incompatible, the server can convert it into a virtual disk format supported by the target platform.
[0071] Optionally, before generating the target virtual machine disk, the server can perform disk partitioning and file system optimization according to different storage requirements. In a specific embodiment, when the target platform has high-performance storage resources, the server can choose to configure the file system into a more efficient structure, or use a disk partitioning method that is more suitable for large-scale data processing to improve the operating efficiency of the virtual machine on the target platform.
[0072] Step S106, writing the virtual machine backup file into the target virtual machine disk, and obtaining the driver information and management script of the target virtual machine to be created, and writing the driver information and management script into the target virtual machine disk.
[0073] Driver information is an important part of the compatibility between the target virtual machine operating system and the hardware environment. The installation of the driver ensures the normal operation of the virtual machine on the target platform. The management script is a set of commands written in a scripting language to ensure that the virtual machine can automatically adapt to the hardware and network configuration on different platforms.
[0074] Optionally, the server first extracts the saved virtual machine backup file from the local storage system, and writes the backup file to the target virtual machine disk, which can be written by direct copying or data block level.
[0075] After the backup file is written, the server further obtains the driver information and management scripts required by the target virtual machine. The driver information may include basic drivers for supporting the target platform hardware, including but not limited to storage controllers, network adapters, etc., and the management script may include system commands or batch scripts for automated configuration. When writing driver information and management scripts, the server can optimize according to different target virtual machine environments by selecting different drivers or making configuration adjustments.
[0076] Step S108: creating a target virtual machine carrying a virtual machine backup file based on the target virtual machine disk containing the driver information and the management script.
[0077] Exemplarily, the server starts the creation process of the target virtual machine through the management interface of the virtualization platform. In this process, the server first extracts and loads driver information from the target virtual machine disk, and the driver information may include a network adapter, a storage controller, and the like.
[0078] When the driver information is loaded into the operating system, the virtual machine can complete the initialization docking with the target hardware. In a specific embodiment, when the driver information is loaded into the operating system, the operating system will identify the storage architecture of the new platform and ensure the normal reading and writing operations through the driver program. The driver of the network adapter enables the virtual machine to access the network and realize communication with external devices.
[0079] On the other hand, the server also executes management scripts. Management scripts are run when the virtual machine is created. These scripts can automatically adjust the configuration of the virtual machine to adapt it to the hardware and software environment of the new platform. Specific operations may include configuring network addresses, adjusting system performance parameters, starting necessary services, or installing additional software packages.
[0080] In this embodiment, by effectively acquiring the resource data of the virtual machine and generating a backup file for migration or recovery, the backup efficiency is improved, and the consistency and integrity of the data are ensured. The server generates a target virtual machine disk that matches the current virtual machine based on its configuration information, achieving the purpose of efficient migration and recovery, ensuring the compatibility and performance stability of the virtual machine when it runs in a new environment. At the same time, by writing driver information and management scripts, an automated configuration adjustment means is provided for the virtual machine in the new environment, achieving rapid startup and environmental adaptation of the virtual machine, improving system automation and flexibility, and achieving the purpose of seamless migration and recovery. Finally, based on the target virtual machine disk containing driver information and management scripts, a target virtual machine carrying a virtual machine backup file is created, ensuring that the virtual machine can be quickly deployed and smoothly started when migrating or recovering across platforms. Thus, the efficiency of virtual machine migration is significantly improved.
[0081] In an exemplary embodiment, obtaining the resource data block of the current virtual machine includes: sending a request to obtain the resource data block to the agentless program interface of the current virtual machine; if the agentless program interface responds to the request, obtaining the resource data block of the current virtual machine through the agentless program interface; if the agentless program interface does not respond to the request, determining the proxy server of the current virtual machine, and obtaining the resource data block of the current virtual machine through the agent deployed on the proxy server.
[0082] Among them, the agentless interface is an API that directly interacts with a virtual machine or a virtualization platform, and can obtain the status and resource data of the virtual machine without installing additional software agents inside the virtual machine.
[0083] The proxy server is an intermediate server located between the virtual machine and the backup system. It is used to indirectly obtain the resource data blocks of the virtual machine through the agent program running on the proxy server when the agentless interface is unavailable.
[0084] Specifically, as shown in Figure 2, the server first directly sends a request to the virtual machine through the VDDK (Virtual Disk Development Kit) API of the virtualization platform to capture the disk data blocks of the virtual machine. The VDDK API provides an agentless program interface function, allowing the server to directly access the virtual machine's disk, memory and other key data.
[0085] If the VDDK API responds successfully, the server captures the resource data blocks of the virtual machine through the interface, mainly including the current disk usage, partition structure, file system status, etc. of the virtual machine. These data are immediately transmitted to the backup system by the server and are persisted in the backup system to form the backup file of the virtual machine. The server also captures the offset information of the virtual machine to accurately restore the disk content.
[0086] If the VDDK API cannot respond to the request, the server immediately switches to proxy server mode. At this point, the server no longer communicates directly with the virtual machine, but obtains the virtual machine's data through the proxy server. In proxy server mode, the proxy server has pre-deployed an agent program. The agent program is designed to be able to communicate indirectly with the virtual machine and capture the resource data of the virtual machine through the virtual machine monitor or virtual disk management tool. The agent program captures the disk data blocks and offset information of the virtual machine through the proxy server interface and transmits it to the backup system.
[0087] In this embodiment, when the agentless program interface is working normally, the server can efficiently and directly obtain data and transmit it to the backup system; when the agentless program interface is not available, the proxy server and the agent program provide a reliable backup path to ensure that the backup process of the virtual machine will not be interrupted, greatly improving the reliability and flexibility of the virtual machine backup operation.
[0088] In an exemplary embodiment, based on the configuration information, a target virtual machine disk that matches the configuration information of the current virtual machine is created, including: parsing the configuration information of the current virtual machine to obtain the parsed configuration information; adjusting the parsed configuration information according to the expected configuration parameters customized by the user for the target virtual machine to obtain the disk configuration information in the target virtual machine; and creating a target virtual machine disk that matches the configuration information of the current virtual machine according to the disk configuration information.
[0089] Specifically, as shown in Figure 3, the server obtains the disk configuration information of the virtual machine from the virtual machine of the source cloud platform through the backup system. The server extracts the disk-related configuration information from the operating environment of the virtual machine and converts the configuration information into formatted data that can be used to create the target disk.
[0090] After the server obtains the user-defined target disk configuration parameters, it will adjust the parsed disk configuration information according to these target disk parameters. The user can specify a new disk size, file system type, or specific partition requirements. During this process, the server adjusts the parsed configuration according to the user's requirements. In a specific embodiment, if the user wants the file system format of the target disk to be different from that of the original virtual machine, the server will modify the disk configuration according to the new requirements to meet the new operating environment.
[0091] After parsing and adjusting the configuration information, the server creates the target virtual machine disk on the target platform through the target platform's API interface. The server is responsible for allocating storage resources, initializing the file system, and setting the disk partition structure to ensure that the configuration of the target disk matches the original virtual machine and meets the user's additional customization requirements.
[0092] In this embodiment, the flexible adjustment and cross-platform compatibility of virtual machine disk configuration are achieved through automated configuration analysis and adjustment, and the disk of the target virtual machine is optimized according to user needs to make it more suitable for the operating environment of the target platform, thereby improving the efficiency and accuracy of virtual machine migration.
[0093] In an exemplary embodiment, writing a virtual machine backup file to a target virtual machine disk includes: determining a data backup host for the target virtual machine, mounting the target virtual machine disk on the data backup host; writing the virtual machine backup file to the data backup host; and writing the virtual machine backup file to the target virtual machine disk through the data backup host.
[0094] Specifically, as shown in Figure 4, the server first communicates with the target cloud platform to query and determine the backup host of the platform where the current target virtual machine is located. The backup host is a key device responsible for performing data writing and backup operations. The server obtains the information of the backup host through the API interface provided by the cloud platform. The server will select a suitable backup host to perform disk recovery operations based on the actual needs of the target virtual machine.
[0095] After the backup host is determined, the server mounts the target virtual machine disk to the backup host through the disk management interface of the target cloud platform. This step is to ensure that the backup host can directly access and operate the target disk. After the mount is successful, the target disk becomes an operational storage device of the backup host, and the backup host can directly read and write to the target disk through its storage system.
[0096] The server retrieves the backup files of the virtual machine from the backup system and transfers them to the backup host of the target cloud platform. The backup host is responsible for receiving and storing these files. After the backup host receives the backup files, the server instructs the backup host to write these files to the disk of the target virtual machine. The write operation is performed block by block according to the structure of the virtual machine disk to ensure that the data is correctly restored to its original location.
[0097] After writing is completed, the target disk contains the complete virtual machine backup file, and the disk structure and data content of the target virtual machine are exactly the same as the state at the time of the original backup.
[0098] In this embodiment, from the determination of the backup host, to the mounting of the target disk, and then to the block-by-block writing of the file, it is ensured that the backup file is correctly restored to the disk of the target virtual machine, greatly improving the efficiency and accuracy of the virtual machine backup and recovery operations. The server can ensure that the data backup file is completely restored to the new target disk, realizing cross-platform seamless migration and recovery of virtual machine data.
[0099] In an exemplary embodiment, writing driver information to a target virtual machine disk includes: if the operating system of the target virtual machine is a Linux system, writing the driver information to the target virtual machine disk through a data backup host of the target virtual machine; if the operating system of the target virtual machine is a Windows system, determining a pre-installed image server corresponding to the target virtual machine, mounting the pre-installed image server on the data backup host, and mounting the target virtual machine disk on the image server; writing the driver information to the target virtual machine disk through the pre-installed image server mounted on the backup host.
[0100] Specifically, as shown in FIG5 , if the operating system of the target virtual machine is a Linux system, the server will mount the disk of the target virtual machine to the data backup host through the management interface of the cloud platform. The mounting operation ensures that the backup host can directly access the target virtual machine disk. Subsequently, the server obtains virtual machine driver information compatible with the Linux system from the backup system. The server transfers this driver information to the target virtual machine disk through the storage interface of the backup host. After the writing is completed, the target disk already contains the required Linux driver.
[0101] If the target VM's operating system is Windows, the server will perform more complex operations, including using a pre-installed image server to complete the writing of driver information. First, query and determine the pre-installed image server associated with the Windows target VM through the target cloud platform. This image server usually contains pre-installed Windows drivers to ensure that the VM can run correctly on the target platform.
[0102] The server mounts the pre-installed image server to the data backup host and also mounts the target virtual machine's disk to the image server. The server transfers the required Windows driver information to the target virtual machine disk through the image server on the backup host. After the writing is completed, the target virtual machine disk contains the necessary Windows drivers.
[0103] In this embodiment, for Linux systems, the server directly writes driver information through the backup host to ensure that the Linux virtual machine can run correctly on the target cloud platform; and for Windows systems, the server mounts the pre-installed image server to ensure the accurate writing of Windows drivers. This dual-mode driver information writing solution greatly improves the flexibility and compatibility of cross-platform migration and recovery of virtual machines.
[0104] In an exemplary embodiment, writing a management script to a target virtual machine disk includes: writing the management script to a preset storage location of the target virtual machine disk through a disk operation tool; after creating a target virtual machine carrying a virtual machine backup file based on the target virtual machine disk containing driver information and the management script, it also includes: when the target virtual machine is not started, using the management script at the preset storage location to uninstall files in the virtual machine backup file that are incompatible with the target virtual machine.
[0105] Specifically, as shown in FIG6 , the server extracts the management script from the backup system and writes it to the preset storage location of the target virtual machine disk through the backup host operation. The server uses the backup file in the backup system to configure the target virtual machine. In the disk configuration phase, the target virtual machine disk is mounted on the backup host, and the backup host is responsible for writing the virtual machine backup file completely to the target disk. At this point, the disk of the target virtual machine contains not only the backup file, but also the management script written by the server.
[0106] When the virtual machine is not started, the server calls the management script through the backup host. The management script is located in the preset storage location and is loaded and executed through the disk operation tool. The management script scans the backup file for files or configurations that may be incompatible with the target virtual machine environment and automatically uninstalls or adjusts them.
[0107] In this embodiment, the management script is correctly written and executed before the virtual machine is started, which realizes the automatic uninstallation of incompatible files and system configuration optimization, and can effectively manage the files in the target virtual machine disk before the virtual machine is started, ensuring that the virtual machine can run smoothly on the target platform. This not only improves the efficiency of virtual machine recovery and migration, but also reduces manual configuration and troubleshooting during the startup process, and improves the stability and compatibility of the system.
[0108] In a specific embodiment, as shown in FIG7 , the server first retrieves the backup data of the current virtual machine through the backup system, writes the backup data obtained from the backup system to the target virtual machine disk on the target platform, and the backup data will be copied to the corresponding partition and storage structure of the target disk. When the target disk completes writing the backup data, the server will use the target disk as the storage basis through the API or management interface of the virtualization platform to create a new virtual machine. The creation process may include allocating computing resources (such as CPU, memory, etc.) of the virtual machine, binding the target disk to the new virtual machine, and configuring the network and operating system startup items of the virtual machine.
[0109] In this embodiment, by efficiently restoring virtual machine data from the backup system and creating a new virtual machine based on the restored data, it is ensured that the virtual machine can be quickly and completely restored in data backup and migration scenarios, thereby achieving efficient use of backup data and rapid creation of virtual machines. It is suitable for cross-platform virtual machine migration and disaster recovery scenarios, and improves the system's recovery capabilities and operating efficiency.
[0110] In order to enable those skilled in the art to better understand the above steps, the embodiment of the present application is illustrated below by using an example, but it should be understood that the embodiment of the present application is not limited to this.
[0111] In modern data centers and cloud computing environments, virtualization technology has become the core of improving resource utilization and flexibility. However, with the development of enterprise computer infrastructure, cross-platform virtual machine migration has become an increasingly important issue. Especially when migrating from virtualization platforms such as VMware to domestic cloud platforms such as OpenStack, data integrity and seamless system transition are key challenges. Traditional virtual machine migration solutions usually require the installation of agent plug-ins in the target virtual machine, which increases the complexity of operations and technical dependence on system configuration. Especially in large-scale virtual machine cluster scenarios, this process is time-consuming and prone to compatibility issues, increasing the risk of migration failure. In addition, during the migration process, virtual machines often need to be paused or shut down to ensure data consistency, affecting business continuity, which is unacceptable for enterprises pursuing high availability.
[0112] At the same time, although the disk file copying and format conversion process circumvents certain compatibility issues, the complex operation process and data integrity risks increase the difficulty of migration. More importantly, the V2V migration tools of different cloud vendors are often platform-specific and only support migration from specific virtualization platforms to their own cloud platforms, limiting the user's flexibility in choice. Due to the lack of an effective migration drill mechanism, it is impossible to fully assess risks before the formal migration, increasing the possibility of migration failure or business interruption. Therefore, when choosing a migration solution, users need to comprehensively consider business needs, technical capabilities, and risk tolerance. In the future, with the further innovation of cloud computing technology, more efficient and flexible migration solutions will continue to emerge to help users complete cross-platform migration more safely and smoothly.
[0113] The present invention can solve the above problem through the following steps. In a specific embodiment, the server sends a request to the current virtual machine by calling the VDDK API of the virtualization platform to obtain the resource data block of the virtual machine. The server communicates with the virtual machine through the agentless interface and directly extracts the disk data block from the virtual machine disk, including the partition information, file system status, etc. of the virtual machine. If the agentless interface does not respond, the server obtains the disk data of the virtual machine through the proxy server and the agent, and transmits the data to the backup system.
[0114] Afterwards, the server generates a virtual machine backup file from the acquired virtual machine resource data blocks through the backup system. The backup file contains information such as the virtual machine's operating system, file system, and application data. After the server saves the virtual machine state data as a backup file, the server extracts the configuration information of the current virtual machine from the virtualization platform. The configuration information includes the virtual machine's disk size, file system format, partition structure, and configuration of other hardware resources. The server parses the configuration information and obtains the disk configuration data related to the target virtual machine. The server creates a target virtual machine disk on the target cloud platform that matches the current virtual machine configuration information. The server allocates disk space, sets the partition structure, and configures the file system through the disk management interface of the target virtualization platform.
[0115] Furthermore, the server determines the backup host of the target virtual machine and mounts the target virtual machine disk to the backup host. Then, the server transfers the virtual machine backup file from the backup system to the backup host, and then writes the backup file to the target virtual machine disk through the backup host. If the operating system of the target virtual machine is a Linux system, the server writes the Linux driver information to the target virtual machine disk through the data backup host of the target virtual machine. If the operating system of the target virtual machine is a Windows system, the server determines the pre-installed image server corresponding to the target virtual machine, mounts the image server to the backup host, and mounts the target virtual machine disk to the image server. Through the image server, the server writes the Windows driver information to the target virtual machine disk.
[0116] The server writes the management script to the preset storage location of the target virtual machine disk through the disk operation tool libguestfs library. The server creates the target virtual machine based on the target virtual machine disk that already contains the driver information and management script. The server loads the target virtual machine disk to the new virtual machine instance through the API interface of the virtualization platform to complete the virtual machine creation process.
[0117] Finally, after the virtual machine is created but not started, the server calls the management script through the disk operation tool. Under the guidance of the management script, the server scans the virtual machine backup files, finds files that are incompatible with the target virtual machine, and uninstalls these files.
[0118] In this embodiment, by integrating efficient data capture, transmission, recovery, and virtualization technologies, the disk data of the original virtual machine is read and restored to the virtual machine of the target cloud platform, thereby improving the efficiency and integrity of data transmission, the flexibility and accuracy of virtual disk creation, the simplicity of system configuration and recovery, and the ability to quickly rebuild virtual machines in a cross-platform environment, greatly simplifying complex operating processes and improving the efficiency and reliability of data migration and system recovery.
[0119] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0120] Based on the same inventive concept, the embodiment of the present application also provides a virtual machine migration device for implementing the virtual machine migration method involved above. The implementation solution provided by the device to solve the problem is similar to the implementation solution recorded in the above method, so the specific limitations in one or more virtual machine migration device embodiments provided below can refer to the limitations of the virtual machine migration method above, and will not be repeated here.
[0121] In an exemplary embodiment, as shown in FIG8 , a virtual machine migration device is provided, including: a virtual machine backup module 810, a target virtual machine disk creation module 820, a backup data writing module 830 and a target virtual machine generation module 840, wherein:
[0122] The virtual machine backup module 810 is used to obtain the resource data blocks of the current virtual machine and generate a virtual machine backup file according to the resource data blocks;
[0123] The target virtual machine disk creation module 820 is used to obtain the configuration information of the current virtual machine, and based on the configuration information, create a target virtual machine disk that matches the configuration information of the current virtual machine;
[0124] The backup data writing module 830 is used to write the virtual machine backup file into the target virtual machine disk, and obtain the driver information and management script of the target virtual machine to be created, and write the driver information and management script into the target virtual machine disk;
[0125] The target virtual machine generation module 840 is used to create the target virtual machine carrying the virtual machine backup file based on the target virtual machine disk containing the driver information and the management script.
[0126] In one embodiment, the virtual machine backup module 810 is used to: send a request to the agentless program interface of the current virtual machine to obtain the resource data block; if the agentless program interface responds to the request, obtain the resource data block of the current virtual machine through the agentless program interface; if the agentless program interface does not respond to the request, determine the proxy server of the current virtual machine, and obtain the resource data block of the current virtual machine through the agent program deployed on the proxy server.
[0127] In one embodiment, the target virtual machine disk creation module 820 is used to: parse the configuration information of the current virtual machine to obtain the parsed configuration information; adjust the parsed configuration information according to the expected configuration parameters customized by the user for the target virtual machine to obtain the disk configuration information in the target virtual machine; and create the target virtual machine disk that matches the configuration information of the current virtual machine according to the disk configuration information.
[0128] In one embodiment, the backup data writing module 830 is used to: determine the data backup host of the target virtual machine and mount the target virtual machine disk on the data backup host; write the virtual machine backup file to the data backup host; and write the virtual machine backup file to the target virtual machine disk through the data backup host.
[0129] In one embodiment, the backup data writing module 830 is used to: if the operating system of the target virtual machine is a Linux system, write the driver information to the target virtual machine disk through the data backup host of the target virtual machine; if the operating system of the target virtual machine is a Windows system, determine the pre-installed image server corresponding to the target virtual machine, mount the pre-installed image server on the data backup host, and mount the target virtual machine disk on the image server; write the driver information to the target virtual machine disk through the pre-installed image server mounted on the backup host.
[0130] In one embodiment, the target virtual machine generation module 840 is used to: write the management script to a preset storage location of the target virtual machine disk through a disk operation tool; and when the target virtual machine is not started, use the management script at the preset storage location to uninstall files in the virtual machine backup file that are incompatible with the target virtual machine.
[0131] Each module in the above-mentioned virtual machine migration device can be implemented in whole or in part by software, hardware and their combination. Each module can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to each module above.
[0132] In an exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be shown in FIG9. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit, and an input device. The processor, the memory, and the input / output interface are connected via a system bus, and the communication interface, the display unit, and the input device are connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner may be implemented through WIFI, a mobile cellular network, near field communication (NFC) or other technologies. When the computer program is executed by the processor, a virtual machine migration method is implemented. The display unit of the computer device is used to form a visually visible picture, which may be a display screen, a projection device, or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.
[0133] Those skilled in the art will understand that the structure shown in FIG. 9 is merely a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.
[0134] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above-mentioned method embodiments when executing the computer program.
[0135] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0136] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0137] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0138] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.
[0139] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, possible combinations of the technical features in the above embodiments are not described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0140] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A virtual machine migration method, characterized in that: The method comprises: Obtaining a resource data block of the current virtual machine, and generating a virtual machine backup file according to the resource data block; Acquire configuration information of the current virtual machine, and based on the configuration information, create a target virtual machine disk that matches the configuration information of the current virtual machine; Writing the virtual machine backup file into the target virtual machine disk, and obtaining the driver information and management script of the target virtual machine to be created, and writing the driver information and management script into the target virtual machine disk; Based on the target virtual machine disk including the driver information and the management script, the target virtual machine carrying the virtual machine backup file is created.
2. The method according to claim 1, characterized in that: The step of obtaining the resource data block of the current virtual machine includes: Sending a request to obtain the resource data block to the agentless program interface of the current virtual machine; If the agentless program interface responds to the request, obtaining the resource data block of the current virtual machine through the agentless program interface; If the agentless program interface does not respond to the request, a proxy server of the current virtual machine is determined, and a resource data block of the current virtual machine is obtained through an agent program deployed on the proxy server.
3. The method according to claim 1, characterized in that The step of creating a target virtual machine disk that matches the configuration information of the current virtual machine based on the configuration information includes: Parsing the configuration information of the current virtual machine to obtain parsed configuration information; According to the expected configuration parameters customized by the user for the target virtual machine, the parsed configuration information is adjusted to obtain the disk configuration information in the target virtual machine; The target virtual machine disk matching the configuration information of the current virtual machine is created according to the disk configuration information.
4. The method according to claim 1, characterized in that Writing the virtual machine backup file into the target virtual machine disk includes: Determine a data backup host for the target virtual machine, and mount the target virtual machine disk on the data backup host; Writing the virtual machine backup file into the data backup host; The virtual machine backup file is written to the target virtual machine disk through the data backup host.
5. The method according to claim 1, characterized in that: Writing the driver information to the target virtual machine disk includes: If the operating system of the target virtual machine is a Linux system, the driver information is written to the target virtual machine disk through the data backup host of the target virtual machine; If the operating system of the target virtual machine is Windows, determine a pre-installed image server corresponding to the target virtual machine, mount the pre-installed image server on the data backup host, and mount the target virtual machine disk on the image server; The driver information is written into the target virtual machine disk by mounting the pre-installed image server on the backup host.
6. The method according to claim 1, characterized in that Writing the management script to the target virtual machine disk includes: Writing the management script to a preset storage location of the target virtual machine disk through a disk operation tool; After creating the target virtual machine carrying the virtual machine backup file based on the target virtual machine disk containing the driver information and the management script, the method further includes: When the target virtual machine is not started, the files in the virtual machine backup file that are incompatible with the target virtual machine are uninstalled using the management script in the preset storage location.
7. A virtual machine migration device, characterized in that: The device comprises: A virtual machine backup module, used to obtain resource data blocks of the current virtual machine and generate a virtual machine backup file according to the resource data blocks; A target virtual machine disk creation module, used to obtain configuration information of a current virtual machine, and based on the configuration information, create a target virtual machine disk that matches the configuration information of the current virtual machine; A backup data writing module, used to write the virtual machine backup file into the target virtual machine disk, and to obtain the driver information and management script of the target virtual machine to be created, and write the driver information and management script into the target virtual machine disk; The target virtual machine generation module is used to create the target virtual machine carrying the virtual machine backup file based on the target virtual machine disk containing the driver information and the management script.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Virtual machine cross-platform migration method and system
CN112256397A
Cross-OpenStack virtual machine migration method, device and medium
CN112527452A
Method for starting virtual machine based on container mirror image and virtual machine starting device
CN116225618A
Virtual machine backup recovery method and device, computer equipment and storage medium
CN117033082A
Cross-platform virtual machine driver replacement method and system and storage medium
CN117112072A