A virtual resource migration method, device, electronic device and storage medium
By changing the Openstack resource pool and migrating the storage cluster, the problem of complex virtual machine migration process and high cost in the existing technology is solved, and efficient cross-resource pool migration and low-cost virtual machine migration are achieved.
Patent Information
- Application Number
- CN202111273274.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-29
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2041-10-29
AI Technical Summary
The existing technology for migrating virtual machines across Openstack resource pools suffers from the complex image migration process and long downtime, as well as the high cost of third-party tool migration.
By changing the original resource pool and the target resource pool, obtaining a storage cluster, extracting and migrating virtual resources, and establishing a partner cluster, virtual machines can be migrated across resource pools, avoiding shared storage between resource pools, improving migration efficiency and reducing costs. downtime costs.
It achieves high efficiency in migrating virtual machines across resource pools, avoids virtual machine downtime, saves downtime costs, and improves the efficiency of the migration process.
Smart Images

Figure CN114020409B
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, device, electronic device and storage medium for migrating virtual resources. Background Art
[0002] Cloud computing refers to a new computing model based on Internet-related services and using virtualization to share IT resources. Its core idea is to manage and schedule computing, storage, network, software and other resources in a unified manner through the network, to achieve resource integration and configuration optimization, and to meet the needs of different users to obtain and expand at any time, use and pay on demand, and minimize costs in the form of services.
[0003] The common technical solutions for migrating virtual machines across Openstack resource pools on the market are:
[0004] (1) Image migration: Use tools to create a virtual machine image of the virtual machine to be migrated, upload the image to the destination environment, and use the image to create a virtual machine. The disadvantages are that image creation is troublesome, the migration process is complicated, and the downtime is relatively long.
[0005] (2) Migration using third-party tools has short downtime or no downtime, and the migration process can ensure real-time data synchronization; the disadvantage is that it is expensive and requires the installation of an agent program in the operating system of the virtual machine to be migrated. When there are too many migration tasks, the cost is too high. Summary of the invention
[0006] In order to solve the above technical problems or at least partially solve the above technical problems, the present application provides a virtual resource migration method, device, electronic device and storage medium.
[0007] According to one aspect of an embodiment of the present application, a method for migrating virtual resources is provided, comprising:
[0008] Obtaining a target virtual machine for a migration task to be performed, and determining an original resource pool in which the target virtual machine is located, and a target resource pool to which the target virtual machine is migrated;
[0009] The original resource pool and the target resource pool are changed according to a preset rule to obtain a changed original resource pool and a target resource pool;
[0010] Acquire a first storage cluster in the original resource pool and a second storage cluster in the target resource pool, wherein the first storage cluster and the second storage cluster are used to store virtual resources of virtual machines;
[0011] The target virtual resources corresponding to the target virtual machine are extracted from the first storage cluster, and the target virtual resources are migrated to the second storage cluster, so that the changed target resource pool creates a virtual machine identical to the target virtual machine based on the target virtual resources.
[0012] Further, the changing the original resource pool and the target resource pool according to a preset rule to obtain the changed original resource pool and target resource pool includes:
[0013] Obtain a first configuration file and a key file corresponding to the first storage cluster, and a second configuration file corresponding to the second storage cluster, wherein the first configuration file is used as a slave configuration file, and the second configuration file is used as a master configuration file;
[0014] Copying the first configuration file and the key file to the target resource pool to obtain a changed target resource pool;
[0015] The second configuration file is copied to the original resource pool to obtain a changed original resource pool.
[0016] Further, the obtaining a first configuration file corresponding to the first storage cluster and a second configuration file corresponding to the second storage cluster includes:
[0017] Acquire a first original file corresponding to the first storage cluster from the original resource pool, and acquire a second original file corresponding to the second storage cluster from the target resource pool;
[0018] Obtaining a first original file name corresponding to the first original file and a second original file name corresponding to the second original file;
[0019] receiving a file update instruction, wherein the file update instruction is used to update the first original file name and the second original file name;
[0020] Based on the file update instruction, the first original file name is updated to a first preset file name to obtain the first configuration file;
[0021] Based on the file update instruction, the second original file name is updated to a second preset file name to obtain the second configuration file.
[0022] Furthermore, after changing the configuration files of the original resource pool and the target resource pool to obtain the changed original resource pool and target resource pool, the method further includes:
[0023] receiving a service control instruction, wherein the service control instruction is used to control the restart of a target service in the first storage cluster and the second storage cluster;
[0024] The target service in the first storage cluster and the second storage cluster is restarted according to the service control instruction, so that the first configuration file and the second configuration file are valid.
[0025] Furthermore, before extracting the target virtual resource corresponding to the target virtual machine from the first storage cluster, the method further includes:
[0026] Receive cluster control instructions;
[0027] Based on the cluster control instruction, the first storage cluster and the second storage cluster are established as a partner cluster.
[0028] Further, extracting the target virtual resource corresponding to the target virtual machine from the first storage cluster and migrating the target virtual resource to the second storage cluster includes:
[0029] Receive resource migration instructions;
[0030] Based on the resource migration instruction, controlling the target resource pool to migrate the target virtual resource from the original resource pool to the target resource pool;
[0031] When the migration of the target virtual resource is completed, a preset interface is called to store the target virtual resource in the second storage cluster in the target resource pool.
[0032] Further, after controlling the target resource pool to migrate the target virtual resource from the original resource pool to the target resource pool based on the resource migration instruction, the method further includes:
[0033] Detecting the running status of the target virtual machine in the first storage cluster;
[0034] When the running state is the power-on state, the target virtual machine is controlled to stop running.
[0035] According to another aspect of an embodiment of the present application, a virtual machine migration device is also provided, including:
[0036] A determination module is used to obtain a target virtual machine for a migration task to be performed, and determine an original resource pool where the target virtual machine is located, and a target resource pool to which the target virtual machine is migrated;
[0037] A change module, used to change the original resource pool and the target resource pool according to a preset rule to obtain the changed original resource pool and the target resource pool;
[0038] An acquisition module, used to acquire a first storage cluster in the original resource pool and a second storage cluster in the target resource pool, wherein the first storage cluster and the second storage cluster are used to store virtual resources of virtual machines;
[0039] The migration module is used to extract the target virtual resources corresponding to the target virtual machine from the first storage cluster, and migrate the target virtual resources to the second storage cluster, so that the changed target resource pool creates a virtual machine identical to the target virtual machine based on the target virtual resources.
[0040] According to another aspect of an embodiment of the present application, a storage medium is further provided, which includes a stored program, and the above steps are executed when the program is run.
[0041] According to another aspect of an embodiment of the present application, there is also provided an electronic device, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; wherein: the memory is used to store computer programs; and the processor is used to execute the steps in the above method by running the program stored in the memory.
[0042] The embodiment of the present application also provides a computer program product including instructions, which, when executed on a computer, enables the computer to execute the steps in the above method.
[0043] The above technical solution provided by the embodiment of the present application has the following advantages over the prior art: the present application realizes the migration of virtual machines across resource pools by changing the original resource pool and the target resource pool, and compared with the prior art, it no longer requires shared storage between resource pools, thereby improving the efficiency of virtual machine migration. In addition, the target virtual machine does not need to be shut down during the migration process, thereby ensuring that the virtual machine can operate normally and saving downtime costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0045] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0046] Figure 1 A flowchart of a method for migrating virtual resources provided in an embodiment of the present application;
[0047] Figure 2 A flowchart of a virtual resource migration method provided in another embodiment of the present application;
[0048] Figure 3 A flowchart of a virtual resource migration method provided in another embodiment of the present application;
[0049] Figure 4 A block diagram of a virtual resource migration device provided in an embodiment of the present application;
[0050] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0051] In order to make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. The schematic embodiments of the present application and their descriptions are used to explain the present application and do not constitute improper limitations on the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0052] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another similar entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0053] The embodiments of the present application provide a method, device, electronic device and storage medium for migrating virtual resources. The method provided by the embodiments of the present invention can be applied to any required electronic device, for example, it can be a server, a terminal or other electronic device, which is not specifically limited here, and for the convenience of description, it is referred to as an electronic device in the following.
[0054] According to one aspect of an embodiment of the present application, a method embodiment of migrating virtual resources is provided. Figure 1 A flowchart of a method for migrating virtual resources provided in an embodiment of the present application is shown in FIG. Figure 1 As shown, the method includes:
[0055] Step S11, obtaining a target virtual machine for a to-be-performed migration task, and determining an original resource pool where the target virtual machine is located, and a target resource pool to which the target virtual machine is migrated.
[0056] The method provided in the embodiment of the present application is applicable to a host device, in which multiple resource pools are deployed, each resource pool corresponds to a storage cluster, and the storage cluster is used to store virtual resources corresponding to virtual machines in the resource pool. The virtual resources can be cloud hard disks of virtual machines.
[0057] It should be noted that the resource pool in the embodiment of the present application is an Openstack resource pool, and the storage cluster is a Ceph storage cluster, wherein Openstack: is an open source software project that provides open source software for building public and private clouds. It provides an operating platform or tool set for deploying clouds, and its purpose is to help organizations run clouds that provide virtual computing, network or storage services, and provide scalable and flexible cloud computing solutions for public and private clouds. The main goal of Openstack is to simplify the management and allocation of resources, and to virtualize the three major items of computing, network and storage into three major resource pools. Ceph is a software-defined storage that can run on almost all mainstream Linux distributions (such as CentOS and Ubuntu) and other UNIX-like operating systems (typically FreeBSD). Ceph's distributed genes make it easy to manage large-scale clusters with hundreds of nodes and PB-level and above storage capacity. At the same time, the flat addressing design based on computing enables Ceph clients to communicate directly with any node on the server, thereby avoiding performance bottlenecks caused by the existence of access hotspots.
[0058] In the embodiment of the present application, the host device receives a migration task, determines the target virtual machine according to the migration task, and queries the original resource pool where the target virtual machine is located and the target resource pool to which the target virtual machine is migrated. The migration task is used to migrate the target virtual machine from the original resource pool to the target resource pool.
[0059] As an example, the original resource pool is Openstack A and the target resource pool is Openstack B. The storage cluster corresponding to the original resource pool Openstack A is Ceph A, and the storage cluster corresponding to the target resource pool Openstack B is Ceph B. Openstack A uses Ceph A's rbd storage as the storage backend, and Openstack B uses Ceph B's rbd storage as the storage backend. Ceph storage provides a block storage feature rbd mirroring, which is a mechanism for asynchronous replication / synchronous mirroring between two clusters. The migration task is used to migrate the target virtual machine from the original resource pool Openstack A to the target resource pool Openstack B.
[0060] Step S12, changing the original resource pool and the target resource pool according to a preset rule to obtain the changed original resource pool and the target resource pool.
[0061] In the embodiment of the present application, the original resource pool and the target resource pool are changed according to the preset rules to obtain the changed original resource pool and the target resource pool, such as Figure 2 As shown, the following steps A1-A3 are included:
[0062] Step A1, obtaining a first configuration file and a key file corresponding to the first storage cluster, and a second configuration file corresponding to the second storage cluster, wherein the first configuration file is used as a slave configuration file, and the second configuration file is used as a master configuration file.
[0063] In the embodiment of the present application, step A1, obtaining a first configuration file corresponding to the first storage cluster and a second configuration file corresponding to the second storage cluster, includes the following steps A101-A105:
[0064] Step A101: Acquire a first original file corresponding to a first storage cluster from an original resource pool, and acquire a second original file corresponding to a second storage cluster from a target resource pool.
[0065] Step A102, obtaining a first original file name corresponding to the first original file and a second original file name corresponding to the second original file.
[0066] Step A103: receiving a file update instruction, wherein the file update instruction is used to update the first original file name and the second original file name.
[0067] Step A104: based on the file update instruction, update the first original file name to a first preset file name to obtain a first configuration file.
[0068] Step A105: Based on the file update instruction, the second original file name is updated to a second preset file name to obtain a second configuration file.
[0069] Step A2: copy the first configuration file and the key file to the target resource pool to obtain a changed target resource pool.
[0070] Step A3: copy the second configuration file to the original resource pool to obtain a changed original resource pool.
[0071] As an example, obtain the configuration file of Ceph A from the original resource pool Openstack A and rename the file name of Ceph A from Ceph.conf to master.conf. Then obtain the configuration file of Ceph B from the target resource pool Openstack B and rename the file name of Ceph B from Ceph.conf to slave.conf.
[0072] Finally, copy the configuration file master.conf from the original resource pool Openstack A to the target resource pool Openstack B, and copy the configuration file slave.conf from the target resource pool Openstack B to the original resource pool Openstack A. At the same time, copy the key file (keyring file) of CephA in the original resource pool Openstack A to the target resource pool Openstack B.
[0073] It should be noted that the embodiment of the present application aims to achieve the migration of virtual machines across two Openstack resource pools by changing the configuration files of the storage cluster in the original resource pool and the storage cluster in the target resource pool. At the same time, by changing the file name of the configuration file corresponding to the storage medium, the method of using shared storage is replaced, so that the two Openstack resource pools can use two independent sets of Ceph storage resources.
[0074] In the embodiment of the present application, after changing the configuration files of the original resource pool and the target resource pool to obtain the changed original resource pool and the target resource pool, as shown in FIG. Figure 3 As shown, the method also includes the following steps B1-B2:
[0075] Step B1: receiving a service control instruction, wherein the service control instruction is used to control the restart of a target service in the first storage cluster and the second storage cluster.
[0076] Step B2: restarting the target service in the first storage cluster and the second storage cluster according to the service control instruction, so that the first configuration file and the second configuration file are valid.
[0077] In the embodiment of the present application, the modified Ceph configuration file takes effect by restarting the cinder-volume service in the original resource pool Openstack A and the target resource pool Openstack B.
[0078] Step S13: acquiring a first storage cluster in the original resource pool and a second storage cluster in the target resource pool, wherein the first storage cluster and the second storage cluster are used to store virtual resources of the virtual machine.
[0079] In the embodiment of the present application, before extracting the target virtual resource corresponding to the target virtual machine from the first storage cluster, the method further includes the following steps C1-C2:
[0080] Step C1, receiving a cluster control instruction.
[0081] Step C2: based on the cluster control instruction, the first storage cluster and the second storage cluster are established as partner clusters.
[0082] In the embodiment of the present application, the cluster control instruction may be an RBD command, and by executing the RBD command, Ceph B is added as a partner cluster in Ceph A, and Ceph A is added as a partner cluster in Ceph B. By establishing the first storage cluster and the second storage cluster as partner clusters, the purpose is to enable direct resource migration between subsequent storage clusters.
[0083] Step S14: extracting target virtual resources corresponding to the target virtual machine from the first storage cluster, and migrating the target virtual resources to the second storage cluster, so that the changed target resource pool creates a virtual machine identical to the target virtual machine based on the target virtual resources.
[0084] In an embodiment of the present application, extracting a target virtual resource corresponding to a target virtual machine from a first storage cluster and migrating the target virtual resource to a second storage cluster includes the following steps D1-D3:
[0085] Step D1, receiving a resource migration instruction.
[0086] Step D2: Based on the resource migration instruction, control the target resource pool to migrate the target virtual resource from the original resource pool to the target resource pool.
[0087] Step D3: when the migration of the target virtual resource is completed, calling a preset interface to store the target virtual resource in a second storage cluster in the target resource pool.
[0088] In an embodiment of the present application, according to the resource migration instruction, the rbd-mirror process is started in the second storage cluster Ceph B to synchronize the virtual resources of the virtual machine in Ceph A. In the target resource pool Openstack B, the rbd storage synchronized from the first storage cluster Ceph A is managed using the cinder api. After management, the corresponding virtual resources can be seen in the target storage cluster Openstack B environment. In the target storage cluster Openstack B environment, new virtual resources are used to create a virtual machine with the same configuration as the source virtual machine. In this way, the virtual machine started from the virtual resource is migrated from the original resource pool OpenstackA to the target resource pool OpenstackB. If the virtual machine to be migrated has multiple virtual resources, the multiple virtual resources can be migrated separately. After the migration of the cloud hard disks is completed, a new virtual machine can be created.
[0089] This application achieves the migration of virtual machines across resource pools by changing the original resource pool and the target resource pool. Compared with the prior art, it no longer requires shared storage between resource pools, thereby improving the efficiency of virtual machine migration. In addition, the target virtual machine does not need to be shut down during the migration process, thereby ensuring that the virtual machine can operate normally and saving downtime costs.
[0090] In the embodiment of the present application, after controlling the target resource pool to migrate the target virtual resource from the original resource pool to the target resource pool based on the resource migration instruction, the method further includes:
[0091] Step E1: Detect the running status of the target virtual machine in the first storage cluster.
[0092] Step E2: when the running state is the on state, control the target virtual machine to stop running.
[0093] In an embodiment of the present application, after the target virtual resources are migrated to the target resource pool and stored in the second storage cluster corresponding to the target resource pool, the running status of the target virtual machine in the first storage cluster is detected. If it is in the powered-on state, the target virtual machine is controlled to stop running, so as to ensure that the target virtual machine does not conflict with the virtual machine recreated by the target resource pool based on the target virtual resources.
[0094] The following is a completion process of a virtual resource migration method provided in an embodiment of the present application:
[0095] Step K1, obtain the migration task, determine the target virtual machine, the original resource pool Openstack A where the target virtual machine is located, and the target resource pool Openstack B to which the target virtual machine is migrated according to the migration task, rename the Ceph configuration file Ceph.conf of Openstack A to master.conf, and rename the Ceph configuration file Ceph.conf of Openstack B to slave.conf.
[0096] Step K2: Copy the configuration file master.conf from Openstack A to Openstack B, and copy the configuration file slave.conf from Openstack B to Openstack A.
[0097] Step K3: Copy the Ceph keyring file in Openstack A to Openstack B.
[0098] Step K4, execute the RBD command to add CephB as a partner cluster in Ceph A, and add Ceph A as a partner cluster in Ceph B.
[0099] Step K5: Restart the cinder-volume service in Openstack A and Openstack B to make the modified Ceph configuration file take effect.
[0100] Step K6, start the rbd-mirror process in Ceph B to synchronize the virtual resources of the target virtual machine in CephA.
[0101] Step K7, waiting for storage synchronization to be completed, if the target virtual machine is powered on at this time, shutting down the target virtual machine.
[0102] Step K8: In the Openstack B environment, use the cinder API to manage the rbd storage synchronized from CephA. After management, the corresponding virtual resources can be seen in the Openstack B environment.
[0103] Step K9, in the Openstack B environment, use the new virtual resources to create a target virtual machine with the same configuration as the source target virtual machine, so that the target virtual machine started from the virtual resources is migrated from the Openstack resource pool A to the Openstack resource pool B.
[0104] Figure 4This is a block diagram of a virtual machine migration device provided in an embodiment of the present application. The device can be implemented as part or all of an electronic device through software, hardware, or a combination of both. Figure 4 As shown, the device comprises:
[0105] The determination module 41 is used to obtain a target virtual machine for a migration task to be performed, and determine an original resource pool where the target virtual machine is located, and a target resource pool to which the target virtual machine is migrated;
[0106] A changing module 42, used to change the original resource pool and the target resource pool according to a preset rule to obtain the changed original resource pool and the target resource pool;
[0107] An acquisition module 43 is used to acquire a first storage cluster in the original resource pool and a second storage cluster in the target resource pool, wherein the first storage cluster and the second storage cluster are used to store virtual resources of the virtual machine;
[0108] The migration module 44 is used to extract the target virtual resources corresponding to the target virtual machine from the first storage cluster, and migrate the target virtual resources to the second storage cluster, so that the changed target resource pool creates a virtual machine identical to the target virtual machine based on the target virtual resources.
[0109] In an embodiment of the present application, the change module 42 is used to obtain a first configuration file and a key file corresponding to the first storage cluster, and a second configuration file corresponding to the second storage cluster, wherein the first configuration file is used as a slave configuration file and the second configuration file is used as a master configuration file; the first configuration file and the key file are copied to the target resource pool to obtain a changed target resource pool; the second configuration file is copied to the original resource pool to obtain a changed original resource pool.
[0110] In an embodiment of the present application, the change module 42 is used to obtain a first original file corresponding to the first storage cluster from the original resource pool, and to obtain a second original file corresponding to the second storage cluster from the target resource pool; to obtain a first original file name corresponding to the first original file, and a second original file name corresponding to the second original file; to receive a file update instruction, wherein the file update instruction is used to update the first original file name and the second original file name; based on the file update instruction, the first original file name is updated to a first preset file name to obtain a first configuration file; based on the file update instruction, the second original file name is updated to a second preset file name to obtain a second configuration file.
[0111] In an embodiment of the present application, the migration device also includes: a first control module, used to receive service control instructions, wherein the service control instructions are used to control the restart of the target service in the first storage cluster and the second storage cluster; according to the service control instructions, the target service in the first storage cluster and the second storage cluster is restarted to make the first configuration file and the second configuration file valid.
[0112] In the embodiment of the present application, the migration device further includes: a second control module, configured to receive a cluster control instruction; and based on the cluster control instruction, establish the first storage cluster and the second storage cluster as partner clusters.
[0113] In an embodiment of the present application, the migration module 44 is used to receive resource migration instructions; based on the resource migration instructions, control the target resource pool to migrate the target virtual resources from the original resource pool to the target resource pool; when the migration of the target virtual resources is completed, call the preset interface to store the target virtual resources in the second storage cluster in the target resource pool.
[0114] In the embodiment of the present application, the migration device further includes: a detection module, configured to detect the running state of the target virtual machine in the first storage cluster; and control the target virtual machine to stop running when the running state is a power-on state.
[0115] The present application also provides an electronic device, such as Figure 5 As shown, the electronic device may include: a processor 1501 , a communication interface 1502 , a memory 1503 and a communication bus 1504 , wherein the processor 1501 , the communication interface 1502 , and the memory 1503 communicate with each other via the communication bus 1504 .
[0116] Memory 1503, used for storing computer programs;
[0117] The processor 1501 is used to implement the steps of the above embodiment when executing the computer program stored in the memory 1503.
[0118] The communication bus mentioned in the above terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0119] The communication interface is used for communication between the above terminal and other devices.
[0120] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0121] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0122] In another embodiment provided in the present application, a computer-readable storage medium is provided, in which instructions are stored. When the computer-readable storage medium is executed on a computer, the computer executes the virtual resource migration method described in any of the above embodiments.
[0123] In another embodiment provided by the present application, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute the virtual resource migration method described in any one of the above embodiments.
[0124] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk SolidState Disk), etc.
[0125] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application are included in the protection scope of the present application.
[0126] The above description is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest range consistent with the principles and novel features applied for herein.
Claims
1. A method for migrating virtual resources, It is characterized in that include: Obtaining a target virtual machine for a migration task to be performed, and determining an original resource pool in which the target virtual machine is located, and a target resource pool to which the target virtual machine is migrated; The original resource pool and the target resource pool are changed according to a preset rule to obtain a changed original resource pool and a target resource pool; Acquire a first storage cluster in the original resource pool and a second storage cluster in the target resource pool, wherein the first storage cluster and the second storage cluster are used to store virtual resources of virtual machines; Extracting the target virtual resource corresponding to the target virtual machine from the first storage cluster, and migrating the target virtual resource to the second storage cluster, so that the changed target resource pool creates a virtual machine identical to the target virtual machine based on the target virtual resource; The changing the original resource pool and the target resource pool according to the preset rules to obtain the changed original resource pool and the target resource pool includes: obtaining a first configuration file and a key file corresponding to the first storage cluster, and a second configuration file corresponding to the second storage cluster, wherein the first configuration file is used as a slave configuration file and the second configuration file is used as a master configuration file; copying the first configuration file and the key file to the target resource pool to obtain the changed target resource pool; copying the second configuration file to the original resource pool to obtain the changed original resource pool; After changing the configuration files of the original resource pool and the target resource pool to obtain the changed original resource pool and the target resource pool, the method further includes: receiving a service control instruction, wherein the service control instruction is used to control the restart of the target service in the first storage cluster and the second storage cluster; and restarting the target service in the first storage cluster and the second storage cluster according to the service control instruction to make the first configuration file and the second configuration file valid.
2. The method according to claim 1, It is characterized in that The obtaining a first configuration file corresponding to the first storage cluster and a second configuration file corresponding to the second storage cluster includes: Acquire a first original file corresponding to the first storage cluster from the original resource pool, and acquire a second original file corresponding to the second storage cluster from the target resource pool; Obtaining a first original file name corresponding to the first original file and a second original file name corresponding to the second original file; receiving a file update instruction, wherein the file update instruction is used to update the first original file name and the second original file name; Based on the file update instruction, the first original file name is updated to a first preset file name to obtain the first configuration file; Based on the file update instruction, the second original file name is updated to a second preset file name to obtain the second configuration file.
3. The method according to claim 1, It is characterized in that Before extracting the target virtual resource corresponding to the target virtual machine from the first storage cluster, the method further includes: Receive cluster control instructions; Based on the cluster control instruction, the first storage cluster and the second storage cluster are established as a partner cluster.
4. The method according to claim 1, It is characterized in that The step of extracting the target virtual resource corresponding to the target virtual machine from the first storage cluster and migrating the target virtual resource to the second storage cluster includes: Receive resource migration instructions; Based on the resource migration instruction, controlling the target resource pool to migrate the target virtual resource from the original resource pool to the target resource pool; When the migration of the target virtual resource is completed, a preset interface is called to store the target virtual resource in the second storage cluster in the target resource pool.
5. The method according to claim 4, It is characterized in that After controlling the target resource pool to migrate the target virtual resource from the original resource pool to the target resource pool based on the resource migration instruction, the method further includes: Detecting the running status of the target virtual machine in the first storage cluster; When the running state is the power-on state, the target virtual machine is controlled to stop running.
6. A virtual machine migration device, It is characterized in that include: A determination module is used to obtain a target virtual machine for a migration task to be performed, and determine an original resource pool where the target virtual machine is located, and a target resource pool to which the target virtual machine is migrated; A change module, used to change the original resource pool and the target resource pool according to a preset rule to obtain the changed original resource pool and the target resource pool; An acquisition module, used to acquire a first storage cluster in the original resource pool and a second storage cluster in the target resource pool, wherein the first storage cluster and the second storage cluster are used to store virtual resources of virtual machines; A migration module, configured to extract target virtual resources corresponding to the target virtual machine from the first storage cluster, and migrate the target virtual resources to the second storage cluster, so that the changed target resource pool creates a virtual machine identical to the target virtual machine based on the target virtual resources; The change module is used to obtain a first configuration file and a key file corresponding to the first storage cluster, and a second configuration file corresponding to the second storage cluster, wherein the first configuration file is used as a slave configuration file and the second configuration file is used as a master configuration file; copy the first configuration file and the key file to the target resource pool to obtain a changed target resource pool; copy the second configuration file to the original resource pool to obtain a changed original resource pool; The device also includes: a first control module, used to receive a service control instruction, wherein the service control instruction is used to control the restart of a target service in the first storage cluster and the second storage cluster; according to the service control instruction, the target service in the first storage cluster and the second storage cluster is restarted to make the first configuration file and the second configuration file valid.
7. A storage medium, It is characterized in that The storage medium includes a stored program, wherein when the program is run, a processor executes the method according to any one of claims 1 to 5.
8. An electronic device, It is characterized in that It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; wherein: Memory, used to store computer programs; A processor, configured to execute the method according to any one of claims 1 to 5 by running a program stored in a memory.
