CN112395050A - Virtual machine backup method and device, electronic equipment and readable storage medium - Google Patents

Virtual machine backup method and device, electronic equipment and readable storage medium Download PDF

Info

Publication number
CN112395050A
CN112395050A CN202011373888.5A CN202011373888A CN112395050A CN 112395050 A CN112395050 A CN 112395050A CN 202011373888 A CN202011373888 A CN 202011373888A CN 112395050 A CN112395050 A CN 112395050A
Authority
CN
China
Prior art keywords
target
data
virtual machine
backup
coroutine
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202011373888.5A
Other languages
Chinese (zh)
Other versions
CN112395050B (en
Inventor
欧佳展
符学葳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Sangfor Technologies Co Ltd
Original Assignee
Sangfor Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Sangfor Technologies Co Ltd filed Critical Sangfor Technologies Co Ltd
Priority to CN202011373888.5A priority Critical patent/CN112395050B/en
Publication of CN112395050A publication Critical patent/CN112395050A/en
Application granted granted Critical
Publication of CN112395050B publication Critical patent/CN112395050B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • 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/1448Management of the data involved in backup or backup restore
    • 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/1464Management of the backup or restore process for networked environments
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

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

Abstract

The application discloses a virtual machine backup method, a virtual machine backup device, electronic equipment and a computer readable storage medium, wherein the method comprises the following steps: if the target coroutine is detected, updating offset information corresponding to the target virtual machine; the target coroutine is a coroutine in an idle state in any one of the coroutines; based on the offset information, reading corresponding data to be backed up by using a target protocol; writing the data to be backed up into a target position by using a target coroutine; in the method, in the process of reading the data to be backed up by the target protocol, other protocols can also read the data; or the read data can be written in, and in the process of writing data in the target coroutine, other coroutines can read or write the data, so that the concurrent processing of virtual machine backup is realized; and multiple coroutines are processed concurrently, so that the data reading speed and the data writing speed are greatly improved, the backup speed of the virtual machine is improved, and the backup time is reduced.

Description

Virtual machine backup method and device, electronic equipment and readable storage medium
Technical Field
The present disclosure relates to the field of virtual machine technologies, and in particular, to a virtual machine backup method, a virtual machine backup apparatus, an electronic device, and a computer-readable storage medium.
Background
In a virtualization environment, backing up a virtual machine is an important mechanism for service guarantee. When the running storage of the virtual machine fails or the virtual machine is invaded by viruses, the rapid recovery can be realized through the backup file of the virtual machine, and the data loss and the long-time service interruption are avoided. In the related technology, the backup speed is low when the virtual machine is backed up and is far lower than the storage throughput speed, so the required backup time is long and the backup efficiency is low.
Disclosure of Invention
In view of the above, an object of the present application is to provide a virtual machine backup method, a virtual machine backup apparatus, an electronic device, and a computer-readable storage medium, which improve data reading speed and data writing speed, and improve virtual machine backup speed.
In order to solve the above technical problem, the present application provides a virtual machine backup method, including:
if the target coroutine is detected, updating offset information corresponding to the target virtual machine; the target coroutine is the coroutine in an idle state in any one of a plurality of coroutines;
based on the offset information, reading corresponding data to be backed up by using the target protocol;
and writing the data to be backed up into a target position by using the target coroutine.
Optionally, the updating offset information corresponding to the target virtual machine includes:
if the target virtual machine is in a full backup state, determining a target reading threshold value of the target coroutine;
updating the offset information based on the target read threshold.
Optionally, the updating offset information corresponding to the target virtual machine includes:
if the target virtual machine is in an incremental backup state, determining a target reading threshold value of the target coroutine;
and updating the offset information based on the target reading threshold and the incremental bitmap corresponding to the target virtual machine.
Optionally, the method further comprises:
backing up the incremental bitmap to obtain a backup bitmap;
and if the virtual machine backup error is detected, performing data rollback operation by using the backup bitmap.
Optionally, the method further comprises:
acquiring a modification instruction corresponding to target data to be backed up;
generating secondary backup data corresponding to the target data to be backed up, and modifying the secondary backup data according to the modification instruction;
after the target virtual machine finishes the backup, synchronizing the secondary backup data to a backup mirror image corresponding to the target virtual machine by using a plurality of coroutines.
Optionally, after the target coroutine is detected, before the updating offset information corresponding to the target virtual machine, the method further includes:
judging whether the offset information is smaller than the data volume corresponding to the target virtual machine or not;
if not, stopping updating the offset information;
and if so, executing the step of updating the offset information corresponding to the target virtual machine.
Optionally, the writing the data to be backed up into a target location by using the target coroutine includes:
writing the data to be backed up into a buffer area by using the target coroutine;
if the target write-in coroutine is detected, judging whether the buffer area has data to be backed up adjacent to the target position; the target write protocol is the write protocol in which any one of a plurality of write protocols is in an idle state;
if the data to be backed up adjacent to the target position exists, generating corresponding merged data, and writing the merged data into the target position by using the target writing protocol;
and if the data to be backed up adjacent to the target position does not exist, writing any one of the data to be backed up in the buffer area into the target position by using the target writing coroutine.
The present application further provides a virtual machine backup device, including:
the updating module is used for updating the offset information corresponding to the target virtual machine if the target coroutine is detected; the target coroutine is the coroutine in an idle state in any one of a plurality of coroutines;
the reading module is used for reading corresponding data to be backed up by using the target protocol based on the offset information;
and the writing module is used for writing the data to be backed up into a target position by using the target coroutine.
The present application further provides an electronic device comprising a memory and a processor, wherein:
the memory is used for storing a computer program;
the processor is configured to execute the computer program to implement the virtual machine backup method.
The present application also provides a computer readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the virtual machine backup method described above.
According to the virtual machine backup method, if the target coroutine is detected, offset information corresponding to the target virtual machine is updated; the target coroutine is a coroutine in an idle state in any one of the coroutines; based on the offset information, reading corresponding data to be backed up by using a target protocol; and writing the data to be backed up into the target position by using the target coroutine.
Therefore, when the method backs up the target virtual machine, a plurality of coroutines for reading and writing data are established in a single thread, and the target coroutine can be any coroutine in an idle state. After the target protocol is detected, the protocol is in an idle state, and data is read, so that the offset information is modified. The offset information is used for dividing the read data and the unread data, and the offset information is modified before the target protocol does not really start to read the data, so that the problem of repeated data reading caused by the fact that other protocols read the data similarly when the target protocol reads the data can be avoided. After the modification, the target protocol is used for reading the corresponding data to be backed up, and other protocols can also execute the steps to read the data in the process of reading the data to be backed up by the target protocol; or the read data can be written in, so that the concurrent processing of the virtual machine backup is realized, the data reading and writing speed is increased, and the virtual machine backup speed is further increased. Correspondingly, after the target coroutine finishes reading the data to be backed up, the data to be backed up is written into the corresponding target position. During the process of writing data by the target coroutine, other coroutines can read or write data. The multiple coroutines are processed concurrently, so that the data reading speed and the data writing speed are greatly improved, the backup speed of the virtual machine is improved, the backup time is reduced, and the problems of long backup time and low backup efficiency in the related technology are solved.
In addition, the application also provides a virtual machine backup device, electronic equipment and a computer readable storage medium, and the virtual machine backup device, the electronic equipment and the computer readable storage medium also have the beneficial effects.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments or related technologies of the present application, the drawings needed to be used in the description of the embodiments or related technologies are briefly introduced below, it is obvious that the drawings in the following description are only embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
Fig. 1 is a flowchart of a virtual machine backup method according to an embodiment of the present disclosure;
FIG. 2 is a flow chart of a modified instruction execution process provided by an embodiment of the present application;
FIG. 3 is a diagram illustrating a reading effect according to an embodiment of the present disclosure;
FIG. 4 is a diagram illustrating a writing effect provided by an embodiment of the present application;
fig. 5 is a flowchart of an initialization process provided in an embodiment of the present application;
fig. 6 is a flowchart of a modified instruction execution process in a backup process according to an embodiment of the present application;
fig. 7 is a flowchart of a control routine provided in the embodiment of the present application;
fig. 8 is a flowchart of a monitoring coroutine work flow provided by an embodiment of the present application;
fig. 9 is a flowchart of a coroutine work provided by an embodiment of the present application;
fig. 10 is a schematic structural diagram of a virtual machine backup device according to an embodiment of the present disclosure;
fig. 11 is a schematic diagram of a hardware composition framework to which a virtual machine backup method according to an embodiment of the present disclosure is applied.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
In the related art, a single-thread mode is adopted, and after one IO (Input/Output) data is read from a virtual machine disk by the same thread, the IO data is written into a backup image in backup storage, and the reading and the writing are coupled together. And performing write IO operation once again after the thread needs to read one IO data, and performing read IO operation once again after write IO is completed. For example, the hot standby mechanism (boot backup) of a qemu (Virtual operating system simulator), a Virtual Machine, and a kvm (Kernel-based Virtual Machine) all use an IO model with single-depth read-write and non-separation for backup. Therefore, the performance of the distributed storage system cannot be fully utilized in the related art, so that the backup speed is slow and the requirement cannot be met. The backup of the virtual machine is the backup of data in the virtual machine, and the backup speed is only up to 20MB/s when the virtual machine is actually backed up, and the backup of 10T data needs 145 hours. The random read-write IO throughput of the storage system can actually reach 200MB/s, the backup speed of the related technology can not reach the bottleneck of the storage system, and the storage performance can not be fully utilized.
In order to solve the above problem, because the IO rate can basically increase linearly with the increase of the depth within a certain IO depth range (for example, 16 depth ranges), the storage performance is fully utilized by using the multi-depth IO model, and the backup speed of the virtual machine is increased. Based on the method and the device, a plurality of coroutines are created in a single thread, the coroutines are executed concurrently, and the reading and the writing of the data are executed independently, so that the backup speed of the virtual machine is improved.
Referring to fig. 1, fig. 1 is a flowchart of a virtual machine backup method according to an embodiment of the present disclosure. The method comprises the following steps:
s101: and if the target coroutine is detected, updating offset information corresponding to the target virtual machine.
In this embodiment, all or part of the steps in the virtual machine backup method provided in this embodiment may be executed by using a specified electronic device, where the electronic device may be a computer or a server, for example, a server with a striping function, and any device that can implement multi-program work may be the specified electronic device. More specifically, in one embodiment, in addition to multiple routines for performing virtual machine backup work, there may be a control routine for performing common-time individual routines for the entire virtual machine backup work. The control coroutine schedules and monitors the work of each coroutine, namely the control coroutine executes each step in the virtual machine backup method, so that the function of concurrent work of multiple coroutines is realized, and the backup speed of the virtual machine is further improved.
It should be noted that the target coroutine in the present application is a coroutine in which any one of a plurality of coroutines is in an idle state. The target coroutine is a coroutine in an idle state, namely the target coroutine does not read data or write data; the target coroutine can be any one of a plurality of coroutines, namely, when no data is read or written in any coroutine, the coroutine can be determined as the target coroutine. By detecting the target coroutines, the concurrent processing of each coroutine can be realized. In this embodiment, the specific number of coroutines in the idle state is not limited, and since the number of coroutines is plural, one or more coroutines in the idle state may be provided. Further, the present embodiment does not limit the determination method of the target coroutine. In one embodiment, if a coroutine in an idle state is detected, it can be directly determined as a target coroutine. In another embodiment, when a plurality of protocol runs in the idle state are detected, each protocol run in the idle state may be determined as a target protocol run once according to a preset sequence, and specific contents of the preset sequence are not limited, for example, the sequence of the number of each protocol run may be used, or the time sequence of each protocol run converting into the idle state may be used.
Further, the present embodiment does not limit the detection manner of the target coroutine, that is, how to determine whether the coroutine is in the idle state. In a possible implementation manner, a plurality of status tags respectively corresponding to the coroutines may exist, the status tags may reflect the operating status of each coroutine, and the coroutine may actively modify the status tags according to the operating status. After a protocol has written the data that has been read, the state tag may be modified to indicate that it is in an idle state to be identified as an idle state. The specific form of the status tag is not limited, and for example, the status tag may be a flag bit, and the flag bit may have multiple statuses, for example, 0 may be used to indicate idle, 1 may be used to indicate read, and 2 may be used to indicate write. In another possible implementation manner, a channel is provided between each coroutine and the control coroutine, and can perform communication, after a certain coroutine finishes writing, the written information can be sent to the control coroutine, and after receiving the written information sent by the coroutine, the control coroutine determines that the coroutine is in an idle state. After the target coroutine is detected, the data can be continuously read by using the target coroutine, so that the target coroutine is used for parallel processing when other coroutines read or write the data. Before reading data by using the target protocol, the offset information corresponding to the target virtual machine needs to be modified.
The target virtual machine is a virtual machine which needs to be backed up, the specific form of the target virtual machine is not limited, and backing up the target virtual machine is backing up data in the target virtual machine. The offset information corresponds to the target virtual machine, and is used to divide the backed-up data and the data that is not backed-up in the target virtual machine, and the specific form is not limited. The offset information needs to be updated before the data is to be read by the target protocol. Since a certain time is required for the target coroutine to read data, when the target coroutine reads data, other coroutines may be converted into an idle state and determined as a new target coroutine. If the offset information is not modified, the new target protocol will read the same data as the old target protocol, resulting in repeated reading of data and also causing data write errors. The related art only uses a single thread to read and write data, which does not cause the above problems, but the application uses multiple coroutines to read and write data, which may cause the above problems. In order to solve the above problem, in this embodiment, after the target protocol is detected, before the data is read by using the target protocol, the offset information is modified, and after the data is modified, the data is read by using the target protocol. The virtual machine backup is generally performed in a continuous manner from low to high or from high to low of the storage addresses, so the offset information can be in the form of a cursor, and the connection positions of the backed-up data and the un-backed-up data are recorded. It should be noted that the ability of each protocol to read data may be the same or different, that is, each protocol may read data of the same size each time it reads data, or may read data of different sizes. Therefore, when the offset information is modified, the same modification can be performed, for example, the offset information is increased by a preset size, for example, 256 KB; or different modifications may be made, for example, a target read threshold corresponding to the target coroutine may be determined according to the correspondence between the coroutine and the read threshold, and the offset information may be increased by the target read threshold, for example, 256KB or 512 KB. In a preferred embodiment, the read threshold corresponding to each coroutine is the same, and the read threshold is the same as the granularity of data modification. For example, when data in the virtual machine is modified, the data is modified in units of 256KB, and when the protocol reads the data, the 256KB data can be read once, so that accurate data backup can be performed when needed (for example, when incremental backup is performed), backup of unchanged data is avoided, and backup speed is increased.
S102: and reading the corresponding data to be backed up by using the target protocol based on the offset information.
After the offset information is modified, the target coroutine can be used to read the data to be backed up corresponding to the target coroutine. The data to be backed up is a part of the data that is not backed up in the target virtual machine, and the specific content is not limited. It should be noted that the target protocol needs to be executed based on the offset information when reading the data to be backed up, and since the offset information has been modified in step S101, there is a portion of data that has been recorded as having been backed up by the offset information, but has not actually been backed up. The portion of data, i.e., the data to be backed up, may be determined based on the offset information. Specifically, the present embodiment does not limit the specific determination manner of the data to be backed up, and in a possible implementation, there is also history offset information corresponding to the offset information, where the history offset information is used to record a value of the offset information before each update, and if the offset information is updated, the history offset information may be updated. When determining the data to be backed up, the data between the historical offset information and the offset information can be directly determined as the data to be backed up. In another possible implementation, the data to be backed up may be determined according to the read threshold and the offset information corresponding to the coroutine. When determining the data to be backed up, dividing the data to be backed up in the direction of the backed up data by taking the offset information as a base point and taking a reading threshold value as a unit, so that the obtained data interval corresponds to the data to be backed up. For example, when the offset information is 512KB and the read threshold is 256KB, the data interval obtained by dividing 256KB in the direction of 0KB with 512KB as the base point is [257KB, 512KB ], and the data to be backed up is the data from 257KB to 512 KB. After the data to be backed up is determined, the data to be backed up may be read by using the target protocol, and the reading mode of the data to be backed up is not limited in this embodiment and may refer to the related art. In the process of reading the data to be backed up by using the target protocol, other protocols may read the data, or may write the data, or may be in an idle state after writing the data, and perform step S101 when the data is determined to be a new target protocol. That is, when step S102 is executed, step S101 or step S103 may be executed in parallel, and the coroutines are independent of each other and do not affect each other.
S103: and writing the data to be backed up into the target position by using the target coroutine.
After the data to be backed up is read, the data to be backed up can be written into the target position corresponding to the data to be backed up by using the target coroutine. It can be understood that the target location corresponds to the data to be backed up, which is specifically a writing location of the data to be backed up, and may be, for example, a relative location of the data to be backed up in a backup image, where the backup image is an image of the target virtual machine. The embodiment does not limit the specific generation manner of the backup image, for example, an initial backup image may be created, the initial backup image is mounted as an nbd Device, and the nbd Device (Network Block Device) is determined as the backup image. In a possible implementation manner, when the data to be backed up is read by using the target protocol, the data to be backed up is determined based on the offset data, and the offset data is used to divide the backed-up data and the data that is not backed up, so that when the data to be backed up is determined, the position of the data to be backed up in all the data of the target virtual machine can also be determined, and the position is corresponding to the backup image, so that the target position can be obtained. After the target position is determined, the data to be backed up can be written into the target position by using the target coroutine, and the backup of the data to be backed up is completed. The specific writing method of the data to be backed up is not limited in this embodiment, and reference may be made to related technologies. Similar to the step S102, when the data to be backed up is written by using the target protocol, other protocols may read the data, or may write the data, or may be in an idle state after writing the data, and is determined as a new target protocol.
By applying the virtual machine backup method provided by the embodiment of the application, when the target virtual machine is backed up, a plurality of coroutines for data reading and writing are established in a single thread, and the target coroutine can be any coroutine in an idle state. After the target protocol is detected, the protocol is in an idle state, and data is read, so that the offset information is modified. The offset information is used for dividing the read data and the unread data, and the offset information is modified before the target protocol does not really start to read the data, so that the problem of repeated data reading caused by the fact that other protocols read the data similarly when the target protocol reads the data can be avoided. After the modification, the target protocol is used for reading the corresponding data to be backed up, and other protocols can also execute the steps to read the data in the process of reading the data to be backed up by the target protocol; or the read data can be written in, so that the concurrent processing of the virtual machine backup is realized, the data reading and writing speed is increased, and the virtual machine backup speed is further increased. Correspondingly, after the target coroutine finishes reading the data to be backed up, the data to be backed up is written into the corresponding target position. During the process of writing data by the target coroutine, other coroutines can read or write data. The multiple coroutines are processed concurrently, so that the data reading speed and the data writing speed are greatly improved, the backup speed of the virtual machine is improved, the backup time is reduced, and the problems of long backup time and low backup efficiency in the related technology are solved.
Based on the above embodiments, the present embodiment will specifically describe several steps in the above embodiments. Before updating the offset information, whether the backup of the target virtual machine is completed or not can be judged. Specifically, in the step S101, after the target coroutine is detected, before the updating the offset information corresponding to the target virtual machine, the method may further include:
step 11: and judging whether the offset information is smaller than the data volume corresponding to the target virtual machine.
Because the data volume of the target virtual machine is limited, the data update needs to be stopped after the backup of the target virtual machine is completed. Therefore, after the target coordination process is detected, whether the offset information is smaller than the data volume corresponding to the target virtual machine is judged. If the offset information is less than the data volume, it indicates that part of the data is not backed up, and in this case, step 13 may be performed; if the offset information is not less than the data volume, it indicates that the target virtual machine has been completely backed up, in which case step 12 may be entered.
Step 12: and if the data volume is not smaller than the data volume corresponding to the target virtual machine, stopping updating the offset information.
If the offset information is not smaller than the data volume of the target virtual machine, all data of the target virtual machine are backed up, and at the moment, the virtual machine backup process can be stopped by stopping updating the offset information. Specifically, since the offset information is not updated, there is no data to be backed up, and thus the data to be backed up cannot be read or written.
It is to be understood that the above-described manner is only one specific manner for stopping the virtual machine backup process, and in practical applications, other manners may also be used to stop the virtual machine backup process. For example, the target coroutine may be closed after determining that the offset information is not less than the data volume, and the virtual machine backup process may be stopped in a manner of closing the coroutine.
Step 13: and if the data volume is smaller than the data volume corresponding to the target virtual machine, executing a step of updating the offset information corresponding to the target virtual machine.
If the offset information is smaller than the data volume, it indicates that there is still some data that is not backed up, so the step of updating the offset information corresponding to the target virtual machine may be performed, so as to backup the target virtual machine by using the target protocol.
By applying the virtual machine backup method provided by the embodiment of the application, the data of the target virtual machine may not be stored separately, but be connected with other data such as data of other virtual machines, for example, connected on a logical address, so that when the backup of the target virtual machine is performed by using multiple coroutines, whether the backup of the target virtual machine is completed or not can be judged by using the offset information, and the specific way is to compare the offset information with the data volume. When the offset information is not less than the data volume, it is indicated that all data of the target virtual machine has been backed up, so that updating of the target virtual machine can be finished by stopping updating the offset information, and data backup errors caused by taking other data as data of the target virtual machine are avoided.
Based on the foregoing embodiment, in a possible implementation manner, the backup of the target virtual machine is a full backup, that is, all data corresponding to the target virtual machine is backed up. In this case, the step of updating the offset information corresponding to the target virtual machine may include:
step 21: and if the target virtual machine is in a full backup state, determining a target reading threshold value of the target coroutine.
Before updating the offset information, the backup state of the target virtual machine may be determined. If the target virtual machine is in the full backup state, it indicates that the backup of the target virtual machine is the full backup, and this embodiment does not limit a specific confirmation manner of the state of the target virtual machine. For example, a status flag may be set, and the status flag may be used to identify the status of the target virtual machine, and the status flag may be in a digital form, or may be in another character form. For example, when the status flag bit is 1, it indicates that the target virtual machine is in the full backup state. The target reading threshold is a data reading unit corresponding to the target coroutine, and the specific size of the target reading threshold is not limited.
Step 22: the offset information is updated based on the target read threshold.
After the target virtual machine is determined to be in the full backup state, the offset information is updated based on the target reading threshold value. Since all data needs to be backed up, only the offset information needs to be updated in the order of backup. It can be appreciated that if the target virtual machine is backed up for the first time, then a full backup is required.
In another possible embodiment, the backup of the target virtual machine is an incremental backup, that is, not all data is backed up, but part of the data is backed up. The specific content of the part of data is not limited, and it is generally data that changes after the last backup, such as newly added data or modified data. In this case, the step of updating the offset information corresponding to the target virtual machine may include:
step 31: and if the target virtual machine is in the incremental backup state, determining a target reading threshold value of the target coroutine.
Under the condition that the target virtual machine is in an incremental backup state, a target reading threshold corresponding to the target coroutine also needs to be determined. Unlike full backup, at the time of incremental backup, the offset information needs to be updated based on an incremental bitmap (bitmap).
Step 32: and updating the offset information based on the target reading threshold and the incremental bitmap corresponding to the target virtual machine.
Specifically, the incremental bitmap is used to record data that needs to be backed up in the target virtual machine, for example, data that has been modified after the last backup, or data that is newly added after the last backup. It can be understood that the incremental backup is generally a non-initial backup, and after the initial backup, in order to reduce the time required for the subsequent backup process, data that has not changed may not be backed up, and only data that has changed may be backed up, so that data that needs to be backed up needs to be recorded by using the incremental bitmap. In a preferred embodiment, the incremental bitmap includes a plurality of flag bits, each flag bit corresponds to a unit of data, and a unit of data can be referred to as a cluster of data, which is also the minimum unit of data modification. The target reading threshold of each protocol is the same as the size of a cluster of data, so that the effect of backing up only the changed data can be realized.
When the offset information is updated, the updating is carried out based on the target reading threshold and the incremental bitmap, namely, the data part needing to be updated is determined according to the incremental bitmap, the data with the size of the target reading threshold is extracted from the data part as the data to be backed up after the data part is determined, and the offset information is updated based on the data. For example, when the offset information before updating is 256KB, each flag bit in the incremental bitmap corresponds to 256KB of data, the incremental bitmap is [1, 0, 1, 1, … ], and when updating the offset information, the incremental bitmap is used to determine the data to be backed up. Specifically, the offset information may be used to locate in the incremental bitmap, for example, when the offset information is 256KB, it is described that the determination of whether the backup is needed is performed from the second bit in the incremental bitmap. Since the second bit is 0, it can be determined that data of 257KB to 512KB does not need to be backed up, data of 513KB to 768KB needs to be backed up, the target read threshold is 256KB, and thus offset information can be updated to 768 KB. In another case, the target read threshold is 512KB, at which time the offset information can be updated to 1024 KB.
In another embodiment, the incremental bitmap may be updated after the offset information is updated, for example, the incremental bitmap is [1, 0, 1, 1, … ], and when the offset information is updated for the first time, the incremental bitmap is updated from 0 to 256KB, and at this time, the incremental bitmap may be updated to [0, 0, 1, 1, … ]. When the offset information is updated next time, the offset information does not need to be located in the incremental bitmap by using the current offset information, but can be directly screened from the first bit of the incremental bitmap, the 3 rd bit is detected to be 1, and the target reading threshold is 256KB, and then the offset information can be updated to 768 KB. In another case, the target read threshold is 512KB, at which time the offset information can be updated to 1024 KB.
By applying the virtual machine backup method provided by the embodiment of the application, the backup state of the target virtual machine can be determined when the offset information is updated, namely, the target virtual machine is judged to be in a full backup state or an incremental backup state. And selecting a proper mode to update the offset information according to the state of the target virtual machine, thereby meeting the requirements of full backup or incremental backup.
Based on the above embodiments, the incremental bitmap may be updated during the process of using incremental backup. In this case, the incremental bitmap may be backed up for data rollback in the event of a backup error. Specifically, the method may further include:
step 41: and backing up the incremental bitmap to obtain a backup bitmap.
The embodiment does not limit the specific way of backing up the incremental bitmap, for example, after the incremental bitmap is copied, a corresponding relationship between the bitmap obtained by copying and the incremental bitmap is generated, and after the corresponding relationship is generated and recorded, the bitmap obtained by copying is determined as the backup bitmap. It should be noted that step 41 should be performed before the backup is started, i.e. before the incremental bitmap is not updated.
Step 42: and if the virtual machine backup error is detected, performing data rollback operation by using the backup bitmap.
It should be noted that, the present embodiment does not limit the detection manner of whether the virtual machine backup error occurs, for example, it may detect whether each coroutine normally operates, and if there is a coroutine that does not normally operate, for example, data cannot be normally read or written, it is determined that the virtual machine backup error occurs. After a virtual machine backup error is detected, the backup needs to be restarted, and since the incremental bitmap has been updated in the previous backup process and some flag bits thereof have been modified, the problem of data inconsistency can be caused by continuing to perform backup by using the incremental bitmap. In order to avoid the above problem, data rollback may be performed using a previously obtained backup bitmap, that is, data rollback may be performed on the incremental bitmap, so that the state of the incremental bitmap before being updated is restored, so as to reuse the incremental bitmap for virtual machine backup. And the backup bitmap can be kept to perform data rollback operation again when the virtual machine backup error occurs again.
It should be noted that performing rollback after detecting a virtual machine backup error actually belongs to a virtual machine backup control operation. In other feasible embodiments, control operations such as monitoring of the running state of the program, cancelling backup of the virtual machine, limiting the speed of the backup, and the like may also be performed in coordination with the program, which is not limited in this embodiment.
By applying the virtual machine backup method provided by the embodiment of the application, the incremental bitmap can be backed up before incremental backup, so that after a virtual machine backup error occurs, the incremental bitmap is used for performing data rollback operation on the incremental bitmap, the incremental bitmap is reused for performing virtual machine backup, and the problem of data inconsistency is avoided.
Based on the above embodiment, in a feasible implementation manner, when the data to be backed up is written into the target location, the data to be backed up may be written into the buffer, and the data to be backed up is written into the target location by using the write coroutine, so as to implement read-write separation of the data to be backed up. Specifically, the step S103 may include:
step 51: and writing the data to be backed up into a buffer area by using the target coroutine.
The buffer may specifically be a ring buffer, which may be located in the cache for fast reading and writing. After the target coroutine reads the data to be backed up, the data to be backed up can be written into the buffer area, and the target coroutine can be in an idle state after being written into the buffer area so as to read the data again. The data to be backed up in the buffer area can be written by a plurality of writing routines, that is, the data to be backed up in the buffer area is written to the corresponding target position by a plurality of writing routines. The write coroutine operates in the same manner as the coroutine described above, except that the write coroutine reads data from the buffer and writes the data to the target location, and the coroutine reads data from the original storage location of the target virtual machine and writes the data to the buffer. By separating the read and write, the number of write coroutines and the number of coroutines can be flexibly set.
Step 52: and if the target write-in coroutine is detected, judging whether the buffer area has data to be backed up adjacent to the target position.
It should be noted that the target write protocol is a write protocol in which any one of the plurality of write protocols is in an idle state. The specific detection method of the target write-in coroutine may refer to a detection method of the target coroutine, and this embodiment is not described herein again. After the target write-in coroutine is detected, whether the data to be backed up adjacent to the target position exists in the buffer area can be judged. The target positions are adjacent, that is, the target position corresponding to one data to be backed up is end-to-end connected with the target position corresponding to another data to be backed up, for example, when one of the target positions is 0KB to 256KB and the other target position is 257KB to 512KB, the two target positions are adjacent.
Step 53: and if the data to be backed up adjacent to the target position exists, generating corresponding merged data, and writing the merged data into the target position by using the target writing protocol.
If the data to be backed up adjacent to the target position exists, the data can be merged to generate corresponding merged data, and the merged data is written into the target position by using the target writing protocol. By combining the data to be backed up, the small IO can be combined into the large IO, and the writing speed of the large IO is higher, so that the writing speed of the data to be backed up is higher. By increasing the writing speed, the virtual machine backup speed can be further increased under the condition that the virtual machine backup speed is limited by the writing speed, and the time required by virtual machine backup is reduced.
Step 54: and if the data to be backed up adjacent to the target position does not exist, writing any data to be backed up in the buffer area into the target position by using the target writing coroutine.
If the data to be backed up adjacent to the target position does not exist, any data to be backed up can be written into the target position by using the target writing protocol, and the writing of the data to be backed up is completed.
By applying the virtual machine backup method provided by the embodiment of the application, read-write separation can be performed on the virtual machine backup process by using the buffer area and the write-in coroutine, and corresponding merged data is generated when the data to be backed up adjacent to the target position is detected, so that the write-in speed is increased, and the virtual machine backup speed is increased.
Based on the above embodiment, when the target virtual machine is backed up, a modification instruction for modifying data of the target virtual machine may be acquired, and if the data corresponding to the modification instruction is backed up, the modification instruction may be directly executed; if the corresponding data is not backed up, in order to ensure data consistency, the part of data is locked and cannot be written, so that the modification instruction cannot be executed, and the modification instruction cannot be responded, which causes the problem of overlong response time. To solve the above problem, please refer to fig. 2, where fig. 2 is a flowchart of a modified instruction execution process provided by an embodiment of the present application, and the modified instruction execution process includes:
s201: and acquiring a modification instruction corresponding to the target data to be backed up.
The modification instruction may specifically be a data update instruction, that is, the target data to be backed up is updated, where the target data to be backed up is data that is already in the target virtual machine but has not yet been backed up. In another possible case, the modification instruction is specifically a data adding instruction, and at this time, the data to be backed up is data that the target virtual machine does not own yet, so that the data cannot be backed up.
S202: and generating secondary backup data corresponding to the target data to be backed up.
S203: and modifying the secondary backup data according to the modification instruction, and responding to the modification instruction.
After the modification instruction is acquired, in order to prevent the problem of data inconsistency from being directly executed, secondary backup data corresponding to target data to be backed up may be generated, and the modification instruction is executed on the secondary backup data, that is, the secondary backup data is modified according to the modification instruction. Specifically, when the target data to be backed up is data that is already existing in the target virtual machine but has not yet been backed up, the corresponding secondary backup data is the data itself, that is, after the data is copied, a modification instruction is executed on the secondary backup data obtained by copying. When the target data to be backed up is data which is not owned by the target virtual machine, the corresponding secondary backup data is blank data with the same size as the data, and the process of modifying the secondary backup data according to the modification instruction is the process of writing the target data to be backed up into the secondary backup data. After the secondary backup data is modified, the modification instruction can be responded, and the problem of overlong response time is avoided.
S204: after the target virtual machine finishes the backup, the secondary backup data is synchronized to the backup mirror image corresponding to the target virtual machine by using a plurality of coroutines.
After the target virtual machine finishes the backup, the secondary backup data can be synchronized to the backup mirror image by using a plurality of coroutines, and the execution of the modification instruction is completely finished. The specific process of synchronization is not described in detail in this embodiment, and reference may be made to the above embodiments.
By applying the virtual machine backup method provided by the embodiment of the application, the secondary backup data can be executed after the modification instruction for the target data to be backed up is obtained, so that the problems of overlong response time and inconsistent data are avoided, and the synchronization of the secondary backup data is performed after the backup of the target virtual machine is finished, so that the consistency of the data is ensured.
Through actual measurement, when a virtual machine backup test is performed by using a fio tool (an IO performance testing tool), the data reading speed of the related art is 70MB/s, and the data writing speed is 67 MB/s. Referring to fig. 3, fig. 3 is a diagram illustrating a read effect according to an embodiment of the present disclosure. When 8 IO depths are used for virtual machine backup, namely 8 coroutines are used for virtual machine backup, the data reading speed can reach 370 MB/s. Referring to fig. 4, fig. 4 is a diagram illustrating a write effect according to an embodiment of the present disclosure. When the virtual machine backup is carried out by using 8 IO depths, the data writing speed can reach 310 MB/s. The backup speed can be increased by 4-5 times. Referring to table 1, table 1 is a comparison table of the virtual machine backup speed and the cluster read speed, and it can be seen that, in the case of write-in without pressure, when the virtual machine backup is performed under multiple depths (i.e. under the case of multiple coroutines), the backup speed can almost reach the upper limit of the cluster read speed, and the performance of the cluster can be fully utilized.
TABLE 1 comparison table of backup speed and cluster read speed
4 depth (MB/s) 8 depth (MB/s) 16 depth (MB/s)
Reading a target virtual machine bare disk 199 270 368
Reading backup images 214 284 403
Backup speed 176 262 344
Based on the above embodiments, this embodiment will describe a specific virtual machine backup process. The whole process is as follows: the virtual machine provides an qmp interface (qemu monitor protocol) to the outside, the whole life cycle of the virtual machine instance can be managed through the interface, the backup mirror image is mounted as nbd equipment after the backup mirror image is created outside, and then the qmp interface of the virtual machine is called to trigger a backup task. And the virtual machine process creates a backup task, reads the disk data of the virtual machine, writes the data into the nbd device, and writes the data into the backup mirror image through the server side of the nbd device. Specifically, please refer to fig. 5, and fig. 5 is a flowchart of an initialization process according to an embodiment of the present disclosure. In this embodiment, qemu may be used to represent a virtual machine backup process, which includes only one thread. Before the virtual machine backup is performed, a backup mirror image may be created and mounted with nbd, so that the electronic device can read and write the backup mirror image, and specific creation and mounting processes may refer to related technologies and are not described herein. After a backup request is detected, i.e. when the backup request comes, a relevant initialization operation can be performed on the bitmap, i.e. the bitmap. For example, if the backup is incremental, the initialization operation may be to generate a backup bitmap; or if the backup is full, the initialization operation may be to generate a corresponding new bitmap. Of course, the initialization operation may also be other contents, which is not limited in this embodiment. After the initialization is finished, the management structure backupBlockJob can be initialized, so that the backupBlockJob originally only applicable to the single coroutine is applicable to the multi-coroutine. The specific initialization process is not limited, and for example, information such as a coroutine state, a current disk backup offset (i.e., offset information), and a coroutine lock may be added to manage the entire backup task. In one case, the initialized BackupBlockJob structure may be as follows:
Figure BDA0002807618000000161
Figure BDA0002807618000000171
after the BackupBlockJob structure is initialized, a backup main coroutine backup _ run, that is, a control coroutine, may be created, and may control the entire backup process, and specifically may control the backup process directly or through another coroutine (for example, a monitoring coroutine). Meanwhile, sf _ backup _ bitmap _ sync protocol can be created to operate the bitmap. And then creating a plurality of do _ backup _ co coroutines, namely coroutines, for performing specific read-write operation. And running all coroutines after the creation is finished, and for convenience of understanding, subsequently, referring the coroutines as child coroutines or backup IO processing coroutines and starting to perform virtual machine backup. And a plurality of subprograms, namely the do _ backup _ co subprogram, are created and are only responsible for IO reading and writing. The sub coroutines specify the current IO cluster address to be backed up through backup _ cluster _ offs (namely offset information) in the backup Block Job, and IO read requests can be submitted among the sub coroutines in sequence, so that the effect of multi-depth and sequential backup is realized.
Referring to fig. 6, fig. 6 is a flowchart illustrating a modified instruction execution process in a backup process according to an embodiment of the present disclosure. Firstly, a hot copy protocol callback is registered in a service IO write function, namely, the service IO is allowed to be executed (namely, a modification instruction) when the virtual machine is backed up. When a write IO request of a target virtual machine is acquired in a backup process, a hot copy protocol is created, whether a cluster corresponding to the write IO request is backed up or not is judged, and if the cluster is backed up, IO can be directly executed. If not, reading the written cluster data by IO and writing the cluster data into a temporary file, namely generating a corresponding secondary backup file, marking the part backed up by hbtmap (incremental bitmap) and executing IO on the secondary backup file. Which may be responded to after execution is complete.
Referring to fig. 7, fig. 7 is a flowchart of a control routine provided in an embodiment of the present application. In this embodiment, the control coroutine, i.e., the master coroutine, may monitor and control the entire backup process through the monitoring coroutine. Or the monitoring coroutine and the main coroutine jointly control the whole backup process. Specifically, when the initialization operation is performed, the service IO write request is registered to call back the function before _ write, so that the service IO is executed in the backup process. The hbtmap, i.e. the incremental bitmap, is initialized, which is specifically a read-only bitmap marking the backup areas. The monitoring protocol is executed, and it should be noted that the monitoring protocol do _ backup _ state _ monitor _ co in fig. 7 is not the above-mentioned control protocol, and is only used for monitoring the operating status of each protocol. After the monitoring protocol is executed, the backup is waited to be finished and the monitoring backup state is executed, and the control operation of limiting the backup speed and the like can be executed. Specifically, in the sub-coroutine execution process, the monitoring coroutine detects whether the current backup task has cancel operation, calculates the current backup speed and monitors the states of other sub-coroutines, and can also set related signal variables to inform other coroutines to execute corresponding operations. In the execution process of each subprogram, the IO state of the subprogram can be informed to the monitoring subprogram in a mode of setting corresponding signal variables, and relevant signals of the monitoring subprogram are detected to execute speed-limiting operation or quit backup in time. After the backup is finished, if the service IO is not executed in the backup process, after the backup is finished, qemu-nbd can be disconnected, namely, the mounted nbd device is disconnected, the backup _ complete cleaning operation is executed, and the virtual machine backup process is finished. If the service IO is executed or the temporary file is found to exist in the backup _ complete cleaning operation, the data of the temporary file in the hot standby process may be written into the backup image and then the qemu-nbd is disconnected, and the backup _ complete cleaning operation is executed.
Referring to fig. 8, fig. 8 is a flowchart illustrating a monitoring routine according to an embodiment of the present disclosure. The monitoring coroutine do _ backup _ state _ monitor _ co can release a coroutine lock according to the requirement of the control coroutine, and allow each backup IO processing coroutine to run, thereby ensuring that the main coroutine initializes each condition successfully and then performs IO backup. In the operation process, whether the operation state of each subprogram (namely the backup IO processing corogram) is normal or not is detected. If the backup task is normal, whether a backup task canceling signal exists is detected, and if the backup task canceling signal does not exist, whether all the subprograms are operated to be finished (for example, whether all the subprograms are in an idle state) is detected. If not, and if the backup speed limit is needed, the operator coroutine can be paused for a long time according to the backup speed limit value, and the backup speed is controlled by adding a coroutine lock to the subroutine. After the above process is completed, the monitoring coroutine may be switched out temporarily, i.e. the work is stopped temporarily, the switching-out duration is the detection period, and if the switching-out duration is 4ms, the detection period is 4 ms. If the subprogram state is wrong, or a backup task canceling signal exists, or all the subprograms are already working and finished, all the subprograms can be notified to quit and wait for the execution to finish (i.e. successfully quit). And then detecting the final execution state of each subprogram, judging whether the backup is successfully completed or not, namely judging whether the backup is normally completed or not, if the state of each subprogram is abnormal, if the state of each subprogram is 1, the running is performed, the task fails, and if the states are normal, the task is normally completed and the task is successful. The result is fed back to the master coroutine backup _ run so as to execute subsequent operations.
Specifically, the backup cancellation logic, that is, the process of canceling the virtual machine backup task, may be: the external part sets the backup jobstate to cancel (i.e., cancel) by calling the qmp interface. And detecting the state of the jobs (namely judging whether a backup task canceling signal is detected) in the process of monitoring coroutine running, exiting the cycle after detecting the canceling state, and informing the subprocess to exit. And detecting a monitoring coroutine notification exit signal in the subprocess loop running process, and if the monitoring coroutine notification exit signal is detected, exiting the loop by the subprocess. If the sub-coroutine running state is abnormal, namely an IO error occurs in the sub-coroutine executing IO operation process, the sub-coroutine exits, meanwhile, the sub-coroutine state corresponding to the sub-coroutine is modified, and the IO abnormality is marked. And if the monitoring coroutine detects that the IO exception occurs in the subprocess, exiting the cycle and informing other subprocesses to exit. And after all the subprograms exit, the main subprogram executes bitmap rollback processing, namely the incremental bitmap is rolled back by using the backup bitmap, the backup task exits, and the backup fails.
Further, when backup speed limit needs to be carried out, the monitoring coroutine counts the backup data volume in the current speed limit time window, calculates the time that the subprocess needs yield (namely, switching-out and stopping working), and adds a coroutine lock to the subprocess before yield so that the yield reaches the specified time. Before the sub-coroutine executes IO backup, coroutine read lock is required to be added, locking success indicates that the current monitoring coroutine does not require speed limiting, IO backup can be carried out, locking failure indicates that the current monitoring coroutine informs to limit speed, and the IO backup coroutine keeps yield until locking is successful, so that speed limiting is carried out on a backup task. The purpose of limiting the speed is to limit the speed of the backup speed of the virtual machine under certain conditions, so as to avoid the influence on the normal service of the virtual machine caused by the fact that the backup process occupies too large storage performance.
Referring to fig. 9, fig. 9 is a flowchart illustrating a coroutine workflow according to an embodiment of the present disclosure. After each do _ backup _ co coroutine, namely the backup IO processing coroutine is created, the monitoring coroutine is waited to start running and the coroutine lock is released. Firstly, whether the main coroutine notifies to quit the backup or not is detected, specifically, a backup task canceling signal can be sent out by the main coroutine through a monitoring coroutine, if so, a subprocess state is quitted and set, so that the monitoring coroutine can judge a final backup execution result. If the backup is not informed, the view is locked, if the speed limit occurs, the lock cannot be successfully locked, and if the read lock is successfully locked, the offset information, namely backup _ cluster _ offs, can be backed up so as to determine the data to be backed up. And then modifying the offset information, determining the data to be backed up (namely the data with the current offset) after the modification is finished, and backing up the data, namely reading the data and writing the data. And after the work is finished, judging whether the disk backup is finished or not, namely judging whether the virtual machine backup is finished or not. If the backup task is finished, exiting the current subprogram and setting the subprogram state, and if the backup task is not finished, re-executing the detection of whether exiting the backup task.
In the following, the virtual machine backup apparatus provided in the embodiment of the present application is introduced, and the virtual machine backup apparatus described below and the virtual machine backup method described above may be referred to correspondingly.
Referring to fig. 10, fig. 10 is a schematic structural diagram of a virtual machine backup device according to an embodiment of the present application, including:
an updating module 110, configured to update offset information corresponding to the target virtual machine if the target coroutine is detected; the target coroutine is a coroutine in an idle state in any one of the coroutines;
a reading module 120, configured to read, based on the offset information, corresponding data to be backed up by using a target protocol;
and a writing module 130, configured to write the data to be backed up into the target location by using the target coroutine.
Optionally, the updating module 110 includes:
the first threshold value determining unit is used for determining a target reading threshold value of the target coroutine if the target virtual machine is in a full backup state;
a first updating unit for updating the offset information based on the target read threshold.
Optionally, the updating module 110 includes:
the second threshold determining unit is used for determining a target reading threshold of the target coroutine if the target virtual machine is in an incremental backup state;
and the second updating unit is used for updating the offset information based on the target reading threshold and the incremental bitmap corresponding to the target virtual machine.
Optionally, the method further comprises:
the bitmap backup module is used for backing up the incremental bitmap to obtain a backup bitmap;
and the rollback module is used for performing data rollback operation by using the backup bitmap if the virtual machine backup error is detected.
Optionally, the method further comprises:
the modification instruction acquisition module is used for acquiring a modification instruction corresponding to the target data to be backed up;
the secondary backup module is used for generating secondary backup data corresponding to the target data to be backed up;
the modification instruction execution module is used for modifying the secondary backup data according to the modification instruction and responding to the modification instruction;
and the synchronization module is used for synchronizing the secondary backup data to the backup mirror image corresponding to the target virtual machine by utilizing a plurality of coroutines after the backup of the target virtual machine is finished.
Optionally, the method further comprises:
the volume judgment module is used for judging whether the offset information is smaller than the data volume corresponding to the target virtual machine;
the updating stopping module is used for stopping updating the offset information if the data volume is not smaller than the data volume corresponding to the target virtual machine;
correspondingly, the updating module 110 is a module that updates the offset information corresponding to the target virtual machine if the target corotation is detected and the offset information is smaller than the data volume corresponding to the target virtual machine.
Optionally, the writing module 130 includes:
the buffer area writing unit is used for writing the data to be backed up into the buffer area by using the target coroutine;
the adjacent judgment unit is used for judging whether the data to be backed up adjacent to the target position exists in the buffer area or not if the target write-in coroutine is detected; the target write protocol is a write protocol in an idle state in any one of the plurality of write protocols;
the merging and writing unit is used for generating corresponding merging data if the data to be backed up adjacent to the target position exists, and writing the merging data into the target position by using a target writing protocol;
and the direct writing unit is used for writing any data to be backed up in the buffer into the target position by using the target writing coroutine if the data to be backed up adjacent to the target position does not exist.
In the following, the electronic device provided by the embodiment of the present application is introduced, and the electronic device described below and the virtual machine backup method described above may be referred to correspondingly.
Referring to fig. 11, fig. 11 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure. Wherein the electronic device 100 may include a processor 101 and a memory 102, and may further include one or more of a multimedia component 103, an information input/information output (I/O) interface 104, and a communication component 105.
The processor 101 is configured to control overall operations of the electronic device 100 to complete all or part of the steps in the virtual machine backup method; the memory 102 is used to store various types of data to support operation at the electronic device 100, such data may include, for example, instructions for any application or method operating on the electronic device 100, as well as application-related data. The Memory 102 may be implemented by any type or combination of volatile and non-volatile Memory devices, such as one or more of Static Random Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read-Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (ROM), magnetic Memory, flash Memory, magnetic or optical disk.
The multimedia component 103 may include a screen and an audio component. Wherein the screen may be, for example, a touch screen and the audio component is used for outputting and/or inputting audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signal may further be stored in the memory 102 or transmitted through the communication component 105. The audio assembly also includes at least one speaker for outputting audio signals. The I/O interface 104 provides an interface between the processor 101 and other interface modules, such as a keyboard, mouse, buttons, etc. These buttons may be virtual buttons or physical buttons. The communication component 105 is used for wired or wireless communication between the electronic device 100 and other devices. Wireless Communication, such as Wi-Fi, bluetooth, Near Field Communication (NFC), 2G, 3G, or 4G, or a combination of one or more of them, so that the corresponding Communication component 105 may include: Wi-Fi part, Bluetooth part, NFC part.
The electronic Device 100 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components, and is configured to perform the virtual machine backup method according to the above embodiments.
In the following, a computer-readable storage medium provided by an embodiment of the present application is introduced, and the computer-readable storage medium described below and the virtual machine backup method described above may be referred to correspondingly.
The present application further provides a computer-readable storage medium, on which a computer program is stored, and the computer program, when executed by a processor, implements the steps of the virtual machine backup method described above.
The computer-readable storage medium may include: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The embodiments are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same or similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description.
Those of skill would further appreciate that the various illustrative components and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
Finally, it should also be noted that, herein, relationships such as first and second, etc., are intended only to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms include, or any other variation is intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that includes a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus.
The principle and the implementation of the present application are explained herein by applying specific examples, and the above description of the embodiments is only used to help understand the method and the core idea of the present application; meanwhile, for a person skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.

Claims (10)

1. A virtual machine backup method is characterized by comprising the following steps:
if the target coroutine is detected, updating offset information corresponding to the target virtual machine; the target coroutine is the coroutine in an idle state in any one of a plurality of coroutines;
based on the offset information, reading corresponding data to be backed up by using the target protocol;
and writing the data to be backed up into a target position by using the target coroutine.
2. The virtual machine backup method according to claim 1, wherein the updating offset information corresponding to the target virtual machine includes:
if the target virtual machine is in a full backup state, determining a target reading threshold value of the target coroutine;
updating the offset information based on the target read threshold.
3. The virtual machine backup method according to claim 1, wherein the updating offset information corresponding to the target virtual machine includes:
if the target virtual machine is in an incremental backup state, determining a target reading threshold value of the target coroutine;
and updating the offset information based on the target reading threshold and the incremental bitmap corresponding to the target virtual machine.
4. The virtual machine backup method according to claim 3, further comprising:
backing up the incremental bitmap to obtain a backup bitmap;
and if the virtual machine backup error is detected, performing data rollback operation by using the backup bitmap.
5. The virtual machine backup method according to claim 1, further comprising:
acquiring a modification instruction corresponding to target data to be backed up;
generating secondary backup data corresponding to the target data to be backed up;
modifying the secondary backup data according to the modification instruction, and responding to the modification instruction;
after the target virtual machine finishes the backup, synchronizing the secondary backup data to a backup mirror image corresponding to the target virtual machine by using a plurality of coroutines.
6. The virtual machine backup method according to claim 1, wherein after detecting the target coroutine, before updating the offset information corresponding to the target virtual machine, further comprising:
judging whether the offset information is smaller than the data volume corresponding to the target virtual machine or not;
if not, stopping updating the offset information;
and if so, executing the step of updating the offset information corresponding to the target virtual machine.
7. The virtual machine backup method according to any one of claims 1 to 6, wherein the writing the data to be backed up to a target location by using the target coroutine includes:
writing the data to be backed up into a buffer area by using the target coroutine;
if the target write-in coroutine is detected, judging whether the buffer area has data to be backed up adjacent to the target position; the target write protocol is the write protocol in which any one of a plurality of write protocols is in an idle state;
if the data to be backed up adjacent to the target position exists, generating corresponding merged data, and writing the merged data into the target position by using the target writing protocol;
and if the data to be backed up adjacent to the target position does not exist, writing any one of the data to be backed up in the buffer area into the target position by using the target writing coroutine.
8. A virtual machine backup apparatus, comprising:
the updating module is used for updating the offset information corresponding to the target virtual machine if the target coroutine is detected; the target coroutine is the coroutine in an idle state in any one of a plurality of coroutines;
the reading module is used for reading corresponding data to be backed up by using the target protocol based on the offset information;
and the writing module is used for writing the data to be backed up into a target position by using the target coroutine.
9. An electronic device comprising a memory and a processor, wherein:
the memory is used for storing a computer program;
the processor, configured to execute the computer program to implement the virtual machine backup method according to any one of claims 1 to 7.
10. A computer-readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the virtual machine backup method of any one of claims 1 to 7.
CN202011373888.5A 2020-11-30 2020-11-30 Virtual machine backup method and device, electronic equipment and readable storage medium Active CN112395050B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011373888.5A CN112395050B (en) 2020-11-30 2020-11-30 Virtual machine backup method and device, electronic equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011373888.5A CN112395050B (en) 2020-11-30 2020-11-30 Virtual machine backup method and device, electronic equipment and readable storage medium

Publications (2)

Publication Number Publication Date
CN112395050A true CN112395050A (en) 2021-02-23
CN112395050B CN112395050B (en) 2024-02-23

Family

ID=74605639

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011373888.5A Active CN112395050B (en) 2020-11-30 2020-11-30 Virtual machine backup method and device, electronic equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN112395050B (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111104206A (en) * 2019-12-25 2020-05-05 曙光信息产业(北京)有限公司 Virtual machine storage migration method and device and computer equipment
CN113254268A (en) * 2021-05-20 2021-08-13 深信服科技股份有限公司 Data processing method and device, equipment and storage medium
CN118035004A (en) * 2024-04-10 2024-05-14 深圳市科力锐科技有限公司 Data synchronization method, storage medium and device
CN118035004B (en) * 2024-04-10 2024-06-25 深圳市科力锐科技有限公司 Data synchronization method, storage medium and device

Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090113109A1 (en) * 2007-10-26 2009-04-30 Vmware, Inc. Using Virtual Machine Cloning To Create a Backup Virtual Machine in a Fault Tolerant System
CN101609419A (en) * 2009-06-29 2009-12-23 北京航空航天大学 The data back up method and the device of the migration of virtual machine consistently online
WO2017132872A1 (en) * 2016-02-03 2017-08-10 华为技术有限公司 Virtual machine backup method, backup device and host
CN107329812A (en) * 2017-06-09 2017-11-07 腾讯科技(深圳)有限公司 A kind of method and apparatus for running association's journey
CN109298977A (en) * 2018-10-19 2019-02-01 深信服科技股份有限公司 A kind of virtual machine business quick recovery method, system, device and storage medium
CN109471699A (en) * 2018-10-29 2019-03-15 北京京航计算通讯研究所 The virtual machine incremental backup system of difference bitmap characteristic based on Qcow2 image file
US20190213104A1 (en) * 2018-01-08 2019-07-11 Microsoft Technology Licensing, Llc Cloud validation as a service
CN111061690A (en) * 2019-11-22 2020-04-24 武汉达梦数据库有限公司 RAC-based database log file reading method and device
CN111078436A (en) * 2019-12-18 2020-04-28 上海金仕达软件科技有限公司 Data processing method, device, equipment and storage medium
CN111078357A (en) * 2019-11-29 2020-04-28 苏州浪潮智能科技有限公司 Virtual machine backup method and equipment
CN111417931A (en) * 2017-11-30 2020-07-14 华睿泰科技有限责任公司 Performing backup operations using a copy
US20200241908A1 (en) * 2019-01-30 2020-07-30 Commvault Systems, Inc. Cross-hypervisor live mount of backed up virtual machine data, including management of cache storage for virtual machine data

Patent Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090113109A1 (en) * 2007-10-26 2009-04-30 Vmware, Inc. Using Virtual Machine Cloning To Create a Backup Virtual Machine in a Fault Tolerant System
CN101609419A (en) * 2009-06-29 2009-12-23 北京航空航天大学 The data back up method and the device of the migration of virtual machine consistently online
WO2017132872A1 (en) * 2016-02-03 2017-08-10 华为技术有限公司 Virtual machine backup method, backup device and host
CN107329812A (en) * 2017-06-09 2017-11-07 腾讯科技(深圳)有限公司 A kind of method and apparatus for running association's journey
CN111417931A (en) * 2017-11-30 2020-07-14 华睿泰科技有限责任公司 Performing backup operations using a copy
US20190213104A1 (en) * 2018-01-08 2019-07-11 Microsoft Technology Licensing, Llc Cloud validation as a service
CN109298977A (en) * 2018-10-19 2019-02-01 深信服科技股份有限公司 A kind of virtual machine business quick recovery method, system, device and storage medium
CN109471699A (en) * 2018-10-29 2019-03-15 北京京航计算通讯研究所 The virtual machine incremental backup system of difference bitmap characteristic based on Qcow2 image file
US20200241908A1 (en) * 2019-01-30 2020-07-30 Commvault Systems, Inc. Cross-hypervisor live mount of backed up virtual machine data, including management of cache storage for virtual machine data
CN111061690A (en) * 2019-11-22 2020-04-24 武汉达梦数据库有限公司 RAC-based database log file reading method and device
CN111078357A (en) * 2019-11-29 2020-04-28 苏州浪潮智能科技有限公司 Virtual machine backup method and equipment
CN111078436A (en) * 2019-12-18 2020-04-28 上海金仕达软件科技有限公司 Data processing method, device, equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
龚玮玮等: "基于Oracle 11g的备份恢复策略的研究与实现", 《电脑知识与技术 》 *

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111104206A (en) * 2019-12-25 2020-05-05 曙光信息产业(北京)有限公司 Virtual machine storage migration method and device and computer equipment
CN111104206B (en) * 2019-12-25 2023-09-01 曙光信息产业(北京)有限公司 Virtual machine storage migration method and device and computer equipment
CN113254268A (en) * 2021-05-20 2021-08-13 深信服科技股份有限公司 Data processing method and device, equipment and storage medium
CN113254268B (en) * 2021-05-20 2024-05-24 深信服科技股份有限公司 Data processing method and device, equipment and storage medium
CN118035004A (en) * 2024-04-10 2024-05-14 深圳市科力锐科技有限公司 Data synchronization method, storage medium and device
CN118035004B (en) * 2024-04-10 2024-06-25 深圳市科力锐科技有限公司 Data synchronization method, storage medium and device

Also Published As

Publication number Publication date
CN112395050B (en) 2024-02-23

Similar Documents

Publication Publication Date Title
JP4321705B2 (en) Apparatus and storage system for controlling acquisition of snapshot
US10268695B2 (en) Snapshot creation
TWI608419B (en) Method for pre-testing software compatibility and system thereof
EP2849048B1 (en) Data sending method, data receiving method and storage device
CN108932338B (en) Data updating method, device, equipment and medium
US8127174B1 (en) Method and apparatus for performing transparent in-memory checkpointing
TWI575362B (en) Backup method, pre-testing method for enviornment updating and system thereof
CN110543386B (en) Data storage method, device, equipment and storage medium
US20150278046A1 (en) Methods and systems to hot-swap a virtual machine
US7865782B2 (en) I/O device fault processing method for use in virtual computer system
JP2011060055A (en) Virtual computer system, recovery processing method and of virtual machine, and program therefor
CN112395050A (en) Virtual machine backup method and device, electronic equipment and readable storage medium
CN110807064A (en) Data recovery device in RAC distributed database cluster system
CN110825562B (en) Data backup method, device, system and storage medium
US20160266924A1 (en) Apparatus and method for identifying a virtual machine having changeable settings
US20150186059A1 (en) Memory management program, memory management method, and memory management device
US7970736B2 (en) System, method and computer program product for storing transient state information
JP2007140777A (en) Computer system, management computer and data recovery method
CN112199240A (en) Method for switching nodes during node failure and related equipment
CN109324549B (en) Dual-master control equipment configuration method and dual-master control equipment
CN115495278B (en) Exception repair method, device and storage medium
CN114461341A (en) Method, device and medium for preventing brain crack of cloud platform virtual machine
US20210049240A1 (en) Highly available policy agent for backup and restore operations
CN116578446B (en) Virtual machine backup method, device and system, electronic equipment and storage medium
CN114138557B (en) Consistency test method and device for rollback data of stored snapshot

Legal Events

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