CN117573280A - Virtual machine state synchronization method, device, equipment and storage medium - Google Patents
Virtual machine state synchronization method, device, equipment and storage medium Download PDFInfo
- Publication number
- CN117573280A CN117573280A CN202311541162.1A CN202311541162A CN117573280A CN 117573280 A CN117573280 A CN 117573280A CN 202311541162 A CN202311541162 A CN 202311541162A CN 117573280 A CN117573280 A CN 117573280A
- Authority
- CN
- China
- Prior art keywords
- virtual machine
- task
- updating
- database
- result
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 61
- 238000004891 communication Methods 0.000 claims abstract description 27
- 230000015654 memory Effects 0.000 claims description 25
- 230000004044 response Effects 0.000 claims description 21
- 230000005012 migration Effects 0.000 claims description 8
- 238000013508 migration Methods 0.000 claims description 8
- 230000003993 interaction Effects 0.000 description 14
- 230000001360 synchronised effect Effects 0.000 description 13
- 230000001960 triggered effect Effects 0.000 description 13
- 230000008859 change Effects 0.000 description 12
- 230000008569 process Effects 0.000 description 7
- 238000010586 diagram Methods 0.000 description 3
- 230000006870 function Effects 0.000 description 3
- 238000005516 engineering process Methods 0.000 description 2
- 230000000977 initiatory effect Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 239000007787 solid Substances 0.000 description 2
- 230000002159 abnormal effect Effects 0.000 description 1
- 238000012512 characterization method Methods 0.000 description 1
- 230000003111 delayed effect Effects 0.000 description 1
- 238000010295 mobile communication Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45533—Hypervisors; Virtual machine monitors
- G06F9/45558—Hypervisor-specific management and integration aspects
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/23—Updating
- G06F16/2365—Ensuring data consistency and integrity
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45533—Hypervisors; Virtual machine monitors
- G06F9/45558—Hypervisor-specific management and integration aspects
- G06F2009/4557—Distribution of virtual machine instances; Migration and load balancing
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45533—Hypervisors; Virtual machine monitors
- G06F9/45558—Hypervisor-specific management and integration aspects
- G06F2009/45575—Starting, stopping, suspending or resuming virtual machine instances
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computer Security & Cryptography (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Hardware Redundancy (AREA)
Abstract
The invention relates to the technical field of computers, and discloses a virtual machine state synchronization method, device, equipment and storage medium, comprising the following steps: acquiring a virtual machine closing task issued by a virtualization platform, wherein the virtual machine closing task comprises a virtual machine task tag and a virtual machine identifier; when the virtual machine task label characterizes that the virtual machine is in a to-be-powered-off state, updating the virtual machine task label into a database of a computing cluster and generating a label updating result; when the label updating result represents that the task label of the virtual machine is successfully updated to the database of the computing cluster, generating a database updating result and feeding back the database updating result to the virtualization platform; when the database updating result is not fed back to the virtualization platform successfully, calling a corresponding virtual machine interface to be closed based on the virtual machine identifier; recording a task execution result and an actual state of the virtual machine, and updating a database and a virtual machine task tag based on the task execution result and the actual state when the communication is restored by the virtualization platform; the invention can improve the running reliability and stability of the virtual machine.
Description
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method, an apparatus, a device, and a storage medium for synchronizing virtual machine states.
Background
With the increasing maturity of cloud computing technology, the computing scale supported by the virtualization system is increasingly larger at present, the number of virtual machines in the virtualization system is continuously increased, after the number of virtual machines in the virtualization system reaches a certain scale, the load of a corresponding virtualization system disk is higher, the writing delay of input and output of a database is also increased, and finally the problem that the virtual machine is down caused by a triggered conflict task even though the task state of some operations of the virtual machine, such as the task state to be shut down, is updated by an update statement is still not fallen into the database, namely the actual task execution result of the virtual machine is not synchronous with the change of the virtual machine state.
Disclosure of Invention
In view of the above, the present invention provides a method, apparatus, device and storage medium for synchronizing virtual machine states, so as to solve the problem that the actual task execution result of the existing virtual machine is not synchronized with the virtual machine state change, and thus the triggered conflicting task causes the virtual machine to crash.
In a first aspect, the present invention provides a method for synchronizing states of virtual machines, applied to a computing cluster, where the computing cluster includes a computing node and a control node, the control node is operated with a virtualization platform for managing virtual machines and a service bottom layer for providing services for the virtualization platform, and the computing node is a host of the virtual machines, and the method includes: acquiring a virtual machine closing task issued by a virtualization platform, wherein the virtual machine closing task comprises a virtual machine task tag and a virtual machine identifier; when the virtual machine task label characterizes that the virtual machine is in a to-be-powered-off state, updating the virtual machine task label to a database of a computing cluster and generating a label updating result, wherein the to-be-powered-off state is determined by fault information of the computing cluster; when the label updating result represents that the task label of the virtual machine is successfully updated to the database of the computing cluster, generating a database updating result, and feeding back the database updating result to the virtualization platform; when the database updating result is not fed back to the virtualization platform successfully, calling a corresponding virtual machine closing interface based on the virtual machine identification so as to bypass the virtualization platform to close the virtual machine; and recording the task execution result and the actual state of the virtual machine, and updating the database and the task label of the virtual machine based on the task execution result and the actual state when the communication is restored by the virtualization platform so as to realize the synchronization of the state of the virtual machine. Through the process, when the virtual machine is in the to-be-powered-off state, the virtual machine of which the virtual platform is in the to-be-powered-off state is not informed any more, the virtual machine interface is directly called to be closed through the service bottom layer, and related logs are recorded, so that interaction between the service bottom layer and the virtual platform is reduced, the virtual machine state of the virtual platform is ensured to be consistent with task result records stored in the database, and the problem that the virtual machine is down due to a triggered conflict task because an actual task execution result of the virtual machine is not synchronous with the change of the virtual machine state is avoided.
In some alternative embodiments, updating the virtual machine task labels into the database of the computing cluster and generating label update results includes:
generating a label update request based on the virtual machine task label, and recording a timestamp initiated by the label update request;
acquiring a response time threshold of the tag update request;
based on the response time threshold and the timestamp initiated by the tag update request, receiving tag update information fed back by the database aiming at the tag update request;
and comparing the tag updating information with the virtual machine task tag in the tag updating request, and generating a tag updating result based on the comparison result.
In some optional embodiments, comparing the tag update information with the virtual machine task tag in the tag update request, and generating a tag update result based on the comparison result, including:
acquiring character values of all characters in the virtual machine task labels;
the character values of the characters in the virtual machine task labels are correspondingly compared with the character values of the contents defined in the label updating information, and a character comparison result is obtained;
when the character comparison result represents that the virtual machine task label is the same as the content defined in the label updating information, generating a label updating result in a database for representing that the virtual machine task label is successfully updated to the computing cluster;
And when the character comparison result represents that the virtual machine task label is different from the content defined in the label updating information, generating a label updating result in the database representing that the virtual machine task label is not successfully updated to the computing cluster.
In some alternative embodiments, the above method further comprises:
when the label updating result indicates that the virtual machine task label of the virtual machine is not successfully updated to the database of the computing cluster, a corresponding closing virtual machine interface is called based on the virtual machine identification so as to bypass the virtualization platform to close the virtual machine.
In some optional embodiments, after feeding back the database update result to the virtualization platform, the method further includes:
when the database updating result is fed back to the virtualization platform successfully, acquiring a service bottom layer calling request initiated by the virtualization platform;
closing the virtual machine based on the service bottom layer calling request to obtain a virtual machine closing result;
and updating the database of the computing cluster and the virtual machine task labels based on the virtual machine closing result.
In some optional embodiments, recording the task execution result and the actual state of the virtual machine, and updating the database and the virtual machine task tag based on the task execution result and the actual state when the virtualization platform resumes communication, including:
Acquiring call information and call results for closing the virtual machine interface;
generating an operation log for operating the virtual machine based on the calling information and the calling result;
updating the operation log into the data of the computing cluster based on the virtual machine identification, and generating a log updating result;
when the log updating result represents that the operation log is successfully updated into the database, the virtualization platform resumes communication and the computing cluster is recovered to be normal, determining an actual execution result of the virtual machine based on the operation log;
comparing the state update label corresponding to the actual execution result with the virtual machine task label to obtain a label comparison result;
when the tag comparison result represents that the state update tag is different from the virtual machine task tag, updating the virtual machine task tag into a state update tag;
when the log updating result indicates that the operation log is not successfully updated to the database, the virtualization platform resumes communication and the computing cluster is recovered to be normal, an initial log for operating the virtual machine in the database is obtained;
updating an initial log stored in a database based on the operation log to obtain a log updating result;
and when the log update result represents that the initial log is successfully updated into the operation log, executing the step of determining the actual execution result of the virtual machine based on the operation log.
In some alternative embodiments, the above method further comprises:
when the control node where the virtual machine is located cannot work normally, generating a virtual machine migration request;
obtaining the rest computing node information in the computing cluster based on the virtual machine migration request;
and determining a target computing node based on the remaining computing node information in the computing cluster, and migrating the virtual machine to a control node in the target computing node.
In a second aspect, the present invention provides a virtual machine state synchronization device, which mainly includes: the system comprises a request acquisition module, a label updating module, a result updating module, an interface calling module and a state synchronization module; the system comprises a request acquisition module, a virtual machine closing module and a virtual machine identification module, wherein the request acquisition module is used for acquiring a virtual machine closing task issued by a virtualization platform, and the virtual machine closing task comprises a virtual machine task tag and a virtual machine identification; the label updating module is used for updating the virtual machine task label to a database of the computing cluster and generating a label updating result when the virtual machine task label represents that the virtual machine is in a to-be-powered-off state, wherein the to-be-powered-off state is determined by fault information of the computing cluster; the result updating module is used for generating a database updating result when the label updating result represents that the task label of the virtual machine is successfully updated to the database of the computing cluster, and feeding the database updating result back to the virtualization platform; the interface calling module is used for calling a corresponding virtual machine closing interface based on the virtual machine identification when the database updating result is not fed back to the virtualization platform successfully so as to bypass the virtualization platform to close the virtual machine; the state synchronization module is used for recording the task execution result and the actual state of the virtual machine, and updating the database and the virtual machine task tag based on the task execution result and the actual state when the communication is restored by the virtualization platform so as to realize the synchronization of the state of the virtual machine. Through the process, when the virtual machine is in the to-be-powered-off state, the virtual machine of which the virtual platform is in the to-be-powered-off state is not informed any more, the virtual machine interface is directly called to be closed through the service bottom layer, and related logs are recorded, so that interaction between the service bottom layer and the virtual platform is reduced, the virtual machine state of the virtual platform is ensured to be consistent with task result records stored in the database, and the problem that the virtual machine is down due to a triggered conflict task because an actual task execution result of the virtual machine is not synchronous with the change of the virtual machine state is avoided.
In a third aspect, the present invention provides a computer device comprising: the virtual machine state synchronization method comprises the steps of storing computer instructions in a memory and a processor, wherein the memory and the processor are in communication connection, and the processor executes the computer instructions, so that the virtual machine state synchronization method of the first aspect or any corresponding implementation mode of the first aspect is executed.
In a fourth aspect, the present invention provides a computer readable storage medium having stored thereon computer instructions for causing a computer to perform the virtual machine state synchronization method of the first aspect or any of its corresponding embodiments.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings that are needed in the description of the embodiments or the prior art will be briefly described, and it is obvious that the drawings in the description below are some embodiments of the present invention, and other drawings can be obtained according to the drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a virtual machine state synchronization method according to an embodiment of the present invention;
FIG. 2 is a flow chart of another virtual machine state synchronization method according to an embodiment of the present invention;
FIG. 3 is a flow chart of a method for synchronizing states of a virtual machine according to an embodiment of the present invention;
FIG. 4 is a flowchart of a method for synchronizing states of a virtual machine according to an embodiment of the present invention;
FIG. 5 is a block diagram of a virtual machine state synchronization device according to an embodiment of the present invention;
fig. 6 is a schematic diagram of a hardware structure of a computer device according to an embodiment of the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments of the present invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
The terms first and second in the description and claims of the invention and in the above-mentioned figures are used for distinguishing between different objects and not for describing a particular sequential order. Furthermore, the term "include" and any variations thereof is intended to cover non-exclusive protection. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those listed steps or elements but may include other steps or elements not listed or inherent to such process, method, article, or apparatus. The term "plurality" in the present invention may mean at least two, for example, two, three or more, and embodiments of the present invention are not limited.
In this embodiment, a method for synchronizing states of virtual machines is provided, the method is applied to a computing cluster, the computing cluster includes a computing node and a control node, a virtualized platform for managing virtual machines and a service bottom layer for providing services for the virtualized platform are operated on the control node, the computing node is a host of the virtual machines, fig. 2 is a flowchart of the method for synchronizing states of virtual machines according to an embodiment of the present invention, as shown in fig. 2, the flowchart includes the following steps:
step S101, a virtual machine closing task issued by a virtualization platform is obtained, wherein the virtual machine closing task comprises a virtual machine task tag and a virtual machine identifier.
And the virtual machine closing task issued by the virtualization platform is acquired, so that the virtual machine identification and the virtual machine task label in the virtual machine closing task close the corresponding virtual machine, and the virtual machine task label is updated.
In some alternative embodiments, when any virtual machine on the virtual platform needs to be closed, a virtual machine closing task is issued through a virtual control on the virtual platform first, and the virtual machine closing task may be recorded in a platform log.
Step S102, when the virtual machine task label characterizes that the virtual machine is in a to-be-powered-off state, updating the virtual machine task label into a database of a computing cluster and generating a label updating result.
As described above, when the virtual machine task label characterizes that the virtual machine is in a to-be-powered-off state, the virtual machine task label is updated to the database of the computing cluster and a label updating result is generated, so that whether the database of the computing cluster is reachable or not is judged, and a necessary condition is provided for data synchronization of the virtualization platform and the service bottom layer.
In some optional embodiments, the to-be-shutdown state (in_shutdown state) is determined by failure information of the computing cluster, that is, shutdown data cannot be dropped later (the shutdown data cannot be updated into the database) due to a failure in the computing cluster, and the state of the virtual machine on the virtualization platform is always in the to-be-shutdown state. Namely, shutdown data is delayed and cannot be dropped due to failure information of a computing cluster, for example: when the service bottom layer acquires that the virtual machine task label of the virtual machine is in a to-be-powered-off state, a label update request can be generated based on the virtual machine task label so as to update the virtual machine task label of the virtual machine into a database of a computing cluster, and a timestamp initiated by the label update request is recorded so as to ensure that the platform record of the virtualization platform is consistent with the database record; meanwhile, a response time threshold value of the tag update request is obtained; based on the response time threshold and the timestamp initiated by the tag update request, receiving tag update information fed back by the database aiming at the tag update request; when the label updating information arrives within the response time threshold, the label updating information is compared with the virtual machine task label in the label updating request, a label updating result is generated based on the comparison result, and a necessary condition is provided for the subsequent virtual machine shutdown mode through the generation of the label updating result.
And step S103, when the label updating result represents that the task label of the virtual machine is successfully updated to the database of the computing cluster, generating a database updating result, and feeding back the database updating result to the virtualization platform.
As above, when the tag update result represents that the task tag of the virtual machine is successfully updated to the database of the computing cluster, the database update result is generated, and the database update result is fed back to the virtualization platform, so that the virtualization platform can generate a request for calling the service bottom layer to close the virtual machine.
In some optional embodiments, the comparison result is obtained by comparing the tag update information with the virtual machine task tag in the tag update request, and when the information identical to the virtual machine task tag in the tag update request exists in the tag update information of the comparison result, a tag update result in a database for representing the virtual machine task tag is generated and successfully updated to the computing cluster, and the database update result is fed back to the virtualization platform, so that the virtualization platform can be informed that the virtual machine task tag representing the virtual machine state is updated, and then execution of the virtual machine task can be closed.
Further, when the database update result is fed back to the virtualization platform, a feedback timestamp of the database update result may be recorded, and timing is performed based on the feedback timestamp, when no response information fed back by the virtualization platform for the database update result is received within a feedback threshold time, it indicates that the database update result is not fed back to the virtualization platform successfully, that is, the virtualization platform is unreachable, and at this time, if the virtualization platform is consistent to call the service bottom layer to close the virtual machine, two risk points exist: the method comprises the steps that a risk point 1, when a management service (including a database) of a virtualization platform has a problem, a virtual machine in a to-be-shut-down state cannot be processed; the risk point 2, the service bottom layer- > the virtualization platform- > the secondary interaction of the service bottom layer are also at execution risk, each interaction is a logic call crossing the virtualization platform and the control node, long call probability is problematic, the task execution result cannot be updated to the database record normally, and the condition that the upper layer data record is inconsistent with the bottom layer is also possible to occur in state change of the virtual machine. And further triggering some system tasks, so that different tasks are triggered simultaneously, for example, after the shutdown failure of the first subtask in the shutdown task, triggering the forced shutdown of the other subtask. Because the shutdown task is not successfully recorded, but the virtual machine is actually shutdown, the system triggers a downtime alarm so as to trigger the virtual machine to restart or migrate, the virtual machine is pulled up again, and the same virtual machine generates superposition of two tasks.
Step S104, when the database updating result is not fed back to the virtualization platform successfully, the corresponding virtual machine closing interface is called based on the virtual machine identification so as to bypass the virtualization platform to close the virtual machine.
And when the database updating result is not fed back to the virtualization platform successfully, calling a corresponding virtual machine closing interface based on the virtual machine identifier so as to bypass the virtualization platform to close the virtual machine, and reducing interaction between the service bottom layer and the virtualization platform, thereby ensuring that the state of the virtual machine of the virtualization platform is consistent with the task result record stored in the database.
In some optional embodiments, when the response information fed back by the virtualization platform for the database update result is not received within the feedback threshold time, the response information indicates that the database update result is not fed back to the virtualization platform successfully, and at this time, the service bottom layer directly calls a corresponding shutdown virtual machine interface based on the virtual machine identifier to bypass the virtualization platform to shutdown the virtual machine.
Step S105, recording the task execution result and the actual state of the virtual machine, and updating the database and the task labels of the virtual machine based on the task execution result and the actual state when the communication is restored by the virtualization platform so as to realize the synchronization of the state of the virtual machine.
As described above, by recording the task execution result and the actual state of the virtual machine, and updating the database and the virtual machine task tag based on the task execution result and the actual state when the virtualization platform resumes communication, synchronization of the virtual machine state is achieved, and the situation that the virtual machine is down due to a triggered conflict task when the actual task execution result of the virtual machine and the virtual machine state change are not synchronized is avoided. The reliability and stability of the virtual machine can be improved, and the normal operation of the virtual machine under the situation that the computing cluster fails or high-voltage load is ensured not to influence the service.
In some optional embodiments, when the service bottom layer directly calls the corresponding shutdown virtual machine interface to shutdown the virtual machine based on the virtual machine identifier, relevant operation logs of the task execution result and the actual state (for example, found vm [ i-0000xx]is in_shutdown status,try to destory it.The execution was successful// execution result is successful) may be recorded in the virtualized proxy service of the service bottom layer, and the database and the virtual machine task tag may be updated based on the task execution result and the actual state when the virtualized platform resumes communication, so as to achieve synchronization of the virtual machine state.
In some optional embodiments, recording a task execution result and an actual state of the virtual machine, and when the virtual platform resumes communication, updating the database and the virtual machine task tag based on the task execution result and the actual state, and acquiring call information and call results for closing the virtual machine interface; generating an operation log for operating the virtual machine based on the calling information and the calling result; updating the operation log into the data of the computing cluster based on the virtual machine identification, and generating a log updating result; when the log updating result represents that the operation log is successfully updated into the database, the virtualization platform resumes communication and the computing cluster is recovered to be normal, determining an actual execution result of the virtual machine based on the operation log; comparing the state update label corresponding to the actual execution result with the virtual machine task label to obtain a label comparison result; when the tag comparison result represents that the state update tag is different from the virtual machine task tag, updating the virtual machine task tag into a state update tag; when the log updating result indicates that the operation log is not successfully updated to the database, the virtualization platform resumes communication and the computing cluster is recovered to be normal, an initial log for operating the virtual machine in the database is obtained; updating an initial log stored in a database based on the operation log to obtain a log updating result; when the log updating result represents that the initial log is successfully updated into the operation log, determining an actual execution result of the virtual machine based on the operation log; and when the tag comparison result represents that the state update tag is different from the virtual machine task tag, updating the virtual machine task tag into a state update tag.
In some optional embodiments, when a control node where the virtual machine is located cannot work normally, a virtual machine migration request is generated; obtaining the rest computing node information in the computing cluster based on the virtual machine migration request; and determining a target computing node based on the rest computing node information in the computing cluster, and migrating the virtual machine to a control node in the target computing node so as to realize normal operation of the virtual machine.
According to the virtual machine state synchronization method provided by the embodiment, firstly, a virtual machine closing task issued by a virtualization platform is acquired, so that a virtual machine identifier and a virtual machine task label in the virtual machine closing task close a corresponding virtual machine, and the virtual machine task label is updated; when the virtual machine task label characterizes that the virtual machine is in a to-be-powered-off state, the virtual machine task label is updated to a database of a computing cluster and a label updating result is generated so as to judge whether the database of the computing cluster is reachable or not, and a necessary condition is provided for data synchronization of a virtualization platform and a service bottom layer; when the task labels of the virtual machines are represented by the label updating results and are successfully updated to the database of the computing cluster, generating a database updating result, and feeding back the database updating result to the virtualization platform so that the virtualization platform can generate a request for calling a service bottom layer to close the virtual machines; when the database updating result is not fed back to the virtualization platform successfully, a corresponding virtual machine closing interface is called based on the virtual machine identification so as to bypass the virtualization platform to close the virtual machine, reduce interaction between a service bottom layer and the virtualization platform and interaction between the service bottom layer and other computing nodes in the computing cluster, and further ensure that the state of the virtual machine of the virtualization platform is consistent with task result records stored in the database; the method comprises the steps of recording a task execution result and an actual state of a virtual machine, updating a database and a virtual machine task tag based on the task execution result and the actual state when the communication is restored by a virtualization platform, so that the state of the virtual machine is synchronized, and the situation that the virtual machine is down due to a triggered conflict task when the actual task execution result of the virtual machine is not synchronized with the change of the state of the virtual machine is avoided. Therefore, when the virtual machine is in the to-be-powered-off state, the virtual machine of the to-be-powered-off state of the virtual platform is not notified any more, the virtual machine interface is directly called to be closed through the service bottom layer, and related logs are recorded, so that interaction between the service bottom layer and the virtual platform is reduced, the virtual machine state of the virtual platform is ensured to be consistent with task result records stored in the database, and the problem that the virtual machine is down due to a triggered conflict task because an actual task execution result of the virtual machine is not synchronous with a virtual machine state change is avoided.
In this embodiment, a method for synchronizing states of virtual machines is provided, the method is applied to a computing cluster, the computing cluster includes a computing node and a control node, a virtualized platform for managing virtual machines and a service bottom layer for providing services for the virtualized platform are operated on the control node, the computing node is a host of the virtual machines, fig. 3 is a flowchart of the method for synchronizing states of virtual machines according to an embodiment of the present invention, as shown in fig. 2, the flowchart includes the following steps:
step S201, a virtual machine closing task issued by a virtualization platform is obtained, wherein the virtual machine closing task comprises a virtual machine task tag and a virtual machine identifier.
Please refer to step S101 in the embodiment shown in fig. 1 in detail, which is not described herein.
Step S202, when the virtual machine task label characterizes that the virtual machine is in a to-be-powered-off state, updating the virtual machine task label to a database of a computing cluster and generating a label updating result.
Specifically, the step S202 includes:
in step S2021, a tag update request is generated based on the virtual machine task tag, and a timestamp initiated by the tag update request is recorded.
As above, by generating a tag update request based on the virtual machine task tag and recording a timestamp of the initiation of the tag update request, it is convenient to determine whether the wait for acknowledgement time of the tag update request is greater than an acknowledgement time threshold based on the timestamp of the initiation of the tag update request.
In step S2022, a response time threshold of the tag update request is acquired.
As described above, by acquiring the response time threshold of the tag update request, a necessary condition is provided for determining whether the virtual machine task tag in the database is successfully updated.
Step S2023, based on the response time threshold and the timestamp initiated by the tag update request, receives tag update information fed back by the database for the tag update request.
As described above, the tag update information fed back by the database for the tag update request is received based on the response time threshold and the timestamp initiated by the tag update request, so as to provide data support for determining the tag update result.
Step S2024 compares the label update information with the virtual machine task labels in the label update request, and generates a label update result based on the comparison result.
As described above, the tag update information is compared with the task tag of the virtual machine in the tag update request, and a tag update result is generated based on the comparison result, so that a necessary condition is provided for selection of a mode of shutdown of the subsequent virtual machine.
In some optional embodiments, comparing the tag update information with the virtual machine task tag in the tag update request, and obtaining a character value of each character in the virtual machine task tag when generating a tag update result based on the comparison result; the character values of the characters in the virtual machine task labels are correspondingly compared with the character values of the contents defined in the label updating information, and a character comparison result is obtained; when the character comparison result represents that the virtual machine task label is the same as the content defined in the label updating information, generating a label updating result in a database for representing that the virtual machine task label is successfully updated to the computing cluster; and when the character comparison result represents that the virtual machine task label is different from the content defined in the label updating information, generating a label updating result in the database representing that the virtual machine task label is not successfully updated to the computing cluster.
In some optional embodiments, the tag update information is compared with the virtual machine task tag in the tag update request, and when a tag update result is generated based on the comparison result, a first hash value obtained by performing hash operation on the content defined by the virtual machine task tag may also be obtained; correspondingly comparing the first hash value of the virtual machine task tag with the second hash value of the content defined in the tag update information to obtain a hash comparison result; when the hash comparison result represents that the virtual machine task label is the same as the content defined in the label updating information, generating a label updating result in a database for representing that the virtual machine task label is successfully updated to the computing cluster; and when the hash comparison result represents that the virtual machine task label is different from the content defined in the label updating information, generating a label updating result in the database representing that the virtual machine task label is not successfully updated to the computing cluster.
Step S203, when the label updating result represents that the task label of the virtual machine is successfully updated to the database of the computing cluster, generating a database updating result, and feeding back the database updating result to the virtualization platform.
Please refer to step S103 in the embodiment shown in fig. 1 in detail, which is not described herein.
Step S204, when the database updating result is not fed back to the virtualization platform successfully, the corresponding shutdown virtual machine interface is called based on the virtual machine identification so as to bypass the virtualization platform to shutdown the virtual machine.
Please refer to step S104 in the embodiment shown in fig. 1 in detail, which is not described herein.
Step S205, recording the task execution result and the actual state of the virtual machine, and updating the database and the task labels of the virtual machine based on the task execution result and the actual state when the communication is restored by the virtualization platform so as to realize the synchronization of the state of the virtual machine.
Please refer to step S105 in the embodiment shown in fig. 1 in detail, which is not described herein.
According to the virtual machine state synchronization method provided by the embodiment, firstly, a virtual machine closing task issued by a virtualization platform is acquired, so that a virtual machine identifier and a virtual machine task label in the virtual machine closing task close a corresponding virtual machine, and the virtual machine task label is updated; when the virtual machine task label characterizes that the virtual machine is in a to-be-powered-off state, the virtual machine task label is updated to a database of a computing cluster and a label updating result is generated so as to judge whether the database of the computing cluster is reachable or not, and a necessary condition is provided for data synchronization of a virtualization platform and a service bottom layer; when the task labels of the virtual machines are represented by the label updating results and are successfully updated to the database of the computing cluster, generating a database updating result, and feeding back the database updating result to the virtualization platform so that the virtualization platform can generate a request for calling a service bottom layer to close the virtual machines; when the database updating result is not fed back to the virtualization platform successfully, a corresponding virtual machine closing interface is called based on the virtual machine identification so as to bypass the virtualization platform to close the virtual machine, and interaction between the service bottom layer and the virtualization platform is reduced, so that the state of the virtual machine of the virtualization platform is ensured to be consistent with the task result record stored in the database; the method comprises the steps of recording a task execution result and an actual state of a virtual machine, updating a database and a virtual machine task tag based on the task execution result and the actual state when the communication is restored by a virtualization platform, so that the state of the virtual machine is synchronized, and the situation that the virtual machine is down due to a triggered conflict task when the actual task execution result of the virtual machine is not synchronized with the change of the state of the virtual machine is avoided. Therefore, when the virtual machine is in the to-be-powered-off state, the virtual machine of the to-be-powered-off state of the virtual platform is not notified any more, the virtual machine interface is directly called to be closed through the service bottom layer, and related logs are recorded, so that interaction between the service bottom layer and the virtual platform is reduced, the virtual machine state of the virtual platform is ensured to be consistent with task result records stored in the database, and the problem that the virtual machine is down due to a triggered conflict task because an actual task execution result of the virtual machine is not synchronous with a virtual machine state change is avoided.
In this embodiment, a method for synchronizing states of virtual machines is provided, the method is applied to a computing cluster, the computing cluster includes a computing node and a control node, a virtualized platform for managing virtual machines and a service bottom layer for providing services for the virtualized platform are operated on the control node, the computing node is a host of the virtual machines, fig. 3 is a flowchart of the method for synchronizing states of virtual machines according to an embodiment of the present invention, as shown in fig. 3, the flowchart includes the following steps:
step S301, a virtual machine closing task issued by a virtualization platform is obtained, wherein the virtual machine closing task comprises a virtual machine task tag and a virtual machine identifier.
Please refer to step S101 in the embodiment shown in fig. 1 in detail, which is not described herein.
Step S302, when the virtual machine task label characterizes that the virtual machine is in a to-be-powered-off state, updating the virtual machine task label to a database of a computing cluster and generating a label updating result.
Please refer to step S202 in the embodiment shown in fig. 2, which is not described herein.
Step S303, when the label updating result represents that the task label of the virtual machine is successfully updated to the database of the computing cluster, generating a database updating result, and feeding back the database updating result to the virtualization platform.
Please refer to step S203 in the embodiment shown in fig. 1 in detail, which is not described herein.
Step S304, when the label updating result indicates that the virtual machine task label of the virtual machine is not successfully updated to the database of the computing cluster, a corresponding virtual machine closing interface is called based on the virtual machine identification so as to bypass the virtualization platform to close the virtual machine.
As described above, when the label update result indicates that the virtual machine task label of the virtual machine is not successfully updated to the database of the computing cluster, the corresponding virtual machine closing interface is called based on the virtual machine identification, so that the virtual machine is closed by bypassing the virtualization platform, the interaction between the service bottom layer and the virtualization platform is reduced, and the condition that the virtual machine state of the virtualization platform is consistent with the task result record stored in the database is ensured.
In some optional embodiments, a tag update request may be generated based on a virtual machine task tag, so as to update the virtual machine task tag of the virtual machine to a database of a computing cluster, and record a timestamp initiated by the tag update request, so as to ensure that a platform record of a virtualization platform is consistent with a database record; meanwhile, a response time threshold value of the tag update request is obtained; based on the response time threshold and the timestamp initiated by the tag update request, receiving tag update information fed back by the database aiming at the tag update request; and when the tag update information arrives within the response time threshold, generating a tag update result that the virtual machine task tag representing the virtual machine is not successfully updated to the database of the computing cluster. At this time, the service bottom layer directly calls a corresponding shutdown virtual machine interface based on the virtual machine identification so as to bypass the virtualization platform to shutdown the virtual machine.
According to the virtual machine state synchronization method provided by the embodiment, firstly, a virtual machine closing task issued by a virtualization platform is acquired, so that a virtual machine identifier and a virtual machine task label in the virtual machine closing task close a corresponding virtual machine, and the virtual machine task label is updated; when the virtual machine task label characterizes that the virtual machine is in a to-be-powered-off state, the virtual machine task label is updated to a database of a computing cluster and a label updating result is generated so as to judge whether the database of the computing cluster is reachable or not, and a necessary condition is provided for data synchronization of a virtualization platform and a service bottom layer; when the task labels of the virtual machines are represented by the label updating results and are successfully updated to the database of the computing cluster, generating a database updating result, and feeding back the database updating result to the virtualization platform so that the virtualization platform can generate a request for calling a service bottom layer to close the virtual machines; when the label updating result indicates that the virtual machine task label of the virtual machine is not successfully updated to the database of the computing cluster, a corresponding virtual machine closing interface is called based on the virtual machine identification so as to bypass the virtualization platform to close the virtual machine, and interaction between the service bottom layer and the virtualization platform is reduced, so that the state of the virtual machine of the virtualization platform is ensured to be consistent with the task result record stored in the database. Therefore, when the virtual machine is in the to-be-powered-off state, the virtual machine of the to-be-powered-off state of the virtual platform is not notified any more, the virtual machine interface is directly called to be closed through the service bottom layer, and related logs are recorded, so that interaction between the service bottom layer and the virtual platform is reduced, the virtual machine state of the virtual platform is ensured to be consistent with task result records stored in the database, and the problem that the virtual machine is down due to a triggered conflict task because an actual task execution result of the virtual machine is not synchronous with a virtual machine state change is avoided.
In this embodiment, a method for synchronizing states of virtual machines is provided, the method is applied to a computing cluster, the computing cluster includes a computing node and a control node, a virtualized platform for managing virtual machines and a service bottom layer for providing services for the virtualized platform are operated on the control node, the computing node is a host of the virtual machines, fig. 4 is a flowchart of the method for synchronizing states of virtual machines according to an embodiment of the present invention, as shown in fig. 4, the flowchart includes the following steps:
step S401, a virtual machine closing task issued by a virtualization platform is obtained, wherein the virtual machine closing task comprises a virtual machine task tag and a virtual machine identifier.
Please refer to step S101 in the embodiment shown in fig. 1 in detail, which is not described herein.
Step S402, when the virtual machine task label characterizes that the virtual machine is in a to-be-powered-off state, updating the virtual machine task label to a database of a computing cluster and generating a label updating result.
Please refer to step S202 in the embodiment shown in fig. 2, which is not described herein.
Step S403, when the label updating result represents that the task label of the virtual machine is successfully updated to the database of the computing cluster, generating a database updating result, and feeding back the database updating result to the virtualization platform.
Please refer to step S103 in the embodiment shown in fig. 1 in detail, which is not described herein.
Step S404, when the database updating result is fed back to the virtualization platform successfully, a service bottom layer calling request initiated by the virtualization platform is obtained.
As above, when the database updating result is successfully fed back to the virtualization platform, the service bottom layer calling request initiated by the virtualization platform is acquired, so that the virtual machine is conveniently closed based on the service bottom layer calling request.
In some optional embodiments, when response information fed back by the virtualization platform for the database update result is received within a feedback threshold time, the response information indicates that the database update result has been fed back to the virtualization platform successfully, and at this time, the virtualization platform will initiate a service bottom layer call request to close the virtual machine through the service bottom layer.
And step S405, closing the virtual machine based on the service bottom layer calling request to obtain a virtual machine closing result.
As above, the virtual machine is closed based on the service bottom layer calling request to obtain the closing result of the virtual machine, and a necessary condition is provided for updating the database of the computing cluster and updating the task label of the virtual machine in the virtualization platform.
In some optional embodiments, when receiving a service bottom layer call request sent by a virtualization platform, the service bottom layer calls a virtualization management service based on a virtual machine identifier carried in the service bottom layer call request, queries a virtual machine port number corresponding to the virtual machine identifier through the virtualization management service, determines a corresponding virtual machine interface based on the virtual machine port number, and performs forced closing, and simultaneously obtains a corresponding virtual machine closing result.
Step S406, updating the database of the computing cluster and the virtual machine task labels based on the virtual machine closing result.
As described above, the database of the computing cluster and the virtual machine task tag are updated based on the virtual machine closing result, so that the virtual machine state of the virtualization platform is ensured to be consistent with the task result record stored in the database.
In specific implementation, a shutdown task is issued through the virtualization platform, and before the task is successfully executed, a control node where the virtual machine is located fails (a control node network fails, a storage fails, the control node is powered off, restarted, and the like), and two unreachable processes exist due to the control node failure: the service bottom layer can not inform the virtualization platform of the current virtual machine state or the virtualization platform can not call the forced closing virtual machine interface of the service bottom layer virtualization proxy service any more. Therefore, when the control node fails, the service bottom layer detects that the virtual machine is in a to-be-powered-off state and does not inform the virtualization platform any more, and then the virtualization platform recalls the forced shutdown virtual machine interface of the service bottom layer virtualization proxy service. At this time, the service bottom layer detects the virtual machine in the to-be-powered off state, and can automatically call to close the virtual machine interface to close the virtual machine, and record relevant logs (such as found vm [ i-0000xx]is in_shutdown status,try to destory it ]) in the virtualized proxy service. And after the control node fault is recovered, synchronizing the task execution log and the virtual machine state to a virtualized platform database, and synchronously updating the real state of the virtual machine.
Further, on the premise that the virtualized platform has no fault, the virtual machine is closed. After the virtual machine of the virtualized platform reaches a certain scale, the system disk load of the computing cluster is higher, so that the writing delay of the database is higher, the database cannot fall off in delay, and for the virtual machine of the shutdown task and the to-be-shutdown state, although the execution of the shutdown statement updates the task execution result and the virtual machine state, the virtual machine does not fall into the database until the actual task execution result and the virtual machine state are not updated. At this time, the service bottom layer detects the virtual machine in the in_shutdown state, directly calls to close the virtual machine interface to close the virtual machine, and synchronously records the related logs in the virtualized proxy service. And ensuring that the task execution result record is consistent with the state of the virtual machine. Thereby avoiding the conflict of simultaneously triggering two starting and shutdown tasks aiming at the virtual machine.
Further, when the database is abnormal, the scene is similar when the pressure is too large, the task result is not updated normally because the task data cannot be dropped normally, the virtual machine state is not changed, after the platform receives the in_shutdown message, the task of closing the virtual machine forcefully is launched again, but after the shutdown task is started to be executed, the virtual machine state is not updated successfully, the High Availability (HA) startup task is triggered, the virtual machine state is modified by another task, and the failure of the shutdown task is finally caused. The scene is optimized to the virtual machine in the in_shutdown state detected by the bottom layer, the virtual machine interface is directly called to be closed to close the virtual machine, and the task of forcedly closing the virtual machine is not initiated through the platform. Synchronization records the relevant logs in the virtualized proxy service. And ensuring that the task execution result record is consistent with the state of the virtual machine. Thereby avoiding the conflict of simultaneously triggering two starting and shutdown tasks aiming at the virtual machine.
According to the virtual machine state synchronization method provided by the embodiment, firstly, a virtual machine closing task issued by a virtualization platform is acquired, so that a virtual machine identifier and a virtual machine task label in the virtual machine closing task close a corresponding virtual machine, and the virtual machine task label is updated; when the virtual machine task label characterizes that the virtual machine is in a to-be-powered-off state, the virtual machine task label is updated to a database of a computing cluster and a label updating result is generated so as to judge whether the database of the computing cluster is reachable or not, and a necessary condition is provided for data synchronization of a virtualization platform and a service bottom layer; when the task labels of the virtual machines are represented by the label updating results and are successfully updated to the database of the computing cluster, generating a database updating result, and feeding back the database updating result to the virtualization platform so that the virtualization platform can generate a request for calling a service bottom layer to close the virtual machines; when the database updating result is fed back to the virtualization platform successfully, a service bottom layer calling request initiated by the virtualization platform is acquired, so that the virtual machine is closed based on the service bottom layer calling request; closing the virtual machine based on the service bottom layer calling request to obtain a virtual machine closing result, and providing necessary conditions for updating a database of the computing cluster and updating task labels of the virtual machine in the virtualization platform; and updating the database of the computing cluster and the task labels of the virtual machines based on the closing result of the virtual machines, so that the state of the virtual machines of the virtualization platform is ensured to be consistent with the task result record stored in the database. Therefore, when the virtual machine is in the to-be-powered-off state, the virtual machine of the to-be-powered-off state of the virtual platform is not notified any more, the virtual machine interface is directly called to be closed through the service bottom layer, and related logs are recorded, so that interaction between the service bottom layer and the virtual platform is reduced, the virtual machine state of the virtual platform is ensured to be consistent with task result records stored in the database, and the problem that the virtual machine is down due to a triggered conflict task because an actual task execution result of the virtual machine is not synchronous with a virtual machine state change is avoided.
The embodiment also provides a virtual machine state synchronization device, which is used for implementing the above embodiment and the preferred implementation, and is not described in detail. As used below, the term "module" may be a combination of software and/or hardware that implements a predetermined function. While the means described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware, is also possible and contemplated.
The present embodiment provides a virtual machine state synchronization device, as shown in fig. 5, including:
the request obtaining module 501 is configured to obtain a virtual machine closing task issued by the virtualization platform, where the virtual machine closing task includes a virtual machine task tag and a virtual machine identifier.
The tag updating module 502 is configured to update the task tag of the virtual machine to a database of the computing cluster and generate a tag updating result when the task tag of the virtual machine characterizes that the virtual machine is in a to-be-powered off state.
The result updating module 503 is configured to generate a database update result when the tag update result characterizes that the task tag of the virtual machine is successfully updated to the database of the computing cluster, and feed back the database update result to the virtualization platform.
And the interface calling module 504 is configured to call a corresponding shutdown virtual machine interface based on the virtual machine identifier to bypass the virtualization platform to shutdown the virtual machine when the database update result is not successfully fed back to the virtualization platform.
The state synchronization module 505 is configured to record a task execution result and an actual state of the virtual machine, and update a database and a task tag of the virtual machine based on the task execution result and the actual state when the virtualization platform resumes communication, so as to achieve synchronization of the state of the virtual machine.
In some alternative embodiments, the tag update module 502 includes:
generating a label update request based on the virtual machine task label, and recording a timestamp initiated by the label update request;
acquiring a response time threshold of the tag update request;
based on the response time threshold and the timestamp initiated by the tag update request, receiving tag update information fed back by the database aiming at the tag update request;
the label updating unit is used for comparing the label updating information with the virtual machine task labels in the label updating request and generating a label updating result based on the comparison result.
In some alternative embodiments, the tag updating unit includes:
the character acquisition unit is used for acquiring character values of all characters in the virtual machine task tag;
The character comparison unit is used for correspondingly comparing the character values of the characters in the virtual machine task tag with the character values of the contents defined in the tag updating information to obtain a character comparison result;
the first result generation unit is used for generating a label updating result in a database for successfully updating the task label of the characterization virtual machine to the computing cluster when the character comparison result characterizes the task label of the virtual machine to be the same as the content defined in the label updating information;
and the second result generating unit is used for generating a label updating result in the database for representing that the virtual machine task label is not successfully updated to the computing cluster when the character comparison result represents that the virtual machine task label is different from the content defined in the label updating information.
In some alternative embodiments, the result update module 503 is further configured to:
when the label updating result indicates that the virtual machine task label of the virtual machine is not successfully updated to the database of the computing cluster, a corresponding closing virtual machine interface is called based on the virtual machine identification so as to bypass the virtualization platform to close the virtual machine.
In some alternative embodiments, the interface invocation module 504 includes:
the request acquisition unit is used for acquiring a service bottom layer calling request initiated by the virtualization platform when the database updating result is fed back to the virtualization platform successfully;
The result acquisition unit is used for closing the virtual machine based on the service bottom layer calling request to obtain a virtual machine closing result;
and the result updating unit is used for updating the database of the computing cluster and the task labels of the virtual machines based on the closing result of the virtual machines.
In some alternative embodiments, the interface calling module 504 is specifically configured to:
acquiring call information and call results for closing the virtual machine interface;
generating an operation log for operating the virtual machine based on the calling information and the calling result;
updating the operation log into the data of the computing cluster based on the virtual machine identification, and generating a log updating result;
when the log updating result represents that the operation log is successfully updated into the database, the virtualization platform resumes communication and the computing cluster is recovered to be normal, determining an actual execution result of the virtual machine based on the operation log;
comparing the state update label corresponding to the actual execution result with the virtual machine task label to obtain a label comparison result;
when the tag comparison result represents that the state update tag is different from the virtual machine task tag, updating the virtual machine task tag into a state update tag;
when the log updating result indicates that the operation log is not successfully updated to the database, the virtualization platform resumes communication and the computing cluster is recovered to be normal, an initial log for operating the virtual machine in the database is obtained;
Updating an initial log stored in a database based on the operation log to obtain a log updating result;
and when the log update result represents that the initial log is successfully updated into the operation log, executing the step of determining the actual execution result of the virtual machine based on the operation log.
In some optional embodiments, the state synchronization module 505 is further configured to generate a virtual machine migration request when a control node where the virtual machine is located fails to work normally; obtaining the rest computing node information in the computing cluster based on the virtual machine migration request; and determining a target computing node based on the remaining computing node information in the computing cluster, and migrating the virtual machine to a control node in the target computing node.
Further functional descriptions of the above respective modules and units are the same as those of the above corresponding embodiments, and are not repeated here.
The virtual machine state synchronization device in this embodiment is presented as a functional unit, where the unit refers to an ASIC (application specific integrated circuit) circuit, a processor and a memory that execute one or more software or firmware programs, and/or other devices that may provide the above functions.
The embodiment of the invention also provides computer equipment, which is provided with the virtual machine state synchronization device shown in the figure 5.
Referring to fig. 6, fig. 6 is a schematic structural diagram of a computer device according to an alternative embodiment of the present invention, as shown in fig. 6, the computer device includes: one or more processors 10, memory 20, and interfaces for connecting the various components, including high-speed interfaces and low-speed interfaces. The various components are communicatively coupled to each other using different buses and may be mounted on a common motherboard or in other manners as desired. The processor may process instructions executing within the computer device, including instructions stored in or on memory to display graphical information of the GUI on an external input/output device, such as a display device coupled to the interface. In some alternative embodiments, multiple processors and/or multiple buses may be used, if desired, along with multiple memories and multiple memories. Also, multiple computer devices may be connected, each providing a portion of the necessary operations (e.g., as a storage server array, a set of blade storage servers, or a multiprocessor system). One processor 10 is illustrated in fig. 6.
The processor 10 may be a central processor, a network processor, or a combination thereof. The processor 10 may further include a hardware chip, among others. The hardware chip may be an application specific integrated circuit, a programmable logic device, or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general-purpose array logic, or any combination thereof.
Wherein the memory 20 stores instructions executable by the at least one processor 10 to cause the at least one processor 10 to perform a method for implementing the embodiments described above.
The memory 20 may include a storage program area that may store an operating system, at least one application program required for functions, and a storage data area; the storage data area may store data created from the use of the computer device of the presentation of a sort of applet landing page, and the like. In addition, the memory 20 may include high-speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid-state storage device. In some alternative embodiments, memory 20 may optionally include memory located remotely from processor 10, which may be connected to the computer device via a network. Examples of such networks include, but are not limited to, the internet, intranets, server clusters, mobile communication networks, and combinations thereof.
Memory 20 may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as flash memory, hard disk, or solid state disk; the memory 20 may also comprise a combination of the above types of memories.
The computer device also includes a communication interface 30 for the computer device to communicate with other devices or communication networks.
The embodiments of the present invention also provide a computer readable storage medium, and the method according to the embodiments of the present invention described above may be implemented in hardware, firmware, or as a computer code which may be recorded on a storage medium, or as original stored in a remote storage medium or a non-transitory machine readable storage medium downloaded through a network and to be stored in a local storage medium, so that the method described herein may be stored on such software process on a storage medium using a general purpose computer, a special purpose processor, or programmable or special purpose hardware. The storage medium can be a magnetic disk, an optical disk, a read-only memory, a random access memory, a flash memory, a hard disk, a solid state disk or the like; further, the storage medium may also comprise a combination of memories of the kind described above. It will be appreciated that a computer, processor, microprocessor controller or programmable hardware includes a storage element that can store or receive software or computer code that, when accessed and executed by the computer, processor or hardware, implements the methods illustrated by the above embodiments.
Although embodiments of the present invention have been described in connection with the accompanying drawings, various modifications and variations may be made by those skilled in the art without departing from the spirit and scope of the invention, and such modifications and variations fall within the scope of the invention as defined by the appended claims.
Claims (10)
1. The utility model provides a virtual machine state synchronization method, which is characterized in that the method is applied to a computing cluster, the computing cluster comprises a computing node and a control node, a virtualized platform for managing virtual machines and a service bottom layer for providing services for the virtualized platform are operated on the control node, and the computing node is a host machine of the virtual machines, and the method comprises the following steps:
acquiring a virtual machine closing task issued by the virtualization platform, wherein the virtual machine closing task comprises a virtual machine task tag and a virtual machine identifier;
when the virtual machine task label characterizes that the virtual machine is in a to-be-powered-off state, updating the virtual machine task label into a database of the computing cluster and generating a label updating result;
when the label updating result represents that the virtual machine task label is successfully updated to the database of the computing cluster, generating a database updating result, and feeding back the database updating result to the virtualization platform;
When the database updating result is not fed back to the virtualization platform successfully, calling a corresponding virtual machine closing interface based on the virtual machine identification so as to bypass the virtualization platform to close the virtual machine;
and recording a task execution result and an actual state of the virtual machine, and updating the database and the task tag of the virtual machine based on the task execution result and the actual state when the communication is restored by the virtualization platform so as to realize the synchronization of the state of the virtual machine.
2. The method of claim 1, wherein updating the virtual machine task labels into the database of the computing cluster and generating label update results comprises:
generating a tag update request based on the virtual machine task tag, and recording a timestamp initiated by the tag update request;
acquiring a response time threshold of the tag update request;
based on the response time threshold and the timestamp initiated by the tag update request, receiving tag update information fed back by the database for the tag update request;
and comparing the tag updating information with the virtual machine task tag in the tag updating request, and generating the tag updating result based on the comparison result.
3. The method of claim 2, wherein comparing the tag update information with a virtual machine task tag in the tag update request and generating the tag update result based on the comparison result comprises:
acquiring character values of all characters in the virtual machine task labels;
correspondingly comparing the character value of each character in the virtual machine task tag with the character value of the content defined in the tag updating information to obtain a character comparison result;
when the character comparison result represents that the virtual machine task tag is the same as the content defined in the tag update information, generating a tag update result in a database representing that the virtual machine task tag is successfully updated to the computing cluster;
and when the character comparison result represents that the virtual machine task label is different from the content defined in the label updating information, generating a label updating result in the database representing that the virtual machine task label is not successfully updated to the computing cluster.
4. The method according to claim 1, wherein the method further comprises:
and when the label updating result represents that the virtual machine task label of the virtual machine is not successfully updated to the database of the computing cluster, calling a corresponding closing virtual machine interface based on the virtual machine identification so as to bypass the virtualization platform to close the virtual machine.
5. The method of claim 4, wherein after feeding back the database update result to the virtualization platform, further comprising:
when the database updating result is fed back to the virtualization platform successfully, acquiring a service bottom layer calling request initiated by the virtualization platform;
closing the virtual machine based on the service bottom layer calling request to obtain a virtual machine closing result;
and updating the database of the computing cluster and the virtual machine task tag based on the virtual machine closing result.
6. The method according to any one of claims 1 to 5, wherein the recording the task execution result and the actual state of the virtual machine, and updating the database and the virtual machine task tag based on the task execution result and the actual state when the virtualization platform resumes communication, comprises:
acquiring calling information and calling results of closing the virtual machine interface;
generating an operation log for operating the virtual machine based on the calling information and the calling result;
updating the operation log into the data of the computing cluster based on the virtual machine identifier, and generating a log updating result;
When the log updating result represents that the operation log is successfully updated into the database, and the virtualization platform or the computing cluster resumes communication, determining an actual execution result of the virtual machine based on the operation log;
comparing the state update label corresponding to the actual execution result with the virtual machine task label to obtain a label comparison result;
when the tag comparison result indicates that the state update tag is different from the virtual machine task tag, updating the virtual machine task tag into the state update tag;
when the log updating result represents that the operation log is not successfully updated to the database, the virtualization platform or the computing cluster resumes communication, an initial log for operating the virtual machine in the database is obtained;
updating an initial log stored in the database based on the operation log to obtain a log updating result;
and when the log updating result represents that the initial log is successfully updated into the operation log, executing the step of determining the actual execution result of the virtual machine based on the operation log.
7. The method of claim 6, wherein the method further comprises:
when the control node where the virtual machine is located cannot work normally, generating a virtual machine migration request;
obtaining the rest computing node information in the computing cluster based on the virtual machine migration request;
and determining a target computing node based on the rest computing node information in the computing cluster, and migrating the virtual machine to a control node in the target computing node.
8. A virtual machine state synchronization apparatus, the apparatus comprising:
the request acquisition module is used for acquiring a virtual machine closing task issued by the virtualization platform, wherein the virtual machine closing task comprises a virtual machine task tag and a virtual machine identifier;
the label updating module is used for updating the task label of the virtual machine to a database of a computing cluster and generating a label updating result when the task label of the virtual machine characterizes the virtual machine to be in a to-be-powered off state;
the result updating module is used for generating a database updating result when the label updating result represents that the task label of the virtual machine is successfully updated to the database of the computing cluster, and feeding back the database updating result to the virtualization platform;
The interface calling module is used for calling a corresponding virtual machine closing interface based on the virtual machine identifier to bypass the virtualization platform to close the virtual machine when the database updating result is not fed back to the virtualization platform successfully;
and the state synchronization module is used for recording the task execution result and the actual state of the virtual machine, and updating the database and the virtual machine task tag based on the task execution result and the actual state when the communication is restored by the virtualization platform so as to realize the synchronization of the state of the virtual machine.
9. A computer device, comprising:
a memory and a processor in communication with each other, the memory having stored therein computer instructions which, upon execution, cause the processor to perform the method of any of claims 1 to 7.
10. A computer readable storage medium having stored thereon computer instructions for causing a computer to perform the method of any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311541162.1A CN117573280A (en) | 2023-11-17 | 2023-11-17 | Virtual machine state synchronization method, device, equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311541162.1A CN117573280A (en) | 2023-11-17 | 2023-11-17 | Virtual machine state synchronization method, device, equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN117573280A true CN117573280A (en) | 2024-02-20 |
Family
ID=89860066
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202311541162.1A Pending CN117573280A (en) | 2023-11-17 | 2023-11-17 | Virtual machine state synchronization method, device, equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN117573280A (en) |
-
2023
- 2023-11-17 CN CN202311541162.1A patent/CN117573280A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US20180285216A1 (en) | Virtual Machine Recovery Method and Virtual Machine Management Device | |
CN109656742B (en) | Node exception handling method and device and storage medium | |
CN110247984B (en) | Service processing method, device and storage medium | |
US20070288532A1 (en) | Method of updating an executable file for a redundant system with old and new files assured | |
CN112199240B (en) | Method for switching nodes during node failure and related equipment | |
US11886902B2 (en) | Physical-to-virtual migration method and apparatus, and storage medium | |
CN113656147B (en) | Cluster deployment method, device, equipment and storage medium | |
CN111897558A (en) | Kubernets upgrading method and device for container cluster management system | |
CN113204353B (en) | Big data platform assembly deployment method and device | |
US8990608B1 (en) | Failover of applications between isolated user space instances on a single instance of an operating system | |
CN110196749B (en) | Virtual machine recovery method and device, storage medium and electronic device | |
CN112199178A (en) | Cloud service dynamic scheduling method and system based on lightweight container | |
CN114201458B (en) | Information updating method, micro-service system and computer readable storage medium | |
CN109189480B (en) | File system starting method and device | |
CN111506388B (en) | Container performance detection method, container management platform and computer storage medium | |
CN117573280A (en) | Virtual machine state synchronization method, device, equipment and storage medium | |
CN107085514B (en) | Shared library upgrading method and device | |
US11461131B2 (en) | Hosting virtual machines on a secondary storage system | |
CN116360865A (en) | Cluster management method, device and computing system | |
CN113703823A (en) | BMC (baseboard management controller) firmware upgrading method and device, electronic equipment and storage medium | |
CN114598604A (en) | Monitoring method, monitoring device and terminal for virtual network function instance information | |
CN111858234A (en) | Task execution method, device, equipment and medium | |
CN111078658B (en) | Method and device for mounting cluster file system | |
WO2023050947A1 (en) | Network upgrade method, electronic device and storage medium | |
CN112187753B (en) | Data updating method, device, equipment and readable storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |