CN117130727A - Disk type switching method and device of virtual machine and computer equipment - Google Patents

Disk type switching method and device of virtual machine and computer equipment Download PDF

Info

Publication number
CN117130727A
CN117130727A CN202311070955.XA CN202311070955A CN117130727A CN 117130727 A CN117130727 A CN 117130727A CN 202311070955 A CN202311070955 A CN 202311070955A CN 117130727 A CN117130727 A CN 117130727A
Authority
CN
China
Prior art keywords
disk
switched
type
virtual machine
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311070955.XA
Other languages
Chinese (zh)
Inventor
请求不公布姓名
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Anchao Cloud Software Co Ltd
Original Assignee
Anchao Cloud Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Anchao Cloud Software Co Ltd filed Critical Anchao Cloud Software Co Ltd
Priority to CN202311070955.XA priority Critical patent/CN117130727A/en
Publication of CN117130727A publication Critical patent/CN117130727A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45579I/O management, e.g. providing access to device drivers or storage
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45595Network integration; Enabling network access in virtual machine instances

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The application relates to a disk type switching method and device of a virtual machine and computer equipment. The method comprises the following steps: obtaining disk information of a disk to be switched of a virtual machine according to a mapping table of the virtual machine and the disk; switching the disk type of the disk to be switched to a target type according to the disk information; and updating the mapping table according to the disk of the target type, and deleting the disk to be switched. The method can realize the maximization of the platform resource use.

Description

Disk type switching method and device of virtual machine and computer equipment
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method, an apparatus, a computer device, a storage medium, and a computer program product for switching disk types of a virtual machine.
Background
A Virtual Machine (VM) is an example of a plurality of Operating Systems (OS) that are virtualized on a server. The disk types of the existing cloud platform virtual machine are only one, and when a plurality of disk types are deployed on one cloud platform, a single virtual machine can only use a single disk type for storage, cannot use a plurality of disk types for storage, and is not beneficial to maximizing the use of platform resources.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a disk type switching method, apparatus, computer device, storage medium, and computer program product for a virtual machine that can achieve maximization of platform resource usage.
In a first aspect, the present application provides a method for switching disk types of a virtual machine. The method comprises the following steps:
obtaining disk information of a disk to be switched of the virtual machine according to a mapping table of the virtual machine and the disk;
switching the disk type of the disk to be switched into a target type according to the disk information;
and updating the mapping table according to the magnetic disk of the target type, and deleting the magnetic disk to be switched.
In one embodiment, switching the disk type of the disk to be switched to the target type according to the disk information includes:
when the virtual machine is in a shutdown state, starting network block equipment according to disk information, and exposing a disk to be switched in a network service mode through the network block equipment; accessing network service, and switching the disk type of the disk to be switched into a target type;
and when the virtual machine is in a starting state, executing block copy operation, and switching the disk type of the disk to be switched into a target type.
In one embodiment, starting a network block device according to disk information, and exposing a disk to be switched in a network service mode through the network block device; accessing the network service, switching the disk type of the disk to be switched to the target type, including:
creating a target disk with the same size as the disk to be switched according to the disk information; the disk type of the target disk is the target type;
starting network block equipment according to a disk path in the disk information, and exposing the disk to be switched in a network service mode through the network block equipment;
accessing the network service, and transmitting the disk information of the disk to be switched provided by the network service to the target disk.
In one embodiment, performing a block copy operation to switch a disk type of a disk to be switched to a target type includes:
creating a target disk with the same size as the disk to be switched according to the disk information; the disk type of the target disk is the target type;
and executing the block copy operation, and transmitting the disk information of the disk to be switched to the target disk.
In one embodiment, the method further comprises:
and in the process of switching the disk types, if error reporting prompt information is received, deleting the created target disk.
In one embodiment, the method further comprises:
after the disk type of the disk to be switched is switched to the target type according to the disk information, if the disk to be switched of the virtual machine is not completely switched, returning to the step of switching the disk type of the disk to be switched to the target type according to the disk information until the disk to be switched is completely switched, and updating the mapping table according to the disk of the target type.
In a second aspect, the present application further provides a disk type switching device of the virtual machine. The device comprises:
the acquisition module is used for acquiring disk information of a disk to be switched of the virtual machine according to a mapping table of the virtual machine and the disk;
the switching module is used for switching the disk type of the disk to be switched into a target type according to the disk information;
and the updating module is used for updating the mapping table according to the magnetic disk of the target type and deleting the magnetic disk to be switched.
In a third aspect, the present application also provides a computer device. The computer device comprises a memory storing a computer program and a processor which when executing the computer program performs the steps of:
obtaining disk information of a disk to be switched of the virtual machine according to a mapping table of the virtual machine and the disk;
switching the disk type of the disk to be switched into a target type according to the disk information;
and updating the mapping table according to the magnetic disk of the target type, and deleting the magnetic disk to be switched.
In a fourth aspect, the present application also provides a computer-readable storage medium. The computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of:
obtaining disk information of a disk to be switched of the virtual machine according to a mapping table of the virtual machine and the disk;
switching the disk type of the disk to be switched into a target type according to the disk information;
and updating the mapping table according to the magnetic disk of the target type, and deleting the magnetic disk to be switched.
In a fifth aspect, the present application also provides a computer program product. The computer program product comprising a computer program which, when executed by a processor, performs the steps of:
obtaining disk information of a disk to be switched of the virtual machine according to a mapping table of the virtual machine and the disk;
switching the disk type of the disk to be switched into a target type according to the disk information;
and updating the mapping table according to the magnetic disk of the target type, and deleting the magnetic disk to be switched.
According to the disk type switching method, the device, the computer equipment, the storage medium and the computer program product of the virtual machine, after the disk information of the disk to be switched is obtained from the mapping table of the virtual machine and the disk, the disk type switching can be directly carried out on the virtual machine according to the disk information, the disk type of the virtual machine can be changed under the condition that the node of the virtual machine is not changed, the disk type of the virtual machine can be flexibly switched to different disk types, various disk types deployed on the cloud platform can be fully utilized, and the use of platform resources is maximized. In addition, when the storage capacity of a certain type is exhausted, a new type of disk can be created, and by switching the disk types, one virtual machine can integrate the advantages of different disk types.
Drawings
FIG. 1 is an application environment diagram of a disk type switching method of a virtual machine in one embodiment;
FIG. 2 is a flow chart of a method for switching disk types of a virtual machine according to an embodiment;
FIG. 3 is a flow chart of switching a disk type of a disk to be switched to a target type in one embodiment;
FIG. 4 is a schematic flow chart of a disk type switching method when the virtual machine is in a shutdown state;
FIG. 5 is a flow chart of a disk type switching method when the virtual machine is in a power-on state;
FIG. 6 is a flow chart of a method for switching disk types of a virtual machine according to another embodiment;
FIG. 7 is a block diagram of a disk type switching device of a virtual machine in one embodiment;
fig. 8 is an internal structural diagram of a computer device in one embodiment.
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.
The disk types of the existing cloud platform virtual machine are only one, and when a plurality of disk types are deployed on one cloud platform, a single virtual machine can only use a single disk type for storage and cannot use a plurality of disk types for storage, so that the following problems exist: (1) when the capacity of one storage is exhausted, the virtual machine can not create a disk any more; (2) the characteristics of different types of magnetic disks are different, and at present, one virtual machine cannot integrate the advantages of all magnetic disks; (3) the disk type of the virtual machine on the current platform cannot be flexibly switched. All of the above problems are detrimental to maximizing platform resource usage.
In order to solve the above problems, a disk type switching method of a virtual machine is provided.
The disk type switching method of the virtual machine provided by the embodiment of the application can be applied to an application environment shown in fig. 1. Wherein the terminal 102 communicates with the server 104 via a network. The data storage system may store data that the server 104 needs to process. The data storage system may be integrated on the server 104 or may be located on a cloud or other network server. The terminal 102 sends a disk type switching request to the server 104, the server 104 obtains a mapping table of the virtual machine and the disk according to the disk type switching request, and obtains disk information of the disk to be switched of the virtual machine according to the mapping table, so that the disk type of the disk to be switched is switched to a target type according to the disk information, and then the mapping table is updated according to the disk of the target type, and the disk to be switched is deleted, so that the disk type switching is completed. The terminal 102 may be, but not limited to, various personal computers, notebook computers, smart phones, tablet computers, internet of things devices, and portable wearable devices, where the internet of things devices may be smart speakers, smart televisions, smart air conditioners, smart vehicle devices, and the like. The portable wearable device may be a smart watch, smart bracelet, headset, or the like. The server 104 may be implemented as a stand-alone server or as a server cluster of multiple servers. Further, the method may be performed by a virtual machine virtualized out in server 104.
In one embodiment, as shown in fig. 2, a method for switching a disk type of a virtual machine is provided, and the method is applied to the server in fig. 1 for illustration, and includes the following steps:
step 202, obtaining disk information of a disk to be switched of the virtual machine according to a mapping table of the virtual machine and the disk.
The disk to be switched refers to a disk of the disk type to be switched in the virtual machine. The disk information refers to information related to the disk to be switched, and may include a path, a size, a disk type, a disk identifier, data stored in the disk, and the like of the disk. The path of a disk refers to the path of the disk on a physical machine, i.e., a server.
Specifically, the terminal sends a disk type switching request to the server, and the server analyzes the disk type switching request to obtain a virtual machine identifier of the disk type to be switched, a disk identifier of the disk to be switched and the disk type to be switched. Wherein the virtual machine identifier refers to a unique identifier for distinguishing the virtual machine, and the disk identifier refers to an identifier for distinguishing the disk storage device, for example, "C: "," D: "," E: "," F: "," G: "etc. And then, virtual machine information of the virtual machine corresponding to the virtual machine identifier is obtained, a mapping table of the virtual machine and the magnetic disk is obtained from the virtual machine information, and the mapping table comprises all the magnetic disks mapped to the virtual machine. The disks of the virtual machine may include a system disk and a data disk. And obtaining the disk information of all the disks to be switched of the virtual machine from the mapping table according to the disk symbols of the disks to be switched. Further, the number of the disks to be switched may be multiple, that is, may be part of the disks of the virtual machine, or may be all of the disks of the virtual machine.
And 204, switching the disk type of the disk to be switched to the target type according to the disk information.
Wherein the target type refers to the disk type to be switched. The disk types of the disk to be switched may include qcow2 and raw. The disk type of the disk to be switched is different from the target type.
The virtual machine is switched in different modes of disk types under the starting and key states. Since the block copy operation cannot be performed in a state where the virtual machine is turned off, and the block copy operation can ensure that the disk type is switched under the condition that the service is not interrupted, two methods for switching the disk type of the virtual machine are distinguished. Specifically, when the virtual machine is in a shutdown state, all the disks to be switched are switched to the target type of disk through the network block equipment (Network Block Device, nbd), so that the switching of the disk types is realized. When the virtual machine is in a starting state, all the disks to be switched are switched to the target type of disk by executing the block copy operation. The network block device may use a disk space of a remote server as a block device. And all the disk information of the disk to be switched is migrated to the disk of the target type through the switching of the disk type.
Step 206, updating the mapping table according to the disk of the target type, and deleting the disk to be switched.
After all the disks to be switched are switched, the mapping table of the virtual machine is adjusted, the disk of the target type is mapped onto the virtual machine, the original disk to be switched of the virtual machine is deleted, and the disk type switching of the virtual machine is completed.
According to the disk type switching method of the virtual machine, after the disk information of the disk to be switched is obtained from the mapping table of the virtual machine and the disk, the server can directly switch the disk type of the virtual machine according to the disk information, the disk type of the virtual machine can be changed under the condition that the node of the virtual machine is not changed, the virtual machine can be flexibly switched to different disk types, various disk types deployed on the cloud platform can be fully utilized, and the use of platform resources is maximized. In addition, when the storage capacity of a certain type is exhausted, a new type of disk can be created, and by switching the disk types, one virtual machine can integrate the advantages of different disk types.
In one embodiment, as shown in fig. 3, switching the disk type of the disk to be switched to the target type according to the disk information includes:
step 302, when the virtual machine is in a shutdown state, starting network block equipment according to disk information, and exposing a disk to be switched in a network service mode through the network block equipment; and accessing network service, and switching the disk type of the disk to be switched into the target type.
And 304, when the virtual machine is in a starting state, executing a block copy operation, and switching the disk type of the disk to be switched to a target type.
The disk information includes the path of the disk, and after the path of the disk is obtained, the disk type switching operation is executed.
When the virtual machine is in a critical state, an nbd service may be started from qemu-nbd to expose the disk to be switched in the form of a network service, which is a network connection, but provides the services of the virtual physical disk for remote access. According to ip (Internet Protocol ) and port (port) of the nbd service, accessing the network service, and switching the disk type of the disk to be switched to the target type.
Further, a file format conversion tool qemu-img converter can be adopted for disk type switching.
When the virtual machine is in a shutdown state, a flow chart of a disk type switching manner may be shown in fig. 4, where a disk qcow2 represents a disk to be switched of qcow2 type, nbdserver represents an nbd service, nbd-disk represents a disk qcow2 of a network service form, converter represents a tool qemu-img converter for converting a file format, and disk raw represents a disk of raw type. server and client represent a service provider and a service requester, respectively.
When the virtual machine is in a starting state, the switching of the disk type needs to ensure the continuity of the service, and at the moment, the blocking copy needs to be called to execute the disk of the hot switching virtual machine, specifically, the blocking copy is executed on the disk to be switched, and all the disks of the target type are hung on the disk to be switched, which is mounted on the virtual machine. When the virtual machine is in a power-on state, a flow chart of a disk type switching manner may be shown in fig. 5, where vda, vdb, vdc represents disks of the virtual machine respectively. The vda, vdb and vdc of the virtual machine are respectively provided with a disk1, a disk2 and a disk3, and the disks 1, the disk2 and the disk3 are all of qcow2 type disks. The disks 4, 5 and 6 are created disks to be switched, the disk types are raw, after the block copy is executed on the disks 1, 2 and 3, the disk4 is automatically hung to vda, the disk5 is hung to vdb, and the disk6 is hung to vdc, so that the switching of the disk types of the virtual machine is completed.
In the embodiment, the virtual machine uses different operations in startup and shutdown to realize flexible switching of the disk types of the disk mounted under the virtual machine, so that the effectiveness and accuracy of the disk type switching can be improved.
In an optional manner of the above embodiment, the network block device is started according to the disk information, and the disk to be switched is exposed in the form of network service through the network block device; accessing the network service, switching the disk type of the disk to be switched to the target type, including: creating a target disk with the same size as the disk to be switched according to the disk information; the disk type of the target disk is the target type; starting network block equipment according to a disk path in the disk information, and exposing the disk to be switched in a network service mode through the network block equipment; accessing the network service, and transmitting the disk information of the disk to be switched provided by the network service to the target disk.
The target disk refers to a disk of a created target type, and the disk is empty.
And searching all disk information mounted on the virtual machine in a mapping table of the virtual machine and the disk, and executing the operation of switching the disk types after obtaining the local paths of all the disks from the disk information.
All the disks under the virtual machine need to execute disk type switching operation, and firstly, a target disk with the same size as the disk to be switched is created, wherein the disk type of the target disk is the target type needing to be switched. After the creation, the to-be-switched disk is used for providing the service of the virtual physical disk in the form of network connection by using the nbd, so that the virtual disk provided by the network connection, namely the disk information of the to-be-switched disk, is converted into the target disk by using the file format conversion tool, and the type switching of the single disk is completed.
After all the disks are switched, the mapping table of the virtual machine and the disks is adjusted, a new disk, namely a target disk, is mapped onto the virtual machine, the disk to be switched is deleted, and the disk type switching of the virtual machine is completed.
In this embodiment, by creating a target disk having the same size as the disk to be switched, when the virtual machine is turned off, the disk to be switched is exposed in the form of network service through the network block device, so that when the network service is accessed, disk information of the disk to be switched is transmitted to the target disk. The method can realize flexible and effective switching of the disk types of the virtual machine in the shutdown state.
In an alternative manner of the above embodiment, performing the block copy operation to switch the disk type of the disk to be switched to the target type includes: creating a target disk with the same size as the disk to be switched according to the disk information; the disk type of the target disk is the target type; and executing the block copy operation, and transmitting the disk information of the disk to be switched to the target disk.
When the disk type is switched in the starting state of the virtual machine, a target disk with the same size as the disk to be switched is also required to be created, and the disk type of the target disk is the target type to be switched. And calling virsh block copy (block copy operation provided by virsh) to copy all the disks to be switched under the virtual machine to the created target disk in sequence. Wherein virsh is a management toolkit.
After all the disks are switched, the mapping table of the virtual machine and the disks is adjusted, a new disk, namely a target disk, is mapped onto the virtual machine, the disk to be switched is deleted, and the disk type switching of the virtual machine is completed.
In this embodiment, when the virtual machine is started, the disc type can be switched under the condition that the service is not interrupted through the block copy.
In one embodiment, in the process of switching the disk types, if the error reporting prompt information is received, deleting the created target disk.
If network interruption or physical machine power-down and other emergency occur suddenly in the disk type switching process, the server receives the error reporting prompt information of the emergency, and the disk type is failed to be switched at the moment, the created target disk needs to be deleted, and the occupation of resources of the physical machine is avoided.
In one embodiment, the method further comprises: after the disk type of the disk to be switched is switched to the target type according to the disk information, if the disk to be switched of the virtual machine is not completely switched, returning to the step of switching the disk type of the disk to be switched to the target type according to the disk information until the disk to be switched is completely switched.
After each disk is switched, whether all the disks to be switched of the virtual machine are switched in the disk type is identified. If the disk type switching is not completed completely, the step of switching the disk type of the disk to be switched to the target type according to the disk information is required to be returned, and the disk type switching is continued until the disk type switching of the disk to be switched of the virtual machine is completed completely.
After all the disks to be switched of the virtual machine are switched of the disk types, updating the mapping table according to the disk of the target type, and deleting the disk to be switched.
In this embodiment, by identifying whether all the disks to be switched of the virtual machine complete the disk type switching, it is ensured that after all the disks to be switched of the virtual machine complete the switching, the mapping table is updated uniformly, and the disks to be switched are deleted, so that the disk type switching efficiency can be improved.
In another embodiment, as shown in fig. 6, there is provided a disk type switching method of a virtual machine, the method including the steps of:
step 602, obtaining disk information of a disk to be switched of the virtual machine according to a mapping table of the virtual machine and the disk. When the virtual machine is in a shutdown state, step 604 is executed; when the virtual machine is in a power-on state, step 606 is performed.
Step 604, creating a target disk with the same size as the disk to be switched according to the disk information; the disk type of the target disk is the target type; starting network block equipment according to a disk path in the disk information, and exposing the disk to be switched in a network service mode through the network block equipment; accessing the network service, and transmitting the disk information of the disk to be switched provided by the network service to the target disk. Execution continues with step 608.
Step 606, creating a target disk with the same size as the disk to be switched according to the disk information; the disk type of the target disk is the target type; and executing the block copy operation, and transmitting the disk information of the disk to be switched to the target disk. Execution continues with step 608.
Step 608, identifying whether all the disks to be switched of the virtual machine are switched of the disk type, if yes, executing step 610; if not, return to step 604 or 606.
Step 610, updating the mapping table according to the disk of the target type, and deleting the disk to be switched.
Step 612, in the process of switching the disk types, if the error reporting prompt information is received, deleting the created target disk.
The flow of switching the disk type when the virtual machine is shut down is as follows: s1: the virtual machine created in the cloud platform has a system disk and a data disk, if all disk types of the virtual machine are in qcow2 format, if the system disk is to be switched to raw format or all disks are to be switched to raw format, the disk identifier of the disk to be switched and the disk type to be switched need to be specified. The disk information of all the disks mounted below the current disk symbol of the virtual machine can be obtained from the mapping table of the virtual machine and the disks, and the disk information comprises information such as paths, sizes, disk formats, mounted disk symbols and the like. S2: creating an empty disk according to the disk size information acquired in the S1 and the disk type to be switched, namely a target disk, and transferring the information to be switched to the target disk by using a mode of a command of [ qemu-nbd-d < ip > -p < port > to be switched disk path (starting an nbd service from qemu-nbd to expose the disk to be switched under the disk path to be switched in a network service mode), wherein the disk can be accessed in the form of nbd/ip: port, and then using a mode of [ qemu-img convert raw nbd:https:// ip: port target disk path ] (a file format conversion tool qemu-img controller switches the disk information of the disk to be switched to the target disk under the target disk path according to ip and port of the nbd service) to finish the switching of the disk type. S3: after all the disks are switched, the mapping table of the virtual machine and the disks is adjusted, a new disk, namely a target disk, is mapped onto the virtual machine, the disk to be switched is deleted, the disk type switching of the virtual machine is completed, and the occupation of physical machine resources is avoided. S4: if the error is reported in the switching process, deleting the target disk created in the S1, and switching the disk type is failed.
In this embodiment, after obtaining the disk information of the disk to be switched from the mapping table of the virtual machine and the disk, the server can directly switch the disk type of the virtual machine according to the disk information, can change the disk type of the virtual machine without changing the node where the virtual machine is located, can flexibly switch to different disk types, can fully utilize multiple disk types deployed on the cloud platform, and realizes the maximization of platform resource use. In addition, when the storage capacity of a certain type is exhausted, a new type of disk can be created, and by switching the disk types, one virtual machine can integrate the advantages of different disk types.
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 disk type switching device of the virtual machine for realizing the disk type switching method of the virtual machine. 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 disk type switching device for one or more virtual machines provided below may refer to the limitation of the disk type switching method for a virtual machine hereinabove, and will not be repeated herein.
In one embodiment, as shown in fig. 7, there is provided a disk type switching apparatus of a virtual machine, including: an acquisition module 702, a switching module 704, and an update module 706, wherein:
the obtaining module 702 is configured to obtain disk information of a disk to be switched of the virtual machine according to a mapping table of the virtual machine and the disk.
And the switching module 704 is configured to switch the disk type of the disk to be switched to the target type according to the disk information.
And the updating module 706 is configured to update the mapping table according to the disk of the target type, and delete the disk to be switched.
In one embodiment, the switching module 704 is further configured to start the network block device according to the disk information when the virtual machine is in a shutdown state, and expose the disk to be switched in a network service form through the network block device; accessing network service, and switching the disk type of the disk to be switched into a target type; and when the virtual machine is in a starting state, executing block copy operation, and switching the disk type of the disk to be switched into a target type.
In one embodiment, the switching module 704 is further configured to create a target disk with the same size as the disk to be switched according to the disk information; the disk type of the target disk is the target type; starting network block equipment according to a disk path in the disk information, and exposing the disk to be switched in a network service mode through the network block equipment; accessing the network service, and transmitting the disk information of the disk to be switched provided by the network service to the target disk.
In one embodiment, the switching module 704 is further configured to create a target disk with the same size as the disk to be switched according to the disk information; the disk type of the target disk is the target type; and executing the block copy operation, and transmitting the disk information of the disk to be switched to the target disk.
In one embodiment, the apparatus further comprises:
and the error reporting processing module is used for deleting the created target disk if error reporting prompt information is received in the process of switching the disk types.
In one embodiment, the apparatus further comprises:
and the progress identification module is used for returning to the step of switching the disk type of the disk to be switched to the target type according to the disk information if the disk to be switched of the virtual machine is identified to not completely finish the disk type switching after the disk type of the disk to be switched is switched to the target type according to the disk information, and updating the mapping table according to the disk of the target type until the disk type of the disk to be switched is completely switched.
The above-mentioned respective modules in the disk type switching device of the virtual machine may be implemented in whole or in part by software, hardware, and combinations 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 embodiment, a computer device is provided, which may be a server, and the internal structure of which may be as shown in fig. 8. The computer device includes a processor, a memory, an Input/Output interface (I/O) and a communication interface. The processor, the memory and the input/output interface are connected through a system bus, and the communication interface is 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, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database of the computer device is used for storing data such as mapping tables of the virtual machine and the disk. 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 communicating with an external terminal through a network connection. The computer program, when executed by a processor, implements a disk type switching method for a virtual machine.
It will be appreciated by those skilled in the art that the structure shown in FIG. 8 is merely a block diagram of some of the structures associated with the present inventive arrangements and is not limiting of the computer device to which the present inventive arrangements may be applied, 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 an embodiment, there is also provided a computer device 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, carries out 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 information and data authorized by the user or sufficiently authorized by each party, and the collection, use and processing of the related data need to comply with the related laws and regulations and standards of the related country and region.
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 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 (ReRAM), magnetic random access 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 the form of a variety of forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), and the like. 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 computing, or the like, but is not limited thereto.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
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.

Claims (10)

1. A disk type switching method of a virtual machine, the method comprising:
obtaining disk information of a disk to be switched of a virtual machine according to a mapping table of the virtual machine and the disk;
switching the disk type of the disk to be switched to a target type according to the disk information;
and updating the mapping table according to the disk of the target type, and deleting the disk to be switched.
2. The method of claim 1, wherein switching the disk type of the disk to be switched to the target type according to the disk information comprises:
when the virtual machine is in a shutdown state, network block equipment is started according to the disk information, and the disk to be switched is exposed in a network service mode through the network block equipment; accessing the network service, and switching the disk type of the disk to be switched into a target type;
and when the virtual machine is in a starting state, executing block copy operation, and switching the disk type of the disk to be switched into a target type.
3. The method according to claim 2, wherein the network block device is started according to disk information, and the disk to be switched is exposed in the form of network service through the network block device; accessing the network service, and switching the disk type of the disk to be switched to a target type, wherein the method comprises the following steps:
creating a target disk with the same size as the disk to be switched according to the disk information; the disk type of the target disk is a target type;
starting network block equipment according to a disk path in the disk information, and exposing the disk to be switched in a network service mode through the network block equipment;
and accessing the network service, and transmitting the disk information of the disk to be switched provided by the network service to the target disk.
4. The method of claim 2, wherein the performing a block copy operation to switch the disk type of the disk to be switched to a target type comprises:
creating a target disk with the same size as the disk to be switched according to the disk information; the disk type of the target disk is a target type;
and executing a block copy operation, and transmitting the disk information of the disk to be switched to the target disk.
5. The method according to claim 3 or 4, characterized in that the method further comprises:
and in the process of switching the disk types, if error reporting prompt information is received, deleting the created target disk.
6. The method according to claim 1, wherein the method further comprises:
after the disk type of the disk to be switched is switched to the target type according to the disk information, if the disk to be switched of the virtual machine is not completely switched, returning to the step of switching the disk type of the disk to be switched to the target type according to the disk information until the disk to be switched is completely switched, and updating the mapping table according to the disk of the target type.
7. A disk type switching apparatus of a virtual machine, the apparatus comprising:
the system comprises an acquisition module, a switching module and a switching module, wherein the acquisition module is used for acquiring disk information of a disk to be switched of a virtual machine according to a mapping table of the virtual machine and the disk;
the switching module is used for switching the disk type of the disk to be switched into a target type according to the disk information;
and the updating module is used for updating the mapping table according to the magnetic disk of the target type and deleting the magnetic disk to be switched.
8. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any of claims 1 to 6 when the computer program is executed.
9. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 6.
10. A computer program product comprising a computer program, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 6.
CN202311070955.XA 2023-08-23 2023-08-23 Disk type switching method and device of virtual machine and computer equipment Pending CN117130727A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311070955.XA CN117130727A (en) 2023-08-23 2023-08-23 Disk type switching method and device of virtual machine and computer equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311070955.XA CN117130727A (en) 2023-08-23 2023-08-23 Disk type switching method and device of virtual machine and computer equipment

Publications (1)

Publication Number Publication Date
CN117130727A true CN117130727A (en) 2023-11-28

Family

ID=88850226

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311070955.XA Pending CN117130727A (en) 2023-08-23 2023-08-23 Disk type switching method and device of virtual machine and computer equipment

Country Status (1)

Country Link
CN (1) CN117130727A (en)

Similar Documents

Publication Publication Date Title
US11809726B2 (en) Distributed storage method and device
CN107622091B (en) Database query method and device
WO2017167171A1 (en) Data operation method, server, and storage system
US10356150B1 (en) Automated repartitioning of streaming data
WO2016180055A1 (en) Method, device and system for storing and reading data
CN112685148B (en) Asynchronous communication method and device for mass terminals, computer equipment and storage medium
JP2019531563A (en) Data processing method, storage system, and switching device
WO2024041376A1 (en) Distributed graph data processing system, method, apparatus and device, and storage medium
CN113051102B (en) File backup method, device, system, storage medium and computer equipment
CN111352899B (en) Path aggregation method, access method, communication device, and storage medium
CN107179883B (en) Spark architecture optimization method of hybrid storage system based on SSD and HDD
US20240205292A1 (en) Data processing method and apparatus, computer device, and computer-readable storage medium
CN117130727A (en) Disk type switching method and device of virtual machine and computer equipment
WO2012171363A1 (en) Method and equipment for data operation in distributed cache system
CN117435129A (en) Storage cluster expansion method and device, computer equipment and storage medium
US9971532B2 (en) GUID partition table based hidden data store system
CN112148513A (en) Dump method and device for single point service data and storage medium
WO2023143061A1 (en) Data access method and data access system thereof
CN112804335B (en) Data processing method, data processing device, computer readable storage medium and processor
CN116820430B (en) Asynchronous read-write method, device, computer equipment and storage medium
CN115550317B (en) Network resource management method, device, computer equipment and storage medium
WO2024037223A1 (en) Data operation method and apparatus
CN118964491A (en) Data processing method, apparatus, computer device, readable storage medium, and program product
CN117632009A (en) Data storage method and device based on business application and computer equipment
CN118158094A (en) Configuration information processing method, device, network equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination