CN110109734B - Method and device for realizing stateless virtual machine - Google Patents

Method and device for realizing stateless virtual machine Download PDF

Info

Publication number
CN110109734B
CN110109734B CN201910400858.XA CN201910400858A CN110109734B CN 110109734 B CN110109734 B CN 110109734B CN 201910400858 A CN201910400858 A CN 201910400858A CN 110109734 B CN110109734 B CN 110109734B
Authority
CN
China
Prior art keywords
virtual machine
snapshot
creating
virtual
disk
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.)
Active
Application number
CN201910400858.XA
Other languages
Chinese (zh)
Other versions
CN110109734A (en
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.)
Suzhou Inspur Intelligent Technology Co Ltd
Original Assignee
Suzhou Inspur Intelligent Technology 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 Suzhou Inspur Intelligent Technology Co Ltd filed Critical Suzhou Inspur Intelligent Technology Co Ltd
Priority to CN201910400858.XA priority Critical patent/CN110109734B/en
Publication of CN110109734A publication Critical patent/CN110109734A/en
Application granted granted Critical
Publication of CN110109734B publication Critical patent/CN110109734B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

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
    • 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/45562Creating, deleting, cloning virtual machine instances
    • 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/45575Starting, stopping, suspending or resuming 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 invention provides a method for realizing a stateless virtual machine in order to solve the problems in the prior art, the method is characterized in that the existing kvm virtualization function is utilized, the qemu disk chain snapshot function is utilized, the virtual machine is quickly created, the first snapshot of the existing virtual machine is deleted after the virtual machine is used, and the restoration point is redirected to a new third snapshot file, so that the function of quickly restoring an operating system is achieved, the stateless virtual machine is realized in a cloud platform, the stateless virtual machine realizing device is further provided, the software restoration in the operating system of the virtual machine is not relied on, the whole process is quick and efficient, data is not reserved, the configuration is realized, the safety of data is better protected, meanwhile, a physical restoration card is not adopted, the operation cost is greatly reduced, and the effective utilization of resources in a cloud environment is improved.

Description

Method and device for realizing stateless virtual machine
Technical Field
The invention relates to the field of virtual machines, in particular to a method and a device for realizing a stateless virtual machine.
Background
With the popularization of information technology, information systems are deployed and applied in most governments, armies and enterprises, while with the development of cloud computing, the development of cloud concepts and virtualization technology is deeply concentrated, and some enterprises have migrated traditional servers to cloud environments and delivered and used in a form of virtual machines providing infrastructure as a service (IaaS).
A virtual machine refers to a complete computer system with complete hardware functionality, which is emulated by software, running in a completely isolated environment. The hardware implementation of the virtual machine on the virtual machine layer is transparent to a user, and the user cannot perceive whether system software and application software run on physical hardware or virtual hardware, so that the user can install basic software conforming to hardware characteristics, such as a window system of an x86 architecture, a Linux system of an ARM architecture, an android system and the like. At present, some users need to quickly restore the content and state of an operating system to support a specific application environment, such as a teaching machine room in a school, a test environment in software development, and a system application environment in a public place, most of the application scenes are temporarily used without storing personal data, in the prior art, a physical restoration card is generally adopted, the content of the operating system is restored by using physical hardware, or software is used for performing backup restoration on a certain disk partition in the operating system, but in the prior art, the cost of the physical hardware is too high, each machine needs to be equipped with a corresponding physical restoration card, the software can only backup and restore the content of a certain partition, a large amount of resources are also occupied, so that the operating system runs slowly, meanwhile, the software is easy to crack, and data leakage is caused by data retention, which is not beneficial to data security.
Disclosure of Invention
The invention aims to solve the problems in the prior art, and innovatively provides a method and a device for realizing a stateless virtual machine.
The first aspect of the present invention provides a method for implementing a stateless virtual machine, where the method includes the following steps:
s1, creating a virtual disk, creating a plurality of first snapshots according to the virtual disk, and marking each first snapshot as a first restoring point;
s2, acquiring user information, the virtual disk information and the first restoring point information, and creating a second snapshot;
s3, creating a configuration file of the virtual machine according to the second snapshot, and creating and operating the virtual machine according to the configuration file of the virtual machine;
s4, deleting the first snapshot to be restored, which is created according to the virtual disk, creating a third snapshot according to the virtual disk, marking the third snapshot as a second restoration point, and pointing the second restoration point to the first restoration point to be restored before operation.
With reference to the first aspect, in a first possible implementation manner of the first aspect, the step S1 is to create a virtual disk, create a plurality of first snapshots according to the virtual disk, and mark each first snapshot as a first restore point specifically includes:
s11, creating a qcow2 type virtual disk by using a qemu-img command provided by qemu-kvm;
s12, mounting the created virtual disk under a virtual machine, allocating a memory and a CPU for the virtual machine, and mounting an iso image file of an operating system to be installed;
s13, installing an operating system on the created virtual disk by using an operating system iso image file, and running a virtual machine;
s14, using the snapshot function of qemu-img, creating a plurality of first snapshots, and marking each first snapshot as a first restoring point.
With reference to the first aspect, in a second possible implementation manner of the first aspect, the acquiring, in step S2, the user information includes: user name information.
With reference to the first aspect, in a third possible implementation manner of the first aspect, the acquiring, by the step S2, user information further includes: user data disk information.
With reference to the first aspect, in a fourth possible implementation manner of the first aspect, the creating a configuration file of a virtual machine by using a second snapshot in step S3 further includes: a user data disk in a configuration file attached to the virtual machine.
The second aspect of the present invention provides an apparatus for implementing a stateless virtual machine, including:
the first creating module is used for creating a virtual disk, creating a plurality of first snapshots according to the virtual disk, and marking each first snapshot as a first restoring point;
the acquisition module acquires user information, the virtual disk information and the first restoring point information, and creates a second snapshot;
the second creating module is used for creating a configuration file of the virtual machine according to the second snapshot and creating and operating the virtual machine according to the configuration file of the virtual machine;
and the deleting and restoring module deletes the first snapshot to be restored, which is created according to the virtual disk, creates a third snapshot according to the virtual disk, marks the third snapshot as a second restoring point, and points the second restoring point to the first restoring point to be restored before operation.
With reference to the second aspect, in a first possible implementation manner of the second aspect, the first creating module specifically includes:
the first creating submodule is used for creating a qcow2 type virtual disk by using a qemu-img command provided by qemu-kvm;
the mounting submodule mounts the created virtual disk under a virtual machine, allocates a memory and a CPU for the virtual machine, and mounts an iso image file of an operating system to be installed;
installing and running sub-modules, installing an operating system on the created virtual disk by using an operating system iso image file, and running a virtual machine;
and the second creating submodule creates a plurality of first snapshots by using a snapshot function of qemu-img, and marks each first snapshot as a first restoring point.
The technical scheme adopted by the invention comprises the following technical effects:
the invention provides a method and a device for realizing a stateless virtual machine in order to solve the problems in the prior art, and the method and the device are not dependent on software restoration in an operating system of the virtual machine, but use the existing characteristics of the kvm virtual machine to finish the process from creation to use to restoration, have the advantages of high speed and high efficiency in the whole process, do not leave data, are configurable, really realize the quick restoration of the virtual machine, and better protect the safety of the data. And the invention can establish a plurality of first snapshots at the same time, each first snapshot can be used for starting one virtual machine, and can also realize the restoration of a plurality of virtual machines at the same time.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the invention, as claimed.
Drawings
In order to more clearly illustrate the embodiments or technical solutions in the prior art of the present invention, the drawings used in the description of the embodiments or prior art will be briefly described below, and it is obvious for those skilled in the art that other drawings can be obtained based on these drawings without any creative effort.
Fig. 1 is a schematic flowchart of a method for implementing a stateless virtual machine according to an embodiment of the present invention;
fig. 2 is a schematic flowchart of step S1 in a method for implementing a stateless virtual machine according to a second embodiment of the present invention;
fig. 3 is a schematic structural diagram of an implementation apparatus of a stateless virtual machine according to a third embodiment of the present invention;
fig. 4 is a schematic structural diagram of a first creating module 101 in an implementation apparatus of a stateless virtual machine according to four embodiments of the present invention.
Detailed Description
In order to clearly explain the technical features of the present invention, the following detailed description of the present invention is provided with reference to the accompanying drawings. The following disclosure provides many different embodiments, or examples, for implementing different features of the invention. To simplify the disclosure of the present invention, the components and arrangements of specific examples are described below. Furthermore, the present invention may repeat reference numerals and/or letters in the various examples. This repetition is for the purpose of simplicity and clarity and does not in itself dictate a relationship between the various embodiments and/or configurations discussed. It should be noted that the components illustrated in the figures are not necessarily drawn to scale. Descriptions of well-known components and processing techniques and procedures are omitted so as to not unnecessarily limit the invention.
Example one
As shown in fig. 1, the present invention provides a method for implementing a stateless virtual machine, including the following steps:
s1, creating a virtual disk, creating a plurality of first snapshots according to the virtual disk, and marking each first snapshot as a first restoring point;
s2, acquiring user information, the virtual disk information and the first restoring point information, and creating a second snapshot;
s3, creating a configuration file of the virtual machine according to the second snapshot, and creating and operating the virtual machine according to the configuration file of the virtual machine;
s4, deleting the first snapshot to be restored, which is created according to the virtual disk, creating a third snapshot according to the virtual disk, marking the third snapshot as a second restoration point, and pointing the second restoration point to the first restoration point to be restored before operation.
In step S2, the user information, the virtual disk information, and the first restore point information are obtained mainly through the management software, where the user information includes: user name information. Acquiring the user information further comprises: user data disk information. If the user has the own data disk, the information of the data disk can be acquired. The second snapshot is created primarily for the disks of the virtual machine for user operations including, but not limited to, storage, access, and the like.
In step S3, creating a configuration file of a virtual machine according to the second snapshot, and creating and running the virtual machine according to the configuration file of the virtual machine; if the user has the user data disk, the user data disk can be attached to the configuration file of the virtual machine, that is, the second snapshot creating the configuration file of the virtual machine further includes: the user data disk configuration file is added to the configuration file of the virtual machine, which is equivalent to that the virtual machine is provided with two disks, one disk is a system disk and can be quickly restored, and the other disk is a user data disk and is used for storing user data without data restoration; the whole process is fast and efficient, data is not reserved, the configuration can be realized, the fast restoration of the virtual machine is really realized, and the data safety is better protected. After step S3 is completed, the configured stateless virtual machine may be started for the user to use.
In step S4, the virtual machine that the user has finished using is first closed, the first snapshot created according to the virtual disk to be restored is then deleted, the third snapshot is created according to the virtual disk, the third snapshot is marked as the second restoring point, and the second restoring point points to the first restoring point to be restored before the operation, so that the rapid restoration of the stateless virtual machine can be realized.
The embodiment of the invention not only can realize the quick reduction of the operating system disk, but also can realize the quick reduction of the data disk, so that the data between each user is separated, no data is remained, and the data safety of the user is better protected.
The scheme of the invention can not only recover the system disk or the C disk, but also recover other disks allocated to the virtual machine, when the scheme is recovered, the first snapshot is deleted, and then the third snapshot is created according to the template, the scheme is applied to the kvm virtualization platform, has no requirement on the virtual machine operating system, and supports the systems of window, linux, unix and the like.
Example two
As shown in fig. 2, step S1 in the implementation method of the stateless virtual machine in the technical solution of the present invention specifically includes:
s11, creating a qcow2 type virtual disk by using a qemu-img command provided by qemu-kvm;
s12, mounting the created virtual disk under a virtual machine, allocating a memory and a CPU for the virtual machine, and mounting an iso image file of an operating system to be installed;
s13, installing an operating system on the created virtual disk by using an operating system iso image file, and running a virtual machine;
s14, using the snapshot function of qemu-img, creating a plurality of first snapshots, and marking each first snapshot as a first restoring point.
In step S13, an operating system is installed on the created virtual disk using an operating system iso image file, after the operating system is installed, the required application software may be installed, and the system is modified accordingly, including but not limited to a memory environment, so as to meet the use requirements of the application software;
then, after the operating system is installed, closing the virtual machine;
in step S14, a first snapshot is created using the snapshot function of qemu-img and marked as a first restore point;
if multiple restore points are created, the virtual machine may be started multiple times, and the steps S13 and S14 may be repeated to create multiple first snapshots.
EXAMPLE III
As shown in fig. 3, the technical solution of the present invention further provides an implementation apparatus of a stateless virtual machine, including:
a first creating module 101, configured to create a virtual disk, create a plurality of first snapshots according to the virtual disk, and mark each first snapshot as a first restore point;
the obtaining module 102 is configured to obtain user information, the virtual disk information, and the first restore point information, and create a second snapshot;
a second creating module 103, configured to create a configuration file of a virtual machine according to the second snapshot, and create and run the virtual machine according to the configuration file of the virtual machine;
and the deleting and restoring module 104 is configured to delete the first snapshot to be restored, which is created according to the virtual disk, create a third snapshot according to the virtual disk, mark the third snapshot as a second restoring point, and point the second restoring point to the first restoring point to be restored before operation.
Example four
As shown in fig. 4, the technical solution of the present invention further provides an implementation apparatus of a stateless virtual machine, where the first creating module 101 specifically includes:
a first creating sub-module 201, which uses a qemu-img command provided by qemu-kvm to create a qcow2 type virtual disk;
the mounting submodule 202 mounts the created virtual disk under the virtual machine, allocates a memory and a CPU for the virtual machine, and mounts an iso image file of the operating system to be installed;
the installation and operation submodule 203 is used for installing an operating system on the created virtual disk by using an operating system iso image file and operating a virtual machine;
the second creating sub-module 204 creates a plurality of first snapshots by using the snapshot function of qemu-img, and marks each first snapshot as a first restoring point.
Although the embodiments of the present invention have been described with reference to the accompanying drawings, it is not intended to limit the scope of the present invention, and it should be understood by those skilled in the art that various modifications and variations can be made without inventive efforts by those skilled in the art based on the technical solution of the present invention.

