WO2017132872A1 - Virtual machine backup method, backup device and host - Google Patents

Virtual machine backup method, backup device and host Download PDF

Info

Publication number
WO2017132872A1
WO2017132872A1 PCT/CN2016/073318 CN2016073318W WO2017132872A1 WO 2017132872 A1 WO2017132872 A1 WO 2017132872A1 CN 2016073318 W CN2016073318 W CN 2016073318W WO 2017132872 A1 WO2017132872 A1 WO 2017132872A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
source
virtual machine
hard disk
storage block
Prior art date
Application number
PCT/CN2016/073318
Other languages
French (fr)
Chinese (zh)
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 华为技术有限公司
Priority to CN201680003386.9A priority Critical patent/CN107003893B/en
Priority to PCT/CN2016/073318 priority patent/WO2017132872A1/en
Publication of WO2017132872A1 publication Critical patent/WO2017132872A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • 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
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1458Management of the backup or restore process
    • G06F11/1466Management of the backup or restore process to make the backup process non-disruptive
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1479Generic software techniques for error detection or fault masking
    • G06F11/1482Generic software techniques for error detection or fault masking by means of middleware or OS functionality
    • G06F11/1484Generic software techniques for error detection or fault masking by means of middleware or OS functionality involving virtual machines
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45562Creating, deleting, cloning virtual machine instances
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45575Starting, stopping, suspending or resuming virtual machine instances

