Disclosure of Invention
In view of the foregoing, it is desirable to provide a virtual machine migration method, apparatus, computer device, computer readable storage medium, and computer program product.
In a first aspect, the present application provides a virtual machine migration method, including:
Acquiring a resource data block of a current virtual machine, and generating a virtual machine backup file according to the resource data block;
Acquiring configuration information of a current virtual machine, and creating a target virtual machine disk matched with the configuration information of the current virtual machine based on the configuration information;
Writing the virtual machine backup file into the target virtual machine disk, acquiring driving information and management script of the target virtual machine to be created, and writing the driving information and the management script into the target virtual machine disk;
And creating the target virtual machine carrying the virtual machine backup file based on the target virtual machine disk containing the driving information and the management script.
In one embodiment, the obtaining the resource data block of the current virtual machine includes:
Sending a request for acquiring the resource data block to a agentless program interface of the current virtual machine;
if the agent-free program interface responds to the request, acquiring a resource data block of the current virtual machine through the agent-free program interface;
And if the agent-free program interface does not respond to the request, determining an agent server of the current virtual machine, and acquiring a resource data block of the current virtual machine through an agent program deployed in the agent server.
In one embodiment, the creating, based on the configuration information, a target virtual machine disk that matches the configuration information of the current virtual machine includes:
analyzing the configuration information of the current virtual machine to obtain analyzed configuration information;
according to the user-defined expected configuration parameters aiming at the target virtual machine, adjusting the analyzed configuration information to obtain disk configuration information in the target virtual machine;
and creating the target virtual machine disk matched with the configuration information of the current virtual machine according to the disk configuration information.
In one embodiment, writing the virtual machine backup file to a target virtual machine disk includes:
determining a data backup host of the target virtual machine, and mounting the disk of the target virtual machine on the data backup host;
Writing the virtual machine backup file into the data backup host;
and writing the virtual machine backup file into the target virtual machine disk through the data backup host.
In one embodiment, writing the drive information to the target virtual machine disk includes:
if the operating system of the target virtual machine is a Linux system, writing the driving information into a disk of the target virtual machine 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 mirror server corresponding to the target virtual machine, mounting the pre-installed mirror server on the data backup host, and mounting the target virtual machine disk on the mirror server;
and writing the driving information into the target virtual machine disk through the pre-installed mirror server mounted on the backup host.
In one embodiment, writing the management script to the target virtual machine disk includes:
writing the management script into a preset storage position 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 driving information and the management script, the method further comprises:
And under the condition that the target virtual machine is not started, unloading the file incompatible with the target virtual machine in the virtual machine backup file by utilizing the management script of the preset storage position.
In a second aspect, the application further provides a virtual machine backup module, which is used for obtaining a resource data block of a current virtual machine and generating a virtual machine backup file according to the resource data block;
The system comprises a target virtual machine disk creation module, a target virtual machine disk creation module and a virtual machine management module, wherein the target virtual machine disk creation module is used for acquiring configuration information of a current virtual machine and creating a target virtual machine disk matched with the configuration information of the current virtual machine based on the configuration information;
the backup data writing module is used for writing the virtual machine backup file into the target virtual machine disk, acquiring driving information and management script of the target virtual machine to be created, and writing the driving information and the management script into the target virtual machine disk;
and the target virtual machine generation module is used for creating the target virtual machine carrying the virtual machine backup file based on the target virtual machine disk containing the driving information and the management script.
In a third aspect, the present application also provides a computer device comprising a memory and a processor, the memory storing a computer program, the processor implementing the following steps when executing the computer program:
Acquiring a resource data block of a current virtual machine, and generating a virtual machine backup file according to the resource data block;
Acquiring configuration information of a current virtual machine, and creating a target virtual machine disk matched with the configuration information of the current virtual machine based on the configuration information;
Writing the virtual machine backup file into the target virtual machine disk, acquiring driving information and management script of the target virtual machine to be created, and writing the driving information and the management script into the target virtual machine disk;
And creating the target virtual machine carrying the virtual machine backup file based on the target virtual machine disk containing the driving information and the management script.
In a fourth aspect, the present application also provides a computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of:
Acquiring a resource data block of a current virtual machine, and generating a virtual machine backup file according to the resource data block;
Acquiring configuration information of a current virtual machine, and creating a target virtual machine disk matched with the configuration information of the current virtual machine based on the configuration information;
Writing the virtual machine backup file into the target virtual machine disk, acquiring driving information and management script of the target virtual machine to be created, and writing the driving information and the management script into the target virtual machine disk;
Creating the target virtual machine carrying the virtual machine backup file using the target virtual machine disk based on the management script and the drive information.
In a fifth aspect, the application also provides a computer program product comprising a computer program which, when executed by a processor, performs the steps of:
Acquiring a resource data block of a current virtual machine, and generating a virtual machine backup file according to the resource data block;
Acquiring configuration information of a current virtual machine, and creating a target virtual machine disk matched with the configuration information of the current virtual machine based on the configuration information;
Writing the virtual machine backup file into the target virtual machine disk, acquiring driving information and management script of the target virtual machine to be created, and writing the driving information and the management script into the target virtual machine disk;
Creating the target virtual machine carrying the virtual machine backup file using the target virtual machine disk based on the management script and the drive information.
The virtual machine migration method, the virtual machine migration device, the computer equipment, the computer readable storage medium and the computer program product are characterized by obtaining a resource data block of a current virtual machine, generating a virtual machine backup file according to the resource data block, obtaining configuration information of the current virtual machine, creating a target virtual machine disk matched with the configuration information of the current virtual machine based on the configuration information, writing the virtual machine backup file into the target virtual machine disk, obtaining driving information and management scripts of a target virtual machine to be created, writing the driving information and the management scripts into the target virtual machine disk, and creating the target virtual machine carrying the virtual machine backup file based on the target virtual machine disk containing the driving information and the management scripts. According to the method and the system, the resource data of the virtual machine are effectively obtained, the backup file for migration or recovery is generated, the backup efficiency is improved, the consistency and the integrity of the data are ensured, the server generates the target virtual machine disk matched with the current virtual machine based on the configuration information of the virtual machine, the purpose of efficient migration and recovery is achieved, the compatibility and the performance stability of the virtual machine in a new environment are ensured when the virtual machine runs, meanwhile, an automatic configuration adjustment means is provided for the virtual machine in the new environment through writing of driving information and management scripts, the quick starting and environment adaptation of the virtual machine are realized, the automation and the flexibility of the system are improved, the purpose of seamless migration and recovery is achieved, and finally, the target virtual machine carrying the backup file of the virtual machine is created based on the target virtual machine disk containing the driving information and the management scripts, so that the virtual machine can be rapidly deployed and smoothly started when the virtual machine is migrated or recovered in a cross-platform manner. Thereby achieving remarkable improvement of virtual machine migration efficiency.
Detailed Description
The present application will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present application more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the application.
In one embodiment, as shown in fig. 1, a virtual machine migration method is provided, where this embodiment is applied to a server for illustration, and it is understood that the method may also be applied to a terminal, and may also be applied to a system including a terminal and a server, and implemented through interaction between the terminal and the server. In this embodiment, the method includes the steps of:
Step S102, obtaining a resource data block of the current virtual machine, and generating a virtual machine backup file according to the resource data block.
Wherein the virtual machine resource data block is a collection of memory, storage and other system resources in the virtual machine system that constitute the operating environment of the virtual machine. The virtual machine backup file is a file for storing the current state of the virtual machine, and contains resource data blocks of the virtual machine, a virtual hard disk and configuration information, so that the data can be restored on the target virtual machine.
Illustratively, the server first makes a request to acquire a resource data block of the current virtual machine by establishing a connection with the virtual machine interface. In one embodiment, the server invokes a virtual machine management interface, interacts with the virtual machine through the virtual machine management interface, retrieves information such as memory, CPU, disk, etc. of the virtual machine, and packages the data blocks in a binary or standard format.
In order to ensure the consistency of the data, the server can prevent the change of the data by locking the state of the virtual machine in the execution process, 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 a local storage of the server as intermediate data for further processing in a subsequent step.
The server then packages and compresses the resource data blocks to generate virtual machine backup files. The Virtual machine backup file may include multiple formats, such as an open virtualization format (Open Virtualization Format, OVF), a quick emulation copy version 2 (QEMU Copy On Write version, qcoo2), a Virtual hard disk extension format (Virtual HARD DISK V2, VHDX), and the like, and may be specifically set according to the requirements of the user and the configuration of the target system. The virtual machine backup file may be stored on a server local disk awaiting a subsequent restore operation.
Step S104, obtaining the configuration information of the current virtual machine, and creating a target virtual machine disk matched with the configuration information of the current virtual machine based on the configuration information.
The configuration information of the current virtual machine refers to a set of parameters in the virtualized environment, and the parameters define hardware and software configuration of the virtual machine, including, but not limited to, the number of CPUs, the memory size, the storage configuration, the network interface configuration, the format of a virtual disk, the file system, and the like, so that the running state of the virtual machine and the requirement of the virtual machine on hardware resources can be controlled.
The target virtual machine disk is a virtual disk created by the server for the target virtual machine, is a carrier for restoring the backup file of the virtual machine, and can ensure that the restored or migrated virtual machine can normally operate.
Illustratively, the server first obtains the configuration information of the current virtual machine through an application program interface (API, application Programming Interface) or management tool of the virtualization platform. After the configuration information is obtained, the server starts to create a corresponding virtual machine disk in the storage system of the target virtual machine according to the parameters. And the server customizes the target virtual machine disk according to the configuration information. In one embodiment, the server may selectively adjust the configuration information to meet compatibility requirements between different virtualized platforms, e.g., where the disk formats are not compatible, the server may translate to virtual disk formats supported by the target platform.
Alternatively, the server may perform disk partitioning and file system optimization according to different storage requirements prior to generating the target virtual machine disk. In a specific embodiment, when the target platform has high-performance storage resources, the server may choose to configure the file system into a more efficient structure, or use a disk partition mode that is more suitable for large-scale data processing, so as to improve the running efficiency of the virtual machine on the target platform.
Step S106, writing the virtual machine backup file into a target virtual machine disk, acquiring driving information and management script of the target virtual machine to be created, and writing the driving information and the management script into the target virtual machine disk.
The driving information is an important component compatible with the hardware environment of the target virtual machine operating system, and the normal running of the virtual machine on the target platform is ensured by installing the driving program. The management script is a command set written by a script language and is used for ensuring that the virtual machine can automatically adapt to hardware and network configuration on different platforms.
Optionally, the server first extracts the saved virtual machine backup file from the local storage system. The server writes the backup file to the target virtual machine disk, either through direct replication or data block level write operations.
After the backup file is written, the server further acquires driving information and management scripts required by the target virtual machine. The driver information may include basic drivers for supporting the target platform hardware, may include, but is not limited to, a storage controller, a network adapter, etc., and the management script may then contain system commands or batch scripts for automated configuration. When the server writes the driving information and the management script, the server can optimize according to different target virtual machine environments, and different driving or configuration adjustment can be performed.
Step S108, creating a target virtual machine carrying a virtual machine backup file based on the target virtual machine disk containing the driving information and the management script.
Illustratively, the server initiates the creation flow of the target virtual machine through the management interface of the virtualization platform. In this process, the server first extracts and loads drive information from the target virtual machine disk, which may include a network adapter, a storage controller, and the like.
When the drive information is loaded into the operating system, the virtual machine may complete the initialization interfacing with the target hardware. In a specific embodiment, when the driving information is loaded into the operating system, the operating system identifies the storage architecture of the new platform and ensures the normal operation of the read-write operation through the driving program. The driving of the network adapter enables the virtual machine to access the network, so as to realize communication with external equipment.
On the other hand, the server will also execute the management script. The management scripts run when the creation of the virtual machine is completed, and the scripts can automatically adjust the configuration of the virtual machine to adapt to the hardware and software environment of the new platform. Specific operations may include configuring network addresses, adjusting system performance parameters, launching necessary services, or installing additional software packages.
In this embodiment, by effectively acquiring resource data of a virtual machine and generating a backup file for migration or recovery, backup efficiency is improved, consistency and integrity of data are also ensured, a server generates a target virtual machine disk matched with the current virtual machine based on configuration information of the virtual machine, so as to achieve the purpose of efficient migration and recovery, ensure compatibility and performance stability of the virtual machine when running in a new environment, and simultaneously, provide an automatic configuration adjustment means for the virtual machine in the new environment through writing of driving information and management scripts, realize quick start and environment adaptation of the virtual machine, promote system automation and flexibility, achieve the purpose of seamless migration and recovery, and finally, establish a target virtual machine carrying the backup file of the virtual machine based on the target virtual machine disk containing the driving information and the management scripts, so as to ensure quick deployment and smooth start of the virtual machine when the virtual machine is migrated or recovered across platforms. Thereby achieving remarkable improvement of virtual machine migration efficiency.
In one exemplary embodiment, acquiring the resource data block of the current virtual machine includes sending a request for acquiring the resource data block to a non-proxy program interface of the current virtual machine, acquiring the resource data block of the current virtual machine through the non-proxy program interface if the non-proxy program interface responds to the request, determining a proxy server of the current virtual machine if the non-proxy program interface does not respond to the request, and acquiring the resource data block of the current virtual machine through a proxy program deployed on the proxy server.
The agent-free program interface is an API which directly interacts with the virtual machine or the virtualization platform, and can acquire the state and resource data of the virtual machine without installing an additional software agent program in the virtual machine.
The proxy server is an intermediate server located between the virtual machine and the backup system, and is used for indirectly acquiring the resource data blocks of the virtual machine through a proxy program running in the proxy server under the condition that no proxy program interface is available.
Specifically, as shown in fig. 2, the server first directly sends a request to the virtual machine through VDDK (Virtual Disk Development Kit) API of the virtualization platform, and requests to capture disk data blocks of the virtual machine. VDDK API provides a proxy-less program interface function, allowing the server to directly access critical data such as disk, memory, etc. of the virtual machine.
If VDDK API responds successfully, the server captures the resource data block of the virtual machine through the interface, wherein the resource data block mainly comprises the use condition, partition structure, file system state and the like of the current disk of the virtual machine. The data are transmitted to the backup system by the server in real time and are persisted in the backup system to form backup files of the virtual machine. The server may also capture offset information for the virtual machine to accurately restore disk content.
If VDDK API fails to respond to the request, the server immediately switches to proxy mode. At this time, the server no longer communicates directly with the virtual machine, but acquires the data of the virtual machine through the proxy server. In proxy mode, the proxy has pre-deployed the proxy. The agent is designed to be able to communicate indirectly with the virtual machine, capturing resource data of the virtual machine through a virtual machine monitor or virtual disk management tool. The agent program captures the disk data block and offset information of the virtual machine through the agent server interface and transmits the disk data block and offset information to the backup system.
In the embodiment, the server can efficiently and directly acquire data and transmit the data to the backup system when the agent-free program interface works normally, and the agent server and the agent program provide a reliable backup way when the agent-free program interface cannot be used, so that the backup process of the virtual machine is ensured not to be interrupted, and the reliability and the flexibility of the backup operation of the virtual machine are greatly improved.
In an exemplary embodiment, creating a target virtual machine disk that matches configuration information of a current virtual machine based on the configuration information includes parsing the configuration information of the current virtual machine to obtain parsed configuration information, adjusting the parsed configuration information to obtain disk configuration information in the target virtual machine according to expected configuration parameters customized by a user for the target virtual machine, and creating the target virtual machine disk that matches the configuration information of the current virtual machine according to the disk configuration information.
Specifically, as shown in fig. 3, the server obtains disk configuration information of the virtual machine from the virtual machine of the source cloud platform through the backup system. The server extracts 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.
After the server obtains the target disk configuration parameters defined by the user, the analyzed disk configuration information is adjusted according to the target disk parameters. The user may specify a new disk size, file system type, or specific partition requirements. In this process, the server adjusts the parsed configuration according to the user's needs, and in a specific embodiment, if the user wants the file system format of the target disk to be different from the original virtual machine, the server will modify the disk configuration according to the new requirements to satisfy the new operating environment.
After the analysis and adjustment of the configuration information are completed, the server creates a target virtual machine disk on the target platform through an API interface of the target platform. The server is responsible for distributing storage resources, initializing a file system and setting a disk partition structure, ensuring that the configuration of a target disk can be matched with the original virtual machine, and meeting the additional customization demands of users.
In the embodiment, flexible adjustment and cross-platform compatibility of the disk configuration of the virtual machine are realized through automatic configuration analysis and adjustment. And the disk of the target virtual machine is optimized according to the requirements of the user, so that the disk is more suitable for the running environment of the target platform, and the efficiency and accuracy of virtual machine migration are improved.
In one exemplary embodiment, writing the virtual machine backup file to the target virtual machine disk includes determining a data backup host of the target virtual machine, mounting the target virtual machine disk to 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.
Specifically, as shown in fig. 4, the server first communicates with the target cloud platform, queries and determines the backup host of the platform where the current target virtual machine is located. The backup host is a key device responsible for executing data writing and backup operation, and the server acquires information of the backup host through an API interface provided by the cloud platform. The server selects a proper backup host to execute the disk recovery operation according to the actual requirement of the target virtual machine.
After the backup host is determined, the server mounts the disk of the target virtual machine to the backup host through the disk management interface of the target cloud platform. This is to ensure that the backup host can directly access and operate the target disk. After the mounting is successful, the target disk becomes an operable storage device of the backup host, and the backup host can directly perform read-write operation on the target disk through the storage system of the backup host.
The server invokes the backup files of the virtual machine from the backup system, transmits the backup files to the backup host of the target cloud platform, and the backup host is responsible for receiving and storing the files. After receiving the backup files, the backup host instructs the backup host to write the files into the disk of the target virtual machine. The writing operation is performed block by block according to the structure of the virtual machine disk, so that the data is ensured to be correctly restored to the original position.
After the writing is completed, the target disk contains the complete virtual machine backup file, and the disk structure and the data content of the target virtual machine are completely consistent with the state of the original backup.
In the 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, the backup file is ensured to be correctly restored to the disk of the target virtual machine, the efficiency and accuracy of the backup and restoration operation of the virtual machine are greatly improved, the server can ensure that the data backup file is completely restored to the new target disk, and the cross-platform seamless migration and restoration of the virtual machine data are realized.
In an exemplary embodiment, writing the driving information to the target virtual machine disk includes writing the driving information to the target virtual machine disk through a data backup host of the target virtual machine if an operating system of the target virtual machine is a Linux system, determining a pre-installed mirror server corresponding to the target virtual machine if the operating system of the target virtual machine is a Windows system, mounting the pre-installed mirror server on the data backup host and mounting the target virtual machine disk on the mirror server, and writing the driving information to the target virtual machine disk through the pre-installed mirror server mounted on the backup host.
Specifically, as shown in fig. 5, if the operating system of the target virtual machine is a Linux system, the server may mount the disk of the target virtual machine to the data backup host through the management interface of the cloud platform. The mount operation ensures that the backup host is able to directly access the target virtual machine disk. Then, the server acquires virtual machine driving information compatible with the Linux system from the backup system. The server transmits the driving 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.
If the operating system of the target virtual machine is a Windows system, the server may perform more complex operations, including using a pre-installed mirror server to complete the writing of the drive information. Firstly, a target cloud platform is used for inquiring and determining a preinstalled mirror server related to the Windows target virtual machine. This mirror server typically contains a pre-installed Windows driver to ensure that the virtual machine is able to run properly on the target platform.
The server mounts the pre-installed mirror server to the data backup host and also mounts the disk of the target virtual machine to the mirror server. The server transmits the needed Windows driving information to the target virtual machine disk through the mirror image server on the backup host. After the writing is completed, the target virtual machine disk contains the necessary Windows driver.
In the embodiment, the server directly writes the driving information through the backup host computer for the Linux system to ensure that the Linux virtual machine can correctly run on the target cloud platform, and the server ensures the accurate writing of the Windows driving program through mounting the pre-installed mirror image server for the Windows system. The dual-mode driving information writing scheme greatly improves the flexibility and compatibility of cross-platform migration and recovery of the virtual machine.
In one exemplary embodiment, 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 operating tool, and after creating the target virtual machine with the virtual machine backup file based on the target virtual machine disk including the drive information and the management script, unloading a file of the virtual machine backup file that is incompatible with the target virtual machine using the management script of the preset storage location without starting the target virtual machine.
Specifically, as shown in fig. 6, 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. And the server configures the target virtual machine by using the backup files in the backup system. In the disk configuration stage, a target virtual machine disk is mounted on a backup host, and the backup host is responsible for completely writing a virtual machine backup file into the target disk. At this time, the disk of the target virtual machine contains not only the backup file but also the management script written by the server.
In the case that the virtual machine has not been started, the server invokes the management script through the backup host. The management script is located at a preset storage position, and is loaded and executed through a disk operation tool. The management script scans the backup files for files or configurations that may not be compatible with the target virtual machine environment and automatically uninstalls or adjusts.
In the embodiment, the management script is correctly written and executed before the virtual machine is started, so that the automatic unloading of incompatible files and the system configuration optimization are realized, the files in the disk of the target virtual machine can be effectively managed before the virtual machine is started, and the smooth running of the virtual machine on the target platform is ensured. The recovery and migration efficiency of the virtual machine is improved, manual configuration and fault detection in the starting process are reduced, and the stability and compatibility of the system are improved.
In a specific embodiment, as shown in fig. 7, the server firstly calls the backup data of the current virtual machine through the backup system, the backup data acquired from the backup system is written into a target virtual machine disk on the target platform, the backup data is copied into a corresponding partition and a storage structure of the target disk, and when the target disk completes the writing of the backup data, the server creates a new virtual machine by using the target disk as a storage basis through an API or a management interface of the virtualization platform. The creation process may include allocating computing resources (e.g., CPU, memory, etc.) of the virtual machine, binding the target disk with the new virtual machine, and configuring the virtual machine's network, operating system startup items, etc.
In the embodiment, by efficiently recovering the virtual machine data from the backup system and creating a brand-new virtual machine based on the recovered data, the virtual machine can be quickly and completely recovered in the data backup and migration scene, the efficient utilization of the backup data and the quick creation of the virtual machine are realized, the method is suitable for the migration and disaster recovery scene of the cross-platform virtual machine, and the recovery capacity and the operation efficiency of the system are improved.
In order that those skilled in the art may better understand the above steps, an embodiment of the present application will be described below by way of an example, but it should be understood that the embodiment of the present application is not limited thereto.
In modern data centers and cloud computing environments, virtualization technology has become the core to promote resource utilization and flexibility. However, as enterprise computer infrastructure evolves, cross-platform virtual machine migration has become an increasingly important issue. In particular, when migrating from virtualized platforms such as VMware to domestic cloud platforms such as OpenStack, seamless transition of data integrity and systems is a critical challenge. Traditional virtual machine migration solutions generally require that proxy plugins be installed in target virtual machines, increase operational complexity and technical dependence of system configuration, and especially in a large-scale virtual machine cluster scenario, the process is time-consuming and is easy to encounter compatibility problems, and the risk of migration failure is increased. In addition, virtual machines often need to be suspended or shut down during migration to ensure data consistency, affecting business continuity, which is unacceptable to businesses seeking high availability.
Meanwhile, the copying and format conversion process of the disk file bypasses some compatibility problems, but the complex operation flow and the risk of data integrity increase the migration difficulty. More importantly, V2V migration tools of different cloud vendors often have platform specificity, only support migration from a specific virtualized platform to an own cloud platform, limiting the flexibility of choice for users. Because of the lack of an effective migration exercise mechanism, risk cannot be fully assessed before formal migration, increasing the likelihood of migration failure or service disruption. Therefore, when a user selects a migration scheme, the service requirement, the technical capability and the risk bearing capability need to be comprehensively considered, and more efficient and flexible migration schemes are continuously emerging along with further innovation of cloud computing technology in the future, so that the user is helped to complete cross-platform migration more safely and smoothly.
The present invention solves the above-mentioned problems by the following steps, and in a specific embodiment, the server obtains the resource data block of the virtual machine by calling VDDK API of the virtualization platform to send a request to the current virtual machine. The server communicates with the virtual machine through the agent-free program interface, and directly extracts disk data blocks from the disk of the virtual machine, including partition information, file system state and the like of the virtual machine. If the no-proxy interface does not respond, the server acquires disk data of the virtual machine through the proxy server and the proxy program, and transmits the data to the backup system.
And then, the server generates a virtual machine backup file through the backup system by using the acquired virtual machine resource data blocks. The backup file contains information such as an operating system, a file system, application data and the like of the virtual machine. 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 disk size, file system format, partition structure, and configuration of other hardware resources of the virtual machine. And the server analyzes the configuration information to obtain disk configuration data related to the target virtual machine. The server creates a target virtual machine disk on the target cloud platform, which is matched with the current virtual machine configuration information. The server distributes disk space, sets partition structures and configures file systems through a disk management interface of the target virtualization platform.
Further, the server determines a backup host of the target virtual machine, and mounts the target virtual machine disk to the backup host. Then, the server transmits the virtual machine backup file from the backup system to the backup host, and writes the backup file into 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 Linux driving information into a disk of the target virtual machine through a data backup host of the target virtual machine. If the operating system of the target virtual machine is a Windows system, the server determines a preinstalled mirror server corresponding to the target virtual machine, mounts the mirror server to the backup host, and mounts the disk of the target virtual machine to the mirror server. And the server writes the Windows driving information into the target virtual machine disk through the mirror image server.
And the server writes the management script into a preset storage position of the target virtual machine disk through a disk operation tool libguestfs library. The server creates a target virtual machine based on the target virtual machine disk that already contains the drive information and the management script. And the server loads the target virtual machine disk to the new virtual machine instance through an API interface of the virtualization platform, and the creation process of the virtual machine is completed.
Finally, the server calls the management script through the disk operating tool after the virtual machine is created but not started. Under the direction of the management script, the server scans the virtual machine backup files, searches for files incompatible with the target virtual machine, and uninstalls the files.
In the embodiment, by integrating efficient data capturing, transmitting, recovering and virtualizing technologies, virtual machine recovery from disk data of an original virtual machine to a target cloud platform is realized, high efficiency and integrity guarantee of data transmission, flexibility and accuracy of virtual disk creation, simplicity of system configuration and recovery and capability of fast reconstruction of the virtual machine in a cross-platform environment are improved, complex operation flow is greatly simplified, and efficiency and reliability of data migration and system recovery are improved.
It should be understood that, although the steps in the flowcharts related to the embodiments described above are sequentially shown as indicated by arrows, these steps are not necessarily sequentially performed in the order indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least some of the steps in the flowcharts described in the above embodiments may include a plurality of steps or a plurality of stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of the steps or stages is not necessarily performed sequentially, but may be performed alternately or alternately with at least some of the other steps or stages.
Based on the same inventive concept, the embodiment of the application also provides a virtual machine migration device for realizing the virtual machine migration method. The implementation of the solution provided by the device is similar to the implementation described in the above method, so the specific limitation in the embodiments of the virtual machine migration device or devices provided below may refer to the limitation of the virtual machine migration method hereinabove, and will not be repeated herein.
In one exemplary embodiment, as shown in FIG. 8, a virtual machine migration apparatus is provided, comprising a virtual machine backup module 810, a target virtual machine disk creation module 820, a backup data write module 830, and a target virtual machine generation module 840, wherein:
the virtual machine backup module 810 is configured to obtain a resource data block of a current virtual machine, and generate a virtual machine backup file according to the resource data block;
The target virtual machine disk creation module 820 is configured to obtain configuration information of a 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;
The backup data writing module 830 is configured to write the virtual machine backup file into the target virtual machine disk, obtain driving information and a management script of a target virtual machine to be created, and write the driving information and the management script into the target virtual machine disk;
And a target virtual machine generating module 840, configured to create the target virtual machine carrying the virtual machine backup file based on the target virtual machine disk containing the driving information and the management script.
In one embodiment, the virtual machine backup module 810 is configured to send a request for obtaining the resource data block to a agentless program interface of the current virtual machine, obtain the resource data block of the current virtual machine through the agentless program interface if the agentless program interface responds to the request, determine a proxy server of the current virtual machine if the agentless program interface does not respond to the request, and obtain the resource data block of the current virtual machine through a proxy program deployed in the proxy server.
In one embodiment, the target virtual machine disk creation module 820 is configured to parse the configuration information of the current virtual machine to obtain parsed configuration information, adjust the parsed configuration information according to an expected configuration parameter customized by a user for the target virtual machine to obtain disk configuration information in the target virtual machine, and create the target virtual machine disk matched with the configuration information of the current virtual machine according to the disk configuration information.
In one embodiment, the backup data writing module 830 is configured to determine a data backup host of the target virtual machine, mount the target virtual machine disk on the data backup host, write the virtual machine backup file into the data backup host, and write the virtual machine backup file into the target virtual machine disk through the data backup host.
In one embodiment, the backup data writing module 830 is configured to write the driving 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 Linux system, determine a pre-installed mirror server corresponding to the target virtual machine if the operating system of the target virtual machine is a Windows system, mount the pre-installed mirror server on the data backup host and mount the target virtual machine disk on the mirror server, and write the driving information to the target virtual machine disk through the pre-installed mirror server mounted on the backup host.
In one embodiment, the target virtual machine generating module 840 is configured to write the management script to a preset storage location of the target virtual machine disk through a disk operating tool, and unload, when the target virtual machine is not started, a file incompatible with the target virtual machine from the virtual machine backup file by using the management script of the preset storage location.
The modules in the virtual machine migration apparatus may be implemented in whole or in part by software, hardware, or a combination thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In one exemplary embodiment, a computer device is provided, which may be a server, the internal structure of which may be as shown in fig. 9. The computer device includes a processor, a memory, an input/output interface, a communication interface, a display unit, and an input means. The processor, the memory and the input/output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input/output interface. Wherein the processor of the computer device is configured 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 computer programs in the non-volatile storage media. The input/output interface of the computer device is used to exchange information between the processor and the external device. The Communication interface of the computer device is used for conducting wired or wireless Communication with an external terminal, and the wireless Communication can be realized through WIFI, a mobile cellular network, near field Communication (NEAR FIELD Communication) or other technologies. The computer program, when executed by a processor, implements a virtual machine migration method. The display unit of the computer device is used for forming a visual picture, and can 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 equipment can be a touch layer covered on the display screen, can also be a key, a track ball or a touch pad arranged on the shell of the computer equipment, and can also be an external keyboard, a touch pad or a mouse and the like.
It will be appreciated by persons skilled in the art that the architecture shown in fig. 9 is merely a block diagram of some of the architecture relevant to the present inventive arrangements and is not limiting as to the computer device to which the present inventive arrangements are applicable, and that a particular computer device may include more or fewer components than shown, or may combine some of the components, or have a different arrangement of components.
In one embodiment, a computer device is provided, comprising a memory and a processor, the memory having stored therein a computer program, the processor implementing the steps of the method embodiments described above when the computer program is executed.
In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored which, when executed by a processor, implements the steps of the method embodiments described above.
In an embodiment, a computer program product is provided, comprising a computer program which, when executed by a processor, implements the steps of the method embodiments described above.
It should be noted that, the user information (including but not limited to user equipment information, user personal information, etc.) and the data (including but not limited to data for analysis, stored data, presented data, etc.) related to the present application are both information and data authorized by the user or sufficiently authorized by each party, and the collection, use and processing of the related data are required to meet the related regulations.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, database, or other medium used in embodiments provided herein may include at least one of non-volatile memory and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, high density embedded nonvolatile Memory, resistive random access Memory (RESISTIVE RANDOM ACCESS MEMORY, reRAM), magneto-resistive Memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric Memory (Ferroelectric Random Access Memory, FRAM), phase change Memory (PHASE CHANGE Memory, PCM), graphene Memory, and the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, and the like. By way of illustration, and not limitation, RAM can be in various forms such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), etc. The databases referred to in the embodiments provided herein may include at least one of a relational database and a non-relational database. The non-relational database may include, but is not limited to, a blockchain-based distributed database, and the like. The processor referred to in the embodiments provided in the present application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computation, an artificial intelligence (ARTIFICIAL INTELLIGENCE, AI) processor, or the like, but is not limited thereto.
The technical features of the above embodiments may be arbitrarily combined, and for brevity, all of the possible combinations of the technical features of the above embodiments are not described, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the present application.
The foregoing examples illustrate only a few embodiments of the application and are described in detail herein without thereby limiting the scope of the application. It should be noted that it will be apparent to those skilled in the art that several variations and modifications can be made without departing from the spirit of the application, which are all within the scope of the application. Accordingly, the scope of the application should be assessed as that of the appended claims.