WO2014079194A1 - 恢复虚拟机的方法、系统及控制器、服务器、寄宿主机 - Google Patents

恢复虚拟机的方法、系统及控制器、服务器、寄宿主机 Download PDF

Info

Publication number
WO2014079194A1
WO2014079194A1 PCT/CN2013/074295 CN2013074295W WO2014079194A1 WO 2014079194 A1 WO2014079194 A1 WO 2014079194A1 CN 2013074295 W CN2013074295 W CN 2013074295W WO 2014079194 A1 WO2014079194 A1 WO 2014079194A1
Authority
WO
WIPO (PCT)
Prior art keywords
virtual machine
host
server
controller
migration instruction
Prior art date
Application number
PCT/CN2013/074295
Other languages
English (en)
French (fr)
Inventor
吴燕青
Original Assignee
华为技术有限公司
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 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2014079194A1 publication Critical patent/WO2014079194A1/zh

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
    • 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/45575Starting, stopping, suspending or resuming virtual machine instances

Definitions

  • the present invention relates to the field of computer technologies, and in particular, to a method, system, and controller, server, and host computer for restoring a virtual machine. Background technique
  • a virtual machine is a complete computer system that runs through a software and has full hardware system functionality running in a fully isolated environment. After entering the operating system of the virtual machine, all operations are carried out in this new independent virtual system.
  • the software can be installed independently, the data can be saved, and its own independent desktop can be created without any impact on the real system.
  • one or more virtual machines can be virtualized on one physical computer.
  • CD-ROM boot refers to the virtual machine booting from the CD-ROM drive.
  • Network boot means that the virtual machine is not booted from the local hard disk of the host machine, but is booted from the hard disk of the network share.
  • Hard disk boot refers to the virtual machine booting from the host's hard disk.
  • the CD-ROM boot is mainly applicable to the installation scenario of the operating system of an empty virtual machine. However, it is slow to start and should not be promoted. It is not suitable for large-scale scenarios.
  • the network startup requires that all the virtual machines that use the shared hard disk must have the same application scenario, which limits the application scenarios of the virtual machine.
  • the startup time is affected by the network status. The startup process is unstable and the application is unfavorable.
  • Hard disk booting is a common startup mode for virtual machines. It is also the simplest and most direct way, but the startup time is slow. As described above, when the virtual machine is restored in the prior art, the startup speed is too slow, which greatly affects the promotion and application of the virtual machine. Summary of the invention
  • the technical problem to be solved by the embodiments of the present invention is to provide a method for recovering a virtual machine, a controller, a server, and a host machine, which can improve the startup time of the virtual machine.
  • the first aspect provides a method for recovering a virtual machine, including the following steps:
  • the controller receives a startup notification of starting a virtual machine; the controller queries whether the server has a virtual machine image, and if the server has a virtual machine image, the controller separately Send the first migration command to the server and the host machine, the first move The move instruction is used to instruct the server to pre-copy the mirrored memory data of the virtual machine to the host machine.
  • the controller receives the startup notification of starting the virtual machine, specifically: the controller receives the virtual machine restart notification sent by the server; or the controller receives the virtuality sent by the host host
  • the special status notification of the machine, the special status includes the virtual machine startup status or the down state.
  • the method before the controller receives the startup notification of starting the virtual machine, the method further includes: the controller separately sending the second migration to the server and the host of the virtual machine
  • the second migration instruction is used to instruct the host to pre-copy the virtual machine's memory data to the server for a single time, so that the server generates a mirror of the virtual machine.
  • the method before the step of the controller separately sending the second migration instruction to the host of the server and the virtual machine, the method further includes: receiving, by the controller, the server Backing up the first backup instruction of the virtual machine, and generating a second migration instruction according to the first backup instruction.
  • a method for recovering a virtual machine comprising the steps of: receiving, by a server, a first migration instruction from a controller, where the first migration instruction is used to instruct the server to pre-copy the mirrored memory data of the virtual machine to a single time to The host machine; the server pre-copyes the mirrored memory data of the virtual machine to the host machine according to the first migration instruction, so that the host machine recovers the virtual machine.
  • the server receives the first migration instruction from the controller, specifically: the server receives the first message from the virtual machine, where the first message is used to indicate that the virtual machine is restarted; A message, sending a virtual machine restart notification to the controller, and sending a destroy command to the host machine to destroy the virtual machine; the server receives the first migration instruction sent by the controller according to the restart notification of the virtual machine.
  • the method before the step of the server receiving the first migration instruction from the controller, the method further includes: the server receiving the second migration instruction from the controller, The second migration instruction is used to instruct the host computer to pre-copy the virtual machine's memory data to the server for a single time; the server receives the memory data from the virtual machine and generates a mirror of the virtual machine.
  • the method before the step of the server receiving the second migration instruction from the controller, the method further includes:
  • the server receives the connection request from the virtual machine, establishes a connection with the virtual machine; the server obtains the virtual The IP address and computer name of the virtual machine; the server queries whether there is a virtual machine image according to the virtual machine's IP address and computer name; if the server does not have a virtual machine image, the server sends the first backup of the backup virtual machine to the controller.
  • the step of receiving, by the server, the second migration instruction from the controller comprises: the server receiving the second migration instruction sent by the controller according to the first backup instruction.
  • the step of the server receiving the second migration instruction from the controller includes: the server receiving is triggered by the trigger module of the controller The second migration instruction.
  • the method before the step of the server receiving the first migration instruction from the controller, the method further includes: the server receiving the backup virtual machine sent by the virtual machine
  • the second backup instruction is sent by the server to the host machine according to the second backup instruction; the server receives the memory data of the virtual machine transmitted by the host machine according to the third migration instruction, and generates a mirror image of the virtual machine.
  • a method for recovering a virtual machine comprising the steps of: receiving, by a host machine, a first migration instruction from a controller, where the first migration instruction is used to instruct the server to pre-copy a mirrored memory data of the virtual machine To the host machine; the host machine receives the mirrored memory data of the virtual machine according to the first migration instruction, and restores the virtual machine on the host machine.
  • the method before the step of receiving, by the host, the first migration instruction from the controller, the method further includes: the host computer detecting a special state of the virtual machine, where the special state includes a virtual machine startup state or a downtime The host sends a special status notification of the virtual machine to the controller when detecting the special state of the virtual machine; the host receives the first migration instruction from the controller, specifically: the host receives the virtual machine according to the virtual machine. The first migration instruction sent by the special status notification.
  • the method before the receiving host receives the first migration instruction from the controller, the method further includes: the host receiving the second migration instruction from the controller, The second migration instruction is used to instruct the host machine to pre-copy the virtual machine's memory data to the server in a single time; the host machine suspends the virtual machine according to the second migration instruction or the third migration instruction, and pre-copyes the virtual machine's memory data in a single time. To the server, generate a mirror of the virtual machine on the server.
  • the method before the host receiving the first migration instruction from the controller, the method further includes: the host receiving the first from the server The third migration instruction is used to instruct the host machine to pre-copy the virtual machine's memory data to the server for a single time, and generate a virtual machine image on the server; the host machine suspends the virtual machine according to the third migration instruction, and virtualizes The machine's in-memory data is pre-copied to the server for a single time so that the server generates a mirror of the virtual machine.
  • a controller including: a first receiving module, configured to receive a startup notification of activating a virtual machine; a querying module, configured to query whether a server has a virtual machine image; and a first sending module, configured to After querying the mirror of the virtual machine, the query module sends a first migration instruction to the server and the host machine, and the first migration instruction is used to instruct the server to pre-copy the mirrored memory data of the virtual machine to the host machine.
  • the first receiving module is specifically configured to: receive a virtual machine restart notification sent by the server; or receive a special status notification from the virtual machine sent by the host machine, where the special status includes a virtual state The start state and down state of the machine.
  • the controller further includes: a second sending module, configured to send a second migration instruction to the host host and the server, and the second migration instruction Used to instruct the host machine to pre-copy the virtual machine's memory data to the server for a single time, so that the server generates a mirror of the virtual machine.
  • the controller further includes: a second receiving module, configured to receive a first backup instruction of the backup virtual machine from the server And a generating module, configured to generate a second migration instruction according to the first backup instruction.
  • the controller includes: a trigger generating module, configured to trigger the second migration instruction.
  • a server including: a first receiving module, configured to receive a first migration instruction from a controller, where the first migration instruction is used to instruct the server to pre-copy a mirrored memory data of the virtual machine To the host machine; the pre-copy module is configured to pre-copy the mirrored memory data of the virtual machine to the host machine according to the first migration instruction, so that the virtual machine is restored on the host machine.
  • the server further includes: a second receiving module, configured to receive a first message from the virtual machine, where the first message is used to indicate that the virtual machine is restarted; and the first sending module is configured to: Sending a virtual machine restart notification to the controller according to the first message, and sending a destroy command to the host machine to destroy the virtual machine; the first receiving module is specifically: receiving by the controller according to the virtual machine restart notification The first migration instruction sent.
  • the server further includes: a third receiving module, configured to receive a second migration instruction from the controller; and a first receiving generation module, according to the second The migration instruction receives memory data from the virtual machine of the host machine and generates a mirror of the virtual machine.
  • the server further includes: a receiving and establishing module, configured to receive a connection request from the virtual machine, and establish a connection with the virtual machine;
  • the obtaining module is configured to obtain an IP address and a computer name of the virtual machine, and a query module, configured to query whether a virtual machine image exists according to the IP address and the computer name;
  • the second sending module is configured to: the query module does not query the virtual machine When mirroring, send the first backup instruction of the backup virtual machine to the controller.
  • the third receiving module is specifically configured to receive a second migration instruction sent by the controller according to the first backup instruction.
  • the third receiving module is specifically configured to: receive the second migration instruction triggered by the trigger module of the controller.
  • the server includes: a fourth receiving module, receiving a second backup instruction from the backup virtual machine sent by the virtual machine; and a third sending module, configured to: Sending a third migration instruction to the host of the virtual machine according to the second backup instruction; the second receiving generation module is configured to receive the memory data of the virtual machine transmitted by the host machine according to the third migration instruction, and generate a mirror image of the virtual machine .
  • a host computer including: a first receiving module, configured to receive a first migration instruction from a controller, where the first migration instruction is used to instruct the server to pre-copy a mirrored memory data of the virtual machine To the host computer; the receiving recovery module, configured to receive the memory data of the mirror of the virtual machine transmitted from the server according to the first migration instruction, and recover the virtual machine on the host machine.
  • the host computer further includes: a detecting module, configured to detect a special state of the virtual machine, where the special state includes a startup state and a down state of the virtual machine; and a first sending module, configured to: When the detecting module detects the special state of the virtual machine, the special state notification of the virtual machine is sent to the controller; the first receiving module is specifically configured to receive the first migration instruction sent by the controller according to the special state notification of the virtual machine.
  • a detecting module configured to detect a special state of the virtual machine, where the special state includes a startup state and a down state of the virtual machine
  • a first sending module configured to: When the detecting module detects the special state of the virtual machine, the special state notification of the virtual machine is sent to the controller; the first receiving module is specifically configured to receive the first migration instruction sent by the controller according to the special state notification of the virtual machine.
  • the host The machine further includes: a second receiving module, configured to receive a second migration instruction from the controller, where the second migration instruction is used to instruct the host computer to pre-copy the virtual machine memory data to the server; the pre-copy module is configured to hang Start the virtual machine and pre-copy the virtual machine's memory data to the server.
  • the host computer further includes: a third receiving module, configured to receive a third migration instruction of the server, where the third migration instruction is used to indicate the host host Pre-copy the virtual machine's memory data to the server for a single time; the pre-copy module is used to suspend the virtual machine according to the third migration instruction, and pre-copy the virtual machine's memory data to the server.
  • a third receiving module configured to receive a third migration instruction of the server, where the third migration instruction is used to indicate the host host Pre-copy the virtual machine's memory data to the server for a single time; the pre-copy module is used to suspend the virtual machine according to the third migration instruction, and pre-copy the virtual machine's memory data to the server.
  • the embodiment of the present invention further provides a virtual machine recovery system, comprising any one of the controllers of the fourth aspect, any one of the servers of the fifth aspect, Host the machine.
  • the beneficial effects of the embodiments of the present invention are as follows:
  • the present invention pre-copyes the memory data of the virtual machine to the server in a single manner by means of memory migration, and generates a virtual machine image on the server; after the virtual machine restarts or shuts down, it starts or When the virtual machine is down, the mirrored memory data of the virtual machine on the server is pre-copied to the host computer, and the host machine mounts the hard disk for the virtual machine to recover the virtual machine, and the virtual machine can have a startup item.
  • the virtual machine no longer needs to go through the process of generating the virtual machine in the host machine and the startup process of the virtual machine itself, effectively improving the startup time of the virtual machine.
  • the memory data of the virtual machine is generally small, and the time from the server's single pre-copy to the host machine is extremely short, which does not affect the startup time of the virtual machine.
  • FIG. 1 is a flow chart of a first embodiment of a method for recovering a virtual machine of the present invention
  • FIG. 2 is a flow chart of a second embodiment of a method for recovering a virtual machine of the present invention
  • FIG. 3 is a flow chart of a third embodiment of a method for recovering a virtual machine of the present invention.
  • FIG. 4 is a flow chart of a fourth embodiment of a method for recovering a virtual machine according to the present invention.
  • FIG. 5 is a flow chart showing a sub-step of a server receiving a first migration instruction in a fourth embodiment of the present invention.
  • FIG. 6 is a flow chart of a fifth embodiment of a method for recovering a virtual machine according to the present invention.
  • FIG. 7 is a flow chart of a sixth embodiment of a method for restoring a virtual machine according to the present invention.
  • Figure 8 is a schematic structural view of a first embodiment of the controller of the present invention
  • Figure 9 is a schematic structural view of a second embodiment of the controller of the present invention
  • FIG. 10 is a schematic structural view of a first embodiment of a server of the present invention.
  • Figure 11 is a schematic structural view of a second embodiment of the server of the present invention.
  • Figure 12 is a schematic structural view of a first embodiment of the host machine of the present invention.
  • Figure 13 is a schematic structural view of a second embodiment of the host machine of the present invention.
  • FIG. 14 is a schematic structural diagram of a system implementation manner for restoring a virtual machine according to the present invention.
  • FIG. 15 is a flowchart of initial startup of a virtual machine in a system implementation manner for restoring a virtual machine according to the present invention
  • FIG. 16 is a flow chart of internal operation backup of a virtual machine in a system implementation manner for restoring a virtual machine according to the present invention
  • 17 is a flow chart of a virtual machine initiating an internal restart in a system implementation manner for restoring a virtual machine according to the present invention
  • FIG. 1 is a flowchart of a first embodiment of a method for restoring a virtual machine according to the present invention. As shown, the method includes:
  • Step S101 The controller receives a startup notification of starting the virtual machine.
  • the controller is a node that manages all virtual machines under one cluster, and the controller is connected to all the host machines under the cluster.
  • a virtual machine is a virtualized computer system hosted on a host computer.
  • the host computer is a computer in the physical sense.
  • a host machine can divide multiple virtual machines.
  • the host machine can sense the shutdown, startup, etc. of the virtual machine hosted on the host.
  • the step S101 may be specifically: the controller receives a special status notification from the virtual machine sent by the host machine, and the special status includes a startup status and a down state of the virtual machine.
  • the server acts as a shadow node for the virtual machine and maintains the server client relationship with the clients of all virtual machines under the cluster.
  • the client perceives the behavior of the virtual machine through the system interface, and sends the perceived behavior information of the virtual machine to the server. Since the client acts as a program inside the virtual machine, the client will perceive the virtual one earlier than the host. The behavior of the machine.
  • the server sends the obtained virtual machine behavior information to the controller. Therefore, the steps
  • S101 may be specifically: The controller receives a virtual machine restart notification sent by the server.
  • Step S102 The controller queries whether the server has a mirror of the virtual machine. If the server has a mirror of the virtual machine, the process proceeds to step S103.
  • Step S103 The controller sends a first migration instruction to the server and the host machine respectively, where the first migration instruction is used to instruct the server to pre-copy the mirrored memory data of the virtual machine to the host host; the virtual machine mirroring is the virtual machine in the server.
  • the server is running the same virtual machine as the virtual machine running on the host machine.
  • the server can also compress the image of the virtual machine to form a compressed image.
  • a single pre-copy is a one-time (including dirty data in memory) that copies the memory data of the host's virtual machine to the server.
  • the server After the server receives the virtual machine's memory data, it will generate a virtual machine at the server.
  • the controller may also send a mount command to the host to enable the host to mount the hard disk for the virtual machine.
  • the controller instructs the server to pre-copy the mirrored memory data of the virtual machine to the host computer for a single time to restore the virtual machine.
  • the startup of the virtual machine does not need to go through the process of generating the virtual machine on the host machine and the startup process of the virtual machine itself, thereby effectively improving the startup time of the virtual machine.
  • the virtual machine's memory data is small, and the time from pre-copying to the host machine is extremely short, which does not affect the startup time of the virtual machine.
  • FIG. 2 is a flowchart of a second embodiment of a method for restoring a virtual machine according to the present invention. As shown in the figure, including:
  • Step S201 The controller receives a first backup instruction of the backup virtual machine from the server, and generates a second migration instruction according to the first backup instruction.
  • a virtual machine is a virtualized computer system hosted on a host computer.
  • the server is the shadow node of the virtual machine in the cluster.
  • the server can be a physically deployed server or a virtual server deployed for virtualization, for example: Provides server functionality in the form of a virtual machine.
  • the server is at the same level as the controller, the server is connected to all the virtual machines in the cluster, and the server can obtain the virtual machine's IP address and computer name. Further, the server queries whether the virtual machine image exists locally according to the IP address and the computer name. If the virtual machine does not have the image of the virtual machine locally, after receiving the information about the startup of the virtual machine sent by the client, the server sends the backup virtual machine to the controller. First backup Order.
  • the controller is used to manage all the virtual machines under the cluster and connect with the host of the virtual machine to sense the behavior of the virtual machine by receiving the information of the host machine, such as: startup and shutdown of the virtual machine.
  • the trigger module may be set in the controller, and the trigger module triggers the second migration instruction, wherein the trigger point of the trigger module may be set according to the actual situation, for example: restart or power on automatic synchronization, manual synchronization, application Modified synchronization, timing synchronization, and more.
  • the controller senses that the behavior of the virtual machine meets the trigger point, the second migration instruction is triggered.
  • step S201 can also be: triggering the trigger module of the controller to generate a second migration instruction.
  • Step S202 The controller sends a second migration instruction to the host machine and the server of the virtual machine, where the second migration instruction is used to instruct the host computer to pre-copy the virtual machine's memory data to the server for a single time to generate a virtual machine image on the server. .
  • the host machine is the physical host on which the virtual machine is running.
  • a single host machine can run multiple virtual machines.
  • a single pre-copy is to directly suspend the virtual machine of the host machine, and copy the memory data (including dirty data) of the virtual machine on the host machine to the server at one time, and generate a mirror image of the virtual machine on the server.
  • the virtual machine's image is the same virtual machine running on the server as the virtual machine running on the host machine.
  • the server can also compress the image of the virtual machine to form a compressed image.
  • Step S203 The controller receives a startup notification of starting the virtual machine.
  • the host machine is aware of all the behavior of the virtual machine hosted on the host machine and sends the perceived information to the controller.
  • the host machine senses that the virtual machine is started and down, and the virtual machine's startup state and down state are regarded as special states of the virtual machine, and a special status notification is sent to the controller. It should be noted that: After the host machine detects the virtual machine down, in addition to sending a special status notification to the controller, the host machine also forcibly shuts down the virtual machine that has been down.
  • Step S203 may be specifically: The controller receives a special status notification from a virtual machine sent by the host machine, and the special status includes a virtual machine startup state and a down state.
  • the virtual machine needs to be restarted, but the system does not restart.
  • the client senses that the virtual machine needs to be restarted through the system interface. Compared to the host machine, the client senses the restart behavior of the virtual machine one step earlier. At this time, the virtual machine's quick start process is performed immediately, so that the startup of the virtual machine no longer needs to go through the shutdown time of the virtual machine, thereby further improving the startup time of the virtual machine.
  • the client will restart the perceived virtual machine
  • the behavioral information is sent to the server.
  • the server sends a virtual machine restart notification to the controller. Therefore, the steps
  • S203 may be specifically: The controller receives a virtual machine restart notification sent by the server.
  • Step S204 The controller queries whether the server has a mirror of the virtual machine. If the server has a mirror of the virtual machine, the process proceeds to step S205.
  • Step S205 The controller sends a first migration instruction to the server and the host machine respectively, where the first migration instruction is used to instruct the server to pre-copy the mirrored memory data of the virtual machine to the host host; the server stores the mirrored memory data of the virtual machine. A single pre-copy to the host machine, the virtual machine is restored on the host.
  • the controller can also send a mount command to the host to enable the host to mount the hard disk for the virtual machine. After the host machine mounts the hard disk for the virtual machine, the virtual machine has the complete virtual machine function.
  • the hard disk that the host machine mounts for the virtual machine can be the hard disk carried by the host computer itself or the hard disk shared by the network.
  • the controller instructs the server to pre-copy the mirrored memory data of the virtual machine to the host machine where the virtual machine is located, and restore the virtual machine on the host machine.
  • the startup of the virtual machine does not need to go through the process of generating the virtual machine on the host machine and the startup process of the virtual machine itself, effectively increasing the startup time of the virtual machine.
  • the virtual machine's memory data is small, and the time from the server pre-copy to the host machine is extremely short, which does not affect the startup time of the virtual machine.
  • FIG. 3 is a flowchart of a third embodiment of a method for restoring a virtual machine according to the present invention. As shown, the method includes:
  • Step S301 The server receives a first migration instruction from the controller, where the first migration instruction is used to instruct the server to pre-copy the mirrored memory data of the virtual machine to the host machine.
  • Both the controller and the server are at the management level.
  • the controller is connected to all the hosts in the cluster, and the server maintains the relationship of the server client with the clients of all the virtual machines in the cluster.
  • the virtual machine's image is a copy of the virtual machine running on the server.
  • the server can also compress the virtual machine's mirrored memory data to form a compressed image. If the image of the virtual machine on the server is a compressed image, uncompress the compressed image before pre-copying the mirrored memory data of the virtual machine to the host.
  • Step S302 The server pre-copyes the mirrored memory data of the virtual machine to the host computer in a single manner according to the first migration instruction, so as to restore the virtual machine on the host machine.
  • a single pre-copy is to directly suspend the virtual machine on the server, and copy the memory data (including dirty data) of the virtual machine on the server to the host computer at one time. After pre-copying the mirrored memory data of the virtual machine to the host machine, the virtual machine is directly restored on the host.
  • the virtual machine by pre-copying the mirrored memory data of the virtual machine on the server to the host machine, the virtual machine is directly restored on the host machine, so that the startup of the virtual machine no longer needs to be generated in the host machine.
  • the virtual machine generation process and the virtual machine's own startup process effectively increase the startup time of the virtual machine.
  • the virtual machine's memory data is small, and the time from the server pre-copy to the host is extremely short, which does not affect the startup time of the virtual machine.
  • FIG. 4 is a flowchart of a fourth embodiment of a method for restoring a virtual machine according to the present invention. As shown, the method includes:
  • Step S401 The server receives the connection request from the virtual machine and establishes a connection with the virtual machine.
  • the server acts as a shadow node of the virtual machine, and the virtual machine can be migrated to the server, and a virtual machine image is run on the server.
  • the server remains connected to all virtual machines under the cluster. .
  • Step S402 The server acquires an IP address and a computer name of the virtual machine.
  • IP address and computer name form the unique identifier of the virtual machine. Different virtual machines can be identified by IP address and computer name.
  • Step S403 The server queries whether there is a mirror of the virtual machine according to the IP address and the computer name, and if not, proceeds to step S404;
  • the virtual machine is mirrored as a virtual machine running on the host machine, except that the virtual machine's image runs on the server as a copy of the virtual machine running on the host machine.
  • Step S404 The server sends a first backup instruction of the backup virtual machine to the controller.
  • the controller is used to manage all virtual machines under the cluster, and the controller is connected to all the hosts under the cluster. After receiving the first backup instruction, the controller sends a second migration instruction to the host where the server and the virtual machine are located.
  • Step S405 The server receives a second migration instruction sent by the controller according to the first backup instruction, where the second migration instruction is used to instruct the host machine to pre-copy the virtual machine memory data to the server in a single time; the host machine receives the second migration instruction. After that, the virtual machine's memory data is pre-copied to the server.
  • a trigger module can be set on the controller, and the trigger module is mainly used for backing up the virtual machine.
  • the trigger module triggers the second migration instruction, wherein the trigger point can be set according to the actual situation, for example: restart or power on automatic synchronization, manual synchronization, application Synchronized after modification, automatic timing synchronization, etc.
  • the controller triggers the second migration instruction when the controller senses that the behavior of the virtual machine meets the trigger point.
  • Step S406 The server receives a second migration instruction triggered by the trigger module of the controller, and the second migration instruction is used to instruct the host machine to pre-copy the virtual machine's memory data to the server.
  • the virtual machine sends a second backup instruction of the backup virtual machine to the server.
  • a backup button may be set on the virtual machine, and the backup button is clicked, and the virtual machine sends a second backup instruction to the server.
  • the virtual machine may be triggered to send a second backup instruction to the server, for example: voice. Command and so on.
  • Step S407 The server receives a second backup instruction from the backup virtual machine sent by the virtual machine.
  • Step S409 The server receives the memory data of the virtual machine from the host machine, and generates an image of the virtual machine.
  • the server After the server receives the memory data from the virtual machine of the host machine, it generates a virtual machine on the server that acts as a mirror of the virtual machine running on the host machine. Also, the virtual machine's image can be mounted without a hard disk.
  • Step S410 The server receives a first migration instruction from the controller, where the first migration instruction is used to instruct the server to pre-copy the mirrored memory data of the virtual machine to the host host.
  • the controller can learn the startup behavior of the virtual machine by receiving information from the host machine.
  • the controller queries the server for the presence of a mirror of the virtual machine. If there is a mirror of the virtual machine, the first migration instruction is sent to the host and the server respectively.
  • step S410 It can also include:
  • Sub-step S4101 The server receives a first message from the virtual machine, where the first message is used to indicate that the virtual machine is restarted;
  • Sub-step S4102 the server sends a virtual machine restart notification to the controller according to the first message, and sends a destroy command for destroying the virtual machine to the host machine of the virtual machine;
  • the host machine After the host machine receives the destroy command to destroy the virtual machine, it immediately destroys the virtual machine. Compared with the traditional method of shutting down the virtual machine, this method can shorten the virtual machine for a shorter period of time and further shorten the startup time of the virtual machine. Moreover, the host machine destroys the virtual machine by destroying the command, and then recovers the virtual machine by receiving the memory data of the virtual machine from the server, which is not a traditional restart process of the virtual machine. Therefore, the host does not sense the restart behavior of the virtual machine, and the host is hosted. The host does not send a virtual machine restart notification to the controller.
  • Sub-step S4103 The server receives the first migration instruction sent by the controller according to the virtual machine restart notification.
  • Step S411 The server pre-copyes the mirrored memory data of the virtual machine to the host machine according to the first migration instruction to restore the virtual machine on the host machine.
  • the virtual machine by pre-copying the memory data of the virtual machine on the server to the host machine, the virtual machine is directly restored on the host machine, so that the virtual machine no longer needs to recover from the recovery of the virtual machine on the host machine.
  • the process and the virtual machine's own startup process effectively increase the startup time of the virtual machine.
  • the virtual machine's memory data is small, and the time from the server pre-copy to the host machine is extremely short, which does not affect the startup time of the virtual machine.
  • FIG. 6 is a flowchart of a fifth embodiment of a method for restoring a virtual machine according to the present invention. As shown, the method includes:
  • Step S501 The host machine receives a first migration instruction from the controller, where the first migration instruction is used to instruct the server to pre-copy the mirrored memory data of the virtual machine to the host machine for a single time;
  • the controller is the node that manages all virtual machines under the cluster.
  • the host machine is a physical host, and the virtual machine must be running on the host machine.
  • a single pre-copy is to copy all the memory data of the virtual machine on the server to the host computer at one time.
  • Step S502 The host computer receives the mirrored memory data of the virtual machine according to the first migration instruction, and restores the virtual machine;
  • the host machine can also receive a mount command from the controller and mount the hard disk for the virtual machine according to the mount command.
  • the hard disk here can be the hard disk of the host machine itself or a shared hard disk on the network.
  • the host computer receives the mirrored memory data of the virtual machine from the server, and directly restores the virtual machine on the host machine, so that the startup of the virtual machine no longer needs to undergo the process of generating the virtual machine in the host machine and The startup process of the virtual machine itself effectively increases the startup time of the virtual machine.
  • the virtual machine's memory data is small, and the time from the server pre-copy to the host machine is extremely short, which does not affect the startup time of the virtual machine.
  • FIG. 7 is a flowchart of a sixth embodiment of a method for restoring a virtual machine according to the present invention. As shown, the method includes:
  • Step S601 The host machine receives a second migration instruction from the controller, and the second migration instruction is used to instruct the host machine to pre-copy the virtual machine memory data to the server in a single time;
  • the host machine is the physical host used to generate the virtual machine, and the host machine is connected to the controller.
  • the second migration instruction can be sent by the controller.
  • the trigger module of the controller triggers the second migration instruction, or the controller receives the first backup instruction from the server to generate a second migration instruction.
  • the server is at the same level as the controller and is connected to all virtual machines under the cluster.
  • the server may directly send the third migration instruction to the host.
  • Step S601 may be specifically: the host machine receives a third migration instruction from the server, and the third migration instruction is used to instruct the host machine to pre-copy the virtual machine's memory data to the server in a single time, and generate a virtual machine on the server. Mirroring. .
  • Step S602 The host computer suspends the virtual machine according to the second migration instruction, and pre-copyes the virtual machine memory data to the server in a single time, so that the server generates the image of the virtual machine;
  • a single pre-copy is to copy the memory data (including dirty data) of the host's virtual machine to the server at one time.
  • a virtual machine is generated on the server, which is a mirror of the virtual machine running on the host machine.
  • Step S603 The host machine receives a first migration instruction from the controller, where the first migration instruction is used to instruct the server to pre-copy the mirrored memory data of the virtual machine to the host machine for a single time;
  • the virtual machine is mirrored as a virtual machine running on the server, and the virtual machine is the same as the virtual machine running on the host machine, in short, mirrored as a copy of the virtual machine running on the host machine.
  • Step S604 The host computer detects a special state of the virtual machine, and the special state includes a startup state or a down state of the virtual machine;
  • Step S605 The host machine sends a special status notification of the virtual machine to the controller when detecting the special state of the virtual machine;
  • the host machine detects the virtual machine down state, in addition to sending the virtual machine virtual machine down notification to the controller, the host machine also directly shuts down the virtual machine that has been down.
  • Step S606 The host computer receives the first migration instruction sent by the controller according to the special state notification of the virtual machine
  • the first migration instruction may also be an instruction sent by the controller to receive information of the server. Then, step S604 and step S605 may not exist, and step S606 may be specifically: the host machine receives the first migration instruction from the controller.
  • Step S607 The host computer receives the mirrored memory data of the virtual machine according to the first migration instruction, and restores the virtual machine;
  • the host computer After the host computer receives the mirrored memory data of the virtual machine, it immediately generates a virtual machine in the host machine, and the virtual machine has a startup state. Unlike traditional methods, you first need to generate a virtual machine on the host machine and then start the virtual machine.
  • the host machine can also receive a mount command from the controller and mount the hard disk for the virtual machine according to the mount command.
  • the hard disk here can be the hard disk of the host machine itself or a shared hard disk on the network.
  • the memory data of the virtual machine of the host machine is pre-copied to the server for a single time, and the image of the virtual machine is formed on the server.
  • the virtual machine is started or restarted, a single pre-copy from the server to the host machine, and the virtual machine is quickly restored on the host machine.
  • the startup of the virtual machine in the embodiment of the present invention no longer needs to go through the recovery process of the virtual machine at the host machine and the startup process of the virtual machine itself, effectively improving the startup time of the virtual machine.
  • the virtual machine's memory data is small, and the time from the server pre-copy to the host machine is extremely short, which does not affect the startup time of the virtual machine.
  • the invention further provides a controller implementation.
  • the controller 70 includes a first receiving module 701, a query module 702, and a first sending module 703.
  • the first receiving block 701 receives a start notification of starting the virtual machine.
  • the virtual machine runs on the host machine 72, and the host machine 72 can sense all the behavior of the virtual machine.
  • the host machine 72 takes the virtual machine's startup state and down state as special states, and sends a special status notification to the controller 70. Therefore,
  • the first receiving module 701 may in turn be configured to receive a special status notification sent by the host computer 72.
  • the special status includes a startup status and a down state of the virtual machine.
  • the virtual machine When the virtual machine is to be restarted, the virtual machine sends a virtual machine restart message to the server, and after receiving the virtual machine restart message, the server sends a virtual machine re-notification to the controller. Therefore, the first receiving module 701 may specifically be: receiving a virtual machine restart notification sent by the server 71.
  • the query module 702 queries whether there is a mirror of the virtual machine on the server.
  • the virtual machine's image is a copy of the virtual machine running on the server.
  • the memory data is pre-copied to the host machine 72 a single time. After the virtual machine's mirrored memory data is copied to the host computer 72, the virtual machine is directly restored on the host computer 72.
  • Single pre-copy refers to copying all the memory data of the virtual machine on the server to the host machine at one time.
  • the controller 70 also includes a second receiving module 704, a generating module 705, a trigger generating module 706, and a second transmitting module 707.
  • the virtual machine When the virtual machine is started, the virtual machine establishes a connection with the server 71, and the server 71 acquires the IP address and computer name of the virtual machine.
  • the server 71 queries whether there is a mirror of the virtual machine locally, and if not, sends a first backup instruction of the backup virtual machine to the set controller 71 after receiving the message that the startup of the virtual machine is completed.
  • the second receiving module 704 receives the first backup instruction from the backup virtual machine of the server.
  • the generation module 705 generates a second migration instruction based on the first backup instruction.
  • the trigger generation module 706 triggers the second migration instruction based on the trigger point of the controller 70.
  • the trigger point can be set to: restart or power on automatic synchronization, manual synchronization, application modified synchronization, timing synchronization, and the like.
  • the second sending module 707 sends a second migration instruction to the host computer 72 and the server 71, respectively, and the second migration instruction is used to instruct the host computer 72 to pre-copy the virtual machine's memory data to the server 71 for a single time, and generate the virtual machine at the server 71.
  • the controller 70 may further include a third sending module 708, configured to send a mount command to the host computer 72, so that the host host mounts the hard disk for the virtual machine.
  • the first sending module 703 sends the first migration to the server 71 and the host respectively.
  • the instruction instructs the server 71 to pre-copy the mirrored memory data of the virtual machine to the host machine where the virtual machine is located.
  • the startup of the virtual machine does not need to go through the process of generating the virtual machine in the host machine and the startup process of the virtual machine itself, effectively improving the virtual Machine start time.
  • the virtual machine's memory data is small, and the time from the server pre-copy to the host machine is extremely short, which does not affect the startup time of the virtual machine.
  • FIG. 9 is a schematic structural diagram of a second embodiment of the controller of the present invention.
  • set controller node 75 includes a processor 750 and a memory 751.
  • the processor 750 is configured to receive a startup notification of the startup virtual machine; the query server 76 has a virtual machine image, and if the server 76 has a virtual machine image, send the first migration instruction to the server 76 and the host machine 77, respectively.
  • the instructed server 76 pre-copyes the mirrored memory data of the virtual machine to the host machine 77 a single time.
  • the above processing performed by the processor 750 is usually completed by a program control, and the program is stored in the memory 751.
  • the program is transferred to the processor 750 and controlled by the processor 750.
  • the above process can also be completed by hardware.
  • the processor 750 can also send a mount command to the host machine 77 after the first migration instruction is sent, and the mount command is used to instruct the host machine 77 to mount the hard disk for the virtual machine.
  • the invention further provides a server implementation.
  • the server 80 includes a first receiving module 801 and a pre-copy module 802;
  • the first receiving module 801 receives the first migration instruction from the controller 81, wherein the first migration instruction is used to instruct the server 80 to pre-copy the mirrored memory data of the virtual machine to the host machine 82.
  • the controller 81 is used to manage all the virtual machines in the cluster.
  • the controller 81 senses that the virtual machine 83 is booting, and queries the server 80 to send a first migration instruction to the server 80 when it has a mirror of the virtual machine 83. If the virtual machine 83 needs to be restarted in the middle of the run, the virtual machine 83 sends a restart message of the virtual machine to the server 80. Therefore, the server 80 further includes: a second receiving module 803, and a first sending unit 804.
  • the second receiving module 803 receives the first message from the virtual machine 83, and the first message is used to instruct the virtual machine 83 to restart.
  • the first transmitting module 803 sends a virtual machine restart notification to the controller 81 according to the first message, and sends a destroy command to destroy the virtual machine 83 to the host machine 82 of the virtual machine 83.
  • the way in which the host machine 82 shuts down the virtual machine 83 by destroying the instructions is faster and shorter than the traditional way of turning off the virtual machine 83.
  • the first receiving module 801 is specifically configured to: receive a first migration instruction sent by the controller 81 according to the virtual machine restart notification.
  • the pre-copy module 802 pre-copyes the mirrored memory data of the virtual machine 83 to the host machine 82 in accordance with the first migration instruction to recover the virtual machine on the host machine. 83.
  • the server 80 further includes a receiving and establishing module 805, an obtaining module 806, a querying module 807, a second sending module 808, a third receiving module 809, a first receiving generating module 810, a fourth receiving module 811, a third sending module 812, and a second.
  • the receiving generation module 813 is received.
  • the receiving setup module 805 is configured to receive a connection request from the virtual machine 83 and establish a connection with the virtual machine 83.
  • the acquisition module 804 is used to obtain the IP address and computer name of the virtual machine 83.
  • the query module 806 queries whether there is a mirror of the virtual machine 83 based on the IP address and the computer name. If the server 80 has a mirror of the virtual machine 83, the second sending module 808 sends a first backup instruction of the backup virtual machine 83 to the controller 81.
  • the third receiving module 809 receives the second migration instruction transmitted by the controller 81 in accordance with the first backup instruction.
  • the controller 81 can also set a trigger module, and the trigger module triggers sending a second migration instruction to the server 80.
  • the third receiving module 809 can be specifically: receiving the second migration instruction triggered by the trigger module of the controller 81.
  • the first receive generation module 810 receives memory data from the virtual machine 83 on the host machine 82 in accordance with the second migration instruction and generates a mirror image of the virtual machine 83.
  • the virtual machine 83 can also send a backup message of the backup virtual machine 83 to the server 80.
  • the fourth receiving module 811 receives the second backup instruction from the backup virtual machine 83 sent by the virtual machine 83.
  • the third sending module 812 sends a third migration instruction to the host machine 82 of the virtual machine 83 according to the second backup instruction, and the third migration instruction is used to instruct the host machine 82 to pre-copy the virtual machine's memory data to the server 80 for a single time.
  • the second reception generating module 813 receives the memory data of the virtual machine 83 transmitted by the host machine 82 according to the third migration instruction, and generates a mirror image of the virtual machine 83.
  • the pre-copy module 802 pre-copyes the mirrored memory data of the virtual machine 83 on the server 80 to the host host according to the first migration instruction, directly
  • the virtual machine is restored on the host machine, so that the startup of the virtual machine no longer needs to go through the recovery process of the virtual machine generated by the host machine and the startup process of the virtual machine, thereby effectively improving the startup time of the virtual machine.
  • the virtual machine's memory data is small, and the time from pre-copying to the host is extremely short, which does not affect the startup time of the virtual machine.
  • FIG. 11 is a schematic structural diagram of a second embodiment of the server of the present invention.
  • server 85 includes a processor 850 and a memory 851.
  • the processor 850 is configured to receive a first migration instruction from the controller 86, where the first migration instruction is used
  • the instructing server 85 pre-copyes the mirrored memory data of the virtual machine to the host computer 87; pre-copyes the mirrored memory data of the virtual machine to the host computer 87 in a single pass according to the first migration instruction, and restores the virtual machine on the host machine.
  • the above processing performed by the processor 851 is usually completed by a program control, and the program is stored in the memory 852.
  • the program is transferred to the processor 851 and controlled by the processor 851.
  • the above process can also be completed by hardware.
  • the server and the controller can be combined to form a control service node.
  • the control service node integrates the functions of the above servers and controllers.
  • the control service node first instructs the host to pre-copy the virtual machine's memory data to the control service node for a single time, and generates a virtual machine image on the control service node.
  • the control service node pre-copyes the mirrored memory data of the virtual machine to the host machine, restores the virtual machine directly on the host machine, and further instructs the host machine to mount the hard disk for the virtual machine, thereby completing A quick start of the virtual machine.
  • the invention further provides a host machine implementation.
  • the host computer 90 includes a first receiving module 901 and a receiving recovery module 902.
  • the first receiving module 901 receives a first migration instruction from the controller 91, the first migration instruction being used to instruct the server 92 to pre-copy the mirrored memory data of the virtual machine to the host machine 90 a single time.
  • the receive recovery module 902 receives the cached memory data from the virtual machine transmitted by the server 92 in accordance with the first migration instruction and restores the virtual machine at the host machine 90.
  • the host computer 90 also includes a detection module 903, a transmission module 904, a second reception module 905, a third reception module 906, and a pre-copy module 907.
  • the detection module 903 detects a special state of the virtual machine, and the special state includes a virtual machine startup state and a down state.
  • the transmitting module 904 transmits a special status notification of the virtual machine to the controller 91 when the detecting module 903 detects the special state of the virtual machine.
  • the first receiving module 901 may in turn be: receiving a first migration instruction sent by the controller 91 according to a special state of the virtual machine.
  • the second receiving module 905 receives the second migration instruction from the controller, and the second migration instruction is used to instruct the host computer to pre-copy the virtual machine's memory data to the server.
  • the virtual machine directly sends a second backup instruction of the backup virtual machine to the server 92, and the server 92 sends a second migration instruction to the host machine according to the second backup instruction.
  • the third receiving module 906 receives the third migration instruction of the server 92, and the third migration instruction is used to instruct the host machine 90 to pre-copy the virtual machine's memory data to the server. 92.
  • the pre-copy module 907 is configured to suspend the virtual machine according to the second migration instruction or the third migration instruction, and pre-copy the virtual machine's memory data to the server 92.
  • the host computer in the embodiment of the present invention may further include a fourth receiving module 908 and a mounting module 909.
  • the fourth receiving module 908 receives a mounting command from the controller 91, and the mounting module 909 is suspended according to the hanging module 909.
  • the load command is to mount the hard disk for the virtual machine.
  • the receive recovery module 902 receives the memory data from the mirror of the virtual machine transmitted by the server 92, and restores the virtual machine directly on the host machine 90.
  • the startup of the virtual machine no longer needs to go through the process of generating the virtual machine at the host machine and the startup process of the virtual machine itself, effectively improving the startup time of the virtual machine.
  • the virtual machine's memory data is small, and the time from the server pre-copy to the host machine is extremely short.
  • the host machine mounts the hard disk for the virtual machine for a very short time, which does not affect the startup time of the virtual machine.
  • FIG. 13 is a schematic structural view of a second embodiment of the host machine of the present invention.
  • the host computer 95 includes a processor 950 and a memory 951.
  • the processor 950 is configured to receive a first migration instruction from the controller 97, where the first migration instruction is used to instruct the server 96 to pre-copy the mirrored memory data of the virtual machine to the host computer 95; receive according to the first migration instruction.
  • the mirrored memory data of the virtual machine, and the virtual machine is restored on the host computer 95; and can also be used to receive the mount command from the controller 97 after the virtual machine is restored; mount the hard disk for the virtual machine according to the mount command, and complete The startup of the virtual machine.
  • the above processing performed by the processor 950 is usually completed by a program control, and the program is stored in the memory 950.
  • the program is transferred to the processor 950 and controlled by the processor 950.
  • the above process can also be completed by hardware.
  • FIG 14 is a block diagram of a system implementation of the recovery virtual machine of the present invention.
  • the system 1 for restoring a virtual machine includes a controller 2, a server 3, and a host machine 4.
  • the controller 2 is any of the above controllers
  • the server 3 is any of the above servers
  • the host machine 4 is any of the above-mentioned host machines. Further, there may be more than one host machine 4.
  • the virtual machine runs on the host machine 4.
  • FIG. 15 is a flowchart of the initial startup of the virtual machine in the system implementation mode of the recovery virtual machine of the present invention.
  • Step S10 The virtual machine is started for the first time, and there is no mirror of the virtual machine on the server; Step S11: the client broadcasts the data packet;
  • Step S12 The server monitors the data packet of the client, establishes a connection with the client, and obtains information such as the IP address and the computer name of the virtual machine;
  • Step S13 The hook program on the client hooks the keyboard and mouse information, and forms a queue to be stored in the system memory;
  • Step S14 The client refreshes the number of virtual machine processes to form a first variable, delaying Is;
  • Step S15 The client refreshes the number of virtual machine processes to form a second variable, and compares the first variable with the second variable. If the first variable is not equal to the second variable, the delay is continued, and if they are equal, the process ends.
  • Step S16 When the first variable is equal to the second variable, the virtual machine is started, and the client sends a message to the server, where the message is used to indicate that the virtual machine is started.
  • Step S17 The server applies to the controller for backing up the virtual machine.
  • Step S18 The controller sends a single pre-copy command of the memory data of the virtual machine to the host machine;
  • Step S20 The host machine will use the virtual machine memory data sheet Secondary pre-copy server;
  • Step S21 The server compresses the memory data of the virtual machine to form a compressed image.
  • Step S22 The controller updates the state information of the mirror of the virtual machine, indicating that there is a mirror of the virtual machine;
  • Step S23 The server sends a message that the processing is completed to the client;
  • Step S24 The client releases the hook message, and the client uses normally.
  • FIG. 16 is a flowchart of internal operation backup of a virtual machine in the system implementation manner of the present invention. Step S110: Clicking on the backup virtual machine;
  • Step S111 The virtual machine requests a backup virtual machine from the server.
  • Step S112 The host machine suspends the virtual machine
  • Step S113 The host computer pre-copyes the virtual machine's memory data to the server.
  • FIG. 17 is a flowchart of a virtual machine initiating an internal restart in a system implementation manner for restoring a virtual machine according to the present invention
  • Step S120 The virtual machine is internally restarted
  • Step S121 The client invokes the system interface to perceive the behavior
  • Step S122 The client sends a message to the server.
  • Step S123 The server queries the image of the virtual machine.
  • Step SI 24 sends a message to the host machine, shutting down the virtual machine;
  • Step S125 The server invokes a virtual machine migration interface.
  • Step S126 The server pre-copyes the memory data of the virtual machine to the host computer for a single time; Step SI 28 The host machine mounts the hard disk for the virtual machine.
  • FIG. 18 is a flowchart of a virtual machine startup in a system implementation manner for restoring a virtual machine according to the present invention
  • Step S130 The controller senses that the virtual machine is started.
  • Step S131 The controller queries the mirror of the virtual machine in the server memory
  • Step S134 The server decompresses the image of the virtual machine.
  • Step S135 The server pre-copyes the memory data of the decompressed virtual machine to the host in a single step.
  • the virtual machine By pre-copying the mirrored memory data of the virtual machine on the server to the host machine, the virtual machine is directly restored on the host machine, so that the virtual machine no longer needs to undergo the process of generating the virtual machine on the host machine and the virtual machine itself.
  • the startup process effectively increases the startup time of the virtual machine.

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

本发明公开了一种恢复虚拟机的方法、系统及控制器、服务器、寄宿主机,所述方法包括:服务器接收来自控制器的第一迁移指令,第一迁移指令用于指示服务器将虚拟机的镜像的内存数据单次预拷贝至寄宿主机;服务器根据第一迁移指令将虚拟机的镜像的内存数据单次预拷贝至寄宿主机,在寄宿主机恢复虚拟机。通过上述方式,本发明能够有效提高虚拟机的启动时间。

Description

恢复虚拟机的方法、 系统及控制器、 服务器、 寄宿主机 技术领域
本发明涉及计算机技术领域,特别是涉及一种恢复虚拟机的方法、 系统及 控制器、 服务器、 寄宿主机。 背景技术
虚拟机指通过软件模拟的具有完整硬件系统功能的、运行在一个完全隔离 环境中的完整计算机系统。进入虚拟机的操作系统后, 所有操作都是在这个全 新的独立的虚拟系统里面进行, 可以独立安装运行软件, 保存数据, 拥有自己 的独立桌面, 不会对真正的系统产生任何影响。 其中, 一台物理计算机上可以 虚拟出一台或多台虚拟机。
虚拟机的启动方式主要有三种,分别为:光驱启动、硬盘启动及网络启动。 光驱启动指虚拟机从光驱启动。网络启动为指虚拟机不是在寄宿主机的本地硬 盘启动, 而是从网络共享的硬盘启动。硬盘启动指虚拟机从寄宿主机的硬盘启 动。
光驱启动主要适用于空虚拟机的操作系统的安装场景,但启动时较慢, 不 宜推广, 不适用于大规模场景使用。 网络启动要求所有使用该共享的硬盘启动 的虚拟机的应用场景必须一致, 因而限制虚拟机的应用场景, 并且启动时间受 网络状况的影响, 启动过程不稳定, 不利推广应用。 硬盘启动为虚拟机常用的 启动方式, 也是最简单最直接的方式, 但启动时间慢。 如前述, 现有技术恢复 虚拟机时启动速度过慢, 极大地影响了虚拟机的推广应用。 发明内容
本发明实施方式主要解决的技术问题是提供一种恢复虚拟机的方法及控 制器、 服务器、 寄宿主机, 能够提高虚拟机的启动时间。
第一方面, 提供一种恢复虚拟机的方法, 其包括以下步骤: 控制器接收启 动虚拟机的启动通知; 控制器查询服务器是否存在虚拟机的镜像, 若服务器存 在虚拟机的镜像,控制器分别向服务器及寄宿主机发送第一迁移指令, 第一迁 移指令用于指示服务器将虚拟机的镜像的内存数据单次预拷贝至寄宿主机。 在第一方面的第一种可能的实现方式中,控制器接收启动虚拟机的启动通 知, 具体包括: 控制器接收来自服务器发送的虚拟机重启通知; 或者, 控制器 接收来自寄宿主机发送的虚拟机的特殊状态通知,特殊状态包括虚拟机启动状 态或者宕机状态。
结合第一方面实现方式, 在第一方面的第二种可能的实现方式中,控制器 接收启动虚拟机的启动通知之前,还包括: 控制器分别向服务器和虚拟机的寄 宿主机发送第二迁移指令,第二迁移指令用于指示寄宿主机将虚拟机的内存数 据单次预拷贝至服务器, 以使服务器生成虚拟机的镜像。
结合第一方面实现方式, 在第一方面的第三种可能的实现方式中,控制器 分别向服务器和虚拟机的寄宿主机发送第二迁移指令的步骤之前,还包括: 控 制器接收来自服务器的备份虚拟机的第一备份指令,并根据第一备份指令生成 第二迁移指令。
第二方面, 提供一种恢复虚拟机的方法, 其包括以下步骤: 服务器接收来 自控制器的第一迁移指令,第一迁移指令用于指示服务器将虚拟机的镜像的内 存数据单次预拷贝至寄宿主机;服务器根据第一迁移指令将虚拟机的镜像的内 存数据单次预拷贝至寄宿主机, 以使寄宿主机恢复虚拟机。
在第二方面的第一种可能的实现方式中,服务器接收来自控制器的第一迁 移指令, 具体包括: 服务器接收来自虚拟机第一消息, 第一消息用于指示虚拟 机重启; 服务器根据第一消息, 向控制器发送虚拟机重启通知, 并向寄宿主机 发送摧毁虚拟机的摧毁指令;服务器接收由控制器根据虚拟机的重启通知而发 送的第一迁移指令。
结合第二方面实现方式, 在第二方面的第二种可能的实现方式中,服务器 接收来自控制器的第一迁移指令的步骤之前,还包括: 服务器接收来自控制器 的第二迁移指令,第二迁移指令用于指示寄宿主机将虚拟机的内存数据单次预 拷贝到服务器; 服务器接收来自虚拟机的内存数据, 并生成虚拟机的镜像。
结合第二方面的第二种可能的实现方式,在第二方面的第三种可能的实现 方式中, 服务器接收来自控制器的第二迁移指令的步骤之前, 还包括:
服务器接收来自虚拟机的连接请求, 建立与虚拟机的连接; 服务器获取虚 拟机的 IP地址和计算机名称; 服务器根据虚拟机的 IP地址和计算机名称, 查 询是否存在虚拟机的镜像; 若服务器没有存在虚拟机的镜像, 则服务器向控制 器发送备份虚拟机的第一备份指令;服务器接收来自控制器的第二迁移指令的 步骤包括: 服务器接收由控制器根据第一备份指令发送的第二迁移指令。
结合第二方面的第二种可能的实现方式,在第二方面的第四种可能的实现 方式中,服务器接收来自控制器的第二迁移指令的步骤包括: 服务器接收由控 制器的触发模块触发的第二迁移指令。
结合第二方面实现方式, 在第二方面的第五种可能的实现方式中,服务器 接收来自控制器的第一迁移指令的步骤之前,还包括: 服务器接收来自虚拟机 发送的备份虚拟机的第二备份指令;服务器根据第二备份指令向寄宿主机发送 第三迁移指令;服务器接收由寄宿主机根据第三迁移指令而传输的虚拟机的内 存数据, 并生成虚拟机的镜像。
第三方面, 提供一种恢复虚拟机的方法, 其包括以下步骤: 寄宿主机接收 来自控制器的第一迁移指令,第一迁移指令用于指示服务器将虚拟机的镜像的 内存数据单次预拷贝到寄宿主机;寄宿主机根据第一迁移指令接收虚拟机的镜 像的内存数据, 并在寄宿主机上恢复虚拟机。
在第三方面的第一种可能实现方式中,寄宿主机接收来自控制器的第一迁 移指令的步骤之前, 还包括: 寄宿主机检测虚拟机的特殊状态, 特殊状态包括 虚拟机启动状态或者宕机状态; 寄宿主机在检测到虚拟机的特殊状态时, 向控 制器发送虚拟机的特殊状态通知; 寄宿主机接收来自控制器的第一迁移指令, 具体包括:寄宿主机接收由控制器根据虚拟机的特殊状态通知发送的第一迁移 指令。
结合第三方面实现方式, 在第三方面的第二种可能实现方式中, 寄宿主机 接收来自控制器的第一迁移指令的步骤之前,还包括: 寄宿主机接收来自控制 器的第二迁移指令,第二迁移指令用于指示寄宿主机将虚拟机的内存数据单次 预拷贝到服务器; 寄宿主机根据第二迁移指令或者第三迁移指令挂起虚拟机, 并将虚拟机的内存数据单次预拷贝到服务器, 在服务器上生成虚拟机的镜像。
结合第三方面实现方式, 在第三方面的第三种可能实现方式中, 寄宿主机 接收来自控制器的第一迁移指令之前,还包括: 寄宿主机接收来自服务器的第 三迁移指令,第三迁移指令用于指示寄宿主机将虚拟机的内存数据单次预拷贝 到服务器, 在服务器上生成虚拟机的镜像; 寄宿主机根据第三迁移指令挂起虚 拟机, 并将虚拟机的内存数据单次预拷贝到服务器, 以使服务器生成虚拟机的 镜像。
第四方面, 提供一种控制器, 其包括: 第一接收模块, 用于接收启动虚拟 机的启动通知; 查询模块, 用于查询服务器是否存在虚拟机的镜像; 第一发送 模块, 用于在查询模块查询到虚拟机的镜像后, 分别向服务器和寄宿主机发送 第一迁移指令,第一迁移指令用于指示服务器将虚拟机的镜像的内存数据单次 预拷贝至寄宿主机。
在第四方面的第一种可能实现方式中, 第一接收模块具体用于: 接收来自 服务器发送的虚拟机重启通知; 或者,接收来自寄宿主机发送的虚拟机的特殊 状态通知, 特殊状态包括虚拟机的启动状态和宕机状态。
结合第四方面的实现方式,在第四方面的第二种可能的实现方式中,控制 器还包括: 第二发送模块, 用于分别向寄宿主机和服务器发送第二迁移指令, 第二迁移指令用于指示寄宿主机将虚拟机的内存数据单次预拷贝至服务器,以 使服务器生成虚拟机的镜像。
结合第四方面的第二种可能实现方式,在第四方面的第三种可能的实现方 式中, 控制器还包括: 第二接收模块, 用于接收来自服务器的备份虚拟机的第 一备份指令; 生成模块, 用于根据第一备份指令生成第二迁移指令。
结合第四方面的第二种可能的实现方式,在第四方面的第四种可能的实现 方式中, 控制器包括: 触发生成模块, 用于触发第二迁移指令。
第五方面, 提供一种服务器, 包括: 第一接收模块, 用于接收来自控制器 的第一迁移指令, 其中, 第一迁移指令用于指示服务器将虚拟机的镜像的内存 数据单次预拷贝至寄宿主机; 预拷贝模块, 用于根据第一迁移指令, 将虚拟机 的镜像的内存数据单次预拷贝到寄宿主机, 以使寄宿主机上恢复虚拟机。
在第五方面的第一种可能实现方式中, 服务器还包括: 第二接收模块, 用 于接收来自虚拟机的第一消息,第一消息用于指示虚拟机重启;第一发送模块, 用于根据第一消息, 向控制器发送虚拟机重启通知, 并向寄宿主机发送摧毁虚 拟机的摧毁指令; 第一接收模块具体为: 接收由控制器根据虚拟机重启通知发 送的第一迁移指令。
结合第五方面实现方式, 在第五方面的第二种可能实现方式中,服务器还 包括: 第三接收模块, 用于接收来自控制器的第二迁移指令; 第一接收生成模 块,根据第二迁移指令接收来自寄宿主机的虚拟机的内存数据, 并生成虚拟机 的镜像。
结合第五方面的第二种实现方式中, 在第五方面的第三种可能实现方式 中, 服务器还包括: 接收建立模块, 用于接收来自虚拟机的连接请求, 建立与 虚拟机的连接; 获取模块, 用于获取虚拟机的 IP地址和计算机名称; 查询模 块, 用于根据 IP地址和计算机名称, 查询是否存在虚拟机的镜像; 第二发送 模块, 用在于查询模块没有查询到虚拟机的镜像时, 向控制器发送备份虚拟机 的第一备份指令。第三接收模块具体用于接收由控制器根据第一备份指令而发 送的第二迁移指令。
结合第五方面的第二种实现方式中, 在第五方面的第四种可以实现方式 中, 第三接收模块具体用于: 接收由控制器的触发模块触发的第二迁移指令。
结合第五方面实现方式, 在第五方面的第五种可能实现方式中,服务器包 括: 第四接收模块, 接收来自虚拟机发送的备份虚拟机的第二备份指令; 第三 发送模块, 用于根据第二备份指令向虚拟机的寄宿主机发送第三迁移指令; 第 二接收生成模块,用于接收来由寄宿主机根据第三迁移指令而传输的虚拟机的 内存数据, 并生成虚拟机的镜像。
第六方面, 提供一种寄宿主机, 其包括: 第一接收模块, 用于接收来自控 制器的第一迁移指令,第一迁移指令用于指示服务器将虚拟机的镜像的内存数 据单次预拷贝到寄宿主机; 接收恢复模块, 用于根据第一迁移指令接收来自服 务器传输的虚拟机的镜像的内存数据, 并在寄宿主机上恢复出虚拟机。
在第六方面的第一种可以实现方式中, 寄宿主机还包括: 检测模块, 用于 检测虚拟机的特殊状态, 特殊状态包括虚拟机的启动状态和宕机状态; 第一发 送模块, 用于在检测模块检测到虚拟机的特殊状态时, 向控制器发送虚拟机的 特殊状态通知;第一接收模块具体用于接收由控制器根据虚拟机的特殊状态通 知发送的第一迁移指令。
结合第六方面的实现方式,在第六方面的第二种可能实现方式中, 寄宿主 机还包括: 第二接收模块, 用于接收来自控制器的第二迁移指令, 第二迁移指 令用于指示寄宿主机将虚拟机的内存数据单次预拷贝到服务器; 预拷贝模块, 用于挂起虚拟机, 并将虚拟机的内存数据单次预拷贝到服务器。
结合第六方面的实现方式, 在第六方面的第三种可能实现方式中, 寄宿主 机还包括: 第三接收模块, 用于接收服务器的第三迁移指令, 第三迁移指令用 于指示寄宿主机将虚拟机的内存数据单次预拷贝到服务器; 预拷贝模块, 用于 根据第三迁移指令挂起虚拟机, 并将虚拟机的内存数据单次预拷贝到服务器。
第七方面, 本发明实施例还提供了一种虚拟机恢复系统, 包括上述第四方 面所述任一控制器、上述第五方面所述的任一服务器和上述第六方面任一所述 的寄宿主机。
本发明实施方式的有益效果是: 本发明预先通过内存迁移的方式,把虚拟 机的内存数据单次预拷贝到服务器上, 在服务器上生成虚拟机的镜像; 在虚拟 机重启、 关机后启动或者虚拟机宕机时,将服务器上虚拟机的镜像的内存数据 单次预拷贝到寄宿主机, 寄宿主机再为虚拟机挂载硬盘, 从而恢复出虚拟机, 并且该虚拟机可带启动项。使得虚拟机不再需要经历在寄宿主机生成虚拟机的 生成过程和虚拟机的自身的启动过程,有效地提高虚拟机的启动时间。 而虚拟 机的内存数据一般较小,从服务器单次预拷贝到寄宿主机的时间极短, 不影响 到虚拟机的启动时间。 附图说明
图 1是本发明恢复虚拟机的方法的第一实施方式的流程图;
图 2是本发明恢复虚拟机的方法的第二实施方式的流程图;
图 3是本发明恢复虚拟机的方法的第三实施方式的流程图;
图 4是本发明恢复虚拟机的方法的第四实施方式的流程图;
图 5是本发明第四实施方式中服务器接收第一迁移指令的子步骤的流程 图;
图 6是本发明恢复虚拟机的方法的第五实施方式的流程图;
图 7是本发明恢复虚拟机的方法的第六实施方式的流程图;
图 8是本发明控制器的第一实施方式的结构示意图; 图 9是本发明控制器的第二实施方式的结构示意图;
图 10是本发明服务器的第一实施方式的结构示意图;
图 11是本发明服务器的第二实施方式的结构示意图;
图 12是本发明寄宿主机的第一实施方式的结构示意图;
图 13是本发明寄宿主机的第二实施方式的结构示意图;
图 14是本发明恢复虚拟机的系统实施方式的结构示意图;
图 15是本发明恢复虚拟机的系统实施方式中初次启动虚拟机的流程图; 图 16是本发明恢复虚拟机的系统实施方式中, 虚拟机内部操作备份流程 图;
图 17是本发明恢复虚拟机的系统实施方式中,虚拟机发起内部重启的流程 图;
图 18是本发明恢复虚拟机的系统实施方式中, 虚拟机启动的流程图。 具体实施方式
请参阅图 1 , 图 1是本发明恢复虚拟机的方法的第一实施方式的流程图。 如图所示, 所述方法包括:
步骤 S101 : 控制器接收启动虚拟机的启动通知;
控制器为管理一个集群下所有虚拟机的节点,并且控制器与集群下所有的 寄宿主机相连接。虚拟机为寄宿在寄宿主机上的虚拟化的计算机系统。 寄宿主 机为物理意义上的计算机。一台寄宿主机可以划分出多台虚拟机。 寄宿主机能 够感知寄宿在该寄宿主机的上虚拟机的关机、 启动等行为。 其中, 寄宿主机感 知到的虚拟机的启动状态和宕机状态时,把虚拟机的启动状态和宕机状态作为 虚拟机的特殊状态,并向控制器发送虚拟机的特殊状态通知。 因此, 步骤 S101 可具体为: 控制器接收来自寄宿主机发送的虚拟机的特殊状态通知,特殊状态 包括虚拟机的启动状态和宕机状态。
服务器作为虚拟机的影子节点,并且与集群下所有的虚拟机的客户端保持 服务器客户端的关系。客户端作为虚拟机内部的一个程序,通过系统接口感知 虚拟机的行为, 并且将感知到的虚拟机的行为信息, 发送到服务器。 由于客户 端作为虚拟机内部的一个程序, 因此,客户端会比寄宿主机更早一步感知到虚 拟机的行为。 服务器将获得的虚拟机的行为信息, 发送到控制器。 因此, 步骤
S101又可具体为: 控制器接收来自服务器发送的虚拟机重启通知。
步骤 S102: 控制器查询服务器是否存在虚拟机的镜像, 若服务器存在虚 拟机的镜像, 则进入步骤 S103;
步骤 S103: 控制器分别向服务器及寄宿主机发送第一迁移指令, 第一迁 移指令用于指示服务器将虚拟机的镜像的内存数据单次预拷贝至寄宿主机; 虚拟机的镜像为虚拟机在服务器上的一个副本,并且服务器上运行着该虚 拟机的镜像, 简而言之,服务器上运行着与运行在寄宿主机上的虚拟机一样的 虚拟机。 当然, 服务器还可以对虚拟机的镜像进行内存压缩, 形成压缩镜像。
单次预拷贝是一次性 (包括内存中的脏数据 )将寄宿主机的虚拟机的内存 数据拷贝到服务器。服务器接收到虚拟机的内存数据后,会在服务器生成虚拟 机。 其中, 控制器, 还可向寄宿主机发送挂载指令, 使寄宿主机为虚拟机挂载 硬盘。
在本发明实施方式中,控制器接收虚拟机的启动通知后, 指示服务器将虚 拟机的镜像的内存数据单次预拷贝到寄宿主机, 恢复虚拟机。使得虚拟机的启 动不需要经历在寄宿主机生成虚拟机的生成过程和虚拟机的自身的启动过程, 有效地提高虚拟机的启动时间。 而虚拟机的内存数据较小,从服务器预拷贝到 寄宿主机的时间极短, 不影响到虚拟机的启动时间。
请参阅图 2, 图 2是本发明恢复虚拟机的方法第二实施方式的流程图。 如 图所示, 包括:
步骤 S201 : 控制器接收来自服务器的备份虚拟机的第一备份指令, 并根 据第一备份指令生成第二迁移指令;
虚拟机为寄宿在寄宿主机上的虚拟化的计算机系统。服务器为集群中的虚 拟机的影子节点。服务器可为单独部署的物理服务器,也可为虚拟化部署的虚 拟服务器, 例如: 通过虚拟机形式, 提供服务器功能。 其中, 服务器与控制器 处于相同级别,服务器与集群中的所有虚拟机的保持连接, 并且服务器能够获 取虚拟机的 IP地址和计算机名称。 进一步的, 服务器根据 IP地址和计算机名 称查询本地是否存在虚拟机的镜像, 若本地没有该虚拟机的镜像,在接收到客 户端发送的虚拟机启动完成的信息后,向控制器发送备份虚拟机的第一备份指 令。
控制器用于管理集群下的所有虚拟机, 并与虚拟机的寄宿主机相连接, 通 过接收寄宿主机的信息, 而感知虚拟机的行为, 比如: 虚拟机的启动、 关机等 等。 在本发明实施方式中, 也可在控制器设置触发模块, 触发模块触发第二迁 移指令, 其中, 触发模块的触发点可以根据实情况进行设置, 例如: 重启或开 机自动同步、 手动同步、 应用修改后同步、 定时同步等等。 控制器感知到虚拟 机的行为满足触发点时触发第二迁移指令, 比如: 应用修改后同步, 则为控制 器感知到虚拟机的增加应用程序或者减少应用程序,则控制器触发第二迁移指 令。 因此, 步骤 S201也可为: 控制器的触发模块触发生成第二迁移指令。
步骤 S202: 控制器分别向虚拟机的寄宿主机和服务器发送第二迁移指令, 第二迁移指令用于指示寄宿主机将虚拟机的内存数据单次预拷贝至服务器,以 在服务器生成虚拟机的镜像。
寄宿主机为运行虚拟机的物理主机。 一台寄宿主机可以运行多个虚拟机。 这里单次预拷贝为指直接挂起寄宿主机的虚拟机,并一次性将寄宿主机上的虚 拟机的内存数据 (包括脏数据 )拷贝到服务器上, 在服务器上生成虚拟机的镜 像。虚拟机的镜像为指在服务器上运行着与运行在寄宿主机上的虚拟机一样的 虚拟机。 当然, 服务器还可以对虚拟机的镜像进行内存压缩, 形成压缩镜像。
步骤 S203 : 控制器接收启动虚拟机的启动通知;
寄宿主机能够感知寄宿在该寄宿主机的虚拟机的一切行为,并且将感知到 的信息发送到控制器。 其中, 寄宿主机感知到虚拟机启动和宕机时, 并虚拟机 的启动状态和宕机状态作为虚拟机的特殊状态,并把向控制器发送特殊状态通 知。 需要说明的是: 寄宿主机检测到虚拟机宕机后, 除了发送特殊状态通知到 控制器之外, 寄宿主机还强行关闭已经宕机的虚拟机。 步骤 S203可具体为: 控制器接收来自寄宿主机发送的虚拟机的特殊状态通知,特殊状态包括虚拟机 启动状态和宕机状态。
其中, 虚拟机要进行重启, 但尚未重启时, 客户端通过系统接口感知到虚 拟机要进行重启。相比于寄宿主机,客户端更早一步的感知虚拟机的重启行为。 若此时, 马上进行虚拟机的快速启动过程,使得虚拟机的启动不再需要经历虚 拟机的关机时间, 进一步提高虚拟机的启动时间。客户端将感知的虚拟机重启 行为的信息发送到服务器。 服务器向控制器发送虚拟机重启通知。 因此, 步骤
S203又可具体为: 控制器接收来自服务器发送的虚拟机重启通知。
步骤 S204: 控制器查询服务器是否存在虚拟机的镜像, 若服务器存在虚 拟机的镜像, 则进入步骤 S205;
步骤 S205 : 控制器分别向服务器及寄宿主机发送第一迁移指令, 第一迁 移指令用于指示服务器将虚拟机的镜像的内存数据单次预拷贝至寄宿主机; 服务器将虚拟机的镜像的内存数据单次预拷贝至寄宿主机,寄宿主机上恢 复虚拟机。 其中, 控制器还可向寄宿主机发送挂载指令, 使寄宿主机为虚拟机 挂载硬盘。寄宿主机为虚拟机挂载硬盘后,使虚拟机具备了完整的虚拟机功能。 寄宿主机为虚拟机挂载的硬盘可为寄宿主机自身携带的硬盘 ,也可以为网络共 享的硬盘。
在本发明实施方式中,通过控制器指示服务器将虚拟机的镜像的内存数据 单次预拷贝到虚拟机所在的寄宿主机, 在寄宿主机上恢复虚拟机。使得虚拟机 的启动不需要经历在寄宿主机生成虚拟机的生成过程和虚拟机的自身的启动 过程, 有效地提高虚拟机的启动时间。 而虚拟机的内存数据较小, 从服务器预 拷贝到寄宿主机的时间极短, 不影响到虚拟机的启动时间。
请参阅图 3 , 图 3是本发明恢复虚拟机的方法的第三实施方式的流程图。 如图所示, 所述方法包括:
步骤 S301 : 服务器接收来自控制器的第一迁移指令, 第一迁移指令用于 指示服务器将虚拟机的镜像的内存数据单次预拷贝至寄宿主机;
控制器和服务器均处于管理级别的节点。其中,控制器与集群下所有的寄 宿主机相连接,服务器与集群下所有的虚拟机的客户端保持服务器客户端的关 系。
虚拟机的镜像为运行在服务器上的虚拟机的一个副本。服务器还可压缩虚 拟机的镜像的内存数据, 形成压缩镜像。若服务器上的虚拟机的镜像为压缩镜 像,将虚拟机的镜像的内存数据单次预拷贝到寄宿主机之前,还要解压该压缩 镜像。
步骤 S302: 服务器根据第一迁移指令将虚拟机的镜像的内存数据单次预 拷贝至寄宿主机, 以在寄宿主机恢复虚拟机。 这里单次预拷贝为指直接挂起服务器上的虚拟机,并一次性将服务器上的 虚拟机的内存数据(包括脏数据 )拷贝到寄宿主机。 将虚拟机的镜像的内存数 据单次预拷贝至寄宿主机之后, 寄宿主机上直接恢复出虚拟机。
在本发明实施方式中 ,通过将服务器上的虚拟机的镜像的内存数据单次预 拷贝到寄宿主机, 在寄宿主机上直接恢复出虚拟机,使得虚拟机的启动不再需 要经历在寄宿主机生成虚拟机的生成过程和虚拟机的自身的启动过程,有效地 提高虚拟机的启动时间。 而虚拟机的内存数据较小,从服务器预拷贝到寄宿主 机的时间极短, 不影响到虚拟机的启动时间。
请参阅图 4, 图 4是本发明恢复虚拟机的方法的第四实施方式的流程图。 如图所示, 所述方法包括:
步骤 S401 : 服务器接收来自虚拟机的连接请求, 建立与虚拟机的连接; 服务器作为虚拟机的影子节点, 可将虚拟机迁移到服务器上,在服务器上 运行一个虚拟机的镜像。 服务器与集群下所有的虚拟机保持连接。。
步骤 S402: 服务器获取虚拟机的 IP地址和计算机名称;
IP地址和计算机名称构成虚拟机的唯一标识。 通过 IP地址和计算机名称 可以识别出不同的虚拟机。
步骤 S403: 服务器根据 IP地址和计算机名称, 查询是否存在虚拟机的镜 像, 若没有, 进入步骤 S404;
虚拟机的镜像为与运行在寄宿主机上的虚拟机一样的虚拟机,只不过虚拟 机的镜像运行在服务器上, 作为运行在寄宿主机上的虚拟机的一个副本。
步骤 S404: 服务器向控制器发送备份虚拟机的第一备份指令;
控制器用于管理集群下所有虚拟机,并且控制器与集群下所有的寄宿主机 相连接。控制器接收到第一备份指令后, 分别向服务器和虚拟机所在的寄宿主 机发送第二迁移指令。
步骤 S405: 服务器接收由控制器根据第一备份指令发送的第二迁移指令, 第二迁移指令用于指示寄宿主机将虚拟机的内存数据单次预拷贝到服务器; 寄宿主机接收到第二迁移指令后,将虚拟机的内存数据单次预拷贝到服务 器。
可选的, 可在控制器上设置触发模块, 触发模块主要用于备份虚拟机。 控 制器监测到集群下的虚拟机的状态到达触发模块的触发点时,触发模块触发第 二迁移指令, 其中, 触发点可以根据实情况进行设置, 例如: 重启或开机自动 同步, 手动同步, 应用修改后同步, 定时自动同步等。 控制器感知到虚拟机的 行为满足触发点时触发第二迁移指令。 则步骤 S406: 服务器接收由控制器的 触发模块触发的第二迁移指令,第二迁移指令用于指示寄宿主机将虚拟机的内 存数据单次预拷贝到服务器。
可选的,虚拟机向服务器发送备份虚拟机的第二备份指令。在本发明实施 方式中, 可在虚拟机上设置备份按钮, 点击备份按钮, 虚拟机向服务器发送第 二备份指令, 当然, 还可以其他方式触发虚拟机向服务器发送第二备份指令, 例如: 语音命令等等。
则步骤 S407 : 服务器接收来自虚拟机发送的备份虚拟机的第二备份指令; 步骤 S408: 服务器根据第二备份指令向寄宿主机发送第二迁移指令, 第 二迁移指令用于指示寄宿主机将虚拟机的内存数据单次预拷贝到服务器;
步骤 S409: 服务器接收来自寄宿主机的虚拟机的内存数据, 并生成虚拟 机的镜像;
服务器接收来自寄宿主机的虚拟机的内存数据后, 在服务器上生成虚拟 机, 该虚拟机作为运行在寄宿主机的虚拟机的镜像。 并且, 该虚拟机的镜像可 以不挂载硬盘。
步骤 S410: 服务器接收来自控制器的第一迁移指令, 第一迁移指令用于 指示服务器将虚拟机的镜像的内存数据单次预拷贝至寄宿主机;
控制器可通过接收来自寄宿主机的信息, 而获知虚拟机的启动行为。控制 器查询服务器是否存在虚拟机的镜像, 若存在虚拟机的镜像, 则分别向寄宿主 机和服务器发送第一迁移指令。
进一步的, 若虚拟机是进行重启动作, 相比于寄宿主机, 虚拟机能够更早 一步感知自身的行为。 并且虚拟机发送虚拟机重启的消息到服务器,服务器再 将虚拟机重启通知发送到控制器,控制器根据虚拟机重启通知分别向虚拟机的 寄宿主机和服务器发送第一迁移指令, 因此, 步骤 S410又可包括:
子步骤 S4101 : 服务器接收来自虚拟机的第一消息, 第一消息用于指示虚 拟机重启; 子步骤 S4102: 服务器根据第一消息, 向控制器发送虚拟机重启通知, 并 向虚拟机的寄宿主机发送摧毁虚拟机的摧毁指令;
寄宿主机接收摧毁虚拟机的摧毁指令后, 马上摧毁虚拟机,相比于传统关 闭虚拟机的方法, 此方法关闭虚拟机的时间更短, 能够进一步的缩短虚拟机的 启动时间。 并且, 寄宿主机通过摧毁指令摧毁虚拟机, 再通过接收来自服务器 的虚拟机的内存数据,恢复虚拟机的过程,不属于虚拟机传统重启过程, 因此, 寄宿主机没有感知虚拟机的重启行为,寄宿主机不会向控制器发送虚拟机重启 通知。
子步骤 S4103: 服务器接收由控制器根据虚拟机重启通知发送的第一迁移 指令。
步骤 S411 : 服务器根据第一迁移指令将虚拟机的镜像的内存数据单次预 拷贝至寄宿主机, 以在寄宿主机恢复虚拟机。
在本发明实施方式中,通过将服务器上的虚拟机的内存数据单次预拷贝到 寄宿主机, 在寄宿主机上直接恢复虚拟机,使得虚拟机不再需要经历在寄宿主 机恢复虚拟机的恢复出过程和虚拟机的自身的启动过程,有效地提高虚拟机的 启动时间。而虚拟机的内存数据较小,从服务器预拷贝到寄宿主机的时间极短, 不影响到虚拟机的启动时间。
请参阅图 6, 图 6是本发明恢复虚拟机的方法第五实施方式的流程图。 如 图所示, 所述方法包括:
步骤 S501 : 寄宿主机接收来自控制器的第一迁移指令, 第一迁移指令用 于指示服务器将虚拟机的镜像的内存数据单次预拷贝到寄宿主机;
控制器为管理集群下所有虚拟机的节点。 寄宿主机为物理意义上的主机, 虚拟机必须运行在寄宿主机上。这里单次预拷贝为指一次性把服务器上上的虚 拟机的所有内存数据拷贝到寄宿主机。
步骤 S502: 寄宿主机根据第一迁移指令接收虚拟机的镜像的内存数据, 并恢复虚拟机;
进一步, 寄宿主机还可接收来自控制器的挂载指令, 并根据挂载指令为虚 拟机挂载硬盘。此处的硬盘可为寄宿主机自身的硬盘,也可以为网络上的共享 硬盘。 在本发明实施方式中,通过寄宿主机接收来自服务器的虚拟机的镜像的内 存数据, 直接在寄宿主机上恢复虚拟机,使得虚拟机的启动不再需要经历在寄 宿主机生成虚拟机的生成过程和虚拟机的自身的启动过程,有效地提高虚拟机 的启动时间。 而虚拟机的内存数据较小,从服务器预拷贝到寄宿主机的时间极 短, 不影响虚拟机的启动时间。
请参阅图 7 , 图 7是本发明恢复虚拟机的方法的第六实施方式的流程图。 如图所示, 所述方法包括:
步骤 S601 : 寄宿主机接收来自控制器的第二迁移指令, 第二迁移指令用 于指示寄宿主机将虚拟机的内存数据单次预拷贝到服务器;
寄宿主机为用于生成虚拟机的物理主机, 并且寄宿主机与控制器连接。可 选的,第二迁移指令可由控制器发送的。控制器的触发模块触发第二迁移指令, 或者, 控制器接收来自服务器的第一备份指令而生成第二迁移指令。
服务器与控制器处于相同级别, 与群集下所有虚拟机连接。 可选的, 服务 器接收来自虚拟机的备份虚拟机的第二备份指令后,可直接向寄宿主机发送第 三迁移指令。 则步骤 S601又可具体为: 寄宿主机接收来自服务器的第三迁移 指令,第三迁移指令用于指示寄宿主机将虚拟机的内存数据单次预拷贝到所述 服务器, 在服务器上生成虚拟机的镜像。。
步骤 S602: 寄宿主机根据第二迁移指令挂起虚拟机, 并将虚拟机的内存 数据单次预拷贝到服务器, 以使服务器生成虚拟机的镜像;
这里单次预拷为指将寄宿主机的虚拟机的内存数据 (包括脏数据 )一次性 拷贝到服务器。虚拟机的内存数据单次预拷贝到服务器后,在服务器上生成一 个虚拟机, 该虚拟机为运行在寄宿主机的虚拟机的镜像。
步骤 S603 : 寄宿主机接收来自控制器的第一迁移指令, 第一迁移指令用 于指示服务器将虚拟机的镜像的内存数据单次预拷贝到寄宿主机;
虚拟机的镜像为运行在服务器上的虚拟机 ,并且该虚拟机与运行在寄宿主 机的虚拟机相同, 简而言之, 镜像为运行在寄宿主机的虚拟机的一个副本。
步骤 S604: 寄宿主机检测虚拟机的特殊状态, 特殊状态包括虚拟机的启 动状态或者宕机状态;
虚拟机寄宿在寄宿主机上, 寄宿主机能够感知虚拟机的一切行为。 步骤 S605 : 寄宿主机在检测到虚拟机的特殊状态时, 向控制器发送虚拟 机的特殊状态通知;
进一步的, 寄宿主机在检测到虚拟机宕机状态时, 除了向控制器发送虚拟 机虚拟机宕机通知之外, 寄宿主机还直接关闭已经宕机的虚拟机。
步骤 S606: 寄宿主机接收由控制器根据虚拟机的特殊状态通知发送的第 一迁移指令;
可选的, 第一迁移指令也可以为控制器接收到服务器的信息而发送的指 令。 则步骤 S604和步骤 S605可以不存在, 步骤 S606可具体为: 寄宿主机接 收来自控制器的第一迁移指令。
步骤 S607 : 寄宿主机根据第一迁移指令接收虚拟机的镜像的内存数据, 并恢复虚拟机;
寄宿主机接收到虚拟机的镜像的内存数据后,马上在寄宿主机中生成一个 虚拟机, 并且该虚拟机带启动状态。 不像传统方法那样, 首先需要在寄宿主机 上生成虚拟机, 再启动虚拟机。
其中, 寄宿主机还可接收来自控制器的挂载指令, 并根据挂载指令为虚拟 机挂载硬盘。此处的硬盘可为寄宿主机自身的硬盘,也可以为网络上的共享硬 盘。
在本发明实施方式中,先将寄宿主机的虚拟机的内存数据单次预拷贝到服 务器, 在服务器上形成虚拟机的镜像。 在虚拟机启动或重启时, 从服务器上单 次预拷贝到寄宿主机, 快速在寄宿主机上恢复虚拟机。 相比于传统方法, 本发 明实施方式中的虚拟机的启动不再需要经历在寄宿主机恢复出虚拟机的恢复 出过程和虚拟机的自身的启动过程,有效地提高虚拟机的启动时间。 而虚拟机 的内存数据较小,从服务器预拷贝到寄宿主机的时间极短, 不影响虚拟机的启 动时间。
本发明又提供控制器实施方式。 如图 8所示, 控制器 70包括第一接收模 块 701、 查询模块 702和第一发送模块 703。 第一接收块 701接收启动虚拟机 的启动通知。 其中, 虚拟机运行在寄宿主机 72上, 寄宿主机 72能够感知虚拟 机的一切行为。 当虚拟机的要进行启动或者宕机时, 寄宿主机 72将虚拟机的 启动状态和宕机状态作为特殊状态, 并向控制器 70发送特殊状态通知。 因此, 第一接收模块 701又可以具体为:接收来自寄宿主机 72发送的特殊状态通知, 特殊状态包括虚拟机的启动状态和宕机状态。 服务器 71与虚拟机的连接。 当 虚拟机要进行重启时,虚拟机向服务器发送虚拟机重启消息,服务器接收到虚 拟机重启消息后, 向控制器发送虚拟机重通知。 因此, 第一接收模块 701又可 以具体为: 接收来自服务器 71发送的虚拟机重启通知。
查询模块 702查询服务器上是否存在虚拟机的镜像。虚拟机的镜像为运行 在服务器上的虚拟机的一个副本。 第一发送模块 703 , 在查询模块 702查询到 存在虚拟机的镜像后, 分别向服务器 71和寄宿主机 72发送第一迁移指令, 其 中, 第一迁移指令用于指示服务器 71将虚拟机的镜像的内存数据单次预拷贝 至寄宿主机 72。 其中, 虚拟机的镜像的内存数据拷贝到寄宿主机 72后, 直接 在寄宿主机 72恢复虚拟机。 单次预拷贝为指一次性将服务器上的虚拟机的所 有内存数据拷贝到寄宿主机。 控制器 70还包括第二接收模块 704、 生成模块 705、 触发生成模块 706和第二发送模块 707。 虚拟机启动时虚拟机与服务器 71建立连接, 并且服务器 71获取到虚拟机的 IP地址和计算机名称。 服务器 71 查询本地是否存在该虚拟机的镜像, 若没有, 则在接收到来自虚拟机的启 动完成的消息后, 向集控制器 71发送备份虚拟机的第一备份指令。 第二接收 模块 704接收来自服务器的备份虚拟机的第一备份指令。生成模块 705根据第 一备份指令生成第二迁移指令。 或者, 触发生成模块 706根据控制器 70的触 发点触发第二迁移指令。触发点可以设置为:重启或开机自动同步、手动同步、 应用修改后同步、 定时同步等。 第二发送模块 707分别向寄宿主机 72和服务 器 71发送第二迁移指令,第二迁移指令用于指示寄宿主机 72将虚拟机的内存 数据单次预拷贝至服务器 71 , 在服务器 71生成虚拟机的镜像。 其中, 控制器 70还可以包括第三发送模块 708, 用于向寄宿主机 72发送挂载指令, 使寄宿 主机为虚拟机挂载硬盘。
在本发明实施方式中,在第一接收模块 701接收虚拟机的启动通知和查询 模块 702查询到服务器 71存在虚拟机的镜像后, 第一发送模块 703分别向服 务器 71和寄宿主机发送第一迁移指令,指示服务器 71将虚拟机的镜像的内存 数据单次预拷贝到虚拟机所在的寄宿主机,。 使得虚拟机的启动不需要经历在 寄宿主机生成虚拟机的生成过程和虚拟机的自身的启动过程,有效地提高虚拟 机的启动时间。 而虚拟机的内存数据较小,从服务器预拷贝到寄宿主机的时间 极短, 不影响到虚拟机的启动时间。
请参阅图 9 ,图 9是本发明控制器第二实施方式的结构示意图。如图所示, 集控制器节点 75包括处理器 750和存储器 751。
处理器 750用于接收启动虚拟机的启动通知; 查询服务器 76是否存在虚 拟机的镜像, 若服务器 76有虚拟机镜像, 分别向服务器 76及寄宿主机 77发 送第一迁移指令, 第一迁移指令用于指示服务器 76将虚拟机的镜像的内存数 据单次预拷贝至寄宿主机 77。
其中, 处理器 750执行的上述处理过程通常是由一段程序控制完成,程序 存放于存储器 751中, 当需要进行上述动作时, 将程序调入处理器 750 , 由处 理器 750 控制完成。 当然, 上述处理过程还可以是由硬件完成。 处理器 750 还可以在完成发送第一迁移指令后, 向寄宿主机 77发送挂载指令, 挂载指令 用于指示寄宿主机 77为虚拟机挂载硬盘。
本发明又提供了服务器实施方式。如图 10所示,服务器 80包括第一接收 模块 801和预拷贝模块 802;
第一接收模块 801接收来自控制器 81的第一迁移指令, 其中, 第一迁移 指令用于指示服务器 80 将虚拟机的镜像的内存数据单次预拷贝至寄宿主机 82。 其中, 控制器 81用于管理集群下所有的虚拟机。 控制器 81感知到虚拟机 83启动, 并查询到服务器 80存在虚拟机 83的镜像时, 向服务器 80发送第一 迁移指令。 若虚拟机 83需要在运行途中进行重启, 虚拟机 83将虚拟机的重 启消息发送到服务器 80。 因此, 服务器 80还包括: 第二接收模块 803、 第一 发送单元 804。
第二接收模块 803接收来自虚拟机 83的第一消息, 第一消息用于指示虚 拟机 83重启。 第一发送模块 803根据第一消息, 向控制器 81发送虚拟机重启 通知, 并向虚拟机 83的寄宿主机 82发送摧毁虚拟机 83的摧毁指令。 寄宿主 机 82通过摧毁指令的方式关闭虚拟机 83比传统关闭虚拟机 83的方式速度更 快、 时间更短。 第一接收模块 801具体为: 接收由控制器 81根据虚拟机重启 通知而发送的第一迁移指令。 预拷贝模块 802根据第一迁移指令, 将虚拟机 83的镜像的内存数据单次预拷贝到寄宿主机 82 , 以在寄宿主机恢复出虚拟机 83。
服务器 80还包括接收建立模块 805、 获取模块 806、 查询模块 807、 第二 发送模块 808、第三接收模块 809、第一接收生成模块 810、第四接收模块 811、 第三发送模块 812和第二接收生成模块 813。
接收建立模块 805用于接收来自虚拟机 83的连接请求, 建立与虚拟机 83 的连接。 获取模块 804用于获取虚拟机 83的 IP地址和计算机名称。 查询模块 806根据 IP地址和计算机名称, 查询是否存在虚拟机 83的镜像。 若服务器 80 存在虚拟机 83的镜像, 第二发送模块 808向控制器 81发送备份虚拟机 83的 第一备份指令。 第三接收模块 809接收由控制器 81根据第一备份指令而发送 的第二迁移指令。 其中, 控制器 81也可以设置触发模块, 触发模块触发向服 务器 80发送第二迁移指令。 则第三接收模块 809又可以具体为: 接收由控制 器 81的触发模块触发的第二迁移指令。 第一接收生成模块 810根据第二迁移 指令接收来自寄宿主机 82上的虚拟机 83的内存数据, 并生成虚拟机 83的镜 像。
可选的, 虚拟机 83也可向服务器 80发送备份虚拟机 83的备份消息。 则 第四接收模块 811接收来自虚拟机 83发送的备份虚拟机 83的第二备份指令。 第三发送模块 812根据第二备份指令向虚拟机 83的寄宿主机 82发送第三迁移 指令, 第三迁移指令用于指示寄宿主机 82将虚拟机的内存数据单次预拷贝到 服务器 80。 第二接收生成模块 813接收来由寄宿主机 82根据第三迁移指令而 传输的虚拟机 83的内存数据, 并生成虚拟机 83的镜像。
在本发明实施方式中, 第一接收模块 801接收第一迁移指令后,预拷贝模 块 802根据第一迁移指令将服务器 80上的虚拟机 83的镜像的内存数据单次预 拷贝到寄宿主机, 直接在寄宿主机上恢复出虚拟机,使得虚拟机的启动不再需 要经历在寄宿主机生成虚拟机的恢复出过程和虚拟机的自身的启动过程,有效 地提高虚拟机的启动时间。 而虚拟机的内存数据较小,从服务器预拷贝到寄宿 主机的时间极短, 不影响到虚拟机的启动时间。
请参阅图 11 , 图 11是本发明服务器第二实施方式的结构示意图。 如图所 示, 服务器 85包括处理器 850和存储器 851。
处理器 850用于接收来自控制器 86的第一迁移指令, 第一迁移指令用于 指示服务器 85将虚拟机的镜像的内存数据单次预拷贝至寄宿主机 87; 根据第 一迁移指令将虚拟机的镜像的内存数据单次预拷贝至寄宿主机 87 , 在寄宿主 机恢复出虚拟机。
其中, 处理器 851执行的上述处理过程通常是由一段程序控制完成,程序 存放于存储器 852中, 当需要进行上述动作时, 将程序调入处理器 851 , 由处 理器 851控制完成。 当然, 上述处理过程还可以是由硬件完成。
需要说明的是:服务器与控制器可以合并在一起,形成一个控制服务节点。 控制服务节点集成上述服务器和控制器的功能。控制服务节点先指示寄宿主机 将虚拟机的内存数据单次预拷贝到控制服务节点,在控制服务节点生成虚拟机 的镜像。在虚拟机启动或者重启时,控制服务节点将虚拟机的镜像的内存数据 单次预拷贝到寄宿主机, 直接在寄宿主机恢复出虚拟机, 并进一步指示寄宿主 机为虚拟机挂载硬盘, 从而完成虚拟机的快速启动。
本发明又提供了寄宿主机实施方式。如图 12所示, 寄宿主机 90包括第一 接收模块 901和接收恢复模块 902。
第一接收模块 901接收来自控制器 91的第一迁移指令, 第一迁移指令用 于指示服务器 92将虚拟机的镜像的内存数据单次预拷贝到寄宿主机 90。 接收 恢复模块 902根据第一迁移指令接收来自服务器 92传输的虚拟机的镜像的内 存数据, 并在寄宿主机 90恢复虚拟机。
寄宿主机 90还包括检测模块 903、 发送模块 904、 第二接收模块 905、 第 三接收模块 906和预拷贝模块 907。 检测模块 903检测虚拟机的特殊状态, 特 殊状态包括虚拟机启动状态和宕机状态。发送模块 904在检测模块 903检测到 虚拟机的特殊状态时, 向控制器 91发送虚拟机的特殊状态通知。 第一接收模 块 901又可具体为: 接收由控制器 91根据虚拟机的特殊状态发送的第一迁移 指令。
第二接收模块 905接收来自控制器的第二迁移指令,第二迁移指令用于指 示寄宿主机将虚拟机的内存数据单次预拷贝到服务器。或者,虚拟机直接发送 备份虚拟机的第二备份指令到服务器 92 , 服务器 92根据第二备份指令向寄宿 主机发送第二迁移指令。则第三接收模块 906接收服务器 92的第三迁移指令, 第三迁移指令用于指示寄宿主机 90将虚拟机的内存数据单次预拷贝到服务器 92。预拷贝模块 907用于根据第二迁移指令或者第三迁移指令挂起虚拟机, 并 将虚拟机的内存数据单次预拷贝到服务器 92。 本发明实施例中的寄宿主机还 可以包括第四接收模块 908和挂载模块 909, 第四接收模块 908在恢复出虚拟 机后, 接收来自控制器 91的挂载指令, 挂载模块 909根据挂载指令为虚拟机 挂载硬盘。
在本发明实施方式中, 接收恢复模块 902接收来自服务器 92传输的虚拟 机的镜像的内存数据, 直接在寄宿主机 90上恢复出虚拟机。 使得虚拟机的启 动不再需要经历在寄宿主机恢复出虚拟机的生成过程和虚拟机的自身的启动 过程, 有效地提高虚拟机的启动时间。 而虚拟机的内存数据较小, 从服务器预 拷贝到寄宿主机的时间极短, 同样的, 寄宿主机为虚拟机挂载硬盘的时间也极 短, 不影响虚拟机的启动时间。
请参阅图 13 , 图 13是本发明寄宿主机第二实施方式的结构示意图。 如图 所示, 寄宿主机 95包括处理器 950和存储器 951。
处理器 950用于接收来自控制器 97的第一迁移指令, 第一迁移指令用于 指示服务器 96将虚拟机的镜像的内存数据单次预拷贝到寄宿主机 95; 根据所 述第一迁移指令接收虚拟机的镜像的内存数据, 并在寄宿主机 95上恢复出虚 拟机; 还可用于在恢复虚拟机后, 接收来自控制器 97的挂载指令; 根据挂载 指令为虚拟机挂载硬盘, 完成虚拟机的启动。
其中, 处理器 950执行的上述处理过程通常是由一段程序控制完成,程序 存放于存储器 950中, 当需要进行上述动作时, 将程序调入处理器 950 , 由处 理器 950控制完成。 当然, 上述处理过程还可以是由硬件完成。
为了让读者更好的理解本发明, 下面又从系统角度阐述本发明的内容。请 参图 14, 图 14是本发明恢复虚拟机的系统实施方式的结构图。 恢复虚拟机的 系统 1包括控制器 2、 服务器 3和寄宿主机 4。 其中, 控制器 2为上述任一控 制器, 服务器 3为上述任一服务器, 寄宿主机 4为上述任一寄宿主机。 进一步 的, 寄宿主机 4可以有多台。 虚拟机运行在寄宿主机 4上。
进一步, 请参阅图 15 , 图 15是本发明恢复虚拟机的系统实施方式中, 虚 拟机初次启动的流程图。
步骤 S10: 虚拟机初次启动, 服务器上尚没有虚拟机的镜像; 步骤 Sll : 客户端广播数据包;
步骤 S12: 服务器监听到客户端的数据包, 并建立与客户端的连接, 取得 虚拟机的 IP、 计算机名称等信息;
步骤 S13: 客户端上的钩子程序钩取键盘鼠标信息, 形成队列保存在系统 内存中;
步骤 S14: 客户端刷新虚拟机进程个数形成第一变量,延迟 Is;
步骤 S15:客户端刷新虚拟机进程个数形成第二变量,对比第一变量和第二 变量, 如果第一变量不等于第二变, 则继续延迟, 如果相等, 则结束;
步骤 S16: 当第一变量等于第二变量, 说明虚拟机启动完成, 客户端发送 向服务器发送消息, 所述消息用于指示虚拟机启动完成;
步骤 S17: 服务器向控制器申请备份虚拟机;
步骤 S18: 控制器向寄宿主机发送虚拟机的内存数据单次预拷贝命令; 步骤 S19: 控制器向服务器发送虚拟机的内存数据单次预拷贝命令; 步骤 S20: 寄宿主机将虚拟机内存数据单次预拷贝服务器;
步骤 S21 : 服务器压缩虚拟机的内存数据, 形成压缩镜像;
步骤 S22:控制器更新虚拟机的镜像的状态信息,指示存在虚拟机的镜像; 步骤 S23: 服务器向客户端发送处理完成的消息;
步骤 S24: 客户端释放钩子消息, 客户正常使用。
请参图 16,图 16是本发明系统实施方式中,虚拟机内部操作备份流程图; 步骤 S110: 点击备份虚拟机;
步骤 S111: 虚拟机向服务器申请备份虚拟机;
步骤 S112: 寄宿主机挂起虚拟机;
步骤 S113: 寄宿主机将虚拟机的内存数据单次预拷贝到服务器。
请参图 17, 图 17是本发明恢复虚拟机的系统实施方式中, 虚拟机发起内 部重启的流程图;
步骤 S120: 虚拟机内部重启;
步骤 S121 : 客户端调用系统接口感知该行为;
步骤 S122: 客户端发消息到服务器;
步骤 S123: 服务器查询到存在虚拟机的镜像; 步骤 SI 24 服务器发消息到寄宿主机, 关闭虚拟机;
步骤 S125 服务器调用虚拟机迁移接口;
步骤 S126 服务器将虚拟机的内存数据单次预拷贝到到寄宿主机; 步骤 SI 28 寄宿主机为虚拟机挂载硬盘。
请参图 18, 图 18是本发明恢复虚拟机的系统实施方式中, 虚拟机启动的 流程图;
步骤 S130 控制器感知到虚拟机启动;
步骤 S131 控制器查询到服务器内存中存在虚拟机的镜像;
步骤 S132 控制
步骤 S133
Figure imgf000023_0001
步骤 S134 服务器解压虚拟机的镜像;
步骤 S135 服务器将解压后的虚拟机的内存数据单次预拷贝到到寄宿主 步骤 S136: 寄宿主机为虚拟机挂载硬盘。
通过将服务器上的虚拟机的镜像的内存数据单次预拷贝到寄宿主机,在寄 宿主机上直接恢复虚拟机,使得虚拟机不再需要经历在寄宿主机生成虚拟机的 生成过程和虚拟机的自身的启动过程, 有效地提高虚拟机的启动时间。
以上所述仅为本发明的实施方式, 并非因此限制本发明的专利范围, 凡是 利用本发明说明书及附图内容所作的等效结构或等效流程变换,或直接或间接 运用在其他相关的技术领域, 均同理包括在本发明的专利保护范围内。

