A data migration method for virtual machines
By using NFS server and event-based triggering methods in virtual machine data migration, combined with pre-copy online migration algorithm and bidirectional state signals, the problems of long downtime and poor fault tolerance during virtual machine data migration are solved, and data migration is realized Uninterrupted and high fault tolerance.
Patent Information
- Application Number
- CN202111116512.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-23
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2041-09-23
AI Technical Summary
When existing virtual machines are migrated, the main virtual machine has a long downtime, which affects customer service, and cannot guarantee the uninterrupted work of data migration, and the system has poor fault tolerance.
Data association between the main virtual machine and the backup virtual machine is established through the NFS server, data migration is carried out using event-based triggering method, pre-copy online migration algorithm maintains the running state during the copying of the main virtual machine memory data, and ensures that it is done through two-way state signals Data synchronization.
It reduces the downtime of the main virtual machine, ensures uninterrupted data migration, improves the system's fault tolerance, and ensures the continuity of customer service.
Smart Images

Figure CN114035999B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of data processing, and in particular relates to a data migration method for a virtual machine. Background Art
[0002] Different from the physical host, virtual machines use disk images for operation. When performing data migration on the virtualization platform, the primary virtual machine and the backup virtual machine need to keep the disk data, memory data, and CPU status data synchronized, so that the backup virtual machine and the primary virtual machine can be completely consistent. Only in this way, when the primary virtual machine has an operating failure and must be shut down, the backup virtual machine can immediately replace the primary virtual machine. Keeping the above disk, memory, and CPU status data consistent is the main problem that virtual machine migration currently deals with.
[0003] Migration in a virtualized environment is divided into dynamic migration and static migration.
[0004] Static migration means copying the disk files and configuration files of the virtual machine on the source host to the target host when the virtual machine is shut down or paused. This method requires explicitly stopping the virtual machine, which is not suitable for high service availability requirements.
[0005] In contrast, dynamic migration does not cause noticeable service suspension, ensuring that customer services are not affected. In the early stages of dynamic migration, services are run on the source host's virtual machine. When the migration reaches a certain stage, the destination host already has the necessary resources to run the virtual machine system. After a very short switch, the source host transfers control to the destination host, and the virtual machine system continues to run on the destination host. For the virtual machine service itself, since the switching time is very short, users do not feel the interruption of the service, so the migration process is transparent to users. Dynamic migration is suitable for occasions with high requirements for virtual machine service availability.
[0006] Live migration does not require copying virtual machine configuration files and disk files, but the hosts to be migrated have the same directory structure to place the virtual machine disk files. Live migration actually encapsulates the virtual machine configuration in a file, and then quickly transfers the virtual machine configuration and memory running status from one physical machine to another through a high-speed network, while the virtual machine remains running. Under existing technical conditions, most virtual machine software requires shared storage support for live migration.
[0007] Therefore, when the data of the existing virtual machine is migrated, the virtual machine will be down for a long time during the dynamic migration process, which affects customer service; the uninterrupted work of the data migration cannot be guaranteed, resulting in poor fault tolerance of the system. Summary of the invention
[0008] In order to solve the above problems, the present invention proposes a data migration method for a virtual machine, which shortens the downtime of the main virtual machine as much as possible and does not affect the customer's service; ensures the uninterrupted operation of data migration and improves the fault tolerance of the system.
[0009] To achieve the above object, the technical solution adopted by the present invention is: a data migration method for a virtual machine, including a primary virtual machine and a backup virtual machine, the primary virtual machine and the backup virtual machine establish data association through an NFS server, and an independent two-way status signal is set between the primary virtual machine and the backup virtual machine, including the steps of:
[0010] S10, the backup virtual machine periodically sends a contact signal to the primary virtual machine and waits for a reply from the primary virtual machine;
[0011] S20, if the current primary virtual machine has no event that triggers data migration, the restore point information part is set to blank in the signal replied to the backup server; if the current primary virtual machine has an event that triggers data migration, the primary virtual machine triggers data migration, sets the restore point information in the signal replied to the backup server, and the primary virtual machine copies the configuration and memory data of the local machine to the NFS server;
[0012] S30, after receiving the signal replied by the primary virtual machine, the backup virtual machine determines whether there is restore point information in the signal, if not, proceeds to the next step; if yes, copies the latest configuration and memory status information from the NFS server, matches it with the received restore point information, and stores it locally;
[0013] S40, after the backup virtual machine completes copying, a confirmation signal is sent to the primary virtual machine; go to step S10.
[0014] Furthermore, the event triggering data migration includes a memory, network or IO action event.
[0015] Furthermore, in the process of copying the memory data of the primary virtual machine to the NFS server, the copy action adopts a pre-copy online migration algorithm.
[0016] Furthermore, the pre-copy online migration algorithm includes the following steps: during the migration process, the master virtual machine remains in operation, the system continuously generates dirty memory pages, and the copying forms an iterative process, that is, multiple rounds of migration are required to make the number of new dirty pages generated in the previous round small enough. At this time, the master virtual machine is paused, the remaining dirty memory pages are migrated out, and the master virtual machine is immediately restarted.
[0017] Furthermore, if the backup virtual machine does not receive any reply signal from the primary virtual machine, the timeout count is set to 1; if the timeout count reaches n times, it can be determined that the primary virtual machine has crashed or is unable to connect, and the backup virtual machine inherits all the working information of the primary virtual machine at the most recent restore point and starts to replace the primary virtual machine.
[0018] Furthermore, the size of n is determined according to the specific network conditions of the application scenario and the restart duration of the main virtual machine.
[0019] Furthermore, an independent bidirectional status signal is provided between the primary virtual machine and the backup virtual machine, and the network connection is based on the TCP protocol.
[0020] Furthermore, when the two-way status signal is communicated:
[0021] The backup virtual machine actively sends a contact signal at regular intervals. The contact signal needs to wait for the reply signal of the primary virtual machine to determine whether the primary virtual machine is in normal working state. If it is not normal, the backup virtual machine will immediately replace the primary virtual machine and set the restore point information in the signal replying to the backup server.
[0022] The backup VM sends a confirmation signal to the primary VM after copying the migration data from the NFS server.
[0023] Furthermore, the restore point information is set in the signal replying to the backup server, including: if the primary virtual machine crashes or is otherwise unavailable, the backup virtual machine inherits all the working information of the primary virtual machine at the nearest location and starts to replace the primary virtual machine; the restore point is used to closely synchronize with each data written by the primary virtual machine to the NFS server, thereby increasing the fault tolerance of the virtual machine data migration system.
[0024] Furthermore, the backup virtual machine sends a confirmation signal to the primary virtual machine after copying the migration data from the NFS server, and the confirmation signal indicates that the backup virtual machine has successfully completed the copying action of the previous data, and the data is synchronized with the currently received restore point information.
[0025] The beneficial effects of adopting this technical solution are:
[0026] In the present invention, the primary virtual machine and the backup virtual machine establish data association through the NFS server. The primary virtual machine always writes the data to be synchronized to the NFS server, and then writes the data in the NFS server to the backup server. In the triggering condition of data migration, the present invention adopts an event-based triggering method, that is, when events such as memory, network and IO actions occur in the system, the system will migrate data. Compared with the generally used timed trigger, it ensures the maximum state synchronization between the primary and backup virtual machines.
[0027] The present invention ensures that the downtime of the primary virtual machine is as short as possible during the dynamic data migration process, and does not affect the customer's service. The present invention establishes a hot backup relationship between the primary virtual machine and the backup virtual machine. Regardless of whether the primary virtual machine is actively shut down to migrate data to the backup virtual machine, or the primary virtual machine unexpectedly crashes; or the primary virtual machine continues to work after data migration, the operation of the backup virtual machine in the present invention can make the entire system work normally, so the fault tolerance of the system is improved as a whole. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 A schematic diagram of a data migration method for a virtual machine according to the present invention;
[0029] Figure 2 The figure is a schematic diagram of the principle structure of a virtual machine in a data migration method of a virtual machine according to an embodiment of the present invention. DETAILED DESCRIPTION
[0030] In order to make the purpose, technical solutions and advantages of the present invention more clear, the present invention is further described below with reference to the accompanying drawings.
[0031] In this embodiment, see Figure 1 and Figure 2 As shown, the present invention proposes a data migration method for a virtual machine, including a primary virtual machine and a backup virtual machine, the primary virtual machine and the backup virtual machine establish data association through an NFS server, and an independent bidirectional status signal is set between the primary virtual machine and the backup virtual machine, including the steps of:
[0032] S10, the backup virtual machine periodically sends a contact signal to the primary virtual machine and waits for a reply from the primary virtual machine;
[0033] S20, if the current primary virtual machine has no event that triggers data migration, the restore point information part is set to blank in the signal replied to the backup server; if the current primary virtual machine has an event that triggers data migration, the primary virtual machine triggers data migration, sets the restore point information in the signal replied to the backup server, and the primary virtual machine copies the configuration and memory data of the local machine to the NFS server;
[0034] S30, after receiving the signal replied by the primary virtual machine, the backup virtual machine determines whether there is restore point information in the signal, if not, proceeds to the next step; if yes, copies the latest configuration and memory status information from the NFS server, matches it with the received restore point information, and stores it locally;
[0035] S40, after the backup virtual machine completes copying, a confirmation signal is sent to the primary virtual machine; go to step S10.
[0036] The event triggering data migration includes a memory, network or IO action event.
[0037] As an optimization solution of the above embodiment, in the process of copying the memory data of the primary virtual machine to the NFS server, the copy action adopts a pre-copy online migration algorithm.
[0038] The pre-copy online migration algorithm includes the following steps: during the migration process, the master virtual machine remains in operation, the system continuously generates dirty memory pages, and the copying forms an iterative process, that is, multiple rounds of migration are required to make the number of new dirty pages generated in the previous round small enough. At this time, the master virtual machine is paused, the remaining dirty memory pages are migrated out, and the master virtual machine is immediately restarted.
[0039] As an optimization solution for the above embodiment, if the backup virtual machine does not receive any reply signal from the primary virtual machine, the timeout count is set to 1; if the timeout count reaches n times, it can be determined that the primary virtual machine has crashed or cannot be connected, and the backup virtual machine inherits all the working information of the primary virtual machine at the most recent restore point and starts to replace the primary virtual machine.
[0040] The size of n is determined according to the specific network conditions of the application scenario and the restart duration of the master virtual machine.
[0041] As an optimization solution of the above embodiment, an independent bidirectional status signal is set between the primary virtual machine and the backup virtual machine, and a network connection method based on the TCP protocol is used.
[0042] In the specific implementation of the communication signal, the backup virtual machine acts as a TCP Client, and the primary virtual machine acts as a TCP Server. The primary virtual machine opens two different TCP ports to listen to the two types of communication signals sent by the backup virtual machine.
[0043] When the two-way status signal is communicated:
[0044] The backup virtual machine actively and regularly sends out a contact signal, which needs to wait for the reply signal of the primary virtual machine to determine whether the primary virtual machine is in normal working condition; if it is not normal, the backup virtual machine will immediately replace the primary virtual machine to run, and set the restore point information in the signal replying to the backup server; the restore point information set in the signal replying to the backup server includes: if the primary virtual machine crashes or is otherwise unavailable, the backup virtual machine inherits all the working information of the primary virtual machine at the nearest location and starts to replace the primary virtual machine; the restore point is used to closely synchronize with each data written by the primary virtual machine to the NFS server to increase the fault tolerance of the virtual machine data migration system.
[0045] The backup virtual machine sends a confirmation signal to the primary virtual machine after copying the migration data from the NFS server. The confirmation signal indicates that the backup virtual machine has successfully completed the copy action of the previous data, and the data is synchronized with the currently received restore point information.
[0046] The above shows and describes the basic principles and main features of the present invention and the advantages of the present invention. It should be understood by those skilled in the art that the present invention is not limited to the above embodiments. The above embodiments and descriptions are only for explaining the principles of the present invention. Without departing from the spirit and scope of the present invention, the present invention may have various changes and improvements, which fall within the scope of the present invention to be protected. The scope of protection of the present invention is defined by the attached claims and their equivalents.
Claims
1. A method for migrating data of a virtual machine, characterized in that: The method comprises a primary virtual machine and a backup virtual machine, wherein the primary virtual machine and the backup virtual machine establish data association through an NFS server, and an independent bidirectional status signal is set between the primary virtual machine and the backup virtual machine, and comprises the following steps: S10, the backup virtual machine periodically sends a contact signal to the primary virtual machine and waits for a reply from the primary virtual machine; S20, if the current primary virtual machine does not have an event that triggers data migration, the restore point information portion is set to empty in the signal replied to the backup server; If an event that triggers data migration occurs on the current master virtual machine, the master virtual machine triggers data migration and sets the restore point information in the signal replying to the backup server. At the same time, the master virtual machine copies the local configuration and memory data to the NFS server. S30, after receiving the signal replied by the primary virtual machine, the backup virtual machine determines whether there is restore point information in the signal, if not, proceeds to the next step; If yes, copy the latest configuration and memory status information from the NFS server, match it with the received restore point information, and store it locally; S40, after the backup virtual machine completes the copy, a confirmation signal is sent to the primary virtual machine; Go to step S10; The restore point information is set in the signal replying to the backup server, including: if the primary virtual machine crashes or is otherwise unavailable, the backup virtual machine inherits all the working information of the primary virtual machine at the nearest location and starts to work in place of the primary virtual machine; Use restore points to tightly synchronize every data written by the primary VM to the NFS server.
2. A method for virtual machine data migration according to claim 1, characterized in that: The event triggering data migration includes a memory, network or IO action event.
3. The method for data migration of a virtual machine according to claim 1, characterized in that: In the process of copying the memory data of the primary virtual machine to the NFS server, the copy action adopts the pre-copy online migration algorithm.
4. The method for data migration of a virtual machine according to claim 3, characterized in that: The pre-copy online migration algorithm includes the following steps: during the migration process, the master virtual machine remains in operation, the system continuously generates dirty memory pages, and the copying forms an iterative process, that is, multiple rounds of migration are required to make the number of new dirty pages generated in the previous round small enough. At this time, the master virtual machine is paused, the remaining dirty memory pages are migrated out, and the master virtual machine is immediately restarted.
5. A method for migrating virtual machine data according to any one of claims 1 to 4, characterized in that: If the backup virtual machine does not receive any reply signal from the primary virtual machine, the timeout count is set to 1; if the timeout count reaches n times, it can be determined that the primary virtual machine has crashed or is unable to connect, and the backup virtual machine inherits all the working information of the primary virtual machine at the most recent restore point and starts to work in place of the primary virtual machine.
6. A method for virtual machine data migration according to claim 5, characterized in that: The value of n is determined according to the specific network conditions of the application scenario and the restart duration of the master virtual machine.
7. The method for data migration of a virtual machine according to claim 1, characterized in that: An independent two-way status signal is set between the primary virtual machine and the backup virtual machine, and the network connection mode is based on the TCP protocol.
8. A method for virtual machine data migration according to claim 7, characterized in that: When the two-way status signal is communicated: The backup virtual machine actively sends a contact signal at regular intervals. The contact signal needs to wait for the reply signal of the primary virtual machine to determine whether the primary virtual machine is in normal working state. If it is not normal, the backup virtual machine will immediately replace the primary virtual machine and set the restore point information in the signal replying to the backup server. The backup VM sends a confirmation signal to the primary VM after copying the migration data from the NFS server.
9. A method for virtual machine data migration according to claim 8, characterized in that: The backup virtual machine sends a confirmation signal to the primary virtual machine after copying the migration data from the NFS server. The confirmation signal indicates that the backup virtual machine has successfully completed the copy operation of the previous data, and the data is synchronized with the currently received restore point information.
Citation Information
Patent Citations
High-availability method and device of virtual machine based on KVM virtualization
CN107203443A