Claims (5)

1. A method for realizing a stateless virtual machine is characterized by comprising the following steps:
s1, creating a virtual disk, creating a plurality of first snapshots according to the virtual disk, and marking each first snapshot as a first restoring point; the step S1 is to create a virtual disk, create a plurality of first snapshots according to the virtual disk, and mark each first snapshot as a first restore point specifically:
s11, creating a qcow2 type virtual disk by using a qemu-img command provided by qemu-kvm;
s12, mounting the created virtual disk under a virtual machine, allocating a memory and a CPU for the virtual machine, and mounting an iso image file of an operating system to be installed;
s13, installing an operating system on the created virtual disk by using an operating system iso image file, and running a virtual machine;
s14, creating a plurality of first snapshots by using a snapshot function of qemu-img, and marking each first snapshot as a first restoring point;
s2, acquiring user information, the virtual disk information and the first restoring point information, and creating a second snapshot;
s3, creating a configuration file of the virtual machine according to the second snapshot, and creating and operating the virtual machine according to the configuration file of the virtual machine;
s4, deleting the first snapshot to be restored, which is created according to the virtual disk, creating a third snapshot according to the virtual disk, marking the third snapshot as a second restoration point, and pointing the second restoration point to the first restoration point to be restored before operation.
2. The method for implementing a stateless virtual machine according to claim 1, wherein the step S2 of obtaining user information includes: user name information.
3. The method for implementing a stateless virtual machine according to claim 2, wherein the step S2 of obtaining user information further includes: user data disk information.
4. The method for implementing a stateless virtual machine according to claim 1 or 3, wherein the step S3 of creating the configuration file of the virtual machine according to the second snapshot further comprises: and adding the user data disk configuration file to the configuration file of the virtual machine.
5. An implementation apparatus of a stateless virtual machine, comprising:
the first creating module is used for creating a virtual disk, creating a plurality of first snapshots according to the virtual disk, and marking each first snapshot as a first restoring point; wherein the first creating module specifically includes:
the first creating submodule is used for creating a qcow2 type virtual disk by using a qemu-img command provided by qemu-kvm;
the mounting submodule mounts the created virtual disk under a virtual machine, allocates a memory and a CPU for the virtual machine, and mounts an iso image file of an operating system to be installed;
installing and running sub-modules, installing an operating system on the created virtual disk by using an operating system iso image file, and running a virtual machine;
the second creating submodule is used for creating a plurality of first snapshots by using a snapshot function of qemu-img, and each first snapshot is marked as a first restoring point;
the acquisition module acquires user information, the virtual disk information and the first restoring point information, and creates a second snapshot;
the second creating module is used for creating a configuration file of the virtual machine according to the second snapshot and creating and operating the virtual machine according to the configuration file of the virtual machine;
and the deleting and restoring module deletes the first snapshot to be restored, which is created according to the virtual disk, creates a third snapshot according to the virtual disk, marks the third snapshot as a second restoring point, and points the second restoring point to the first restoring point to be restored before operation.
CN201910400858.XA 2019-05-15 2019-05-15 Method and device for realizing stateless virtual machine Active CN110109734B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910400858.XA CN110109734B (en) 2019-05-15 2019-05-15 Method and device for realizing stateless virtual machine

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910400858.XA CN110109734B (en) 2019-05-15 2019-05-15 Method and device for realizing stateless virtual machine