Claims

权 利 要 求 书
1、 一种恢复虚拟机的方法, 其特征在于, 包括:
控制器接收启动所述虚拟机的启动通知;
所述控制器查询服务器是否存在所述虚拟机的镜像,若所述服务器 存在所述虚拟机的镜像,所述控制器分别向所述服务器及寄宿主机发送 第一迁移指令,所述第一迁移指令用于指示所述服务器将所述虚拟机的 镜像的内存数据单次预拷贝至所述寄宿主机。
2、 根据权利要求 1所述的方法, 其特征在于, 所述控制器接收启动所述 虚拟机的启动通知, 具体包括:
所述控制器接收来自所述服务器发送的所述虚拟机重启通知;
或者,
所述控制器接收来自所述寄宿主机发送的所述虚拟机的特殊状态通知,所
3、根据权利要求 1所述的方法, 其特征在于, 所述控制器接收启动虚拟机 的启动通知之前, 还包括:
所述控制器分别向所述服务器和所述寄宿主机发送第二迁移指令,所述第 二迁移指令用于指示所述寄宿主机将所述虚拟机的内存数据单次预拷贝至所 述服务器, 以使所述服务器生成所述虚拟机的镜像。
4、根据权利要求 3所述的方法, 其特征在于, 所述控制器分别向所述服务 器和所述寄宿主机发送第二迁移指令的步骤之前, 还包括:
所述控制器接收来自所述服务器的备份虚拟机的第一备份指令,并根据所 述第一备份指令生成所述第二迁移指令。
5、 一种恢复虚拟机的方法, 其特征在于, 包括:
服务器接收来自控制器的第一迁移指令,所述第一迁移指令用于指示所述 服务器将所述虚拟机的镜像的内存数据单次预拷贝至寄宿主机;
所述服务器根据第一迁移指令将所述虚拟机的镜像的内存数据单次预拷 贝至所述寄宿主机, 以使所述寄宿主机恢复所述虚拟机。
6、 根据权利要求 5所述的方法, 其特征在于, 所述服务器接收来自控制 器的第一迁移指令, 具体包括: 所述服务器接收来自所述虚拟机的第一消息,所述第一消息用于指示所述 虚拟机重启;
所述服务器根据所述第一消息, 向所述控制器发送所述虚拟机的重启通 知, 并向所述寄宿主机发送摧毁所述虚拟机的摧毁指令;
所述服务器接收由所述控制器根据所述虚拟机的重启通知而发送的第一 迁移指令。
7、 根据权利要求 5所述的方法, 其特征在于, 所述服务器接收来自控制 器的第一迁移指令的步骤之前, 还包括:
所述服务器接收来自所述控制器的第二迁移指令,所述第二迁移指令用于 指示所述寄宿主机将所述虚拟机的内存数据单次预拷贝到所述服务器;
所述服务器接收来自所述虚拟机的内存数据, 并生成所述虚拟机的镜像。
8、根据权利要求 7所述的方法, 其特征在于, 所述服务器接收来自控制器 的第二迁移指令的步骤之前, 还包括:
所述服务器接收来自所述虚拟机的连接请求, 建立与所述虚拟机的连接; 所述服务器获取所述虚拟机的 IP地址和计算机名称;
所述服务器根据所述虚拟机的 IP地址和计算机名称, 查询是否存在所述 虚拟机的镜像;
若所述服务器没有存在所述虚拟机的镜像,则所述服务器向所述控制器发 送备份所述虚拟机的第一备份指令;
所述服务器接收来自所述控制器的第二迁移指令, 具体包括:
所述服务器接收由所述控制器根据所述第一备份指令发送的所述第二迁 移指令。
9、 根据权利要求 7所述的方法, 其特征在于, 所述服务器接收来自控制 器的第二迁移指令, 具体包括:
所述服务器接收由所述控制器的触发模块触发的所述第二迁移指令。
10、 根据权利要求 5所述的方法, 其特征在于, 所述服务器接收来自控制 器的第一迁移指令的步骤之前, 还包括:
所述服务器接收来自所述虚拟机发送的备份所述虚拟机的第二备份指令; 所述服务器根据所述第二备份指令向所述寄宿主机发送第三迁移指令; 所述服务器接收由所述寄宿主机根据第三迁移指令而传输的所述虚拟机 的内存数据, 并在所述服务器生成所述虚拟机的镜像。
11、 一种恢复虚拟机的方法, 其特征在于, 所述方法包括:
寄宿主机接收来自控制器的第一迁移指令,所述第一迁移指令用于指示服 务器将所述虚拟机的镜像的内存数据单次预拷贝到所述寄宿主机;
所述寄宿主机根据所述第一迁移指令接收所述虚拟机的镜像的内存数据, 并在所述寄宿主机上恢复所述虚拟机。
12、 根据权利要求 11所述的方法, 其特征在于, 所述寄宿主机接收来自 控制器的第一迁移指令之前, 还包括:
所述寄宿主机检测所述虚拟机的特殊状态,所述特殊状态包括所述虚拟机 启动状态或者宕机状态;
所述寄宿主机在检测到所述虚拟机的所述特殊状态时,向所述控制器发送 所述虚拟机的特殊状态通知;
所述寄宿主机接收来自控制器的第一迁移指令, 具体包括:
所述寄宿主机接收由所述控制器根据所述虚拟机的所述特殊状态通知发 送的所述第一迁移指令。
13、 根据权利要求 11所述的方法, 其特征在于, 所述寄宿主机接收来自 控制器的第一迁移指令之前, 还包括:
所述寄宿主机接收来自所述控制器的第二迁移指令,所述第二迁移指令第 三迁移指令用于指示所述寄宿主机将所述虚拟机的内存数据单次预拷贝到所 述服务器, 在所述服务器上生成所述虚拟机的镜像;
所述寄宿主机根据所述第二迁移指令挂起所述虚拟机,并将所述虚拟机的 内存数据单次预拷贝到所述服务器, 以使所述服务器生成所述虚拟机的镜像。
14、 根据权利要求 11所述的方法, 其特征在于, 所述寄宿主机接收来自 控制器的第一迁移指令之前, 还包括:
所述寄宿主机接收来自所述服务器的第三迁移指令,所述第三迁移指令用 于指示所述寄宿主机将所述虚拟机的内存数据单次预拷贝到所述服务器,在所 述服务器上生成所述虚拟机的镜像;
所述寄宿主机根据所述第三迁移指令挂起所述虚拟机,并将所述虚拟机的 内存数据单次预拷贝到所述服务器, 以使所述服务器生成所述虚拟机的镜像。
15、 一种控制器, 其特征在于, 所述控制器包括:
第一接收模块, 用于接收启动虚拟机的启动通知;
查询模块, 用于查询服务器上是否存在所述虚拟机的镜像;
第一发送模块, 用于在所述查询模块查询到所述虚拟机的镜像后, 分别向 所述服务器和寄宿主机发送第一迁移指令,所述第一迁移指令用于指示所述服 务器将所述虚拟机的镜像的内存数据单次预拷贝至所述寄宿主机。
16、 根据权利要求 15所述控制器, 其特征在于, 所述第一接收模块具体 用于:
接收来自所述服务器发送的所述虚拟机重启通知;
或者,
接收来自所述寄宿主机发送的所述虚拟机的特殊状态通知,所述特殊状态 包括所述虚拟机的启动状态或宕机状态。
17、 根据权利要求 15所述的控制器, 其特征在于, 还包括:
第二发送模块, 用于分别向所述寄宿主机和所述服务器发送第二迁移指 令,所述第二迁移指令用于指示所述寄宿主机将所述虚拟机的内存数据单次预 拷贝至所述服务器, 以使所述服务器生成所述虚拟机的镜像。
18、 根据权利要求 17所述的控制器, 其特征在于, 还包括:
第二接收模块,用于接收来自所述服务器的备份所述虚拟机的第一备份指 令;
生成模块, 用于根据所述第一备份指令生成所述第二迁移指令。
19、 根据权利要求 17所述的控制器, 其特征在于, 还包括:
触发生成模块, 用于触发所述第二迁移指令。
20、 一种服务器, 其特征在于, 所述服务器包括:
第一接收模块, 用于接收来自控制器的第一迁移指令, 其中, 所述第一迁 移指令用于指示所述服务器将虚拟机的镜像的内存数据单次预拷贝至寄宿主 机;
预拷贝模块, 用于根据所述第一迁移指令,将所述虚拟机的镜像的内存数 据单次预拷贝到所述寄宿主机, 以使所述寄宿主机恢复所述虚拟机。
21、 根据权利要求 20所述服务器, 其特征在于, 还包括:
第二接收模块, 用于接收来自所述虚拟机的第一消息, 所述第一消息用于 指示所述虚拟机重启;
第一发送模块, 用于根据所述第一消息, 向所述控制器发送虚拟机重启通 知, 并向所述寄宿主机发送摧毁所述虚拟机的摧毁指令;
所述第一接收模块具体为:接收由所述控制器根据所述虚拟机重启通知发 送的第一迁移指令。
22、 根据权利要求 20所述服务器, 其特征在于, 还包括:
第三接收模块, 用于接收来自所述控制器的第二迁移指令;
第一接收生成模块,根据所述第二迁移指令接收来自所述寄宿主机的虚拟 机的内存数据, 并生成所述虚拟机的镜像。
23、 根据权利要求 22所述服务器, 其特征在于, 还包括:
接收建立模块, 用于接收来自所述虚拟机的连接请求, 建立与所述虚拟机 的连接;
获取模块, 用于获取所述虚拟机的 IP地址和计算机名称;
查询模块, 用于根据所述 IP地址和计算机名称, 查询是否存在所述虚拟 机的镜像;
第二发送模块, 用在于所述查询模块没有查询到所述虚拟机的镜像时, 向 所述控制器发送备份所述虚拟机的第一备份指令。
所述第三接收模块具体用于接收由所述控制器根据第一备份指令发送的 第二迁移指令。
24、根据权利要求 22所述服务器, 其特征在于, 所述第三接收模块具体用 于: 接收由所述控制器的触发模块触发的第二迁移指令。
25、 根据权利要求 20所述的服务器, 其特征在于, 还包括:
第四接收模块,用于接收来自所述虚拟机发送的备份所述虚拟机的第二备 份指令;
第三发送模块,用于根据所述第二备份指令向所述虚拟机的寄宿主机发送 第三迁移指令;
第二接收生成模块,用于接收来自所述寄宿主机根据所述第三迁移指令传 输的所述虚拟机的内存数据, 并生成所述虚拟机的镜像。
26、 一种寄宿主机, 其特征在于, 包括:
第一接收模块, 用于接收来自控制器的第一迁移指令, 所述第一迁移指令 用于指示服务器将虚拟机的镜像的内存数据单次预拷贝到所述寄宿主机; 接收恢复模块,用于根据所述第一迁移指令接收来自所述服务器传输的所 述虚拟机的镜像的内存数据, 并在所述寄宿主机上恢复所述虚拟机。
27、 根据权利要求 26所述的寄宿主机, 其特征在于, 还包括:
检测模块, 用于检测所述虚拟机的特殊状态, 所述特殊状态包括所述虚拟 机启动状态或者宕机状态;
发送模块, 用于在所述检测模块检测到所述虚拟机的所述特殊状态时, 向 所述控制器发送所述虚拟机的所述特殊状态通知;
所述第一接收模块具体用于接收由所述控制器根据所述虚拟机的所述特 殊状态通知发送的所述第一迁移指令。
28、 根据权利要求 26所述的寄宿主机, 其特征在于, 所述寄宿主机还包 括:
第二接收模块, 用于接收第二迁移指令, 所述第二迁移指令用于指示所述 寄宿主机将所述虚拟机的内存数据单次预拷贝到所述服务器;
预拷贝模块, 用于根据第二迁移指令挂起所述虚拟机, 并将所述虚拟机的 内存数据单次预拷贝到服务器。
29、 根据权利要求 26所述的寄宿主机, 其特征在于, 还包括:
第三接收模块, 用于接收所述服务器的第三迁移指令, 所述第三迁移指令 用于指示所述寄宿主机将所述虚拟机的内存数据单次预拷贝到所述服务器; 预拷贝模块, 用于根据第三迁移指令挂起所述虚拟机, 并将所述虚拟机的 内存数据单次预拷贝到服务器。
30、 一种恢复虚拟机的系统, 其特征在于, 包括: 如权利要求 15至 19任 一所述的控制器、 如权利要求 20至 25任一所述的服务器和权利要求 26至 29 任一所述的寄宿主机。
PCT/CN2013/074295 2012-11-22 2013-04-17 恢复虚拟机的方法、系统及控制器、服务器、寄宿主机 WO2014079194A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201210479165.2A CN103838593B (zh) 2012-11-22 2012-11-22 恢复虚拟机的方法、系统及控制器、服务器、寄宿主机
CN201210479165.2 2012-11-22

Publications (1)

Publication Number Publication Date
WO2014079194A1 true WO2014079194A1 (zh) 2014-05-30

Family

ID=50775464

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2013/074295 WO2014079194A1 (zh) 2012-11-22 2013-04-17 恢复虚拟机的方法、系统及控制器、服务器、寄宿主机

Country Status (2)

Country Link
CN (1) CN103838593B (zh)
WO (1) WO2014079194A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20230305854A1 (en) * 2022-03-25 2023-09-28 Sap Se Reducing downtime during operating system patching

Families Citing this family (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP3105884A4 (en) 2014-02-11 2018-03-21 Yaana Technologies, LLC Mathod and system for metadata analysis and collection with privacy
US10447503B2 (en) 2014-02-21 2019-10-15 Yaana Technologies, LLC Method and system for data flow management of user equipment in a tunneling packet data network
US10334037B2 (en) 2014-03-31 2019-06-25 Yaana Technologies, Inc. Peer-to-peer rendezvous system for minimizing third party visibility and method thereof
US10285038B2 (en) 2014-10-10 2019-05-07 Yaana Technologies, Inc. Method and system for discovering user equipment in a network
US10542426B2 (en) 2014-11-21 2020-01-21 Yaana Technologies, LLC System and method for transmitting a secure message over a signaling network
WO2016176661A1 (en) 2015-04-29 2016-11-03 Yaana Technologies, Inc. Scalable and iterative deep packet inspection for communications networks
WO2017083855A1 (en) 2015-11-13 2017-05-18 Yaana Technologies Llc System and method for discovering internet protocol (ip) network address and port translation bindings
CN106817238A (zh) * 2015-11-30 2017-06-09 中兴通讯股份有限公司 虚拟机修复方法、虚拟机装置、系统及业务功能网元
CN105718263B (zh) * 2016-01-19 2018-11-13 合肥联宝信息技术有限公司 一种实现基于云的分布式计算机的方法及系统
US20170230242A1 (en) * 2016-02-10 2017-08-10 Yaana Technologies, LLC Dynamic Elastic Shadow Service Orchestrator
CN106708603B (zh) 2016-12-28 2019-04-26 平安科技(深圳)有限公司 虚拟机快速恢复方法及装置
CN110196723B (zh) * 2018-02-27 2023-06-27 阿里巴巴(中国)有限公司 流量数据拷贝的方法、装置以及计算机可读存储介质
CN108694066B (zh) * 2018-05-09 2021-04-27 北京酷我科技有限公司 一种tableView延迟刷新的方法
CN109472680A (zh) * 2018-10-26 2019-03-15 中国银行股份有限公司 一种账务处理方法及系统
CN112835739A (zh) * 2019-11-22 2021-05-25 北京百度网讯科技有限公司 宕机处理方法和装置

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102033755A (zh) * 2009-09-30 2011-04-27 国际商业机器公司 用于运行虚拟机镜像的方法和系统
CN102185928A (zh) * 2011-06-01 2011-09-14 广州杰赛科技股份有限公司 一种在云计算系统创建虚拟机的方法及云计算系统
CN102662751A (zh) * 2012-03-30 2012-09-12 浪潮电子信息产业股份有限公司 一种提高基于热迁移虚拟机系统可用性的方法

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102339229A (zh) * 2010-07-15 2012-02-01 戴元顺 基于操作系统层的虚拟化方法

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102033755A (zh) * 2009-09-30 2011-04-27 国际商业机器公司 用于运行虚拟机镜像的方法和系统
CN102185928A (zh) * 2011-06-01 2011-09-14 广州杰赛科技股份有限公司 一种在云计算系统创建虚拟机的方法及云计算系统
CN102662751A (zh) * 2012-03-30 2012-09-12 浪潮电子信息产业股份有限公司 一种提高基于热迁移虚拟机系统可用性的方法

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20230305854A1 (en) * 2022-03-25 2023-09-28 Sap Se Reducing downtime during operating system patching

Also Published As

Publication number Publication date
CN103838593B (zh) 2020-04-03
CN103838593A (zh) 2014-06-04

Similar Documents

Publication Publication Date Title
WO2014079194A1 (zh) 恢复虚拟机的方法、系统及控制器、服务器、寄宿主机
US10579409B2 (en) Live migration of virtual machines with memory state sharing
US9727429B1 (en) Method and system for immediate recovery of replicated virtual machines
US8473692B2 (en) Operating system image management
US9489230B1 (en) Handling of virtual machine migration while performing clustering operations
US9690662B2 (en) Techniques for virtual machine management
US7240122B2 (en) File sharing device and inter-file sharing device data migration method
US9262212B2 (en) Systems and methods for migrating virtual machines
WO2017162173A1 (zh) 云服务器集群建立连接的方法和装置
EP3213472B1 (en) System and method for optimizing transportation over networks
WO2021129733A1 (zh) 云操作系统的管理方法、装置、服务器、管理系统及介质
WO2015096500A1 (zh) 一种业务迁移方法、装置和一种容灾系统
WO2011066761A1 (zh) 一种物理机到虚拟机的在线迁移方法、装置和系统
US20140359343A1 (en) Method, Apparatus and System for Switching Over Virtual Application Two-Node Cluster in Cloud Environment
US20180150501A1 (en) Database system, server device, computer program product, and information processing method
US20090157882A1 (en) Network connection failover during application service interruption
US8909912B2 (en) Apparatus and method for configuring a target machine with captured operational state comprising a static machine profile and a dynamic machine state to continue operations of a source machine
CN103761166A (zh) 一种虚拟化环境下针对网络服务的双机热备份容灾系统及其方法
US11604806B2 (en) System and method for highly available database service
JP2008293358A (ja) 分散処理プログラム、分散処理方法、分散処理装置、および分散処理システム
WO2015074200A1 (zh) 一种生成快照的方法、系统和装置
US20210081287A1 (en) Data service failover in shared storage clusters
KR20180087278A (ko) 가상 머신의 신속한 복원 방법, 장치 및 시스템
US8495178B1 (en) Dynamic bandwidth discovery and allocation to improve performance for backing up data
US9678838B2 (en) Protecting virtual machines from network failures

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 13856617

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 13856617

Country of ref document: EP

Kind code of ref document: A1