Data synchronization method and device of virtual machine and computer program product

By monitoring the amount and time of dirty data in the virtual machine, and using preset synchronization to trigger threads to synchronize dirty data, the problem of difficult to control downtime during virtual machine data synchronization is solved and fault tolerance performance is improved.

CN118550644APending Publication Date: 2024-08-27AVIC GOLD NETWORK (BEIJING) TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410675134.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-28
Publication Date
2024-08-27

AI Technical Summary

Technical Problem

When virtual machines perform data synchronization, the downtime of the virtual machines cannot be effectively controlled, resulting in service lags or interruptions.

Method used

By monitoring the amount of dirty data and synchronization time of the primary virtual machine, the preset synchronization trigger thread is used to trigger the synchronization thread to synchronize dirty data to the standby virtual machine when the amount or time of dirty data reaches the threshold, and the size of dirty data is controlled to limit downtime.

Benefits of technology

It realizes the control of downtime during the virtual machine data synchronization process, avoids business freezes and interruptions, and improves fault tolerance performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118550644A
    Figure CN118550644A
Patent Text Reader

Abstract

The invention discloses a data synchronization method and device of a virtual machine and a computer program product. The method comprises the steps that a preset synchronous triggering thread of a main virtual machine is monitored, the preset synchronous triggering thread at least comprises a dirty data counting thread used for counting the number of dirty data in the main virtual machine, and synchronous triggering conditions at least comprise a first synchronous triggering condition representing that the number of the dirty data is larger than a preset dirty data threshold value; and under the condition that the preset synchronous triggering thread meets the synchronous triggering condition, pulling up the synchronous thread to synchronize the dirty data to the standby virtual machine. According to the method and the device, the technical problem that the downtime of the virtual machine cannot be controlled under the condition that the virtual machine performs data synchronization is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computers, and in particular to a data synchronization method and device for a virtual machine, and a computer program product. Background Art

[0002] FT (Fault Tolorance), also known as fault-tolerant technology, is a solution to ensure that the virtual machine business running on the host is not interrupted. The technical principle is to use the real-time synchronization function of the primary and standby virtual machines running on two physical hosts. When the physical host where the primary virtual machine is located loses power or restarts abnormally, the auxiliary virtual machine can immediately take over the virtual machine business to ensure that the virtual machine is not interrupted.

[0003] Therefore, fault-tolerant technology requires synchronization between the primary and standby virtual machines according to a strategy. The synchronized data mainly includes the virtual machine's memory, disk io, network data, and virtual machine status data. The synchronization mainly sends the virtual machine dirty data to the synchronization thread in the primary virtual machine.

[0004] Currently, the industry's synchronization strategy combines the two synchronization modes of scheduled synchronization and network consistency comparison. Each time the condition for sending dirty data is triggered, the synchronization thread of the primary virtual machine will stop the virtual machine, and then send the dirty data to the backup virtual machine. After the backup virtual machine successfully receives the data, it returns a completion signal, and the primary virtual machine starts the virtual machine to continue running.

[0005] However, due to network bandwidth limitations, as the CPU utilization of the virtual machine increases and the memory of the virtual machine increases, the amount of dirty data synchronized at one time increases. The longer the primary virtual machine is stopped, the greater the impact on FT performance (the virtual machine cannot run during the stop period). If the stop time of the virtual machine cannot be controlled during a single synchronization, the virtual machine business will be stuck for a long time or even interrupted.

[0006] Currently, no effective solution has been proposed for the above-mentioned problem that the downtime of the virtual machine cannot be controlled when the virtual machine is performing data synchronization. Summary of the invention

[0007] The embodiments of the present invention provide a method, an apparatus and a computer program product for synchronizing data of a virtual machine, so as to at least solve the technical problem that the downtime of the virtual machine cannot be controlled when the virtual machine performs data synchronization.

[0008] According to one aspect of an embodiment of the present invention, a data synchronization method for a virtual machine is provided, comprising: monitoring a preset synchronization trigger thread of the primary virtual machine, wherein the preset synchronization trigger thread at least comprises: the dirty data statistics thread, used to count the number of dirty data in the primary virtual machine, and the synchronization trigger condition at least comprises: a first synchronization trigger condition indicating that the number of dirty data is greater than a preset dirty data threshold; when the preset synchronization trigger thread satisfies the synchronization trigger condition, starting the synchronization thread to synchronize the dirty data to the standby virtual machine.

[0009] Optionally, the preset synchronization trigger thread also includes: a network packet comparison thread, used to compare the network packets of the primary virtual machine and the standby virtual machine, wherein the network packet comparison thread and the dirty data statistics thread are executed separately, and the synchronization trigger condition also includes: a second synchronization condition indicating that the network packets of the primary virtual machine and the standby virtual machine are inconsistent; when the preset synchronization trigger thread satisfies the synchronization trigger condition, pulling up the synchronization thread to synchronize the dirty data to the standby virtual machine includes: when the dirty data statistics thread satisfies the first synchronization trigger condition, or the network packet comparison thread satisfies the second synchronization condition, pulling up the synchronization thread to synchronize the dirty data to the standby virtual machine.

[0010] Optionally, the preset synchronization trigger thread also includes: a timing thread, used to monitor the synchronization time of the primary virtual machine, wherein the timing thread and the dirty data statistics thread are executed separately; the synchronization trigger condition also includes: a third synchronization trigger condition indicating that the synchronization time reaches a preset time threshold; when the preset synchronization trigger thread satisfies the synchronization trigger condition, pulling up the synchronization thread to synchronize the dirty data to the standby virtual machine includes: when the dirty data statistics thread satisfies the first synchronization trigger condition, or the timing thread satisfies the third synchronization condition, pulling up the synchronization thread to synchronize the dirty data to the standby virtual machine.

[0011] Optionally, when the preset synchronization trigger thread satisfies the synchronization trigger condition, after starting the synchronization thread to synchronize the dirty data to the standby virtual machine, the method further includes: clearing the amount of dirty data counted by the dirty data statistics thread.

[0012] Optionally, the synchronization thread includes: a synchronization sending thread in the primary virtual machine, and a synchronization receiving thread in the standby virtual machine. When the preset synchronization trigger thread satisfies the synchronization trigger condition, pulling up the synchronization thread to synchronize the dirty data to the standby virtual machine includes: when the preset synchronization trigger thread satisfies the synchronization trigger condition, controlling the primary virtual machine to shut down, and sending the dirty data to the synchronization receiving thread through the synchronization sending thread.

[0013] According to another aspect of an embodiment of the present invention, a data synchronization method for a virtual machine is also provided, including: starting a dirty data statistics thread to count the number of dirty data in a primary virtual machine; when the number of dirty data is greater than a preset dirty data threshold, starting a synchronization thread to synchronize the dirty data to a backup virtual machine.

[0014] Optionally, when the amount of dirty data is greater than a preset dirty data threshold, after starting the synchronization thread to synchronize the dirty data to the standby virtual machine, the method further includes: clearing the amount of dirty data counted by the dirty data statistics thread.

[0015] Optionally, before clearing the amount of dirty data counted by the dirty data statistics thread, the method further includes: starting a network packet comparison thread to compare the network packets of the primary virtual machine and the backup virtual machine, wherein the network packet comparison thread and the dirty data statistics thread are executed separately; when the network packets of the primary virtual machine and the backup virtual machine are inconsistent, starting a synchronization thread to synchronize the dirty data to the backup virtual machine.

[0016] Optionally, before clearing the amount of dirty data counted by the dirty data statistics thread, the method also includes: starting a timing thread to monitor the synchronization time of the primary virtual machine, wherein the timing thread and the dirty data statistics thread are executed separately; when the synchronization time reaches a preset time threshold, starting the synchronization thread to synchronize the dirty data to the backup virtual machine.

[0017] According to another aspect of an embodiment of the present invention, a data synchronization device for a virtual machine is also provided, including: a monitoring module, used to monitor a preset synchronization trigger thread of the primary virtual machine, wherein the preset synchronization trigger thread at least includes: the dirty data statistics thread, used to count the number of dirty data in the primary virtual machine, and the synchronization trigger condition at least includes: a first synchronization trigger condition indicating that the number of dirty data is greater than a preset dirty data threshold; a first synchronization module, used to pull up the synchronization thread to synchronize the dirty data to the standby virtual machine when the preset synchronization trigger thread meets the synchronization trigger condition.

[0018] According to another aspect of an embodiment of the present invention, a data synchronization device for a virtual machine is also provided, including: a first start-up module, used to start a dirty data statistics thread to count the number of dirty data in a primary virtual machine; a second synchronization module, used to pull up a synchronization thread to synchronize the dirty data to a backup virtual machine when the number of dirty data is greater than a preset dirty data threshold.

[0019] According to another aspect of an embodiment of the present invention, a non-volatile storage medium is provided, in which a computer program is stored, wherein the data synchronization method of the virtual machine is executed by running the computer program on the device where the non-volatile storage medium is located.

[0020] According to another aspect of an embodiment of the present invention, there is further provided an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the above-mentioned virtual machine data synchronization method through the computer program.

[0021] According to another aspect of an embodiment of the present invention, a computer program product is provided, including computer instructions, which implement the steps of the above-mentioned virtual machine data synchronization method when executed by a processor.

[0022] In an embodiment of the present invention, the number of dirty data in the primary virtual machine is counted through a dirty data statistics thread. When the number of dirty data counted by the dirty data statistics thread is greater than a preset dirty data threshold, a synchronization thread is started to synchronize the dirty data to the standby virtual machine. This can achieve the technical effect of controlling the downtime of the virtual machine when the virtual machine is performing data synchronization by controlling the size of the dirty data, thereby solving the technical problem of being unable to control the downtime of the virtual machine when the virtual machine is performing data synchronization. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0024] Figure 1 The following is a flow chart of a method for synchronizing data of a virtual machine according to an embodiment of the present invention. Figure 1 ;

[0025] Figure 2 The following is a flow chart of a method for synchronizing data of a virtual machine according to an embodiment of the present invention. Figure 2 ;

[0026] Figure 3 is a schematic diagram of a virtual machine fault tolerance structure according to an embodiment of the present invention;

[0027] Figure 4 is a schematic diagram of a virtual machine synchronization timing according to an embodiment of the present invention;

[0028] Figure 5 is a schematic diagram of a virtual machine synchronization process according to an embodiment of the present invention;

[0029] Figure 6A schematic diagram of a data synchronization device for a virtual machine according to an embodiment of the present invention Figure 1 ;

[0030] Figure 7 A schematic diagram of a data synchronization device for a virtual machine according to an embodiment of the present invention Figure 2 ;

[0031] Figure 8 It is a structural block diagram of a computer terminal according to an embodiment of the present invention. DETAILED DESCRIPTION

[0032] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0033] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0034] First, some nouns or terms that appear in the description of the embodiments of the present application are subject to the following explanations:

[0035] FT: Fault Tolorance, fault-tolerant technology.

[0036] PVM: primary virtual machine, primary virtual machine.

[0037] SVM: secondary virtual machine, backup virtual machine.

[0038] Dirty pages: Memory that is inconsistent between the primary and standby virtual machines and needs to be synchronized from the primary virtual machine to the standby virtual machine.

[0039] Dirty page threshold: A configuration value that sets the upper limit of dirty pages. It can be set and modified in the configuration file.

[0040] Virtual machine stop: A virtual machine is in a stopped state and cannot respond to external events. The internal services of the virtual machine are in a stopped state.

[0041] According to an embodiment of the present invention, an embodiment of a data synchronization method for a virtual machine is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0042] Figure 1 The following is a flow chart of a method for synchronizing data of a virtual machine according to an embodiment of the present invention. Figure 1 ,like Figure 1 As shown, the method comprises the following steps:

[0043] Step S102, monitoring a preset synchronization trigger thread of the master virtual machine, wherein the preset synchronization trigger thread at least includes: a dirty data counting thread, used to count the number of dirty data in the master virtual machine, and the synchronization trigger condition at least includes: a first synchronization trigger condition indicating that the number of dirty data is greater than a preset dirty data threshold;

[0044] Step S104: when the preset synchronization triggering thread meets the synchronization triggering condition, start the synchronization thread to synchronize dirty data to the standby virtual machine.

[0045] In an embodiment of the present invention, the number of dirty data in the primary virtual machine is counted through a dirty data statistics thread. When the number of dirty data counted by the dirty data statistics thread is greater than a preset dirty data threshold, a synchronization thread is started to synchronize the dirty data to the standby virtual machine. This can achieve the technical effect of controlling the downtime of the virtual machine when the virtual machine is performing data synchronization by controlling the size of the dirty data, thereby solving the technical problem of being unable to control the downtime of the virtual machine when the virtual machine is performing data synchronization.

[0046] In the above step S102, dirty data at least includes dirty pages, and the preset dirty data threshold at least includes a dirty page threshold.

[0047] It should be noted that in the above-mentioned virtual machine data synchronization method, the master virtual machine responds to external data and generates dirty data, wherein the external data may be user interaction data or network data received from the network.

[0048] In the above step S104, after the synchronization thread is started to synchronize the dirty data to the standby virtual machine, the primary virtual machine can respond to the external data again to generate new dirty data.

[0049] In the above step S104, the standby virtual machine is used to receive synchronization data synchronized from the primary virtual machine, wherein the synchronization data at least includes dirty data synchronized by the primary virtual machine; the standby virtual machine does not respond to external data, wherein the external data does not include synchronization data from the primary virtual machine.

[0050] As an optional embodiment, the preset synchronization trigger thread also includes: a network packet comparison thread, used to compare network packets of the primary virtual machine and the standby virtual machine, wherein the network packet comparison thread and the dirty data statistics thread are executed separately, and the synchronization trigger condition also includes: a second synchronization condition indicating that the network packets of the primary virtual machine and the standby virtual machine are inconsistent; when the preset synchronization trigger thread satisfies the synchronization trigger condition, pulling up the synchronization thread to synchronize dirty data to the standby virtual machine includes: when the dirty data statistics thread satisfies the first synchronization trigger condition, or the network packet comparison thread satisfies the second synchronization condition, pulling up the synchronization thread to synchronize dirty data to the standby virtual machine.

[0051] In the above-mentioned embodiment of the present invention, the preset synchronization trigger thread in the primary virtual machine also includes a network packet comparison thread, and the synchronization trigger condition corresponding to the network packet comparison thread is a second synchronization condition indicating that the network packets of the primary virtual machine and the standby virtual machine are inconsistent. When the dirty data statistics thread satisfies the first synchronization trigger condition, or the network packet comparison thread satisfies the second synchronization condition, that is, when the amount of dirty data is greater than the preset dirty data threshold, or the network packets of the primary virtual machine and the standby virtual machine are inconsistent, the synchronization thread can be pulled up to synchronize the dirty data to the standby virtual machine, thereby triggering the operation of synchronizing the dirty data to the standby virtual machine based on the synchronization trigger condition.

[0052] As an optional embodiment, the preset synchronization trigger thread also includes: a timing thread, used to monitor the synchronization time of the primary virtual machine, wherein the timing thread and the dirty data statistics thread are executed separately; the synchronization trigger condition also includes: a third synchronization trigger condition indicating that the synchronization time reaches a preset time threshold; when the preset synchronization trigger thread satisfies the synchronization trigger condition, pulling up the synchronization thread to synchronize dirty data to the standby virtual machine includes: when the dirty data statistics thread satisfies the first synchronization trigger condition, or the timing thread satisfies the third synchronization condition, pulling up the synchronization thread to synchronize dirty data to the standby virtual machine.

[0053] In the above-mentioned embodiment of the present invention, the preset synchronization trigger thread in the main virtual machine also includes a timing thread, and the synchronization trigger condition corresponding to the timing thread is a third synchronization trigger condition indicating that the synchronization time reaches a preset time threshold. When the dirty data statistics thread satisfies the first synchronization trigger condition, or the timing thread satisfies the third synchronization condition, that is, when the amount of dirty data is greater than the preset dirty data threshold, or the synchronization time reaches the preset time threshold, the synchronization thread can be pulled up to synchronize dirty data to the standby virtual machine, thereby triggering the operation of synchronizing dirty data to the standby virtual machine based on the synchronization trigger condition.

[0054] As an optional embodiment, when the preset synchronization trigger thread meets the synchronization trigger condition, after starting the synchronization thread to synchronize dirty data to the standby virtual machine, the method further includes: clearing the amount of dirty data counted by the dirty data statistics thread.

[0055] In the above-mentioned embodiments of the present invention, when any preset synchronization trigger thread satisfies the synchronization trigger condition, the synchronization thread can be pulled up to synchronize dirty data to the standby virtual machine, and when synchronizing the dirty data to the standby virtual machine, the number of dirty data counted by the dirty data statistics thread is cleared to reset the dirty data statistics thread, so that the dirty data statistics thread performs a new round of dirty data statistics.