Definitions

  • the present invention relates to the field of computers, and in particular, to a virtual machine backup method, a backup device, and a host machine.
  • a virtual machine is a complete system that runs through a software and has a complete hardware system function and runs in a completely isolated environment.
  • the host where the virtual machine is located that is, the host virtual machine virtualizes various hardware units, such as virtual machine memory and virtual machine hard disk.
  • the data in the virtual machine's memory is managed by the virtual machine itself, while the data on the virtual machine's hard disk is stored and managed by the host.
  • FIG. 1 is a schematic structural diagram of a virtual machine in the prior art.
  • all resources used by the virtual machine 101 such as CPU, memory, network, and storage resources, are all derived from the host 102, and the host 102 will itself.
  • Resources such as virtual multiprocessors, virtual machine cluster file systems, virtual network cards and switches, storage protocol stacks, network protocol stacks, and device drivers are provided to the virtual machine 101 in a shared manner to enable the virtual machine 101 to provide external Business services.
  • the external service provided by the virtual machine 101 is implemented by an application (aplication, abbreviated as APP) 103 inside the virtual machine.
  • APP application
  • the backup data of the virtual machine is consistent with the running data and can also be called the consistency of the virtual machine.
  • there are two backup methods for a virtual machine One is cold backup, the cold backup is to back up data when the virtual machine is shut down, and the other is hot backup.
  • the hot backup is when the virtual machine keeps working. The data is backed up.
  • Cold backup can guarantee the consistency of the virtual machine.
  • the cold backup needs to shut down the virtual machine. When the virtual machine is shut down, it cannot provide external services. Therefore, cold backup is less used.
  • Hot backup does not need to shut down the virtual machine, but when the virtual machine runs, the data of the internal application of the virtual machine is first saved in the cache, and then written into the virtual machine hard disk, that is, the data in the virtual machine hard disk is read, written, and updated at any time. During the backup process, the data is also updated at any time. Therefore, the hot backup method in the prior art cannot back up the updated data in the virtual machine hard disk in real time, resulting in data loss during the virtual machine backup process, and the virtual machine backup cannot be guaranteed.
  • the purpose of the embodiments of the present invention is to provide a virtual machine backup method and a backup device, which ensure consistency of backup data when backing up data in the case of providing virtual machine functions externally.
  • a virtual machine backup method which is applied to a host machine, and a plurality of virtual machines are created on the host machine, and when the user needs to back up data in the virtual machine on the host machine, the method is released.
  • a virtual machine backup command when the host receives the backup command, interrupts the service of the source virtual machine to be backed up, and creates a cloned virtual machine and a cloned hard disk of the cloned virtual machine.
  • the mapping relationship between the cloned hard disk and the storage space of the source virtual disk of the source virtual machine is established, and then the running data of the source virtual machine is mirrored to the cloned virtual machine, so that the The clone virtual machine starts running according to the running data, and sets the clone virtual machine to receive an IO request, so that the cloned virtual machine can take over the service of the source virtual machine.
  • the service of the source virtual machine that is interrupted can be resumed, and the IO request that has not been executed when the backup command of the user is received is executed to ensure data consistency.
  • the modified data is recorded into the cloned hard disk, and the recorded data is recorded.
  • the location is marked.
  • the source hard disk is the hard disk of the cloned virtual machine.
  • the service executed by the virtual machine during the backup process is transferred to the cloned virtual machine by creating a cloned virtual machine including the cloned hard disk, and the virtual machine is backed up during the backup process.
  • the modification of the data stored in the source virtual machine is recorded in the cloned hard disk, and the modified data is marked, so that after the data backup of the virtual machine is completed, the source may be updated by the modified data recorded in the cloned hard disk.
  • the data in the virtual machine in this way, while ensuring the consistency of the backup data, it does not interrupt the business of the virtual machine, thereby improving the operating efficiency of the virtual machine.
  • the source hard disk and the clone hard disk may be separately divided into multiple storage blocks according to a preset size, and then the source storage block is established.
  • the mapping between the address and the address of the cloned block may be separately divided into multiple storage blocks according to a preset size, and then the source storage block is established.
  • each storage block in the source hard disk can be corresponding to one clone storage block, so that the modified source storage block and the modified data recorded in the clone storage block can be accurately marked.
  • the modified source storage block may be marked by setting an update identifier for an address mapping relationship of an address of each source storage block in the mapping table and a clone storage block, wherein the modified method is to record the modified The update flag corresponding to the mapping relationship of the address of the cloned storage block of the data is set to be updated.
  • the updated identifier can conveniently identify the modified data in the source hard disk.
  • Modifying the data in the source hard disk may be writing new data on the basis of the data stored in the source hard disk at the backup time point, or updating the data stored in the source hard disk at the backup time point. It is also possible to delete data on the basis of the data stored in the source hard disk at the backup time point.
  • the data update request is updated Whether the update identifier corresponding to the mapping relationship of the address of the source storage block is updated, and the data is determined when the update identifier corresponding to the mapping relationship of the address of the source storage block updated by the data update request is not updated. And updating the updated data in the updated source storage block to the clone storage block corresponding to the source storage block updated by the data update request, and writing the data update in the source storage block updated by the data update request.
  • the update data in the request; and the update identifier corresponding to the source storage block updated by the data update request is set to be updated.
  • the service executed in the source virtual machine is also mirrored to the cloned virtual machine, the same service as the source virtual machine is also performed in the cloned virtual machine, so when the data in the source virtual machine is updated The updated data in the source virtual machine also needs to be transferred to the cloned storage block, so that the cloned virtual machine subsequently uses the data.
  • the method for processing the read IO request is as follows:
  • mapping relationship when copying the data at the marked location in the cloned hard disk to the location of the source hard disk mapped at the marked location of the cloned hard disk according to the mapping relationship, first determining the updated update identifier pair that is set to be updated. a clone storage block in the mapping relationship; copying data stored in the clone storage block in the mapping relationship corresponding to the updated update identifier to the mapping relationship corresponding to the updated update identifier set to be updated The source storage block in ; then set the update identifier set to updated to not updated.
  • the modification flag is also set, so that when the read IO request is received during this period, the position of the read data can be determined according to the modification flag.
  • the data to be written in the data write request is written into the source hard disk, and the write to be written is written.
  • the update identifier corresponding to the source storage block of the incoming data is set to not updated.
  • the cloned hard disk and the mapping table may be deleted.
  • a virtual machine backup device in a second aspect, includes a creation unit, a marking unit, a backup unit, a reading unit, and an update unit, the creation unit, the marking unit, the backup unit, the reading unit, And the functions performed by the update unit correspond to the methods provided in the first aspect, and are not described herein again.
  • a host in a third aspect, includes: a processor, a memory, a hard disk, a communication interface, and a system bus.
  • the processor, the memory, the hard disk, and the communication interface are connected through a system bus and complete each other. Communication in the memory for storing computer execution instructions, when the host is running, the processor executes the computer execution instructions in the memory to establish a virtual machine with hardware resources in the host machine, and executes The method provided by the first aspect.
  • the service executed by the virtual machine during the backup process is transferred to the cloned virtual machine by creating a cloned virtual machine including the cloned hard disk, and
  • the modification of the data stored in the source virtual machine is recorded in the cloned hard disk, and the modified data is marked, so that after the virtual machine data backup is completed, the cloned hard disk can be recorded.
  • the modified data updates the data in the source virtual machine, so that the consistency of the backup data is ensured, and the service of the virtual machine is not interrupted, thereby improving the operating efficiency of the virtual machine.
  • FIG. 1 is a schematic structural diagram of a virtual machine in the prior art
  • FIG. 2 is a structural diagram of a host machine according to an embodiment of the present invention.
  • FIG. 3 is a flowchart of a virtual machine backup method according to an embodiment of the present invention.
  • FIG. 4 is a schematic diagram showing a mapping relationship between a source hard disk and a storage space of a cloned hard disk according to an embodiment of the present invention
  • FIG. 5 is a schematic diagram of updating data in a source hard disk during a running of a cloned virtual machine according to an embodiment of the present invention
  • FIG. 6 is a schematic diagram of data read by a cloned virtual machine according to an embodiment of the present invention.
  • FIG. 7 is a schematic diagram of updating data in a source hard disk during operation of a source virtual machine according to an embodiment of the present invention.
  • FIG. 8 is a schematic diagram of copying data in the cloned hard disk to the source hard disk according to an embodiment of the present invention.
  • FIG. 9 is a block diagram of a data backup device according to an embodiment of the present invention.
  • a clone virtual machine and a clone hard disk may be created, and the running data in the source virtual machine is transferred to the clone virtual machine and the subsequent access source virtual machine is accessed.
  • the IO request is redirected, and the cloned virtual machine takes over the service of the source virtual machine, and after the data backup is completed, overwrites data in the source hard disk with data inconsistent with the source hard disk in the cloned hard disk, and the data is Source hard disk as the clone virtual machine
  • the hard disk is such that when the data in the source virtual machine is backed up, the consistency of the backup data is ensured without interrupting the service performed by the virtual machine.
  • FIG. 2 it is a structural diagram of a host machine 20 according to an embodiment of the present invention.
  • the host machine 20 can include a processor 201, a memory 202, a hard disk 204, a communication interface 207, and a system bus 200.
  • the processor 201, the memory 202, the hard disk 204, and the communication interface 207 are connected by the system bus 200 and complete communication with each other.
  • Processor 201 may be a single core or multi-core central processing unit, or a particular integrated circuit, or one or more integrated circuits configured to implement embodiments of the present invention.
  • the memory 202 can be a high speed RAM memory or a non-volatile memory, such as at least one disk memory, and the memory 202 is used to store computer execution instructions. Specifically, the program code may be included in the computer execution instruction.
  • the processor 201 executes the in-memory computer execution instructions 203 to establish a plurality of virtual machines, such as the source virtual machine 208 and the clone virtual machine 209, using hardware resources in the host machine.
  • a source hard disk 205 and a clone hard disk 206 are respectively created in the hard disk 204 for the source virtual machine 208 and the clone virtual machine 209.
  • the clone virtual machine 209 and the clone hard disk 206 are created when the data in the source hard disk 205 of the source virtual machine 208 is backed up to the backup memory 30.
  • the flowchart illustrates the backup process in the source virtual machine.
  • the virtual machine backup method of the embodiment of the present invention includes:
  • Step 301 Receive a backup command, interrupt the service of the source virtual machine, and create a cloned virtual machine and a cloned hard disk of the cloned virtual machine.
  • the service of the source virtual machine 208 is an I/O request being executed by the virtual machine, and the service of the interrupt source virtual machine 208 suspends the IO request being executed by the source virtual machine 208.
  • the service of the source VM can be set according to the actual situation.
  • Step 302 Establish a mapping relationship between the cloned hard disk and a storage space of the source hard disk of the source virtual machine.
  • the source hard disk and the clone hard disk are respectively divided into multiple storage blocks according to a preset size, and then the address and clone of the source storage block are established.
  • the mapping relationship of the addresses of the storage blocks are established.
  • the parameters of the source virtual machine 208 and the source hard disk 205 may be first obtained, and the clone virtual machine 209 is created according to the parameters of the source virtual machine 208 and the source hard disk 205. And cloning the hard disk 206, the capacity of the clone hard disk 206 is equal to the capacity of the source hard disk 205.
  • the source hard disk 205 and the clone hard disk 206 are first divided into a plurality of storage blocks according to a preset size, and then the source storage block is established.
  • the mapping relationship between the address and the address of the cloned storage block is established.
  • the source hard disk 205 and the clone hard disk 206 are both divided into a plurality of storage blocks, for example, source storage blocks 2051 and 2052 of the source hard disk 205. And, clone the memory blocks 2061 and 2062 of the hard disk 206.
  • the mapping relationship between the cloned hard disk 206 and the storage space of the source hard disk 205 includes an address of the source storage block and an address of the clone storage block corresponding to the source storage block, and each of the correspondences may be set with an update identifier.
  • the update identifier corresponding to each corresponding relationship may be indicated by a separate list 401, where the list 401 includes an update identifier corresponding to the storage block index number and the index number.
  • the update identifier may also be recorded with the correspondence between the source storage block and the clone storage block without being recorded by the independent list 401.
  • the update identifier includes updated or not updated.
  • the data is not updated with 0, and the data is updated with 1. In other embodiments of the present invention, it may also be indicated by 1 that the data is not updated, and that the data is updated with 0.
  • the role of the update identifier will be described in detail below.
  • mapping relationship between the cloned hard disk and the storage space of the source hard disk, and the corresponding update identifier may be in the form of a mapping table, and may also be in other forms, and details are not described herein again.
  • Step 303 Mirror the running data of the source virtual machine to the cloned virtual machine, so that the cloned virtual machine starts running according to the running data, and the cloned virtual machine is set to receive an IO request, and the execution is interrupted. The service of the source virtual machine.
  • the operational data includes data in memory in the source virtual machine 208, data in CPU registers, IO requests in the IO request stack, and data in the network stack.
  • the data in the memory in the source virtual machine 208 is data required for the source virtual machine to run
  • the data in the CPU register is status bit information of the currently processed process or thread
  • the IO request in the IO request stack Including the IO request being processed by the source virtual machine 208 and the IO request that has been received but not yet processed, the data stored in the network stack is the data to be sent to the external source 208 by the source virtual machine 208 and received from the outside.
  • the cloned virtual machine needs to be set to receive the IO request, so that the subsequently received IO request is sent to the cloned virtual machine for processing.
  • the service of the source virtual machine that is interrupted can be resumed. Since the backup time point that the user instructs to perform the backup starts from the time when the user issues the backup command (that is, the time when the backup command is received), the data required by the user is also all the data received before the backup time point, but due to the processor.
  • the delay of processing the IO request the IO request before the backup time point has not been processed in time, for example, is being executed, or has not been processed in time in the IO request stack, so the start of the business start of the cloned virtual machine is also
  • the service of the source virtual machine that is interrupted needs to be resumed, so that data that has not been written to the source hard disk is written to the source hard disk after the backup time point, thereby ensuring data consistency.
  • Step 304 When it is detected that the clone virtual machine performs a data operation to modify data in the source hard disk, the modified data is recorded into the clone hard disk, and the recorded position is marked.
  • Modifying the data in the source hard disk may be writing new data on the basis of the data stored in the source hard disk at the backup time point, or updating the data stored in the source hard disk at the backup time point. It is also possible to delete data on the basis of the data stored in the source hard disk at the backup time point.
  • the data operation is to write new data, store the new data to be written into the free clone storage block of the clone hard disk, and set the update flag corresponding to the clone storage block in which the data is written to Updated; if the data operation is to update data in the source hard disk, the update data is written into the clone hard disk and the source to be updated according to a mapping relationship between the source storage block and the clone storage block The cloned storage block corresponding to the storage block is set and the update identifier of the source storage block to be updated (or the cloned storage block to which the update data is written) is set to be updated.
  • the data operation is to delete the data in the source hard disk, set the update identifier corresponding to the source storage block where the data to be deleted is located (or the clone storage block corresponding to the source storage block where the data to be deleted is located) It has been updated.
  • the application scenario shown in FIG. 5 is to perform a data operation on the cloned virtual machine to update data in the source hard disk.
  • the source virtual machine includes a source hard disk 205
  • the clone virtual machine includes a clone hard disk 206.
  • the data operation is that the data E in the source storage block 2053 in the source hard disk 205 needs to be updated to F, and the first The update identifier corresponding to the source storage block 2053, that is, the update identifier corresponding to the index number Pe, is first found in the markup list 501, and it is determined whether the update identifier is updated (update identifier is 1), which can be seen from the figure.
  • the update identifier is not updated, that is, not updated (update identifier is 0)
  • the data update data F is written into the clone storage block 2063 of the clone hard disk 206 corresponding to the source storage block 2053, and the mark list is The update identifier corresponding to the index number Pe recorded in 501 is modified to be updated (modified from 0 to 1).
  • the update identifier is updated, only the update data F needs to be written to the clone storage block 2063 without changing the update identifier.
  • the scenario in which the new data is deleted and the data is deleted on the basis of the data stored in the source hard disk at the backup time point is similar to the scenario of the updated data, and is not illustrated here.
  • Step 305 After detecting that the service execution of the source virtual machine is completed, shutting down the source virtual machine and backing up data in the source hard disk.
  • the modified data is also marked by the above method.
  • the cloned virtual machine receives a read IO request
  • the source virtual machine includes a source hard disk 205
  • the clone virtual machine includes a clone hard disk 206.
  • the cloned virtual machine when the cloned virtual machine receives the data read request, it first determines the update flag corresponding to the cloned storage block 2065 corresponding to the read data (that is, the update identifier corresponding to the source storage block 2056). When the update identifier corresponding to the clone storage block 2065 is 0, indicating that the data in the source storage block 2055 corresponding to the clone storage block 2065 has not been updated, the data data B is directly read from the source storage block 2054. .
  • the source virtual machine and the clone virtual machine simultaneously execute the same because the service executed by the source virtual machine is also mirrored to the cloned virtual machine.
  • the source virtual machine may update the data in the source hard disk earlier than the cloned virtual machine, so that the cloned virtual machine needs to read the source hard disk.
  • an error is caused, so in this case, the data in the source hard disk needs to be migrated to the cloned virtual machine first, and an update flag is set for marking.
  • the update identifier corresponding to the source storage block updated by the data update request is set to be updated.
  • the modification flag corresponding to the source storage block 2056 is first determined, when the modification flag corresponding to the source storage block 2056 is 0. Then, the data B stored in the source storage block 2056 is migrated to the clone storage block 2066 corresponding to the source storage block 2056, and then the update data F is written into the source storage block 2056. Conversely, if the corresponding modification flag of the source storage block 2056 is 1, the data B in the source storage block 2056 is directly updated to F, and there is no need to migrate the data B into the clone storage block 2066, the source. The update flag corresponding to the storage block 2056 also does not have to be modified.
  • Step 306 After detecting the end of the data backup, copy the data at the marked location in the cloned hard disk to the location of the source hard disk mapped at the marked location of the cloned hard disk according to the mapping relationship. And setting the source hard disk to be a hard disk of the cloned virtual machine.
  • the cloned hard disk and the mapping table can then be deleted.
  • the clone virtual machine 209 After the data in the cloned hard disk is copied to the source hard disk, the clone virtual machine 209 will replace the source virtual machine 208 to provide external services. At this time, the clone virtual machine 209 uses the source hard disk 205.
  • FIG. 8 is a schematic diagram of copying data in the cloned hard disk to the source hard disk according to an embodiment of the present invention.
  • the source virtual machine includes a source hard disk 205
  • the clone virtual machine includes a clone hard disk 206.
  • the clone storage block with the update identifier 1 is obtained through the identifier list 901, such as the clone storage block 9022 and the clone storage block 9021.
  • the data stored in the clone storage block 9022 is F, and the clone storage block 9021 does not.
  • the data is stored, indicating that the data operation performed on the source memory block 9011 corresponding to the clone memory block 9021 is a delete operation, and thus, when copying, the data in the clone memory block with the update flag of 1 is overwritten with the clone storage.
  • the data of the source storage block corresponding to the block that is, the data in the source storage block 9012 is covered by the data F in the clone storage block 9022, and the data C in the source storage block 9011 is overwritten by the null data in the clone storage block 9021.
  • the data C is deleted directly.
  • the update flag can be set from 1 to 0.
  • the cloned hard disk marked as the updated clone storage block is copied to the source hard disk, the cloned hard disk and the mapping table are deleted, and the cloned virtual machine provides the external service.
  • the data to be written in the data write request is written into the source hard disk, and the The update identifier corresponding to the source storage block to be written data is set to not updated.
  • the cloned virtual machine including the cloned hard disk is created, and the service executed by the virtual machine in the backup process is transferred to the cloned virtual machine for execution, and
  • the data stored in the source virtual machine is recorded in the cloned hard disk, and the modified data is marked.
  • the cloned hard disk may be recorded.
  • the data is updated to update the data in the source virtual machine, so that the consistency of the backup data is ensured, and the service of the virtual machine is not interrupted, thereby improving the operating efficiency of the virtual machine.
  • the embodiment of the present invention further provides a data backup device 10, which includes a creating unit 11, a marking unit 12, a backup unit 13, a reading unit 14, and an updating unit 15.
  • the creating unit 11 is configured to receive a backup command, interrupt the service of the source virtual machine, create a cloned virtual machine, and a cloned hard disk of the cloned virtual machine, and establish a storage space of the cloned hard disk and the source hard disk of the source virtual machine.
  • the operation starts, and the cloned virtual machine is configured to receive an IO request, and resume the execution of the interrupted service of the source virtual machine.
  • the creating unit 11 is configured to divide the source hard disk and the clone hard disk into multiple storage blocks according to a preset size when establishing a mapping relationship between the cloned hard disk and the storage space of the source hard disk; The mapping relationship between the address of the block and the address of the cloned block.
  • the method for establishing a mapping relationship between the cloned hard disk and the storage space of the source hard disk of the source virtual machine and the method for mirroring the running data of the source virtual machine to the cloned virtual machine are described in detail in the method embodiment. , will not repeat them here.
  • the marking unit 12 is configured to: when detecting that the clone virtual machine performs a data operation to modify data in the source hard disk, record the modified data to the cloned hard disk, and record the The location is marked.
  • the marking unit 12 When the marking unit 12 marks the recorded position, the marking unit 12 is specifically configured to set the update flag corresponding to the mapping relationship of the address of the cloned storage block in which the modified data is recorded to be updated.
  • the marking unit 12 is further configured to: when detecting the data operation performed by the source virtual machine, update the data in the source hard disk, determine a mapping of an address of the source storage block updated by the data update request. Whether the update identifier corresponding to the relationship is updated; determining that the update identifier corresponding to the mapping relationship of the address of the source storage block updated by the data update request is not updated, and the data storage request is updated in the source storage block And the updated data is copied to the clone storage block corresponding to the source storage block updated by the data update request; the update data in the data update request is written in the source storage block updated by the data update request; The update identifier corresponding to the source storage block updated by the data update request is set to be updated.
  • the backup unit 13 is configured to shut down the source virtual machine and back up data in the source hard disk after detecting that the service execution of the source virtual machine is completed.
  • the method further includes a reading unit 14 configured to receive a read IO request received to read data in the cloned virtual machine, and determine whether an update identifier corresponding to the cloned storage block read by the read IO request is updated; Reading the data from the source storage block corresponding to the read clone storage block when the update identifier corresponding to the clone storage block read by the IO request is not updated; determining the read by the read IO request When the update identifier corresponding to the cloned storage block is updated, data is read from the read cloned storage block.
  • the updating unit 15 is configured to, after detecting the end of the data backup, copy the data at the marked location in the cloned hard disk to the source mapped at the marked location of the cloned hard disk according to the mapping relationship. Position the hard disk and set the source hard disk to be the hard disk of the cloned virtual machine.
  • the updating unit 15 is specifically configured to determine a clone storage block in a mapping relationship corresponding to the updated update identifier, and store the clone storage block in the mapping relationship corresponding to the updated update identifier.
  • the data is copied to the source storage block in the mapping relationship corresponding to the updated update identifier set; the update identifier set to be updated is set to not updated.
  • the update unit deletes the clone hard disk and the mapping table.
  • the cloned virtual machine including the cloned hard disk is created, and the service executed by the virtual machine in the backup process is transferred to the cloned virtual machine for execution, and
  • the data stored in the source virtual machine is recorded in the cloned hard disk, and the modified data is marked.
  • the cloned hard disk may be recorded.
  • the data is updated to update the data in the source virtual machine, so that the consistency of the backup data is ensured, and the service of the virtual machine is not interrupted, thereby improving the operating efficiency of the virtual machine.
  • the system embodiment since it basically corresponds to the method embodiment, it can be referred to the partial description of the method embodiment.
  • the system embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, ie may be located A place, or it can be distributed to multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the embodiment. Those of ordinary skill in the art can understand and implement without any creative effort.
  • the invention may be described in the general context of computer-executable instructions executed by a computer, such as a program module.
  • program modules include routines, programs, objects, components, data structures, and the like that perform particular tasks or implement particular abstract data types.
  • the invention may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are connected through a communication network.
  • program modules can be located in both local and remote computer storage media including storage devices.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Quality & Reliability (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

A virtual machine backup method and device. The method comprises: receiving a backup command, interrupting a service of a source virtual machine, and creating a clone virtual machine and a clone hard disk for the clone virtual machine (301); establishing a mapping relationship between the clone hard disk and a storage space of a source hard disk of the source virtual machine (302); mirroring operating data of the source virtual machine to the clone virtual machine, so as to enable the clone virtual machine to start operating according to the operating data, configuring the clone virtual machine to receive an IO request, and resuming the interrupted service of the source virtual machine (303); recording, upon detecting that a data operation executed by the clone virtual machine is a modification of data in the source hard disk, the modified data to the clone hard disk, and marking a position of the recording (304); upon detecting that execution of a service of the source virtual machine has been completed, shutting down the source virtual machine and backing up the data in the source hard disk (305); upon detecting that data backup is finished, copying, according to the mapping relationship, data at the marked position in the clone hard disk to a position in the source hard disk mapped to the marked position in the clone hard disk, and configuring the source hard disk as a hard disk for the clone virtual machine (306). The method and device can ensure consistency of backed up data without interrupting the service of a virtual machine.

Description

虚拟机备份方法、备份装置及宿主机Virtual machine backup method, backup device and host machine 技术领域Technical field
本发明涉及计算机领域,特别涉及一种虚拟机备份方法、备份装置及宿主机。The present invention relates to the field of computers, and in particular, to a virtual machine backup method, a backup device, and a host machine.
背景技术Background technique
虚拟机(Virtual Machine,简称VM)是指通过软件模拟的具有完整硬件系统功能的、运行在一个完全隔离环境中的完整系统。虚拟机在运行时,由虚拟机所在的主机,即宿主机为虚拟机虚拟出各种硬件单元,例如虚拟机内存和虚拟机硬盘等。虚拟机内存中的数据由虚拟机自身进行管理,而虚拟机硬盘上的数据则由宿主机存储和管理。A virtual machine (VM) is a complete system that runs through a software and has a complete hardware system function and runs in a completely isolated environment. When the virtual machine is running, the host where the virtual machine is located, that is, the host virtual machine virtualizes various hardware units, such as virtual machine memory and virtual machine hard disk. The data in the virtual machine's memory is managed by the virtual machine itself, while the data on the virtual machine's hard disk is stored and managed by the host.
图1所示为现有技术中虚拟机的结构示意图,如图1所示,虚拟机101使用的所有资源,例如CPU、内存、网络、存储资源均来源于宿主机102,宿主机102将自身资源,例如虚拟多处理器、虚拟机群集文件系统、虚拟网卡和交换机、存储协议栈、网络协议栈及设备驱动程序以共享的方式提供给虚拟机101使用,以使虚拟机101能够对外提供各种业务服务。通常,虚拟机101对外提供各种服务是通过虚拟机内部的应用(aplication,简称APP)103来实现的。1 is a schematic structural diagram of a virtual machine in the prior art. As shown in FIG. 1, all resources used by the virtual machine 101, such as CPU, memory, network, and storage resources, are all derived from the host 102, and the host 102 will itself. Resources, such as virtual multiprocessors, virtual machine cluster file systems, virtual network cards and switches, storage protocol stacks, network protocol stacks, and device drivers are provided to the virtual machine 101 in a shared manner to enable the virtual machine 101 to provide external Business services. Generally, the external service provided by the virtual machine 101 is implemented by an application (aplication, abbreviated as APP) 103 inside the virtual machine.
为保证运行数据不丢失,或保证系统故障后能尽快恢复,虚拟机需要经常性的备份,并且保证备份数据与运行数据相一致。虚拟机的备份数据与运行数据相一致也可以称为虚拟机的一致性。现有技术中,虚拟机的备份方式有两种,一种是冷备份,冷备份是在虚拟机关闭时将数据进行备份;另一种是热备份,热备份是在虚拟机保持工作时对数据进行备份。To ensure that the running data is not lost, or to ensure that the system recovers as soon as possible, the virtual machine needs to be backed up frequently, and the backup data is consistent with the running data. The backup data of the virtual machine is consistent with the running data and can also be called the consistency of the virtual machine. In the prior art, there are two backup methods for a virtual machine. One is cold backup, the cold backup is to back up data when the virtual machine is shut down, and the other is hot backup. The hot backup is when the virtual machine keeps working. The data is backed up.
冷备份可以很好的保证虚拟机的一致性,但是冷备份需要关闭虚拟机,虚拟机被关闭时无法对外提供服务,因此较少采用冷备份。热备份无需关闭虚拟机,但是虚拟机运行时,虚拟机内部应用的数据会首先保存在缓存中,然后写入虚拟机硬盘中,即虚拟机硬盘中的数据是随时被读写和更新的,在备份过程是,数据也是随时更新的。因此,现有技术中热备份的方法无法实时的对虚拟机硬盘中更新数据进行备份,造成虚拟机备份过程中的数据丢失,无法保证虚拟机备份的一致性。Cold backup can guarantee the consistency of the virtual machine. However, the cold backup needs to shut down the virtual machine. When the virtual machine is shut down, it cannot provide external services. Therefore, cold backup is less used. Hot backup does not need to shut down the virtual machine, but when the virtual machine runs, the data of the internal application of the virtual machine is first saved in the cache, and then written into the virtual machine hard disk, that is, the data in the virtual machine hard disk is read, written, and updated at any time. During the backup process, the data is also updated at any time. Therefore, the hot backup method in the prior art cannot back up the updated data in the virtual machine hard disk in real time, resulting in data loss during the virtual machine backup process, and the virtual machine backup cannot be guaranteed.
可见,现有技术中还没有一种备份方法即可以在备份时对外提供虚拟机功能,又能保证虚拟机备份的一致性的方法。 It can be seen that there is no backup method in the prior art, that is, a method for providing virtual machine functions externally during backup and ensuring consistency of virtual machine backup.
发明内容Summary of the invention
有鉴于此,本发明实施例的目的是提供一种虚拟机备份方法及备份装置,在对外提供虚拟机功能的情况下备份数据时,保证备份数据的一致性。In view of this, the purpose of the embodiments of the present invention is to provide a virtual machine backup method and a backup device, which ensure consistency of backup data when backing up data in the case of providing virtual machine functions externally.
为了解决上述技术问题,本发明实施例公开了如下技术方案:In order to solve the above technical problem, the embodiment of the present invention discloses the following technical solutions:
第一方面,提供了一种虚拟机备份方法,应用于与宿主机,所述宿主机上创建有多个虚拟机,在用户需要对所述宿主机上的虚拟机中的数据备份时,下达一虚拟机备份命令,所述宿主机接收到所述备份命令时,即中断待备份源虚拟机的业务,并创建克隆虚拟机及所述克隆虚拟机的克隆硬盘。In a first aspect, a virtual machine backup method is provided, which is applied to a host machine, and a plurality of virtual machines are created on the host machine, and when the user needs to back up data in the virtual machine on the host machine, the method is released. A virtual machine backup command, when the host receives the backup command, interrupts the service of the source virtual machine to be backed up, and creates a cloned virtual machine and a cloned hard disk of the cloned virtual machine.
在克隆硬盘建好后,则建立所述克隆硬盘与所述源虚拟机的源硬盘的存储空间的映射关系,然后将所述源虚拟机的运行数据镜像至所述克隆虚拟机,以使所述克隆虚拟机根据所述运行数据开始运行,并设置所述克隆虚拟机接收IO请求,这样所述克隆虚拟机即可接管源虚拟机的业务。这时即可恢复执行所中断的所述源虚拟机的业务,使在接收到用户的备份命令时还未执行的IO请求继续执行,以保证数据的一致性。After the cloned hard disk is built, the mapping relationship between the cloned hard disk and the storage space of the source virtual disk of the source virtual machine is established, and then the running data of the source virtual machine is mirrored to the cloned virtual machine, so that the The clone virtual machine starts running according to the running data, and sets the clone virtual machine to receive an IO request, so that the cloned virtual machine can take over the service of the source virtual machine. At this time, the service of the source virtual machine that is interrupted can be resumed, and the IO request that has not been executed when the backup command of the user is received is executed to ensure data consistency.
在所述克隆虚拟机运行期间,如果到所述克隆虚拟机执行数据操作为对所述源硬盘中的数据进行修改时,则将修改后的数据记录至所述克隆硬盘中,并对记录的位置进行标记。在侦测到所述源虚拟机的业务执行完成之后,则关闭所述源虚拟机,开始备份所述源硬盘中的数据。During the running of the cloned virtual machine, if a data operation is performed to the cloned virtual machine to modify data in the source hard disk, the modified data is recorded into the cloned hard disk, and the recorded data is recorded. The location is marked. After detecting that the execution of the service of the source virtual machine is completed, the source virtual machine is shut down, and data in the source hard disk is started to be backed up.
在侦测到数据备份结束后,根据所述映射关系将所述克隆硬盘中被标记的位置处的数据复制至所述克隆硬盘被标记的位置处所映射的所述源硬盘的位置,并设置所述源硬盘为所述克隆虚拟机的硬盘。After detecting the end of the data backup, copying the data at the marked location in the cloned hard disk to the location of the source hard disk mapped at the marked location of the cloned hard disk according to the mapping relationship, and setting the location The source hard disk is the hard disk of the cloned virtual machine.
这样,在对虚拟机中的数据进行备份时,通过创建包括克隆硬盘的克隆虚拟机,将虚拟机在备份过程中执行的业务转移至所述克隆虚拟机执行,并将虚拟机备份过程中,将对源虚拟机中存储的数据的修改记录在所述克隆硬盘中,并对修改的数据进行标记,如此,在虚拟机的数据备份完成之后,可用克隆硬盘中记录的修改数据更新所述源虚拟机中的数据,如此,在保证备份数据的一致性的同时,也不会中断虚拟机的业务,从而提高了虚拟机的运行效率。In this way, when the data in the virtual machine is backed up, the service executed by the virtual machine during the backup process is transferred to the cloned virtual machine by creating a cloned virtual machine including the cloned hard disk, and the virtual machine is backed up during the backup process. The modification of the data stored in the source virtual machine is recorded in the cloned hard disk, and the modified data is marked, so that after the data backup of the virtual machine is completed, the source may be updated by the modified data recorded in the cloned hard disk. The data in the virtual machine, in this way, while ensuring the consistency of the backup data, it does not interrupt the business of the virtual machine, thereby improving the operating efficiency of the virtual machine.
可选的,在建立所述克隆硬盘与所述源硬盘的存储空间的映射关系时,可以先将所述源硬盘和克隆硬盘分别按照预设大小分割为多个存储块,然后建立源存储块的地址与克隆存储块的地址的映射关系。 Optionally, when establishing a mapping relationship between the cloned hard disk and the storage space of the source hard disk, the source hard disk and the clone hard disk may be separately divided into multiple storage blocks according to a preset size, and then the source storage block is established. The mapping between the address and the address of the cloned block.
通过这样的划分方式,可以使源硬盘中的每个存储块都对应一个克隆存储块,这样,可以精确的标记被修改的源存储块,及记录在克隆存储块中的修改数据。Through such division, each storage block in the source hard disk can be corresponding to one clone storage block, so that the modified source storage block and the modified data recorded in the clone storage block can be accurately marked.
可选地,可以通过为所述映射表中的每个源存储块的地址与克隆存储块的地址映射关系设置更新标识来标记被修改的源存储块,具体方法为将记录所述修改后的数据的克隆存储块的地址所在的映射关系对应的更新标记设置为已更新。Optionally, the modified source storage block may be marked by setting an update identifier for an address mapping relationship of an address of each source storage block in the mapping table and a clone storage block, wherein the modified method is to record the modified The update flag corresponding to the mapping relationship of the address of the cloned storage block of the data is set to be updated.
更过所述更新标识可以方便的标识出所述源硬盘中被修改的数据。The updated identifier can conveniently identify the modified data in the source hard disk.
对所述源硬盘中的数据进行修改可以是在备份时间点所述源硬盘中存储的数据的基础上写入新的数据,或者是对在备份时间点所述源硬盘中存储的数据的更新,也可以是在备份时间点所述源硬盘中存储的数据的基础上删除数据。Modifying the data in the source hard disk may be writing new data on the basis of the data stored in the source hard disk at the backup time point, or updating the data stored in the source hard disk at the backup time point. It is also possible to delete data on the basis of the data stored in the source hard disk at the backup time point.
可选地,在恢复执行源虚拟机所终端的业务后,在侦测到所述源虚拟机执行的数据操作对所述源硬盘中的数据进行更新时,判断所述数据更新请求所更新的源存储块的地址所在的映射关系对应的更新标识是否为已更新,在确定所述数据更新请求所更新的源存储块的地址所在的映射关系对应的更新标识不是已更新时,将所述数据更新请求所更新的源存储块中被更新数据拷贝至所述数据更新请求所更新的源存储块对应的克隆存储块,在所述数据更新请求所更新的源存储块中写入所述数据更新请求中的更新数据;并将所述数据更新请求所更新的源存储块对应的更新标识设置为已更新。Optionally, after recovering the service of the terminal of the source virtual machine, when it is detected that the data operation performed by the source virtual machine updates the data in the source hard disk, determining that the data update request is updated Whether the update identifier corresponding to the mapping relationship of the address of the source storage block is updated, and the data is determined when the update identifier corresponding to the mapping relationship of the address of the source storage block updated by the data update request is not updated. And updating the updated data in the updated source storage block to the clone storage block corresponding to the source storage block updated by the data update request, and writing the data update in the source storage block updated by the data update request The update data in the request; and the update identifier corresponding to the source storage block updated by the data update request is set to be updated.
由于源虚拟机中执行的业务也被镜像至所述克隆虚拟机,所以在所述克隆虚拟机中也会执行跟源虚拟机相同的业务,所以,在对源虚拟机中的数据进行更新时,也需要将源虚拟机中被更新的数据转移至所述克隆存储块中,以便所述克隆虚拟机后续用到该数据。Since the service executed in the source virtual machine is also mirrored to the cloned virtual machine, the same service as the source virtual machine is also performed in the cloned virtual machine, so when the data in the source virtual machine is updated The updated data in the source virtual machine also needs to be transferred to the cloned storage block, so that the cloned virtual machine subsequently uses the data.
可选的,在所述克隆虚拟机运行期间,对读IO请求进行处理的方法如下:Optionally, during the running of the cloned virtual machine, the method for processing the read IO request is as follows:
接收读IO请求;Receiving a read IO request;
判断所述读IO请求所读取的克隆存储块对应的更新标识是否为已更新;Determining whether the update identifier corresponding to the clone storage block read by the read IO request is updated;
确定所述读IO请求所读取的克隆存储块对应的更新标识为未更新时,从所述所读取的克隆存储块对应的源存储块中读取数据;Determining, when the update identifier corresponding to the clone storage block read by the read IO request is not updated, reading data from the source storage block corresponding to the read clone storage block;
确定所述读IO请求所读取的克隆存储块对应的更新标识为已更新时,从所述所读取的克隆存储块中读取数据。When it is determined that the update identifier corresponding to the clone storage block read by the read IO request is updated, data is read from the read clone storage block.
可选的,在根据所述映射关系将克隆硬盘中被标记的位置处的数据复制至克隆硬盘被标记的位置处所映射的源硬盘的位置时,首先确定被设置为已更新的更新标识对 应的映射关系中的克隆存储块;将所述被设置为已更新的更新标识对应的映射关系中的克隆存储块所存储的数据复制至所述被设置为已更新的更新标识对应的映射关系中的源存储块;然后将所述被设置为已更新的更新标识设置为未更新。Optionally, when copying the data at the marked location in the cloned hard disk to the location of the source hard disk mapped at the marked location of the cloned hard disk according to the mapping relationship, first determining the updated update identifier pair that is set to be updated. a clone storage block in the mapping relationship; copying data stored in the clone storage block in the mapping relationship corresponding to the updated update identifier to the mapping relationship corresponding to the updated update identifier set to be updated The source storage block in ; then set the update identifier set to updated to not updated.
这样,在数据复制完成后,也对修改标记进行设置,可以使在此期间接收到读IO请求时,可以根据所述修改标记判断出所读取数据的位置。In this way, after the data copy is completed, the modification flag is also set, so that when the read IO request is received during this period, the position of the read data can be determined according to the modification flag.
可选地,在侦测到数据备份结束后,接收到数据写入请求时,将所述数据写入请求中的待写入数据写入所述源硬盘中,并将写入所述待写入数据的源存储块对应的更新标识设置为未更新。Optionally, after the data backup request is detected, when the data write request is received, the data to be written in the data write request is written into the source hard disk, and the write to be written is written. The update identifier corresponding to the source storage block of the incoming data is set to not updated.
可选地,在所述克隆硬盘中的数据全部复制至所述源硬盘后,可以删除所述克隆硬盘和所述映射表。Optionally, after the data in the cloned hard disk is all copied to the source hard disk, the cloned hard disk and the mapping table may be deleted.
第二方面,提供了一种虚拟机备份装置,所述备份装置包括创建单元、标记单元、备份单元、读取单元、及更新单元,所述创建单元、标记单元、备份单元、读取单元、及更新单元执行的功能与第一方面的提供的方法相对应,在此不再赘述。In a second aspect, a virtual machine backup device is provided, where the backup device includes a creation unit, a marking unit, a backup unit, a reading unit, and an update unit, the creation unit, the marking unit, the backup unit, the reading unit, And the functions performed by the update unit correspond to the methods provided in the first aspect, and are not described herein again.
第三方面,提供一种宿主机,所述宿主机包括:处理器、内存、硬盘、通讯接口、系统总线,所述处理器、内存、硬盘和通信接口之间通过系统总线连接并完成相互间的通信,所述内存中用于存储计算机执行指令,所述宿主机运行时,所述处理器执行所述内存中的计算机执行指令以利用所述宿主机中的硬件资源建立虚拟机,并执行第一方面所提供的方法。通过本发明所提供的实施例,在对虚拟机中的数据进行备份时,通过创建包括克隆硬盘的克隆虚拟机,将虚拟机在备份过程中执行的业务转移至所述克隆虚拟机执行,并将虚拟机备份过程中,将对源虚拟机中存储的数据的修改记录在所述克隆硬盘中,并对修改的数据进行标记,如此,在虚拟机的数据备份完成之后,可用克隆硬盘中记录的修改数据更新所述源虚拟机中的数据,如此,在保证备份数据的一致性的同时,也不会中断虚拟机的业务,从而提高了虚拟机的运行效率。In a third aspect, a host is provided. The host includes: a processor, a memory, a hard disk, a communication interface, and a system bus. The processor, the memory, the hard disk, and the communication interface are connected through a system bus and complete each other. Communication in the memory for storing computer execution instructions, when the host is running, the processor executes the computer execution instructions in the memory to establish a virtual machine with hardware resources in the host machine, and executes The method provided by the first aspect. With the embodiment of the present invention, when the data in the virtual machine is backed up, the service executed by the virtual machine during the backup process is transferred to the cloned virtual machine by creating a cloned virtual machine including the cloned hard disk, and During the virtual machine backup process, the modification of the data stored in the source virtual machine is recorded in the cloned hard disk, and the modified data is marked, so that after the virtual machine data backup is completed, the cloned hard disk can be recorded. The modified data updates the data in the source virtual machine, so that the consistency of the backup data is ensured, and the service of the virtual machine is not interrupted, thereby improving the operating efficiency of the virtual machine.
附图说明DRAWINGS
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。 In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the embodiments or the description of the prior art will be briefly described below. Obviously, the drawings in the following description are only It is a certain embodiment of the present invention, and other drawings can be obtained from those skilled in the art without any creative work.
图1所示为现有技术中虚拟机的结构示意图;1 is a schematic structural diagram of a virtual machine in the prior art;
图2所示为本发明实施例的宿主机的结构图;2 is a structural diagram of a host machine according to an embodiment of the present invention;
图3所示为本发明实施例的虚拟机备份方法的流程图;FIG. 3 is a flowchart of a virtual machine backup method according to an embodiment of the present invention;
图4所示为本发明实施例的建立源硬盘与克隆硬盘的存储空间的映射关系的示意图;FIG. 4 is a schematic diagram showing a mapping relationship between a source hard disk and a storage space of a cloned hard disk according to an embodiment of the present invention;
图5所示为本发明实施例在克隆虚拟机运行期间,对源硬盘中的数据进行更新的示意图;FIG. 5 is a schematic diagram of updating data in a source hard disk during a running of a cloned virtual machine according to an embodiment of the present invention; FIG.
图6所示为本发明实施例的克隆虚拟机读数据的示意图;6 is a schematic diagram of data read by a cloned virtual machine according to an embodiment of the present invention;
图7所示为本发明实施例在源虚拟机运行期间,对源硬盘中的数据进行更新的示意图;FIG. 7 is a schematic diagram of updating data in a source hard disk during operation of a source virtual machine according to an embodiment of the present invention; FIG.
图8所示为本发明实施例将所述克隆硬盘中的数据复制至所述源硬盘的示意图;及FIG. 8 is a schematic diagram of copying data in the cloned hard disk to the source hard disk according to an embodiment of the present invention; and
图9所示为本发明实施例提供的一种数据备份装置的模块图。FIG. 9 is a block diagram of a data backup device according to an embodiment of the present invention.
通过上述附图,已示出本发明明确的实施例,后文中将有更详细的描述。这些附图和文字描述并不是为了通过任何方式限制本发明构思的范围,而是通过参考特定实施例为本领域技术人员说明本发明的概念。The embodiments of the present invention have been shown in the foregoing drawings and are described in detail herein. The drawings and the written description are not intended to limit the scope of the present invention in any way,
具体实施方式detailed description
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the embodiments of the present invention are clearly and completely described in the following with reference to the accompanying drawings in the embodiments of the present invention. It is obvious that the described embodiments are only a part of the embodiments of the present invention, but not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative efforts are within the scope of the present invention.
为了全面理解本发明,在以下详细描述中提到了众多具体的细节,但是本领域技术人员应该理解,本发明可以无需这些具体细节而实现。在其他实施例中,不详细描述公知的方法、过程、组件和电路,以免不必要地导致实施例模糊。Numerous specific details are set forth in the Detailed Description of the invention in the following detailed description. In other instances, well-known methods, procedures, components, and circuits are not described in detail to avoid unnecessarily obscuring the embodiments.
本发明实施例对源虚拟机的源硬盘中的数据进行备份时,可创建一个克隆虚拟机及克隆硬盘,并将源虚拟机中的运行数据转移至克隆虚拟机并对后续访问源虚拟机的IO请求进行重定向,是所述克隆虚拟机接管所述源虚拟机的业务,并在数据备份完成后,用克隆硬盘中与源硬盘中不一致的数据覆盖源硬盘中的数据,并将所述源硬盘作为所述克隆虚拟机 的硬盘,这样,在备份所述源虚拟机中的数据时,在不中断虚拟机所执行业务的情况下,保证备份数据的一致性。When the data in the source hard disk of the source virtual machine is backed up, a clone virtual machine and a clone hard disk may be created, and the running data in the source virtual machine is transferred to the clone virtual machine and the subsequent access source virtual machine is accessed. The IO request is redirected, and the cloned virtual machine takes over the service of the source virtual machine, and after the data backup is completed, overwrites data in the source hard disk with data inconsistent with the source hard disk in the cloned hard disk, and the data is Source hard disk as the clone virtual machine The hard disk is such that when the data in the source virtual machine is backed up, the consistency of the backup data is ensured without interrupting the service performed by the virtual machine.
下面将结合实施例对本发明实施例所提供的技术方案做详细说明。The technical solutions provided by the embodiments of the present invention will be described in detail below with reference to the embodiments.
如图2所示,为本发明实施例的宿主机20的结构图。所述宿主机20可包括处理器201、内存202、硬盘204、通讯接口207、系统总线200。处理器201、内存202、硬盘204和通信接口207之间通过系统总线200连接并完成相互间的通信。As shown in FIG. 2, it is a structural diagram of a host machine 20 according to an embodiment of the present invention. The host machine 20 can include a processor 201, a memory 202, a hard disk 204, a communication interface 207, and a system bus 200. The processor 201, the memory 202, the hard disk 204, and the communication interface 207 are connected by the system bus 200 and complete communication with each other.
处理器201可能为单核或多核中央处理单元,或者为特定集成电路,或者为被配置成实施本发明实施例的一个或多个集成电路。 Processor 201 may be a single core or multi-core central processing unit, or a particular integrated circuit, or one or more integrated circuits configured to implement embodiments of the present invention.
内存202可以为高速RAM存储器,也可以为非易失性存储器(non-volatile memory),例如至少一个磁盘存储器,内存202用于存储计算机执行指令。具体的,计算机执行指令中可以包括程序代码。The memory 202 can be a high speed RAM memory or a non-volatile memory, such as at least one disk memory, and the memory 202 is used to store computer execution instructions. Specifically, the program code may be included in the computer execution instruction.
在所述宿主机20运行时,所述处理器201执行所述内存中的计算机执行指令203以利用所述宿主机中的硬件资源建立多个虚拟机,如源虚拟机208及克隆虚拟机209,在所述硬盘204中为所述源虚拟机208及克隆虚拟机209分别建立源硬盘205及克隆硬盘206。所述克隆虚拟机209及克隆硬盘206是在将所述源虚拟机208的源硬盘205中的数据备份至所述备份存储器30时创建的,下面将结合图3所示的虚拟机备份方法的流程图说明所述源虚拟机中的备份过程。When the host machine 20 is running, the processor 201 executes the in-memory computer execution instructions 203 to establish a plurality of virtual machines, such as the source virtual machine 208 and the clone virtual machine 209, using hardware resources in the host machine. A source hard disk 205 and a clone hard disk 206 are respectively created in the hard disk 204 for the source virtual machine 208 and the clone virtual machine 209. The clone virtual machine 209 and the clone hard disk 206 are created when the data in the source hard disk 205 of the source virtual machine 208 is backed up to the backup memory 30. The following will be combined with the virtual machine backup method shown in FIG. The flowchart illustrates the backup process in the source virtual machine.
如图3所示,本发明实施例的虚拟机备份方法包括:As shown in FIG. 3, the virtual machine backup method of the embodiment of the present invention includes:
步骤301,接收备份命令,中断源虚拟机的业务,创建克隆虚拟机及所述克隆虚拟机的克隆硬盘。Step 301: Receive a backup command, interrupt the service of the source virtual machine, and create a cloned virtual machine and a cloned hard disk of the cloned virtual machine.
本发明实施例中,源虚拟机208的业务为所述虚拟机正在执行的I/O请求,中断源虚拟机208的业务即将所述源虚拟机208正在执行的IO请求挂起。In the embodiment of the present invention, the service of the source virtual machine 208 is an I/O request being executed by the virtual machine, and the service of the interrupt source virtual machine 208 suspends the IO request being executed by the source virtual machine 208.
在实际应用时,在接收到备份命令后,可以先中断源虚拟机的业务,再创建克隆虚拟机及克隆虚拟机的克隆硬盘,也可以先创建克隆虚拟机及克隆虚拟机的克隆硬盘再中断源虚拟机的业务,具体可以根据实际情况设定两者的顺序。In actual application, after receiving the backup command, you can interrupt the service of the source virtual machine, create a cloned virtual machine and clone the virtual machine's cloned hard disk, or create a cloned virtual machine and clone the virtual machine's cloned hard disk before interrupting. The service of the source VM can be set according to the actual situation.
步骤302,建立所述克隆硬盘与所述源虚拟机的源硬盘的存储空间的映射关系。Step 302: Establish a mapping relationship between the cloned hard disk and a storage space of the source hard disk of the source virtual machine.
在建立所述克隆硬盘与所述源硬盘的存储空间的映射关系时,先将所述源硬盘和克隆硬盘分别按照预设大小分割为多个存储块,然后再建立源存储块的地址与克隆存储块的地址的映射关系。 When the mapping relationship between the cloned hard disk and the storage space of the source hard disk is established, the source hard disk and the clone hard disk are respectively divided into multiple storage blocks according to a preset size, and then the address and clone of the source storage block are established. The mapping relationship of the addresses of the storage blocks.
在创建所述克隆虚拟机209及克隆硬盘206时,可首先获取所述源虚拟机208及源硬盘205的参数,根据所述源虚拟机208及源硬盘205的参数创建所述克隆虚拟机209及克隆硬盘206,所述克隆硬盘206的容量与所述源硬盘205的容量相等。When the clone virtual machine 209 and the clone hard disk 206 are created, the parameters of the source virtual machine 208 and the source hard disk 205 may be first obtained, and the clone virtual machine 209 is created according to the parameters of the source virtual machine 208 and the source hard disk 205. And cloning the hard disk 206, the capacity of the clone hard disk 206 is equal to the capacity of the source hard disk 205.
在建立所述克隆硬盘206与所述源硬盘205的存储空间的映射关系时,首先将所述源硬盘205和克隆硬盘206分别按照预设大小分割为多个存储块,然后建立源存储块的地址与克隆存储块的地址的映射关系。When the mapping relationship between the cloned hard disk 206 and the storage space of the source hard disk 205 is established, the source hard disk 205 and the clone hard disk 206 are first divided into a plurality of storage blocks according to a preset size, and then the source storage block is established. The mapping relationship between the address and the address of the cloned storage block.
图4所示为所述克隆硬盘与所述源硬盘的存储空间的映射关系的示意图,源硬盘205和克隆硬盘206都被分割为多个存储块,例如源硬盘205的源存储块2051和2052等,以及克隆硬盘206的克隆存储块2061和2062。4 is a schematic diagram showing a mapping relationship between the cloned hard disk and the storage space of the source hard disk. The source hard disk 205 and the clone hard disk 206 are both divided into a plurality of storage blocks, for example, source storage blocks 2051 and 2052 of the source hard disk 205. And, clone the memory blocks 2061 and 2062 of the hard disk 206.
所述克隆硬盘206与所述源硬盘205的存储空间的映射关系包括源存储块的地址与源存储块对应的克隆存储块的地址,每个对应关系可设置一个更新标识。如图4所示,每个对应关系对应的更新标识可以通过独立的列表401所示,所述列表401包括存储块索引号和索引号对应的更新标识。存储块索引号Pa~Pe指向各自对应的对应关系。在其他实施方式中,所述更新标识也可与所述源存储块与克隆存储块的对应关系记录在一起,而不需要通过所述独立的列表401来记录。更新标识包括已更新或未更新,图4所示的实施例中,以0表示数据未更新,以1标识数据已更新。在本发明其他实施例中,也可以用1表示数据未更新,用0标识数据已更新。所述更新标识的作用将在下文做详细介绍。The mapping relationship between the cloned hard disk 206 and the storage space of the source hard disk 205 includes an address of the source storage block and an address of the clone storage block corresponding to the source storage block, and each of the correspondences may be set with an update identifier. As shown in FIG. 4, the update identifier corresponding to each corresponding relationship may be indicated by a separate list 401, where the list 401 includes an update identifier corresponding to the storage block index number and the index number. The storage block index numbers Pa to Pe point to respective corresponding correspondences. In other embodiments, the update identifier may also be recorded with the correspondence between the source storage block and the clone storage block without being recorded by the independent list 401. The update identifier includes updated or not updated. In the embodiment shown in FIG. 4, the data is not updated with 0, and the data is updated with 1. In other embodiments of the present invention, it may also be indicated by 1 that the data is not updated, and that the data is updated with 0. The role of the update identifier will be described in detail below.
克隆硬盘与所述源硬盘的存储空间的映射关系,以及对应的更新标识可以采用映射表的形式,也可以采用其他形式,在此不再赘述。The mapping relationship between the cloned hard disk and the storage space of the source hard disk, and the corresponding update identifier may be in the form of a mapping table, and may also be in other forms, and details are not described herein again.
步骤303,将所述源虚拟机的运行数据镜像至所述克隆虚拟机,以使所述克隆虚拟机根据所述运行数据开始运行,设置所述克隆虚拟机接收IO请求,恢复执行所中断的所述源虚拟机的业务。Step 303: Mirror the running data of the source virtual machine to the cloned virtual machine, so that the cloned virtual machine starts running according to the running data, and the cloned virtual machine is set to receive an IO request, and the execution is interrupted. The service of the source virtual machine.
所述运行数据包括所述源虚拟机208中的内存中的数据、CPU寄存器中的数据、IO请求堆栈中的IO请求、网络堆栈中的数据。所述源虚拟机208中的内存中的数据为源虚拟机运行所需要的数据,所述CPU寄存器中的数据为当前处理的进程或者线程的状态位信息,所述IO请求堆栈中的IO请求包括所述源虚拟机208正在处理的IO请求及已经接收但还未被处理的IO请求,所述网络堆栈中所存储的数据为所述源虚拟机208要发送给外部的数据及从外部接收的数据。将所述运行数据镜像至所述克隆虚拟机209 后,还需要设置所述克隆虚拟机接收IO请求,这样后续接收到的IO请求就会发送至所述克隆虚拟机处理。在所述克隆虚拟机开始执行业务开始,即可恢复执行所中断的所述源虚拟机的业务。由于用户指示进行备份的备份时间点为用户下达备份命令(即接收到备份命令的时刻)开始算起,所以用户需要的数据也为所述备份时间点之前接收到的所有数据,但是由于处理器处理IO请求的延时,备份时间点之前的IO请求还没有被及时处理,例如被正在执行,或在IO请求堆栈中还未被及时处理,所以在所述克隆虚拟机开始执行业务开始,也需要恢复执行所中断的所述源虚拟机的业务,以使备份时间点后,还未被写入所述源硬盘的数据写入所述源硬盘,从而保证数据的一致性。The operational data includes data in memory in the source virtual machine 208, data in CPU registers, IO requests in the IO request stack, and data in the network stack. The data in the memory in the source virtual machine 208 is data required for the source virtual machine to run, the data in the CPU register is status bit information of the currently processed process or thread, and the IO request in the IO request stack Including the IO request being processed by the source virtual machine 208 and the IO request that has been received but not yet processed, the data stored in the network stack is the data to be sent to the external source 208 by the source virtual machine 208 and received from the outside. The data. Mirroring the operational data to the clone virtual machine 209 After that, the cloned virtual machine needs to be set to receive the IO request, so that the subsequently received IO request is sent to the cloned virtual machine for processing. When the cloned virtual machine starts to perform the service start, the service of the source virtual machine that is interrupted can be resumed. Since the backup time point that the user instructs to perform the backup starts from the time when the user issues the backup command (that is, the time when the backup command is received), the data required by the user is also all the data received before the backup time point, but due to the processor. The delay of processing the IO request, the IO request before the backup time point has not been processed in time, for example, is being executed, or has not been processed in time in the IO request stack, so the start of the business start of the cloned virtual machine is also The service of the source virtual machine that is interrupted needs to be resumed, so that data that has not been written to the source hard disk is written to the source hard disk after the backup time point, thereby ensuring data consistency.
步骤304,在侦测到所述克隆虚拟机执行数据操作为对所述源硬盘中的数据进行修改时,则将修改后的数据记录至所述克隆硬盘中,并对记录的位置进行标记,这里即可采用上述的更新标识对源硬盘或者克隆硬盘数据更新的位置进行标记。Step 304: When it is detected that the clone virtual machine performs a data operation to modify data in the source hard disk, the modified data is recorded into the clone hard disk, and the recorded position is marked. Here you can use the update flag above to mark the location of the source hard drive or clone hard drive data update.
对所述源硬盘中的数据进行修改可以是在备份时间点所述源硬盘中存储的数据的基础上写入新的数据,或者是对在备份时间点所述源硬盘中存储的数据的更新,也可以是在备份时间点所述源硬盘中存储的数据的基础上删除数据。Modifying the data in the source hard disk may be writing new data on the basis of the data stored in the source hard disk at the backup time point, or updating the data stored in the source hard disk at the backup time point. It is also possible to delete data on the basis of the data stored in the source hard disk at the backup time point.
如果所述数据操作为写入新数据,则将待写入的新数据存储至所述克隆硬盘的空闲的克隆存储块中,并将写入所述数据的克隆存储块对应的更新标记设置为已更新;如果所述数据操作为对源硬盘中的数据进行更新,则根据源存储块与克隆存储块的映射关系,将所述更新数据写入所述克隆硬盘中与所述待更新的源存储块对应的克隆存储块中,并将待更新的源存储块(或者写入更新数据的克隆存储块)的更新标识设置为已更新。如果所述数据操作为对源硬盘中的数据进行删除,则将所述待删除数据所在的源存储块(或者所述待删除数据所在的源存储块对应的克隆存储块)对应的更新标识设置为已更新。If the data operation is to write new data, store the new data to be written into the free clone storage block of the clone hard disk, and set the update flag corresponding to the clone storage block in which the data is written to Updated; if the data operation is to update data in the source hard disk, the update data is written into the clone hard disk and the source to be updated according to a mapping relationship between the source storage block and the clone storage block The cloned storage block corresponding to the storage block is set and the update identifier of the source storage block to be updated (or the cloned storage block to which the update data is written) is set to be updated. If the data operation is to delete the data in the source hard disk, set the update identifier corresponding to the source storage block where the data to be deleted is located (or the clone storage block corresponding to the source storage block where the data to be deleted is located) It has been updated.
下面通过具体应用场景说明修改所述源硬盘中备份时间点存储的数据时进行标记的过程。The process of marking when the data stored in the backup time point in the source hard disk is modified is described below through a specific application scenario.
图5所示的应用场景为在侦测到所述克隆虚拟机执行数据操作为对所述源硬盘中的数据进行更新。如图5所示,源虚拟机包括源硬盘205,克隆虚拟机包括克隆硬盘206。The application scenario shown in FIG. 5 is to perform a data operation on the cloned virtual machine to update data in the source hard disk. As shown in FIG. 5, the source virtual machine includes a source hard disk 205, and the clone virtual machine includes a clone hard disk 206.
所述数据操作为需要将源硬盘205中的源存储块2053中的数据E更新为F,则首 先在所述标记列表501中找到所述源存储块2053对应的更新标识,即索引号Pe对应的更新标识,确定所述更新标识是否为已更新(更新标识为1),从图中可以看出,所述更新标识不是已更新,即未更新(更新标识为0),则将数据更新数据F写入所述源存储块2053对应的克隆硬盘206的克隆存储块2063中,并将标记列表501中记录的索引号Pe对应的更新标识修改为已更新(由0修改为1)。另外一种情况下,即所述更新标识为已更新时,则只需要将所述更新数据F写入所述克隆存储块2063即可,而无需更改更新标识。The data operation is that the data E in the source storage block 2053 in the source hard disk 205 needs to be updated to F, and the first The update identifier corresponding to the source storage block 2053, that is, the update identifier corresponding to the index number Pe, is first found in the markup list 501, and it is determined whether the update identifier is updated (update identifier is 1), which can be seen from the figure. If the update identifier is not updated, that is, not updated (update identifier is 0), the data update data F is written into the clone storage block 2063 of the clone hard disk 206 corresponding to the source storage block 2053, and the mark list is The update identifier corresponding to the index number Pe recorded in 501 is modified to be updated (modified from 0 to 1). In another case, when the update identifier is updated, only the update data F needs to be written to the clone storage block 2063 without changing the update identifier.
在备份时间点在所述源硬盘中所存储的数据的基础上写入新数据的场景和删除数据的场景与上述更新数据的场景类似,在此不再举例说明。The scenario in which the new data is deleted and the data is deleted on the basis of the data stored in the source hard disk at the backup time point is similar to the scenario of the updated data, and is not illustrated here.
步骤305,在侦测到所述源虚拟机的业务执行完成之后,关闭所述源虚拟机,备份所述源硬盘中的数据。Step 305: After detecting that the service execution of the source virtual machine is completed, shutting down the source virtual machine and backing up data in the source hard disk.
在数据备份的过程中,如果所述克隆虚拟机接收到数据操作请求时,也通过上述方法对修改的数据进行标记。In the process of data backup, if the cloned virtual machine receives a data operation request, the modified data is also marked by the above method.
在克隆虚拟机运行期间,如果接收到读IO请求,则通过下面的方法执行:If a read IO request is received while the clone virtual machine is running, it is executed by the following method:
首先,所述克隆虚拟机接收读IO请求;First, the cloned virtual machine receives a read IO request;
然后,判断所述读IO请求所读取的克隆存储块对应的更新标识是否为已更新;Then, determining whether the update identifier corresponding to the clone storage block read by the read IO request is updated;
当确定所述读IO请求所读取的克隆存储块对应的更新标识为未更新时,从所述所读取的克隆存储块对应的源存储块中读取数据;When it is determined that the update identifier corresponding to the clone storage block read by the read IO request is not updated, reading data from the source storage block corresponding to the read clone storage block;
确定所述读IO请求所读取的克隆存储块对应的更新标识为已更新时,从所读取的克隆存储块中读取数据。When it is determined that the update identifier corresponding to the clone storage block read by the read IO request is updated, data is read from the read clone storage block.
下面结合图6说明克隆虚拟机运行期间进行数据读取的方法。The method of data reading during the operation of the cloned virtual machine will be described below with reference to FIG.
在图6所示的应用场景中,源虚拟机包括源硬盘205,克隆虚拟机包括克隆硬盘206。In the application scenario shown in FIG. 6, the source virtual machine includes a source hard disk 205, and the clone virtual machine includes a clone hard disk 206.
如图6所示,当所述克隆虚拟机接收到数据读取请求时,首先确定所读取数据对应的克隆存储块2065对应的更新标记(也即源存储块2056对应的更新标识),当克隆存储块2065对应的更新标识为0时,表示所述克隆存储块2065对应的所述源存储块2055中的数据还未被更新,则直接从所述源存储块2054中读取数据数据B。当另外一个数据读取请求所读取数据对应的克隆存储块2064对应的更新标识为1时,则表示所述克隆存储块2064对应的源存储块2054中的数据已经被修改,则从所述克隆存储块 2064中读取数据F。As shown in FIG. 6, when the cloned virtual machine receives the data read request, it first determines the update flag corresponding to the cloned storage block 2065 corresponding to the read data (that is, the update identifier corresponding to the source storage block 2056). When the update identifier corresponding to the clone storage block 2065 is 0, indicating that the data in the source storage block 2055 corresponding to the clone storage block 2065 has not been updated, the data data B is directly read from the source storage block 2054. . When the update identifier corresponding to the clone storage block 2064 corresponding to the data read by the other data read request is 1, it indicates that the data in the source storage block 2054 corresponding to the clone storage block 2064 has been modified, then Clone memory block The data F is read in 2064.
在恢复执行所中断的所述源虚拟机的业务后,由于所述源虚拟机所执行的业务也被镜像至所述克隆虚拟机,所以所述源虚拟机及所述克隆虚拟机会同时执行相同的业务,但是由于克隆虚拟机与源虚拟机并不同步,源虚拟机对源硬盘中的数据可能会早于克隆虚拟机对数据的更新,这样,在克隆虚拟机需要读取源硬盘中的数据时,则由于源硬盘的数据已经被更新,则会导致错误,所以在这种情况下,需要将所述源硬盘中的数据先迁移至所述克隆虚拟机,并设置更新标记进行标记,具体方法为:After the execution of the interrupted operation of the source virtual machine, the source virtual machine and the clone virtual machine simultaneously execute the same because the service executed by the source virtual machine is also mirrored to the cloned virtual machine. Business, but because the cloned virtual machine is not synchronized with the source virtual machine, the source virtual machine may update the data in the source hard disk earlier than the cloned virtual machine, so that the cloned virtual machine needs to read the source hard disk. In the case of data, since the data of the source hard disk has been updated, an error is caused, so in this case, the data in the source hard disk needs to be migrated to the cloned virtual machine first, and an update flag is set for marking. The specific method is:
在侦测到所述源虚拟机执行的数据操作为对所述源硬盘中的数据进行更新时,判断所述数据更新请求所更新的源存储块的地址所在的映射关系对应的更新标识是否为已更新;When it is detected that the data operation performed by the source virtual machine is to update the data in the source hard disk, determining whether the update identifier corresponding to the mapping relationship of the address of the source storage block updated by the data update request is updated;
确定所述数据更新请求所更新的源存储块的地址所在的映射关系对应的更新标识不是已更新时,将所述数据更新请求所更新的源存储块中被更新数据拷贝至所述数据更新请求所更新的源存储块对应的克隆存储块;Determining, when the update identifier corresponding to the mapping relationship of the address of the source storage block updated by the data update request is not updated, copying the updated data in the source storage block updated by the data update request to the data update request a cloned storage block corresponding to the updated source storage block;
在所述数据更新请求所更新的源存储块中写入所述数据更新请求中的更新数据;Writing update data in the data update request in a source storage block updated by the data update request;
将所述数据更新请求所更新的源存储块对应的更新标识设置为已更新。The update identifier corresponding to the source storage block updated by the data update request is set to be updated.
如图7所示,当源存储块2056中的数据B要被更新为F时,则先确定所述源存储块2056对应的修改标记,当所述源存储块2056对应的修改标记为0时,则将所述源存储块2056中存储的数据B迁移至所述源存储块2056对应的克隆存储块2066中,然后将所述更新数据F写入所述源存储块2056中。相反地,如果所述源存储块2056对应的修改标记为1时,则直接将源存储块2056中的数据B更新为F,无需将数据B迁移至所述克隆存储块2066中,所述源存储块2056对应的更新标记也不必修改。步骤306,在侦测到数据备份结束后,根据所述映射关系将所述克隆硬盘中被标记的位置处的数据复制至所述克隆硬盘被标记的位置处所映射的所述源硬盘的位置,并设置所述源硬盘为所述克隆虚拟机的硬盘。As shown in FIG. 7, when the data B in the source storage block 2056 is to be updated to F, the modification flag corresponding to the source storage block 2056 is first determined, when the modification flag corresponding to the source storage block 2056 is 0. Then, the data B stored in the source storage block 2056 is migrated to the clone storage block 2066 corresponding to the source storage block 2056, and then the update data F is written into the source storage block 2056. Conversely, if the corresponding modification flag of the source storage block 2056 is 1, the data B in the source storage block 2056 is directly updated to F, and there is no need to migrate the data B into the clone storage block 2066, the source. The update flag corresponding to the storage block 2056 also does not have to be modified. Step 306: After detecting the end of the data backup, copy the data at the marked location in the cloned hard disk to the location of the source hard disk mapped at the marked location of the cloned hard disk according to the mapping relationship. And setting the source hard disk to be a hard disk of the cloned virtual machine.
在根据映射关系将克隆硬盘中被标记的位置处的数据复制至克隆硬盘被标记的位置处所映射的源硬盘的位置时,首选确定被设置为已更新的更新标识对应的映射关系中的克隆存储块;将所述被设置为已更新的更新标识对应的映射关系中的克隆存储块所存储的数据复制至所述被设置为已更新的更新标识对应的映射关系中的源存储块;将所述被设置为已更新的更新标识设置为未更新。 When copying the data at the marked location in the cloned hard disk to the location of the source hard disk mapped at the location where the cloned hard disk is marked according to the mapping relationship, it is preferred to determine the clone storage in the mapping relationship corresponding to the updated update identifier. And copying, by the block, the data stored in the clone storage block in the mapping relationship corresponding to the updated update identifier to the source storage block in the mapping relationship corresponding to the update identifier set to be updated; The update ID set to be updated is set to not updated.
然后可以删除所述克隆硬盘和所述映射表。The cloned hard disk and the mapping table can then be deleted.
在将克隆硬盘中的数据拷贝至所述源硬盘后后,克隆虚拟机209将取代源虚拟机208,对外提供业务,此时克隆虚拟机209使用的是源硬盘205。After the data in the cloned hard disk is copied to the source hard disk, the clone virtual machine 209 will replace the source virtual machine 208 to provide external services. At this time, the clone virtual machine 209 uses the source hard disk 205.
图8所示为本发明实施例将所述克隆硬盘中的数据复制至所述源硬盘的示意图。FIG. 8 is a schematic diagram of copying data in the cloned hard disk to the source hard disk according to an embodiment of the present invention.
如图8所示,源虚拟机包括源硬盘205,克隆虚拟机包括克隆硬盘206。在复制数据时,先通过标识列表901获取更新标识为1的克隆存储块,比如克隆存储块9022及克隆存储块9021,克隆存储块9022中存储的数据为F,克隆存储块9021中,并没有存储数据,表示之前对克隆存储块9021对应的源存储块9011的进行的数据操作为删除操作,如此,在复制时,用更新标记为1的所述克隆存储块中的数据覆盖所述克隆存储块对应的源存储块的数据,即用克隆存储块9022中的数据F覆盖源存储块9012中的数据,用克隆存储块9021中的空数据覆盖源存储块9011中的数据C,也可以为直接删除所述数据C。再将克隆存储块中的数据复制至所述源存储块后,即可将更新标记由1设置为0。As shown in FIG. 8, the source virtual machine includes a source hard disk 205, and the clone virtual machine includes a clone hard disk 206. When the data is copied, the clone storage block with the update identifier 1 is obtained through the identifier list 901, such as the clone storage block 9022 and the clone storage block 9021. The data stored in the clone storage block 9022 is F, and the clone storage block 9021 does not. The data is stored, indicating that the data operation performed on the source memory block 9011 corresponding to the clone memory block 9021 is a delete operation, and thus, when copying, the data in the clone memory block with the update flag of 1 is overwritten with the clone storage. The data of the source storage block corresponding to the block, that is, the data in the source storage block 9012 is covered by the data F in the clone storage block 9022, and the data C in the source storage block 9011 is overwritten by the null data in the clone storage block 9021. The data C is deleted directly. After copying the data in the cloned memory block to the source memory block, the update flag can be set from 1 to 0.
当所述克隆硬盘标记为已更新的克隆存储块中的数据全部拷贝至所述源硬盘后,则删除克隆硬盘和映射表,此时由克隆虚拟机对外提供业务。After all the data in the cloned hard disk marked as the updated clone storage block is copied to the source hard disk, the cloned hard disk and the mapping table are deleted, and the cloned virtual machine provides the external service.
本发明实施例中,在侦测到数据备份结束后,接收到数据写入请求时,将所述数据写入请求中的待写入数据写入所述源硬盘中,并将写入所述待写入数据的源存储块对应的更新标识设置为未更新。In the embodiment of the present invention, after the data backup request is detected, when the data write request is received, the data to be written in the data write request is written into the source hard disk, and the The update identifier corresponding to the source storage block to be written data is set to not updated.
通过本发明实施例的方法,在对虚拟机中的数据进行备份时,通过创建包括克隆硬盘的克隆虚拟机,将虚拟机在备份过程中执行的业务转移至所述克隆虚拟机执行,并将虚拟机备份过程中,将对源虚拟机中存储的数据的修改记录在所述克隆硬盘中,并对修改的数据进行标记,如此,在虚拟机的数据备份完成之后,可用克隆硬盘中记录的修改数据更新所述源虚拟机中的数据,如此,在保证备份数据的一致性的同时,也不会中断虚拟机的业务,从而提高了虚拟机的运行效率。According to the method of the embodiment of the present invention, when the data in the virtual machine is backed up, the cloned virtual machine including the cloned hard disk is created, and the service executed by the virtual machine in the backup process is transferred to the cloned virtual machine for execution, and During the virtual machine backup process, the data stored in the source virtual machine is recorded in the cloned hard disk, and the modified data is marked. Thus, after the virtual machine data backup is completed, the cloned hard disk may be recorded. The data is updated to update the data in the source virtual machine, so that the consistency of the backup data is ensured, and the service of the virtual machine is not interrupted, thereby improving the operating efficiency of the virtual machine.
如图9所示,本发明实施例还提供一种数据备份装置10,所述数据备份装置包括创建单元11、标记单元12、备份单元13、读取单元14、及更新单元15。所述创建单元11用于接收备份命令,中断源虚拟机的业务,创建克隆虚拟机及所述克隆虚拟机的克隆硬盘,建立所述克隆硬盘与所述源虚拟机的源硬盘的存储空间的映射关系,并将所述源虚拟机的运行数据镜像至所述克隆虚拟机,以使所述克隆虚拟机根据所述运行数据 开始运行,设置所述克隆虚拟机接收IO请求,恢复执行所中断的所述源虚拟机的业务。As shown in FIG. 9, the embodiment of the present invention further provides a data backup device 10, which includes a creating unit 11, a marking unit 12, a backup unit 13, a reading unit 14, and an updating unit 15. The creating unit 11 is configured to receive a backup command, interrupt the service of the source virtual machine, create a cloned virtual machine, and a cloned hard disk of the cloned virtual machine, and establish a storage space of the cloned hard disk and the source hard disk of the source virtual machine. Mapping the relationship and mirroring the running data of the source virtual machine to the clone virtual machine, so that the cloned virtual machine is based on the running data The operation starts, and the cloned virtual machine is configured to receive an IO request, and resume the execution of the interrupted service of the source virtual machine.
所述创建单元11在建立所述克隆硬盘与所述源硬盘的存储空间的映射关系时,具体用于将所述源硬盘和克隆硬盘分别按照预设大小分割为多个存储块;建立源存储块的地址与克隆存储块的地址的映射关系。The creating unit 11 is configured to divide the source hard disk and the clone hard disk into multiple storage blocks according to a preset size when establishing a mapping relationship between the cloned hard disk and the storage space of the source hard disk; The mapping relationship between the address of the block and the address of the cloned block.
所述克隆硬盘与所述源虚拟机的源硬盘的存储空间的映射关系的建立方法和将所述源虚拟机的运行数据镜像至所述克隆虚拟机的方法在方法实施例中做了详细描述,在此不再赘述。The method for establishing a mapping relationship between the cloned hard disk and the storage space of the source hard disk of the source virtual machine and the method for mirroring the running data of the source virtual machine to the cloned virtual machine are described in detail in the method embodiment. , will not repeat them here.
所述标记单元12用于在侦测到所述克隆虚拟机执行数据操作为对所述源硬盘中的数据进行修改时,则将修改后的数据记录至所述克隆硬盘中,并对记录的位置进行标记。The marking unit 12 is configured to: when detecting that the clone virtual machine performs a data operation to modify data in the source hard disk, record the modified data to the cloned hard disk, and record the The location is marked.
所述标记单元12在对记录的位置进行标记时,具体用于将记录所述修改后的数据的克隆存储块的地址所在的映射关系对应的更新标记设置为已更新。When the marking unit 12 marks the recorded position, the marking unit 12 is specifically configured to set the update flag corresponding to the mapping relationship of the address of the cloned storage block in which the modified data is recorded to be updated.
所述标记单元12还用于在侦测到所述源虚拟机执行的数据操作对所述源硬盘中的数据进行更新时,判断所述数据更新请求所更新的源存储块的地址所在的映射关系对应的更新标识是否为已更新;确定所述数据更新请求所更新的源存储块的地址所在的映射关系对应的更新标识不是已更新时,将所述数据更新请求所更新的源存储块中被更新数据拷贝至所述数据更新请求所更新的源存储块对应的克隆存储块;在所述数据更新请求所更新的源存储块中写入所述数据更新请求中的更新数据;将所述数据更新请求所更新的源存储块对应的更新标识设置为已更新。The marking unit 12 is further configured to: when detecting the data operation performed by the source virtual machine, update the data in the source hard disk, determine a mapping of an address of the source storage block updated by the data update request. Whether the update identifier corresponding to the relationship is updated; determining that the update identifier corresponding to the mapping relationship of the address of the source storage block updated by the data update request is not updated, and the data storage request is updated in the source storage block And the updated data is copied to the clone storage block corresponding to the source storage block updated by the data update request; the update data in the data update request is written in the source storage block updated by the data update request; The update identifier corresponding to the source storage block updated by the data update request is set to be updated.
所述备份单元13用于在侦测到所述源虚拟机的业务执行完成之后,关闭所述源虚拟机,备份所述源硬盘中的数据。The backup unit 13 is configured to shut down the source virtual machine and back up data in the source hard disk after detecting that the service execution of the source virtual machine is completed.
还包括读取单元14,用于接收读取所述克隆虚拟机中的数据的读IO请求接收;判断所述读IO请求所读取的克隆存储块对应的更新标识是否为已更新;确定所述读IO请求所读取的克隆存储块对应的更新标识为未更新时,从所述所读取的克隆存储块对应的源存储块中读取数据;确定所述读IO请求所读取的克隆存储块对应的更新标识为已更新时,从所述所读取的克隆存储块中读取数据。The method further includes a reading unit 14 configured to receive a read IO request received to read data in the cloned virtual machine, and determine whether an update identifier corresponding to the cloned storage block read by the read IO request is updated; Reading the data from the source storage block corresponding to the read clone storage block when the update identifier corresponding to the clone storage block read by the IO request is not updated; determining the read by the read IO request When the update identifier corresponding to the cloned storage block is updated, data is read from the read cloned storage block.
所述更新单元15用于在侦测到数据备份结束后,根据所述映射关系将所述克隆硬盘中被标记的位置处的数据复制至所述克隆硬盘被标记的位置处所映射的所述源硬盘的位置,并设置所述源硬盘为所述克隆虚拟机的硬盘。 The updating unit 15 is configured to, after detecting the end of the data backup, copy the data at the marked location in the cloned hard disk to the source mapped at the marked location of the cloned hard disk according to the mapping relationship. Position the hard disk and set the source hard disk to be the hard disk of the cloned virtual machine.
所述更新单元15具体用于确定被设置为已更新的更新标识对应的映射关系中的克隆存储块;将所述被设置为已更新的更新标识对应的映射关系中的克隆存储块所存储的数据复制至所述被设置为已更新的更新标识对应的映射关系中的源存储块;将所述被设置为已更新的更新标识设置为未更新。The updating unit 15 is specifically configured to determine a clone storage block in a mapping relationship corresponding to the updated update identifier, and store the clone storage block in the mapping relationship corresponding to the updated update identifier. The data is copied to the source storage block in the mapping relationship corresponding to the updated update identifier set; the update identifier set to be updated is set to not updated.
在所述克隆硬盘中的数据复制完成之后,所述更新单元删除所述克隆硬盘及映射表。After the data copying in the cloned hard disk is completed, the update unit deletes the clone hard disk and the mapping table.
通过本发明实施例的方法,在对虚拟机中的数据进行备份时,通过创建包括克隆硬盘的克隆虚拟机,将虚拟机在备份过程中执行的业务转移至所述克隆虚拟机执行,并将虚拟机备份过程中,将对源虚拟机中存储的数据的修改记录在所述克隆硬盘中,并对修改的数据进行标记,如此,在虚拟机的数据备份完成之后,可用克隆硬盘中记录的修改数据更新所述源虚拟机中的数据,如此,在保证备份数据的一致性的同时,也不会中断虚拟机的业务,从而提高了虚拟机的运行效率。According to the method of the embodiment of the present invention, when the data in the virtual machine is backed up, the cloned virtual machine including the cloned hard disk is created, and the service executed by the virtual machine in the backup process is transferred to the cloned virtual machine for execution, and During the virtual machine backup process, the data stored in the source virtual machine is recorded in the cloned hard disk, and the modified data is marked. Thus, after the virtual machine data backup is completed, the cloned hard disk may be recorded. The data is updated to update the data in the source virtual machine, so that the consistency of the backup data is ensured, and the service of the virtual machine is not interrupted, thereby improving the operating efficiency of the virtual machine.
对于系统实施例而言,由于其基本对应于方法实施例,所以相关之处参见方法实施例的部分说明即可。以上所描述的系统实施例仅仅是示意性的,其中所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。本领域普通技术人员在不付出创造性劳动的情况下,即可以理解并实施。For the system embodiment, since it basically corresponds to the method embodiment, it can be referred to the partial description of the method embodiment. The system embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, ie may be located A place, or it can be distributed to multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the embodiment. Those of ordinary skill in the art can understand and implement without any creative effort.
本发明可以在由计算机执行的计算机可执行指令的一般上下文中描述,例如程序模块。一般地,程序模块包括执行特定任务或实现特定抽象数据类型的例程、程序、对象、组件、数据结构等等。也可以在分布式计算环境中实践本发明,在这些分布式计算环境中,由通过通信网络而被连接的远程处理设备来执行任务。在分布式计算环境中,程序模块可以位于包括存储设备在内的本地和远程计算机存储介质中。The invention may be described in the general context of computer-executable instructions executed by a computer, such as a program module. Generally, program modules include routines, programs, objects, components, data structures, and the like that perform particular tasks or implement particular abstract data types. The invention may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are connected through a communication network. In a distributed computing environment, program modules can be located in both local and remote computer storage media including storage devices.
本领域普通技术人员可以理解实现上述方法实施方式中的全部或部分步骤是可以通过程序来指令相关的硬件来完成,所述的程序可以存储于计算机可读取存储介质中,这里所称得的存储介质,如:ROM、RAM、磁碟、光盘等。One of ordinary skill in the art can understand that all or part of the steps in implementing the above method embodiments can be completed by a program to instruct related hardware, and the program can be stored in a computer readable storage medium, which is referred to herein. Storage media, such as: ROM, RAM, disk, CD, etc.
还需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵 盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。It should also be noted that, in this context, relational terms such as first and second, etc. are used merely to distinguish one entity or operation from another entity or operation, without necessarily requiring or implying such entities or operations. There is any such actual relationship or order between them. Moreover, the terms "including", "comprising" or any other variant thereof are intended to be A non-exclusive inclusion, such that a process, method, article, or device that includes a series of elements includes not only those elements but also other elements not specifically listed or included in the process, method, article, or device The inherent elements. An element that is defined by the phrase "comprising a ..." does not exclude the presence of additional equivalent elements in the process, method, item, or device that comprises the element.
以上所述仅为本发明的较佳实施例而已,并非用于限定本发明的保护范围。本文中应用了具体个例对本发明的原理及实施方式进行了闸述,以上实施例的说明只是用于帮助理解本发明的方法及其核心思想;同时,对于本领域的一般技术人员,依据本发明的思想,在具体实施方式及应用范围上均会有改变之处。综上所述,本说明书内容不应理解为对本发明的限制。凡在本发明的精神和原则之内所作的任何修改、等同替换、改进等,均包含在本发明的保护范围内。 The above is only the preferred embodiment of the present invention and is not intended to limit the scope of the present invention. The principles and embodiments of the present invention have been described in detail herein. The description of the above embodiments is only for the purpose of understanding the method of the present invention and the core idea thereof. The idea of the invention will vary in the specific embodiments and applications. In summary, the content of the specification should not be construed as limiting the invention. Any modifications, equivalents, improvements, etc. made within the spirit and scope of the invention are intended to be included within the scope of the invention.

Claims (15)

  1. 一种虚拟机备份方法,其特征在于,所述方法包括:A virtual machine backup method, the method comprising:
    接收备份命令,中断源虚拟机的业务,创建克隆虚拟机及所述克隆虚拟机的克隆硬盘;Receiving a backup command, interrupting the service of the source virtual machine, and creating a cloned virtual machine and a cloned hard disk of the cloned virtual machine;
    建立所述克隆硬盘与所述源虚拟机的源硬盘的存储空间的映射关系;Establishing a mapping relationship between the cloned hard disk and a storage space of the source hard disk of the source virtual machine;
    将所述源虚拟机的运行数据镜像至所述克隆虚拟机,以使所述克隆虚拟机根据所述运行数据开始运行,设置所述克隆虚拟机接收IO请求,恢复执行所中断的所述源虚拟机的业务;Mirroring the running data of the source virtual machine to the cloned virtual machine, so that the cloned virtual machine starts running according to the running data, setting the cloned virtual machine to receive an IO request, and restoring execution of the interrupted source Virtual machine business;
    在侦测到所述克隆虚拟机执行的数据操作为对所述源硬盘中的数据进行修改时,则将修改后的数据记录至所述克隆硬盘中,并对记录的位置进行标记;After detecting that the data operation performed by the cloned virtual machine is to modify data in the source hard disk, the modified data is recorded into the cloned hard disk, and the recorded location is marked;
    在侦测到所述源虚拟机的业务执行完成之后,关闭所述源虚拟机,备份所述源硬盘中的数据;After detecting that the service execution of the source virtual machine is completed, shutting down the source virtual machine and backing up data in the source hard disk;
    在侦测到数据备份结束后,根据所述映射关系将所述克隆硬盘中被标记的位置处的数据复制至所述克隆硬盘被标记的位置处所映射的所述源硬盘的位置,并设置所述源硬盘为所述克隆虚拟机的硬盘。After detecting the end of the data backup, copying the data at the marked location in the cloned hard disk to the location of the source hard disk mapped at the marked location of the cloned hard disk according to the mapping relationship, and setting the location The source hard disk is the hard disk of the cloned virtual machine.
  2. 如权利要求1所述的方法,其特征在于,所述建立所述克隆硬盘与所述源硬盘的存储空间的映射关系,包括:The method of claim 1, wherein the mapping relationship between the cloned hard disk and the storage space of the source hard disk is as follows:
    将所述源硬盘和克隆硬盘分别按照预设大小分割为多个存储块;Separating the source hard disk and the clone hard disk into a plurality of storage blocks according to a preset size;
    建立源存储块的地址与克隆存储块的地址的映射关系。Establish a mapping relationship between the address of the source storage block and the address of the cloned storage block.
  3. 如权利要求2所述的方法,其特征在于,所述映射表中的每个源存储块的地址与克隆存储块的地址映射关系还对应更新标识;The method according to claim 2, wherein the address mapping relationship between the address of each source storage block and the clone storage block in the mapping table further corresponds to an update identifier;
    所述对记录的位置进行标记具体包括:The marking of the recorded location specifically includes:
    将记录所述修改后的数据的克隆存储块的地址所在的映射关系对应的更新标记设置为已更新。The update flag corresponding to the mapping relationship of the address of the clone storage block in which the modified data is recorded is set to be updated.
  4. 如权利要求3所述的方法,其特征在于,所述方法还包括:The method of claim 3, wherein the method further comprises:
    在侦测到所述源虚拟机执行的数据操作为对所述源硬盘中的数据进行更新时,判 断所述数据更新请求所更新的源存储块的地址所在的映射关系对应的更新标识是否为已更新;When it is detected that the data operation performed by the source virtual machine is to update the data in the source hard disk, Whether the update identifier corresponding to the mapping relationship of the address of the source storage block updated by the data update request is updated;
    确定所述数据更新请求所更新的源存储块的地址所在的映射关系对应的更新标识不是已更新时,将所述数据更新请求所更新的源存储块中被更新数据拷贝至所述数据更新请求所更新的源存储块对应的克隆存储块;Determining, when the update identifier corresponding to the mapping relationship of the address of the source storage block updated by the data update request is not updated, copying the updated data in the source storage block updated by the data update request to the data update request a cloned storage block corresponding to the updated source storage block;
    在所述数据更新请求所更新的源存储块中写入所述数据更新请求中的更新数据;Writing update data in the data update request in a source storage block updated by the data update request;
    将所述数据更新请求所更新的源存储块对应的更新标识设置为已更新。The update identifier corresponding to the source storage block updated by the data update request is set to be updated.
  5. 如权利要求3所述的方法,其特征在于,所述方法还包括:The method of claim 3, wherein the method further comprises:
    接收读取所述克隆虚拟机中的数据的读IO请求;Receiving a read IO request to read data in the cloned virtual machine;
    判断所述读IO请求所读取的克隆存储块对应的更新标识是否为已更新;Determining whether the update identifier corresponding to the clone storage block read by the read IO request is updated;
    确定所述读IO请求所读取的克隆存储块对应的更新标识为未更新时,从所述所读取的克隆存储块对应的源存储块中读取数据;Determining, when the update identifier corresponding to the clone storage block read by the read IO request is not updated, reading data from the source storage block corresponding to the read clone storage block;
    确定所述读IO请求所读取的克隆存储块对应的更新标识为已更新时,从所述所读取的克隆存储块中读取数据。When it is determined that the update identifier corresponding to the clone storage block read by the read IO request is updated, data is read from the read clone storage block.
  6. 如权利要求3所述的方法,其特征在于,所述根据映射关系将克隆硬盘中被标记的位置处的数据复制至克隆硬盘被标记的位置处所映射的源硬盘的位置,具体包括:The method according to claim 3, wherein the copying the data at the marked location in the cloned hard disk to the location of the source hard disk mapped at the marked location of the cloned hard disk according to the mapping relationship comprises:
    确定被设置为已更新的更新标识对应的映射关系中的克隆存储块;Determining a clone storage block in a mapping relationship corresponding to the updated update identifier;
    将所述被设置为已更新的更新标识对应的映射关系中的克隆存储块所存储的数据复制至所述被设置为已更新的更新标识对应的映射关系中的源存储块;Copying data stored in the clone storage block in the mapping relationship corresponding to the updated update identifier to the source storage block in the mapping relationship corresponding to the updated update identifier;
    将所述被设置为已更新的更新标识设置为未更新。Set the update ID set to updated to not updated.
  7. 如权利要求3所述的方法,其特征在于,所述方法还包括:The method of claim 3, wherein the method further comprises:
    在侦测到数据备份结束后,接收到数据写入请求时,将所述数据写入请求中的待写入数据写入所述源硬盘中,并将写入所述待写入数据的源存储块对应的更新标识设置为未更新。After detecting the data backup end, when receiving the data write request, writing the data to be written in the data write request to the source hard disk, and writing the source of the data to be written The update ID corresponding to the storage block is set to not updated.
  8. 一种虚拟机备份装置,其特征在于,所述装置包括: A virtual machine backup device, characterized in that the device comprises:
    创建单元,用于接收备份命令,中断源虚拟机的业务,创建克隆虚拟机及所述克隆虚拟机的克隆硬盘,建立所述克隆硬盘与所述源虚拟机的源硬盘的存储空间的映射关系,并将所述源虚拟机的运行数据镜像至所述克隆虚拟机,以使所述克隆虚拟机根据所述运行数据开始运行,设置所述克隆虚拟机接收IO请求,恢复执行所中断的所述源虚拟机的业务;The unit is configured to receive a backup command, interrupt the service of the source virtual machine, create a cloned virtual machine, and clone the hard disk of the cloned virtual machine, and establish a mapping relationship between the cloned hard disk and the storage space of the source virtual disk of the source virtual machine. And mirroring the running data of the source virtual machine to the clone virtual machine, so that the cloned virtual machine starts running according to the running data, and the cloned virtual machine is configured to receive an IO request, and resume execution of the interrupted operation. Describe the business of the source virtual machine;
    标记单元,用于在侦测到所述克隆虚拟机执行数据操作为对所述源硬盘中的数据进行修改时,则将修改后的数据记录至所述克隆硬盘中,并对记录的位置进行标记;a marking unit, configured to: when detecting that the clone virtual machine performs a data operation to modify data in the source hard disk, record the modified data to the cloned hard disk, and perform the recorded location mark;
    备份单元,用于在侦测到所述源虚拟机的业务执行完成之后,关闭所述源虚拟机,备份所述源硬盘中的数据;a backup unit, configured to: after detecting that the service execution of the source virtual machine is completed, shutting down the source virtual machine, and backing up data in the source hard disk;
    更新单元,用于在侦测到数据备份结束后,根据所述映射关系将所述克隆硬盘中被标记的位置处的数据复制至所述克隆硬盘被标记的位置处所映射的所述源硬盘的位置,并设置所述源硬盘为所述克隆虚拟机的硬盘。And an updating unit, configured to: after detecting the end of the data backup, copy the data at the marked location in the cloned hard disk to the source hard disk mapped at the marked location of the cloned hard disk according to the mapping relationship; Position and set the source hard disk to be the hard disk of the cloned virtual machine.
  9. 如权利要求8所述的装置,其特征在于,所述创建单元在建立所述克隆硬盘与所述源硬盘的存储空间的映射关系时,具体用于,The device according to claim 8, wherein the creating unit is specifically configured to establish a mapping relationship between the cloned hard disk and a storage space of the source hard disk.
    将所述源硬盘和克隆硬盘分别按照预设大小分割为多个存储块;Separating the source hard disk and the clone hard disk into a plurality of storage blocks according to a preset size;
    建立源存储块的地址与克隆存储块的地址的映射关系。Establish a mapping relationship between the address of the source storage block and the address of the cloned storage block.
  10. 如权利要求9所述的装置,其特征在于,所述映射表中的每个源存储块的地址与克隆存储块的地址映射关系还对应更新标识;The apparatus according to claim 9, wherein the address mapping relationship of each source storage block in the mapping table and the address mapping relationship of the clone storage block further corresponds to an update identifier;
    所述标记单元在对记录的位置进行标记时,具体用于,When the marking unit marks the recorded position, it is specifically used,
    将记录所述修改后的数据的克隆存储块的地址所在的映射关系对应的更新标记设置为已更新。The update flag corresponding to the mapping relationship of the address of the clone storage block in which the modified data is recorded is set to be updated.
  11. 如权利要求10所述的装置,其特征在于,所述标记单元还用于:The device according to claim 10, wherein said marking unit is further configured to:
    在侦测到所述源虚拟机执行的数据操作对所述源硬盘中的数据进行更新时,判断所述数据更新请求所更新的源存储块的地址所在的映射关系对应的更新标识是否为已更新;When it is detected that the data operation performed by the source virtual machine updates the data in the source hard disk, it is determined whether the update identifier corresponding to the mapping relationship of the address of the source storage block updated by the data update request is Update
    确定所述数据更新请求所更新的源存储块的地址所在的映射关系对应的更新标识 不是已更新时,将所述数据更新请求所更新的源存储块中被更新数据拷贝至所述数据更新请求所更新的源存储块对应的克隆存储块;Determining an update identifier corresponding to a mapping relationship of an address of the source storage block updated by the data update request When not updated, the updated data in the source storage block updated by the data update request is copied to the clone storage block corresponding to the source storage block updated by the data update request;
    在所述数据更新请求所更新的源存储块中写入所述数据更新请求中的更新数据;Writing update data in the data update request in a source storage block updated by the data update request;
    将所述数据更新请求所更新的源存储块对应的更新标识设置为已更新。The update identifier corresponding to the source storage block updated by the data update request is set to be updated.
  12. 如权利要求10所述的装置,其特征在于,还包括读取单元,用于:The device of claim 10, further comprising a reading unit for:
    接收读取所述克隆虚拟机中的数据的读IO请求接收;Receiving a read IO request receipt for reading data in the cloned virtual machine;
    判断所述读IO请求所读取的克隆存储块对应的更新标识是否为已更新;Determining whether the update identifier corresponding to the clone storage block read by the read IO request is updated;
    确定所述读IO请求所读取的克隆存储块对应的更新标识为未更新时,从所述所读取的克隆存储块对应的源存储块中读取数据;Determining, when the update identifier corresponding to the clone storage block read by the read IO request is not updated, reading data from the source storage block corresponding to the read clone storage block;
    确定所述读IO请求所读取的克隆存储块对应的更新标识为已更新时,从所述所读取的克隆存储块中读取数据。When it is determined that the update identifier corresponding to the clone storage block read by the read IO request is updated, data is read from the read clone storage block.
  13. 如权利要求10所述的装置,其特征在于,所述更新单元具体用于:The device according to claim 10, wherein the updating unit is specifically configured to:
    确定被设置为已更新的更新标识对应的映射关系中的克隆存储块;Determining a clone storage block in a mapping relationship corresponding to the updated update identifier;
    将所述被设置为已更新的更新标识对应的映射关系中的克隆存储块所存储的数据复制至所述被设置为已更新的更新标识对应的映射关系中的源存储块;Copying data stored in the clone storage block in the mapping relationship corresponding to the updated update identifier to the source storage block in the mapping relationship corresponding to the updated update identifier;
    将所述被设置为已更新的更新标识设置为未更新。Set the update ID set to updated to not updated.
  14. 如权利要求10所述的装置,其特征在于,所述更新单元还用于在侦测到数据备份结束后,接收到数据写入请求时,将所述数据写入请求中的待写入数据写入所述源硬盘中,并将写入所述待写入数据的源存储块对应的更新标识设置为未更新。The device according to claim 10, wherein the updating unit is further configured to: when the data write request is received after detecting the end of the data backup, write the data to the data to be written in the request Writing to the source hard disk, and setting an update identifier corresponding to the source storage block to which the data to be written is written is not updated.
  15. 一种宿主机,其特征在于,所述宿主机包括:处理器、内存、硬盘、通讯接口、系统总线,所述处理器、内存、硬盘和通信接口之间通过系统总线连接并完成相互间的通信,所述内存中用于存储计算机执行指令,所述宿主机运行时,所述处理器执行所述内存中的计算机执行指令以利用所述宿主机中的硬件资源建立虚拟机,并执行权利要求1-7任意一项所述的方法。 A host machine, comprising: a processor, a memory, a hard disk, a communication interface, and a system bus, wherein the processor, the memory, the hard disk, and the communication interface are connected through a system bus and complete each other Communication, in the memory for storing computer execution instructions, when the host is running, the processor executes the computer execution instructions in the memory to establish a virtual machine with hardware resources in the host machine, and execute the right The method of any of 1-7 is claimed.
PCT/CN2016/073318 2016-02-03 2016-02-03 Virtual machine backup method, backup device and host WO2017132872A1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201680003386.9A CN107003893B (en) 2016-02-03 2016-02-03 Virtual machine backup method, back-up device and host
PCT/CN2016/073318 WO2017132872A1 (en) 2016-02-03 2016-02-03 Virtual machine backup method, backup device and host

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2016/073318 WO2017132872A1 (en) 2016-02-03 2016-02-03 Virtual machine backup method, backup device and host

Publications (1)

Publication Number Publication Date
WO2017132872A1 true WO2017132872A1 (en) 2017-08-10

Family

ID=59431677

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/073318 WO2017132872A1 (en) 2016-02-03 2016-02-03 Virtual machine backup method, backup device and host

Country Status (2)

Country Link
CN (1) CN107003893B (en)
WO (1) WO2017132872A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111858174A (en) * 2020-07-17 2020-10-30 苏州浪潮智能科技有限公司 Ordered management method, system, terminal and storage medium for cloud host
CN112395050A (en) * 2020-11-30 2021-02-23 深信服科技股份有限公司 Virtual machine backup method and device, electronic equipment and readable storage medium
CN115437670A (en) * 2022-09-06 2022-12-06 北京斯年智驾科技有限公司 TFTP-based automobile controller program upgrading system

Families Citing this family (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2019089742A1 (en) * 2017-11-01 2019-05-09 Swirlds, Inc. Methods and apparatus for efficiently implementing a fast-copyable database
US10860434B2 (en) * 2018-04-30 2020-12-08 EMC IP Holding Company LLC Method and system for enabling data backups for virtual machines reliant on raw device mapping disks
CN108959124A (en) * 2018-05-04 2018-12-07 广东睿江云计算股份有限公司 Magnetic disk of virtual machine reproduction process wiring method and device based on dynamic buffering
CN109002401A (en) * 2018-05-04 2018-12-14 广东睿江云计算股份有限公司 Magnetic disk of virtual machine reproduction process read method and device based on dynamic buffering
CN108984430A (en) * 2018-05-04 2018-12-11 广东睿江云计算股份有限公司 Magnetic disk of virtual machine reproduction process wiring method and device based on fixed buffering
CN109032753B (en) * 2018-06-20 2022-02-22 上海市信息网络有限公司 Heterogeneous virtual machine hard disk hosting method and system, storage medium and Nova platform
CN109032762B (en) * 2018-08-09 2022-01-25 腾讯科技(深圳)有限公司 Virtual machine backtracking method and related equipment
CN109344001B (en) * 2018-08-29 2022-01-11 广东微云科技股份有限公司 Concurrent backup method and system for virtual machine files
CN110018881B (en) * 2019-03-28 2021-04-13 西安交通大学 Method and system for rapidly recovering virtual machine fault
CN110262876A (en) * 2019-06-28 2019-09-20 浪潮电子信息产业股份有限公司 A kind of virtual machine method for reconstructing, device, equipment and readable storage medium storing program for executing

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101609419A (en) * 2009-06-29 2009-12-23 北京航空航天大学 The data back up method and the device of the migration of virtual machine consistently online
CN102761566A (en) * 2011-04-26 2012-10-31 国际商业机器公司 Virtual machine migrating method and device
CN103500146A (en) * 2013-09-30 2014-01-08 北京邮电大学 Method and system for migrating stored data of virtual machine disks
CN103699429A (en) * 2013-12-31 2014-04-02 华为技术有限公司 Virtual machine migration method and virtual machine migration device

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101819545B (en) * 2010-04-09 2012-07-25 济南银泉科技有限公司 Method for realizing platform migration by using virtualization technology
CN102594849B (en) * 2011-01-06 2015-05-20 阿里巴巴集团控股有限公司 Data backup and recovery method and device, virtual machine snapshot deleting and rollback method and device
US8832029B2 (en) * 2011-02-16 2014-09-09 Microsoft Corporation Incremental virtual machine backup supporting migration
US8954965B2 (en) * 2012-08-03 2015-02-10 Microsoft Corporation Trusted execution environment virtual machine cloning
CN103678036B (en) * 2013-11-15 2016-08-17 上海爱数信息技术股份有限公司 A kind of backup method found based on virtual machine operation information data

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101609419A (en) * 2009-06-29 2009-12-23 北京航空航天大学 The data back up method and the device of the migration of virtual machine consistently online
CN102761566A (en) * 2011-04-26 2012-10-31 国际商业机器公司 Virtual machine migrating method and device
CN103500146A (en) * 2013-09-30 2014-01-08 北京邮电大学 Method and system for migrating stored data of virtual machine disks
CN103699429A (en) * 2013-12-31 2014-04-02 华为技术有限公司 Virtual machine migration method and virtual machine migration device

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111858174A (en) * 2020-07-17 2020-10-30 苏州浪潮智能科技有限公司 Ordered management method, system, terminal and storage medium for cloud host
CN111858174B (en) * 2020-07-17 2022-06-14 苏州浪潮智能科技有限公司 Ordered management method, system, terminal and storage medium for cloud host
CN112395050A (en) * 2020-11-30 2021-02-23 深信服科技股份有限公司 Virtual machine backup method and device, electronic equipment and readable storage medium
CN112395050B (en) * 2020-11-30 2024-02-23 深信服科技股份有限公司 Virtual machine backup method and device, electronic equipment and readable storage medium
CN115437670A (en) * 2022-09-06 2022-12-06 北京斯年智驾科技有限公司 TFTP-based automobile controller program upgrading system
CN115437670B (en) * 2022-09-06 2023-11-21 北京斯年智驾科技有限公司 Automobile controller program upgrading system based on TFTP

Also Published As

Publication number Publication date
CN107003893A (en) 2017-08-01
CN107003893B (en) 2019-11-12

Similar Documents

Publication Publication Date Title
WO2017132872A1 (en) Virtual machine backup method, backup device and host
US11604708B2 (en) Memory first live snapshot
US10198377B2 (en) Virtual machine state replication using DMA write records
US9400611B1 (en) Data migration in cluster environment using host copy and changed block tracking
US9460028B1 (en) Non-disruptive and minimally disruptive data migration in active-active clusters
US9569200B2 (en) Live operating system update mechanisms
EP3117311B1 (en) Method and system for implementing virtual machine images
JP6310061B2 (en) Selective retention of application program data migrated from system memory to non-volatile data storage
US8738883B2 (en) Snapshot creation from block lists
US8694828B2 (en) Using virtual machine cloning to create a backup virtual machine in a fault tolerant system
WO2018058944A1 (en) Method and device for deleting cascade snapshot
US20150067390A1 (en) Live snapshot of a virtual machine
US8954706B2 (en) Storage apparatus, computer system, and control method for storage apparatus
US20180107605A1 (en) Computing apparatus and method with persistent memory
US9940152B2 (en) Methods and systems for integrating a volume shadow copy service (VSS) requester and/or a VSS provider with virtual volumes (VVOLS)
CN101840362A (en) Method and device for achieving copy-on-write snapshot
CN102012853A (en) Zero-copy snapshot method
JP2004234114A (en) Computer system, computer device, and method and program for migrating operating system
CN112328365A (en) Virtual machine migration method, device, equipment and storage medium
US8566541B2 (en) Storage system storing electronic modules applied to electronic objects common to several computers, and storage control method for the same
US8972351B1 (en) Systems and methods for creating selective snapshots
US10592133B1 (en) Managing raw device mapping during disaster recovery
CN114546604A (en) Thermal migration method and device for virtual machine
US10846011B2 (en) Moving outdated data from a multi-volume virtual disk to a backup storage device
CN113296716A (en) Virtual machine disk online migration method, computer readable storage medium and computer

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: 16888697

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: 16888697

Country of ref document: EP

Kind code of ref document: A1