Publications (2)

Publication Number Publication Date
CN110109734A CN110109734A (en) 2019-08-09
CN110109734B true CN110109734B (en) 2021-08-06

Family

ID=67490104

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910400858.XA Active CN110109734B (en) 2019-05-15 2019-05-15 Method and device for realizing stateless virtual machine

Country Status (1)

Country Link
CN (1) CN110109734B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110879742B (en) * 2019-10-15 2023-08-11 平安科技(深圳)有限公司 Method, device and storage medium for asynchronously creating internal snapshot by virtual machine

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103226493A (en) * 2013-05-15 2013-07-31 百度在线网络技术(北京)有限公司 Method and system for deploying multi-operation system service
CN104142847A (en) * 2013-05-06 2014-11-12 ***股份有限公司 Stateless virtual machine under cloud computation environment and application thereof
CN105094948A (en) * 2015-07-31 2015-11-25 杭州华为数字技术有限公司 System mirror image file updating method of virtual machine, cloud data center and system
CN105740047A (en) * 2016-01-26 2016-07-06 中标软件有限公司 Cloud computing based virtual machine template management system and method
CN109101323A (en) * 2018-09-10 2018-12-28 南京铱迅信息技术股份有限公司 Snapshot implementing method based on qcow2 format under virtual machine operating status

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104142847A (en) * 2013-05-06 2014-11-12 ***股份有限公司 Stateless virtual machine under cloud computation environment and application thereof
CN103226493A (en) * 2013-05-15 2013-07-31 百度在线网络技术(北京)有限公司 Method and system for deploying multi-operation system service
CN105094948A (en) * 2015-07-31 2015-11-25 杭州华为数字技术有限公司 System mirror image file updating method of virtual machine, cloud data center and system
CN105740047A (en) * 2016-01-26 2016-07-06 中标软件有限公司 Cloud computing based virtual machine template management system and method
CN109101323A (en) * 2018-09-10 2018-12-28 南京铱迅信息技术股份有限公司 Snapshot implementing method based on qcow2 format under virtual machine operating status

Also Published As

Publication number Publication date
CN110109734A (en) 2019-08-09

Similar Documents

Publication Publication Date Title
US9092248B1 (en) Systems and methods for restoring distributed applications within virtual data centers
US9626254B2 (en) Backup and non-staged recovery of virtual environment data
US10185637B2 (en) Preserving management services with distributed metadata through the disaster recovery life cycle
US7669020B1 (en) Host-based backup for virtual machines
US8631217B2 (en) Apparatus, system, and method for virtual machine backup
US9424136B1 (en) Systems and methods for creating optimized synthetic backup images
US8407182B1 (en) Systems and methods for facilitating long-distance live migrations of virtual machines
US8555278B2 (en) Method and system for migrating a selected set of virtual machines between volumes
US9430332B1 (en) Systems and methods for enabling efficient access to incremental backups
JP6186374B2 (en) System and method for secure migration to a virtualized platform
US10789135B2 (en) Protection of infrastructure-as-a-service workloads in public cloud
US8881144B1 (en) Systems and methods for reclaiming storage space from virtual machine disk images
US9817592B1 (en) Using an intermediate virtual disk format for virtual disk conversion
US9805068B1 (en) Systems and methods for facilitating features of system recovery environments during restore operations
US9785643B1 (en) Systems and methods for reclaiming storage space in deduplicating data systems
CN106777394B (en) Cluster file system
CN108804189B (en) Cloud desktop management method and system
AU2014290149B2 (en) Systems and methods for instantly restoring virtual machines in high input/output load environments
US9740520B1 (en) Systems and methods for virtual machine boot disk restoration
US9336131B1 (en) Systems and methods for enabling virtual environments to mount non-native storage disks
US9003139B1 (en) Systems and methods for recovering virtual machines after disaster scenarios
US10169027B2 (en) Upgrade of an operating system of a virtual machine
US11307934B1 (en) Virtual backup and restore of virtual machines
EP3398046A1 (en) Systems and methods for backing up large distributed scale-out data systems
US8565545B1 (en) Systems and methods for restoring images

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
GR01 Patent grant
GR01 Patent grant