[0056] As an optional embodiment, the synchronization thread includes: a synchronization sending thread in the primary virtual machine, and a synchronization receiving thread in the standby virtual machine. When the preset synchronization trigger thread meets the synchronization trigger condition, pulling up the synchronization thread to synchronize dirty data to the standby virtual machine includes: when the preset synchronization trigger thread meets the synchronization trigger condition, controlling the primary virtual machine to shut down, and sending dirty data to the synchronization receiving thread through the synchronization sending thread.

[0057] In the above embodiment of the present invention, when the primary virtual machine synchronizes dirty data with the standby virtual machine, the primary virtual machine is shut down, and the primary virtual machine calls the synchronous sending thread to send the dirty data to the synchronous receiving thread in the standby virtual machine to synchronize the dirty data.

[0058] Figure 2 The following is a flow chart of a method for synchronizing data of a virtual machine according to an embodiment of the present invention. Figure 2 ,like Figure 2 As shown, the method comprises the following steps:

[0059] Step S202, start the dirty data statistics thread, and count the dirty data quantity of the dirty data in the master virtual machine;

[0060] Step S204: When the amount of dirty data is greater than a preset dirty data threshold, a synchronization thread is started to synchronize the dirty data to the standby virtual machine.

[0061] In an embodiment of the present invention, the number of dirty data in the primary virtual machine is counted through a dirty data statistics thread. When the number of dirty data counted by the dirty data statistics thread is greater than a preset dirty data threshold, a synchronization thread is started to synchronize the dirty data to the standby virtual machine. This can achieve the technical effect of controlling the downtime of the virtual machine when the virtual machine is performing data synchronization by controlling the size of the dirty data, thereby solving the technical problem of being unable to control the downtime of the virtual machine when the virtual machine is performing data synchronization.

[0062] As an optional embodiment, when the amount of dirty data is greater than a preset dirty data threshold, after starting the synchronization thread to synchronize the dirty data to the standby virtual machine, the method further includes: clearing the amount of dirty data counted by the dirty data statistics thread.

[0063] As an optional embodiment, before clearing the amount of dirty data counted by the dirty data statistics thread, the method also includes: starting a network packet comparison thread to compare the network packets of the primary virtual machine and the standby virtual machine, wherein the network packet comparison thread and the dirty data statistics thread are executed separately; when the network packets of the primary virtual machine and the standby virtual machine are inconsistent, starting a synchronization thread to synchronize dirty data to the standby virtual machine.

[0064] As an optional embodiment, before clearing the amount of dirty data counted by the dirty data statistics thread, the method also includes: starting a timing thread to monitor the synchronization time of the primary virtual machine, wherein the timing thread and the dirty data statistics thread are executed separately; when the synchronization time reaches a preset time threshold, starting the synchronization thread to synchronize the dirty data to the backup virtual machine.

[0065] The present invention also provides a preferred embodiment, which provides a method for limiting the stop time of a virtual machine in a FaultTolorance process.

[0066] Figure 3 is a schematic diagram of a virtual machine fault tolerance structure according to an embodiment of the present invention. Figure 3 As shown, it includes: PVM and SVM parts, among which the PVM part is the main virtual machine, mainly including: a listening thread part and a synchronous sending thread part, the listening thread part includes: a network packet comparison thread, a timing thread and a dirty data statistics thread, when the synchronization trigger condition of any thread in the listening thread part is met, the synchronous sending thread will be notified to perform synchronous data operations; the SVM part is a standby virtual machine, mainly including: a synchronous receiving thread, which is used to passively receive data sent by the PVM part.

[0067] Optionally, the synchronization trigger conditions include: a first synchronization trigger condition corresponding to the dirty data statistics thread, a second synchronization trigger condition corresponding to the network packet comparison thread, and a third synchronization trigger condition corresponding to the timing thread, wherein the first synchronization trigger condition is that the dirty data to be synchronized reaches a specified upper limit, the second synchronization trigger condition is that the network packet output of the primary virtual machine PVM and the standby virtual machine SVM is inconsistent, and the third synchronization trigger condition is that the preset synchronization time is reached.

[0068] Figure 4 is a schematic diagram of a virtual machine synchronization sequence according to an embodiment of the present invention, such as Figure 4 As shown, when the primary virtual machine PVM meets any synchronization trigger condition, it will trigger a synchronization, that is, fault-tolerant FT synchronization. Then, after the standby virtual machine SVM receives the data, it will notify the primary virtual machine PVM to complete a synchronization process and wait for the next synchronization.

[0069] In the above embodiment of the present invention, by adding a dirty data upper limit to the primary virtual machine PVM and then continuously monitoring the dirty data size, a synchronization is triggered after exceeding the upper limit, thereby being able to control the maximum interval time of the synchronization.

[0070] Figure 5 is a schematic diagram of a virtual machine synchronization process according to an embodiment of the present invention, such as Figure 5 As shown, at the beginning, a dirty data statistics thread is started to execute separately, and the current dirty data quantity is counted regularly, and the upper limit of the preset dirty data threshold is judged. If the upper limit of the dirty data threshold is reached, the synchronization thread (such as the synchronization sending thread of the main virtual machine) started by the FT process is notified by sending an event. After receiving the event notification, the synchronization thread performs a synchronization, and continues to wait for the event after completion. At the same time, after clearing the dirty data size, the dirty data statistics thread continues to count and prepares for the next event trigger.

[0071] In the above-mentioned embodiment of the present invention, the synchronization thread is triggered by adding dirty data monitoring. After the dirty data upper limit is determined, the time for sending dirty data can be accurately controlled according to the size of the network bandwidth, thereby controlling the time for stopping the virtual machine, thereby improving the performance of FT. Compared with the synchronization control scheme of the prior art that can only compare and synchronize network packet output, a dynamic stop upper limit time control function is added, which effectively improves the FT performance when the amount of dirty data is high.

[0072] According to an embodiment of the present invention, an embodiment of a data synchronization device for a virtual machine is also provided. It should be noted that the data synchronization device for the virtual machine can be used to execute the data synchronization method for the virtual machine in the embodiment of the present invention, and the data synchronization method for the virtual machine in the embodiment of the present invention can be executed in the data synchronization device for the virtual machine.

[0073] Figure 6 A schematic diagram of a data synchronization device for a virtual machine according to an embodiment of the present invention Figure 1 ,like Figure 6 As shown, the device may include: a monitoring module 62, which is used to monitor the preset synchronization trigger thread of the main virtual machine, wherein the preset synchronization trigger thread at least includes: a dirty data statistics thread, which is used to count the number of dirty data in the main virtual machine, and the synchronization trigger condition at least includes: a first synchronization trigger condition indicating that the number of dirty data is greater than a preset dirty data threshold; a first synchronization module 64, which is used to pull up the synchronization thread to synchronize dirty data to the standby virtual machine when the preset synchronization trigger thread meets the synchronization trigger condition.

[0074] It should be noted that the monitoring module 62 in this embodiment can be used to execute step S102 in the embodiment of the present application, and the first synchronization module 64 in this embodiment can be used to execute step S104 in the embodiment of the present application. The examples and application scenarios implemented by the above modules and corresponding steps are the same, but are not limited to the contents disclosed in the above embodiments.

[0075] In an embodiment of the present invention, the number of dirty data in the primary virtual machine is counted through a dirty data statistics thread. When the number of dirty data counted by the dirty data statistics thread is greater than a preset dirty data threshold, a synchronization thread is started to synchronize the dirty data to the standby virtual machine. This can achieve the technical effect of controlling the downtime of the virtual machine when the virtual machine is performing data synchronization by controlling the size of the dirty data, thereby solving the technical problem of being unable to control the downtime of the virtual machine when the virtual machine is performing data synchronization.

[0076] As an optional embodiment, the preset synchronization trigger thread also includes: a network packet comparison thread, used to compare network packets of the primary virtual machine and the standby virtual machine, wherein the network packet comparison thread and the dirty data statistics thread are executed separately, and the synchronization trigger condition also includes: a second synchronization condition indicating that the network packets of the primary virtual machine and the standby virtual machine are inconsistent; the first synchronization module includes: a first synchronization unit, used to pull up the synchronization thread to synchronize dirty data to the standby virtual machine when the dirty data statistics thread meets the first synchronization trigger condition, or the network packet comparison thread meets the second synchronization condition.

[0077] As an optional embodiment, the preset synchronization trigger thread also includes: a timing thread, used to monitor the synchronization time of the primary virtual machine, wherein the timing thread and the dirty data statistics thread are executed separately; the synchronization trigger condition also includes: a third synchronization trigger condition indicating that the synchronization time reaches a preset time threshold; the first synchronization module includes: a second synchronization unit, used to pull up the synchronization thread to synchronize dirty data to the standby virtual machine when the dirty data statistics thread meets the first synchronization trigger condition, or the timing thread meets the third synchronization condition.

[0078] As an optional embodiment, the device also includes: a reset submodule, which is used to clear the number of dirty data counted by the dirty data statistics thread after starting the synchronization thread to synchronize dirty data to the standby virtual machine when the preset synchronization trigger thread meets the synchronization trigger condition.

[0079] As an optional embodiment, the synchronization thread includes: a synchronization sending thread in the primary virtual machine, and a synchronization receiving thread in the backup virtual machine. The first synchronization module includes: a synchronization sub-module, which is used to control the shutdown of the primary virtual machine when the preset synchronization trigger thread meets the synchronization trigger condition, and send dirty data to the synchronization receiving thread through the synchronization sending thread.

[0080] Figure 7 A schematic diagram of a data synchronization device for a virtual machine according to an embodiment of the present invention Figure 2 ,like Figure 7 As shown, the device may include: a first start module 72, used to start a dirty data statistics thread to count the number of dirty data in the primary virtual machine; a second synchronization module 74, used to pull up a synchronization thread to synchronize dirty data to the backup virtual machine when the number of dirty data is greater than a preset dirty data threshold.

[0081] It should be noted that the first opening module 72 in this embodiment can be used to execute step S202 in the embodiment of the present application, and the second synchronization module 74 in this embodiment can be used to execute step S204 in the embodiment of the present application. The examples and application scenarios implemented by the above modules and corresponding steps are the same, but are not limited to the contents disclosed in the above embodiments.

[0082] In an embodiment of the present invention, the number of dirty data in the primary virtual machine is counted through a dirty data statistics thread. When the number of dirty data counted by the dirty data statistics thread is greater than a preset dirty data threshold, a synchronization thread is started to synchronize the dirty data to the standby virtual machine. This can achieve the technical effect of controlling the downtime of the virtual machine when the virtual machine is performing data synchronization by controlling the size of the dirty data, thereby solving the technical problem of being unable to control the downtime of the virtual machine when the virtual machine is performing data synchronization.

[0083] As an optional embodiment, the device also includes: a reset module, which is used to clear the number of dirty data counted by the dirty data statistics thread after starting the synchronization thread to synchronize the dirty data to the standby virtual machine when the number of dirty data is greater than a preset dirty data threshold.

[0084] As an optional embodiment, the device also includes: a second start-up module, used to start the network packet comparison thread before clearing the number of dirty data counted by the dirty data statistics thread, and compare the network packets of the primary virtual machine and the standby virtual machine, wherein the network packet comparison thread and the dirty data statistics thread are executed separately; a third synchronization module, used to pull up the synchronization thread to synchronize dirty data to the standby virtual machine when the network packets of the primary virtual machine and the standby virtual machine are inconsistent.

[0085] As an optional embodiment, the device also includes: a third start-up module, used to start the timing thread and monitor the synchronization time of the primary virtual machine before clearing the number of dirty data counted by the dirty data statistics thread, wherein the timing thread and the dirty data statistics thread are executed separately; a fourth synchronization module, used to pull up the synchronization thread to synchronize dirty data to the backup virtual machine when the synchronization time reaches a preset time threshold.

[0086] An embodiment of the present invention may provide an electronic device, the electronic device being a computer terminal, and the computer terminal may be any computer terminal device in a computer terminal group. Optionally, in this embodiment, the computer terminal may also be replaced by a terminal device such as a mobile terminal.

[0087] Optionally, in this embodiment, the computer terminal may be located in at least one network device among a plurality of network devices of the computer network.

[0088] In this embodiment, the above-mentioned computer terminal can execute the program code of the following steps in the data synchronization method of the virtual machine: monitoring the preset synchronization trigger thread of the main virtual machine, wherein the preset synchronization trigger thread at least includes: a dirty data statistics thread, used to count the number of dirty data in the main virtual machine, and the synchronization trigger condition at least includes: a first synchronization trigger condition indicating that the number of dirty data is greater than a preset dirty data threshold; when the preset synchronization trigger thread meets the synchronization trigger condition, pull up the synchronization thread to synchronize the dirty data to the standby virtual machine.

[0089] In this embodiment, the above-mentioned computer terminal can execute the program code of the following steps in the data synchronization method of the virtual machine: start the dirty data statistics thread to count the number of dirty data in the main virtual machine; when the number of dirty data is greater than the preset dirty data threshold, start the synchronization thread to synchronize the dirty data to the backup virtual machine.

[0090] Figure 8 is a structural block diagram of a computer terminal according to an embodiment of the present invention. Figure 8 As shown, the computer terminal 80 may include: one or more (only one is shown in the figure) processors 82 , and a memory 84 .

[0091] Among them, the memory can be used to store software programs and modules, such as the program instructions / modules corresponding to the data synchronization method and device of the virtual machine in the embodiment of the present invention. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, that is, the data synchronization method of the virtual machine mentioned above is realized. The memory may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include a memory remotely arranged relative to the processor, and these remote memories may be connected to the terminal 80 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0092] The processor can call the information and application programs stored in the memory through the transmission device to execute the following steps: monitor the preset synchronization trigger thread of the primary virtual machine, wherein the preset synchronization trigger thread includes at least: a dirty data statistics thread, which is used to count the number of dirty data in the primary virtual machine, and the synchronization trigger condition includes at least: a first synchronization trigger condition indicating that the number of dirty data is greater than a preset dirty data threshold; when the preset synchronization trigger thread meets the synchronization trigger condition, pull up the synchronization thread to synchronize the dirty data to the standby virtual machine.

[0093] Optionally, the preset synchronization trigger thread also includes: a network packet comparison thread, used to compare network packets of the primary virtual machine and the standby virtual machine, wherein the network packet comparison thread and the dirty data statistics thread are executed separately, and the synchronization trigger condition also includes: a second synchronization condition indicating that the network packets of the primary virtual machine and the standby virtual machine are inconsistent. The above-mentioned processor can also execute the program code of the following steps: when the dirty data statistics thread meets the first synchronization trigger condition, or the network packet comparison thread meets the second synchronization condition, pull up the synchronization thread to synchronize dirty data to the standby virtual machine.

[0094] Optionally, the preset synchronization trigger thread also includes: a timing thread, used to monitor the synchronization time of the primary virtual machine, wherein the timing thread and the dirty data statistics thread are executed separately; the synchronization trigger condition also includes: a third synchronization trigger condition indicating that the synchronization time reaches a preset time threshold. The above-mentioned processor can also execute the program code of the following steps: when the dirty data statistics thread meets the first synchronization trigger condition, or the timing thread meets the third synchronization condition, pull up the synchronization thread to synchronize dirty data to the standby virtual machine.

[0095] Optionally, the processor may further execute program code of the following steps: clearing the amount of dirty data counted by the dirty data statistics thread.

[0096] Optionally, the synchronization thread includes: a synchronization sending thread in the primary virtual machine, and a synchronization receiving thread in the backup virtual machine. The above-mentioned processor can also execute the program code of the following steps: when the preset synchronization trigger thread meets the synchronization trigger condition, control the primary virtual machine to shut down, and send dirty data to the synchronization receiving thread through the synchronization sending thread.

[0097] The processor can call the information and application stored in the memory through the transmission device to perform the following steps: start the dirty data counting thread to count the number of dirty data in the primary virtual machine; when the number of dirty data is greater than a preset dirty data threshold, pull up the synchronization thread to synchronize the dirty data to the standby virtual machine;

[0098] Optionally, the processor may further execute program code of the following steps: clearing the amount of dirty data counted by the dirty data statistics thread.

[0099] Optionally, the processor may also execute the program code of the following steps: start a network packet comparison thread to compare the network packets of the primary virtual machine and the backup virtual machine, wherein the network packet comparison thread and the dirty data statistics thread are executed separately; when the network packets of the primary virtual machine and the backup virtual machine are inconsistent, start a synchronization thread to synchronize dirty data to the backup virtual machine.

[0100] Optionally, the processor may also execute the following program code: start a timing thread to monitor the synchronization time of the primary virtual machine, wherein the timing thread and the dirty data statistics thread are executed separately; when the synchronization time reaches a preset time threshold, start the synchronization thread to synchronize dirty data to the backup virtual machine.

[0101] By adopting the embodiment of the present invention, a data synchronization scheme for a virtual machine is provided. In the embodiment of the present invention, the dirty data count of the dirty data in the primary virtual machine is counted by the dirty data counting thread, and when the dirty data counted by the dirty data counting thread is greater than the preset dirty data threshold, the synchronization thread is pulled up to synchronize the dirty data to the standby virtual machine, so that the size of the dirty data can be controlled to achieve the technical effect of controlling the downtime of the virtual machine when the virtual machine performs data synchronization, thereby solving the technical problem that the downtime of the virtual machine cannot be controlled when the virtual machine performs data synchronization.

[0102] It can be understood by those skilled in the art that Figure 8 The structure shown is for illustration only, and the computer terminal may also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a handheld computer, a mobile Internet device (Mobile Internet Devices, MID), a PAD, or other terminal devices. Figure 8 The structure of the electronic device is not limited. For example, the computer terminal 80 may also include Figure 8More or fewer components (such as network interfaces, display devices, etc.) shown in, or having Figure 8 Different configurations shown.

[0103] A person of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a computer program. The computer program can be stored in a non-volatile medium. The non-volatile storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0104] The embodiment of the present invention further provides a non-volatile storage medium. Optionally, in this embodiment, the non-volatile storage medium can be used to store the program code executed by the virtual machine data synchronization method provided in the above embodiment.

[0105] Optionally, in this embodiment, the non-volatile storage medium may be located in any computer terminal in a computer terminal group in a computer network, or in any mobile terminal in a mobile terminal group.

[0106] Optionally, in this embodiment, the non-volatile storage medium is configured to store program code for executing the following steps: monitoring a preset synchronization trigger thread of the primary virtual machine, wherein the preset synchronization trigger thread includes at least: a dirty data statistics thread, used to count the number of dirty data in the primary virtual machine, and the synchronization trigger condition includes at least: a first synchronization trigger condition indicating that the number of dirty data is greater than a preset dirty data threshold; when the preset synchronization trigger thread meets the synchronization trigger condition, starting the synchronization thread to synchronize dirty data to the standby virtual machine.

[0107] Optionally, in this embodiment, the preset synchronization trigger thread also includes: a network packet comparison thread, used to compare network packets of the primary virtual machine and the standby virtual machine, wherein the network packet comparison thread and the dirty data statistics thread are executed separately, and the synchronization trigger condition also includes: a second synchronization condition indicating that the network packets of the primary virtual machine and the standby virtual machine are inconsistent, and the non-volatile storage medium is configured to store program code for executing the following steps: when the dirty data statistics thread satisfies the first synchronization trigger condition, or the network packet comparison thread satisfies the second synchronization condition, the synchronization thread is started to synchronize dirty data to the standby virtual machine.

[0108] Optionally, in this embodiment, the preset synchronization trigger thread also includes: a timing thread, used to monitor the synchronization time of the primary virtual machine, wherein the timing thread and the dirty data statistics thread are executed separately; the synchronization trigger condition also includes: a third synchronization trigger condition indicating that the synchronization time reaches a preset time threshold, and the non-volatile storage medium is configured to store program code for executing the following steps: when the dirty data statistics thread satisfies the first synchronization trigger condition, or the timing thread satisfies the third synchronization condition, the synchronization thread is started to synchronize dirty data to the standby virtual machine.

[0109] Optionally, in this embodiment, the non-volatile storage medium is configured to store program codes for executing the following steps: clearing the amount of dirty data counted by the dirty data statistics thread.

[0110] Optionally, in this embodiment, the synchronization thread includes: a synchronization sending thread in the primary virtual machine, and a synchronization receiving thread in the standby virtual machine, and the non-volatile storage medium is configured to store program codes for executing the following steps: when the preset synchronization trigger thread meets the synchronization trigger condition, the primary virtual machine is controlled to shut down, and dirty data is sent to the synchronization receiving thread through the synchronization sending thread.

[0111] Optionally, in this embodiment, the non-volatile storage medium is configured to store program codes for executing the following steps: starting a dirty data statistics thread to count the number of dirty data in the primary virtual machine; when the number of dirty data is greater than a preset dirty data threshold, starting a synchronization thread to synchronize the dirty data to the backup virtual machine.

[0112] Optionally, in this embodiment, the non-volatile storage medium is configured to store program codes for executing the following steps: clearing the amount of dirty data counted by the dirty data statistics thread.

[0113] Optionally, in this embodiment, the non-volatile storage medium is configured to store program codes for executing the following steps: starting a network packet comparison thread to compare network packets of the primary virtual machine and the standby virtual machine, wherein the network packet comparison thread and the dirty data statistics thread are executed separately; when the network packets of the primary virtual machine and the standby virtual machine are inconsistent, starting a synchronization thread to synchronize dirty data to the standby virtual machine.

[0114] Optionally, in this embodiment, the non-volatile storage medium is configured to store program code for executing the following steps: starting a timing thread to monitor the synchronization time of the primary virtual machine, wherein the timing thread and the dirty data statistics thread are executed separately; when the synchronization time reaches a preset time threshold, starting the synchronization thread to synchronize dirty data to the backup virtual machine.

[0115] The embodiment of the present invention further provides a computer program product, including a computer program. Optionally, in this embodiment, the computer program is characterized in that when executed by a processor, the computer program implements the steps of the virtual machine data synchronization method provided in the above embodiment.

[0116] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0117] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0118] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0119] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0120] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0121] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a non-volatile storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a non-volatile storage medium, including several instructions for a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned non-volatile storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.

[0122] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A data synchronization method for a virtual machine, characterized in that: include: Monitoring a preset synchronization trigger thread of the master virtual machine, wherein the preset synchronization trigger thread at least includes: the dirty data counting thread, which is used to count the dirty data quantity of dirty data in the master virtual machine, and the synchronization trigger condition at least includes: a first synchronization trigger condition indicating that the dirty data quantity is greater than a preset dirty data threshold; When the preset synchronization trigger thread meets the synchronization trigger condition, the synchronization thread is started to synchronize the dirty data to the standby virtual machine.

2. The method according to claim 1, characterized in that The preset synchronization trigger thread further includes: a network packet comparison thread, which is used to compare the network packets of the primary virtual machine and the standby virtual machine, wherein the network packet comparison thread and the dirty data statistics thread are executed separately, and the synchronization trigger condition further includes: a second synchronization condition indicating that the network packets of the primary virtual machine and the standby virtual machine are inconsistent; when the preset synchronization trigger thread satisfies the synchronization trigger condition, pulling up the synchronization thread to synchronize the dirty data to the standby virtual machine includes: When the dirty data statistics thread satisfies the first synchronization triggering condition, or the network packet comparison thread satisfies the second synchronization condition, a synchronization thread is started to synchronize the dirty data to the standby virtual machine.

3. The method according to claim 1, characterized in that The preset synchronization trigger thread also includes: a timing thread, which is used to monitor the synchronization time of the primary virtual machine, wherein the timing thread and the dirty data statistics thread are executed separately; the synchronization trigger condition also includes: a third synchronization trigger condition indicating that the synchronization time reaches a preset time threshold; when the preset synchronization trigger thread satisfies the synchronization trigger condition, pulling up the synchronization thread to synchronize the dirty data to the standby virtual machine includes: When the dirty data statistics thread satisfies the first synchronization triggering condition, or the timing thread satisfies the third synchronization condition, a synchronization thread is started to synchronize the dirty data to the standby virtual machine.

4. The method according to any one of claims 1 to 3, characterized in that When the preset synchronization triggering thread satisfies the synchronization triggering condition, after starting the synchronization thread to synchronize the dirty data to the standby virtual machine, the method further includes: Clear the amount of dirty data counted by the dirty data statistics thread.

5. The method according to claim 1, characterized in that The synchronization thread includes: a synchronization sending thread in the primary virtual machine, and a synchronization receiving thread in the standby virtual machine. When the preset synchronization triggering thread satisfies the synchronization triggering condition, starting the synchronization thread to synchronize the dirty data to the standby virtual machine includes: When the preset synchronization triggering thread meets the synchronization triggering condition, the primary virtual machine is controlled to shut down, and the dirty data is sent to the synchronization receiving thread through the synchronization sending thread.

6. A data synchronization method for a virtual machine, characterized in that: include: Start the dirty data statistics thread to count the number of dirty data in the master virtual machine; When the amount of dirty data is greater than a preset dirty data threshold, a synchronization thread is started to synchronize the dirty data to the standby virtual machine.

7. The method according to claim 6, characterized in that When the amount of dirty data is greater than a preset dirty data threshold, after starting a synchronization thread to synchronize the dirty data to the standby virtual machine, the method further includes: Clear the amount of dirty data counted by the dirty data statistics thread.

8. The method according to claim 7, characterized in that Before clearing the amount of dirty data counted by the dirty data statistics thread, the method further includes: Start a network packet comparison thread to compare the network packets of the primary virtual machine and the standby virtual machine, wherein the network packet comparison thread and the dirty data statistics thread are executed separately; When the network packets of the primary virtual machine and the standby virtual machine are inconsistent, a synchronization thread is started to synchronize the dirty data to the standby virtual machine.

9. The method according to claim 7, characterized in that: Before clearing the amount of dirty data counted by the dirty data statistics thread, the method further includes: Start a timing thread to monitor the synchronization time of the primary virtual machine, wherein the timing thread and the dirty data statistics thread are executed separately; When the synchronization time reaches a preset time threshold, a synchronization thread is started to synchronize the dirty data to the standby virtual machine.

10. A data synchronization device for a virtual machine, characterized in that: include: A monitoring module, configured to monitor a preset synchronization trigger thread of the master virtual machine, wherein the preset synchronization trigger thread at least includes: the dirty data counting thread, configured to count the number of dirty data in the master virtual machine, and the synchronization trigger condition at least includes: a first synchronization trigger condition indicating that the number of dirty data is greater than a preset dirty data threshold; The first synchronization module is used to start a synchronization thread to synchronize the dirty data to the standby virtual machine when the preset synchronization trigger thread meets the synchronization trigger condition.

11. A data synchronization device for a virtual machine, characterized in that: include: The first opening module is used to open the dirty data statistics thread to count the number of dirty data in the main virtual machine; The second synchronization module is used to start a synchronization thread to synchronize the dirty data to the standby virtual machine when the amount of dirty data is greater than a preset dirty data threshold.

12. A non-volatile storage medium, characterized in that: The non-volatile storage medium stores a computer program, wherein the data synchronization method for a virtual machine described in any one of claims 1 to 9 is executed by running the computer program on the device where the non-volatile storage medium is located.

13. An electronic device comprising a memory and a processor, characterized in that: The memory stores a computer program, and the processor is configured to execute the data synchronization method for a virtual machine according to any one of claims 1 to 9 through the computer program.

14. A computer program product comprising computer instructions, characterized in that When the computer instructions are executed by a processor, the steps of the data synchronization method for a virtual machine described in any one of claims 1 to 9 are implemented.