CN113918278A - Management method of virtual machine affinity group - Google Patents

Management method of virtual machine affinity group Download PDF

Info

Publication number
CN113918278A
CN113918278A CN202111105200.XA CN202111105200A CN113918278A CN 113918278 A CN113918278 A CN 113918278A CN 202111105200 A CN202111105200 A CN 202111105200A CN 113918278 A CN113918278 A CN 113918278A
Authority
CN
China
Prior art keywords
affinity
virtual machine
affinity group
host
group
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
Application number
CN202111105200.XA
Other languages
Chinese (zh)
Inventor
杨清玉
李金丽
黄科岩
王丽君
王宇琦
王圆圆
李梦雨
杨晶晶
李山峰
张博玮
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Kirin Software Co Ltd
Original Assignee
Kirin Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Kirin Software Co Ltd filed Critical Kirin Software Co Ltd
Priority to CN202111105200.XA priority Critical patent/CN113918278A/en
Publication of CN113918278A publication Critical patent/CN113918278A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/4557Distribution of virtual machine instances; Migration and load balancing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45575Starting, stopping, suspending or resuming virtual machine instances
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45591Monitoring or debugging support
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45595Network integration; Enabling network access in virtual machine instances

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application discloses a management method of a virtual machine affinity group, which configures affinity rules and affinity groups for virtual machines; and respectively carrying out affinity rule check on the running virtual machine and the virtual machine to be started, and carrying out virtual machine configuration according to the affinity rule. The virtual machines can be appointed to be deployed on one host computer as much as possible or to be deployed on different host computers as much as possible in a dispersed manner, and the virtual machines can also be appointed to be deployed on one host computer or to be deployed on different host computers in a dispersed manner.

Description

Management method of virtual machine affinity group
Technical Field
The application relates to the technical field of virtual machine configuration, in particular to a management method for a virtual machine affinity group.
Background
At present, virtualization technology and cloud computing technology are developed at a high speed, enterprises and individual users can conveniently build a virtualization platform by using a plurality of physical servers and storage equipment, and virtual machines are deployed in the virtualization platform, so that flexible and efficient use of resources is realized, and high-quality services are provided for the users.
In a partial virtualization environment, because of business requirements, virtual machines requiring different businesses must be deployed on different physical hosts or dispersedly deployed as much as possible, for example, virtual machines with different roles of Hadoop are deployed, and in order to improve the overall performance of a system, virtual machines with different roles need to be deployed on different physical hosts; for example, to deploy a virtual machine with a master role of a high availability application, in order to ensure high availability of a service, virtual machines with different roles also need to be deployed on different physical hosts as much as possible. Because of other business requirements, it is sometimes necessary or desirable to deploy multiple virtual machines on the same physical host. In the prior art, generally, the management of the virtual machines is to deploy the virtual machines in a centralized manner or in a distributed manner in the physical host according to rules through load balancing or other rules, and a corresponding affinity rule is not configured for each virtual machine, so that the configuration of the virtual machines is not flexible enough, which type or type of virtual machines are not flexibly specified to be deployed together, which type or type of virtual machines are not specified to be deployed together, and the resource utilization rate of the physical host and the network performance between the virtual machines are low.
Disclosure of Invention
The embodiment of the application provides a management method for a virtual machine affinity group, which can flexibly configure virtual machines according to requirements, and improve the resource utilization rate of a physical host and the network performance among the virtual machines.
In view of this, the present application provides a method for managing a virtual machine affinity group, including:
configuring affinity rules and affinity groups for the virtual machines;
checking whether the virtual machine has affinity rule conflict or not at intervals for the running virtual machine, and if so, redeploying the virtual machine according to the type of the conflicting affinity rule and the residual resources of other hosts;
the method comprises the steps of checking an affinity rule of a virtual machine to be started, selecting a target host to be deployed according to the affinity rule, judging whether the residual resources of the target host meet the requirements of the virtual machine to be started on the resources, if so, starting the virtual machine on the target host, and if not, selecting other hosts meeting the conditions to deploy the virtual machine or not to start the virtual machine.
Preferably, the affinity rules include forward affinity rules including forward affinity group forcing rules and forward affinity group non-forcing rules, and reverse affinity rules including reverse affinity group forcing rules and reverse affinity group non-forcing rules; the affinity groups include a forward affinity group and a reverse affinity group.
Preferably, for the running virtual machine, selecting whether to migrate or shut down the virtual machine according to the type to which the conflicting affinity rule belongs and the remaining resources of the other host, including: selecting a target host to be deployed by the problem virtual machine according to an affinity rule, detecting whether the residual resources of the target host meet the requirements of the problem virtual machine on the resources, if so, further judging whether other virtual machines which are migrating exist in the environment, starting to migrate the problem virtual machine when the environment does not have other virtual machines which are migrating, and if so, not migrating the virtual machine, and returning to a waiting detection interval;
if the requirement of the problem virtual machine on the resource is not met, further judging whether the violated affinity rule is mandatory, if so, closing the problem virtual machine, and if not, returning to the waiting detection interval.
Preferably, when the target host does not meet the requirement, the step of selecting other eligible hosts to deploy the virtual machine or not to start the virtual machine to be started includes:
judging whether the violated affinity rule is non-mandatory, if so, selecting other hosts meeting the conditions to deploy the virtual machine, and if so, not starting the virtual machine; and the other hosts meeting the conditions are other hosts selected according to the rest affinity rules after the violated non-mandatory affinity rules are eliminated.
Preferably, checking whether the virtual machine has an affinity rule conflict comprises:
cycling through all affinity groups:
finding a virtual machine violating the forward affinity rule;
find a virtual machine that violates the reverse affinity rule.
Preferably, the method of finding a virtual machine that violates the forward affinity rule comprises:
101, sequencing according to the forward affinity groups id, wherein the number of the forward affinity groups is m, and the variable is i;
step 102, traversing the forward affinity group from small to large to obtain a uniform affinity group k corresponding to the forward affinity groupi
Step 103, finding a uniform affinity group kiThe problem virtual machine of (1), comprising:
step 1031, according to unified affinity group kiThe virtual machine ids are sequenced, and the number of the virtual machines is x;
step 1032, traversing the x virtual machines from small to large, wherein the variable is s, and if the state of the s-th virtual machine is running, inquiring a host where the s-th virtual machine is located;
step 1033, sequence the queried hosts, obtain deployment unified affinity group kiHost a having the most virtual machines;
step 1034, traversing the x virtual machines from small to large, wherein the variable is t, and if the tth virtual machine is in a running state and is not running on the host computer A, the problem virtual machine is determined.
Preferably, step 102 comprises:
step 1021, traversing the m forward affinity groups from small to large, wherein the variable is i, and the affinity groups k are unifiediIs equal to the virtual machine list of forward affinity group i;
step 1022, for each unified affinity group kiPerforming operations comprising: traversing m-i forward affinity groups with group id larger than the forward affinity group i from small to large, wherein the variable is j, and traversing the uniform affinity group kiThe intersection of the virtual machine list and the virtual machine list of the forward affinity group j is solved, and if the intersection is not null, the uniform affinity group kiUpdate the value of the virtual machine list to a unified affinity group kiUnion of the list of virtual machines with forward affinity group j.
Preferably, the method of finding a virtual machine that violates the reverse affinity rule comprises:
step 201, sorting according to a reverse affinity group id, wherein the number of the reverse affinity groups is n;
step 202, traversing the n reverse affinity groups from small to large, wherein a variable is p, the initial value of the number of virtual machines in the reverse affinity group p running on each host is set to be 0, the virtual machines of the reverse affinity group p are sorted according to id, the number of the virtual machines is y, traversing the y virtual machines from small to large, the variable is u, if the state of the u-th virtual machine is running, the host where the u-th virtual machine is located is inquired, the number of the virtual machines in the reverse affinity group p running on the host is added with 1, and if the number of the virtual machines in the reverse affinity group p running on the host is more than 1, the u-th virtual machine is a problem virtual machine.
Preferably, the method further comprises the following steps:
and when the affinity group is added, performing affinity rule conflict detection on the newly added affinity group and the existing affinity group, if the conflict exists, failing to add the affinity group, and prompting the reason of the failure to add.
Preferably, when adding an affinity group, performing affinity rule conflict detection on the newly added affinity group and an existing affinity group includes the following steps:
301, sorting according to the forward affinity group id;
step 302, obtain unified affinity group ki
Step 303, for unified affinity group kiTraversing with variable i, and calculating a uniform affinity group kiIntersecting with the virtual machine list of the reverse affinity group, and if the number of intersection elements is greater than 1, detecting that the affinity rule conflicts.
According to the technical scheme, the embodiment of the application has the following advantages:
the invention relates to a management method of a virtual machine affinity group, which configures affinity rules and affinity groups for virtual machines; and respectively carrying out affinity rule check on the running virtual machine and the virtual machine to be started, and carrying out virtual machine configuration according to the affinity rule. The virtual machines can be appointed to be deployed on one host computer as much as possible or to be deployed on different host computers as much as possible in a dispersed manner, and the virtual machines can also be appointed to be deployed on one host computer or to be deployed on different host computers in a dispersed manner.
Drawings
In order to express the technical scheme of the embodiment of the invention more clearly, the drawings used for describing the embodiment will be briefly introduced below, and obviously, the drawings in the following description are only some embodiments of the invention, and other drawings can be obtained by those skilled in the art without creative efforts.
FIG. 1 is a diagram illustrating deployment changes of a virtual machine after affinity rules are executed according to an embodiment of the present invention;
FIG. 2 is a flowchart of the operation of an embodiment of the present invention for a running virtual machine;
FIG. 3 is a flowchart illustrating operations performed on a virtual machine to be started according to an embodiment of the present invention;
FIG. 4 is a flowchart of finding a virtual machine violating a forward affinity rule in an embodiment of the present invention;
FIG. 5 is a flowchart of finding a virtual machine violating a reverse affinity rule in an embodiment of the present invention;
FIG. 6 is a flowchart illustrating the detection of a conflict in an existing affinity rule according to an embodiment of the present invention;
FIG. 7 is a diagram illustrating an example of a list of virtual machines for finding a unified affinity group according to an embodiment of the present invention;
FIG. 8 is a diagram illustrating an exemplary detection of a conflict in an existing affinity rule according to an embodiment of the present invention.
Detailed Description
In order to make the technical solutions of the present application better understood, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The embodiment of the invention provides a management method of a virtual machine affinity group, which comprises the following steps:
affinity rules and affinity groups are configured for the virtual machine. After the rule is configured, the computer executes the automatic deployment operation of the virtual machine according to the configured rule.
And checking whether the virtual machine has affinity rule conflict or not at intervals for the running virtual machine, and if so, redeploying the virtual machine according to the type of the conflicting affinity rule and the residual resources of other hosts. The term "other hosts" refers to hosts to be deployed by the problem virtual machine according to the affinity rule except the current host where the problem virtual machine is located. By detecting other of the affinity rule determinations, the process of executing the affinity rule, referring to fig. 1, first configures virtual machines as a forward affinity group to which the virtual machines numbered 1 and 2 in the box belong and a reverse affinity group to which the virtual machine numbered 3 in the box belongs. Before the forward affinity group rules and reverse affinity group rules are executed, there are 3 virtual machines on host A, 3 virtual machines on host B, and 3 virtual machines on host C. Forward affinity group 1, comprising VM1 on host a, VM2, and VM4 on host B. Forward affinity group 2, contains VM3 on host a and VM5, VM6 on host B. Reverse affinity group 3, comprising VM7, VM8, VM9 on host C. After the forward affinity group rules and reverse affinity group rules are executed, VM4 on host B, VM8 on host C migrate to host A, and VM3 on host A and VM9 on host C migrate to host B. The effect of the present invention is that the virtual machines in the forward affinity group 1 are all deployed on the host a, the virtual machines in the forward affinity group 2 are all deployed on the host B, and the virtual machines in the reverse affinity group 3 are deployed on different hosts in a decentralized manner.
The method comprises the steps of checking an affinity rule of a virtual machine to be started, selecting a target host to be deployed according to the affinity rule, judging whether the residual resources of the target host meet the requirements of the virtual machine to be started on the resources, if so, starting the virtual machine on the target host, and if not, selecting other hosts meeting the conditions to deploy the virtual machine or not to start the virtual machine.
In the embodiment, the affinity rules and the affinity groups are configured for the virtual machines, and the virtual machines are flexibly configured according to requirements, so that the resource utilization rate of the physical host and the network performance among the virtual machines are improved.
Further, in one embodiment, the affinity rules include forward affinity rules including forward affinity group enforcement rules and forward affinity group non-enforcement rules, and reverse affinity rules including reverse affinity group enforcement rules and reverse affinity group non-enforcement rules; the affinity groups include a forward affinity group and a reverse affinity group. The forward affinity group enforcement rules can specify which virtual machines must be deployed on a host. The forward affinity group non-mandatory rules can specify which virtual machines are to be deployed on one host as much as possible. The reverse affinity group enforcement rules can specify which virtual machines must be deployed scattered across different hosts. The reverse affinity group non-mandatory rules can specify which virtual machines are deployed as scattered as possible on different hosts.
In one embodiment, for a running virtual machine, the selecting whether to migrate or shut down the virtual machine according to the type to which the conflicting affinity rule belongs and the remaining resources of the other host includes: selecting a target host to be deployed by the problem virtual machine according to an affinity rule, detecting whether the residual resources of the target host meet the requirements of the problem virtual machine on the resources, if so, further judging whether other virtual machines which are migrating exist in the environment, starting to migrate the problem virtual machine when the environment does not have other virtual machines which are migrating, and if so, not migrating the virtual machine, and returning to a waiting detection interval; if the requirement of the problem virtual machine on the resource is not met, further judging whether the violated affinity rule is mandatory, if so, closing the problem virtual machine, and if not, returning to the waiting detection interval. The management of the virtual machine by the virtual machine affinity group comprises two conditions: for a running virtual machine and a virtual machine to be started. For a running virtual machine, which is already deployed on a host, migration or shutdown operations on 0 or more virtual machines are required according to the affinity rule. The operation flow is shown in figure 2:
1. waiting a specified interval;
2. checking whether affinity rule conflict exists in the distribution condition of the existing virtual machine;
3. if yes, selecting a problem virtual machine;
4. selecting a target host;
5. judging whether the residual resources of the target host meet the requirements of the problem virtual machine on the resources, if so, judging whether other virtual machines which are being migrated do not exist in the environment, if so, migrating the problem virtual machine, returning to the step 1, and if not, directly returning to the step 1;
6. if the residual resources of the target host do not meet the requirements of the problem virtual machine on the resources, judging whether the violated affinity rules are mandatory, if so, closing the problem virtual machine, returning to the step 1, otherwise, directly returning to the step 1.
The method can enable the running virtual machines to flexibly configure the virtual machines according to business requirements or other requirements, the computer can be automatically deployed, and the running virtual machines are required to be deployed on one host, and the running virtual machines are deployed on the host as much as possible; the virtual machines are required to be dispersedly deployed on different hosts, and the virtual machines are dispersedly deployed on different hosts as much as possible, so that the intelligent deployment of the virtual machines is realized, and the resource utilization rate of the physical host and the network performance among the virtual machines are improved.
In an improved embodiment, when the target host does not meet the requirement, the step of selecting other eligible hosts to deploy the virtual machine or not to start the virtual machine to be started comprises: judging whether the violated affinity rule is non-mandatory, if so, selecting other hosts meeting the conditions to deploy the virtual machine, and if so, not starting the virtual machine; and the other hosts meeting the conditions are other hosts selected according to the rest affinity rules after the violated non-mandatory affinity rules are eliminated. And for the virtual machine to be started, deploying the virtual machine to the host in the starting process. It is necessary to determine on which host to deploy or not to start the virtual machine (start failure) according to the affinity rule. Referring to fig. 3 for an operation flow of a virtual machine to be started in this embodiment, the method includes the following steps:
1. starting;
2. checking all affinity rules to which the virtual machine belongs, wherein the affinity rules are in forward affinity with which running virtual machines in the current environment and in reverse affinity with which running virtual machines in the current environment;
3. selecting a target host according to the affinity rule;
4. judging whether the residual resources of the target host meet the requirements of the virtual machine to be started on the resources, if so, deploying the virtual machine to the target host, and starting successfully;
5. and if the residual resources of the target host do not meet the requirements of the virtual machine to be started on the resources, judging whether the affinity rule is mandatory, and if so, not starting the virtual machine. If not, selecting other qualified hosts to deploy the virtual machine, and starting successfully.
The embodiment can enable the virtual machine to be started to flexibly configure the virtual machine according to business requirements or other requirements, automatically manage the starting of the virtual machine to be started, and realize that which running virtual machines need to be deployed on one host and which virtual machines are deployed on one host as much as possible. The method can automatically deploy which virtual machines are required to be deployed on different hosts in a scattered manner, and which virtual machines are deployed on different hosts in a scattered manner as much as possible, so that the resource utilization rate of the physical host and the network performance among the virtual machines are improved.
Further, in one embodiment, checking whether the virtual machine has an affinity rule conflict comprises:
cycling through all affinity groups:
finding a virtual machine violating the forward affinity rule;
find a virtual machine that violates the reverse affinity rule.
If a virtual machine is found that violates the affinity rules, check if it can migrate: if the migration is possible (the remaining resources of the destination host meet the requirement of the problem virtual machine for the resources and no other virtual machine being migrated exists in the environment), returning the ID of the virtual machine needing to be migrated, and migrating the problem virtual machine.
Specifically, referring to fig. 4, the method of finding a virtual machine that violates the forward affinity rule includes:
the method for finding the virtual machine violating the forward affinity rule comprises the following steps:
101, sequencing according to the forward affinity groups id, wherein the number of the forward affinity groups is m, and the variable is i; the affinity group id is one of the attributes of the affinity group, and like the virtual machine id, when added, an id is given, for example, the first added affinity group id is 0, and the second added affinity group id is 1.
Step 102, traversing the forward affinity group from small to large to obtain a uniform affinity group k corresponding to the forward affinity groupi
Step 103, finding a uniform affinity group kiThe problem virtual machine of (1), comprising:
step 1031, according to unified affinity group kiThe virtual machine ids are sequenced, and the number of the virtual machines is x;
step 1032, traversing the x virtual machines from small to large, wherein the variable is s, and if the state of the s-th virtual machine is running, inquiring a host where the s-th virtual machine is located;
step 1033, sequence the queried hosts, obtain deployment unified affinity group kiHost a having the most virtual machines;
step 1034, traversing the x virtual machines from small to large, wherein the variable is t, and if the tth virtual machine is in a running state and is not running on the host computer A, the problem virtual machine is determined.
Further, step 102 comprises:
step 1021, traversing the m forward affinity groups from small to large, wherein the variable is i, and the affinity groups k are unifiediIs equal to the virtual machine list of forward affinity group i;
step 1022, for each unified affinity group kiPerforming operations comprising: traversing m-i forward affinity groups with group id larger than the forward affinity group i from small to large, wherein the variable is j, and traversing the uniform affinity group kiThe intersection of the virtual machine list and the virtual machine list of the forward affinity group j is solved, and if the intersection is not null, the uniform affinity group kiUpdate the value of the virtual machine list to a unified affinity group kiUnion of the list of virtual machines with forward affinity group j.
In this embodiment, the affinity group is traversed by the setting program, and a manner of finding the uniform affinity group first and then aligning the problem host in the forward affinity group according to the uniform affinity group is adopted, so that the situation that the currently set forward affinity group conflicts to cause inaccurate detection can be avoided.
Further, referring to fig. 5, the method for finding a virtual machine violating the reverse affinity rule includes:
step 201, sorting according to a reverse affinity group id, wherein the number of the reverse affinity groups is n;
step 202, traversing the n reverse affinity groups from small to large, wherein a variable is p, the initial value of the number of virtual machines in the reverse affinity group p running on each host is set to be 0, the virtual machines of the reverse affinity group p are sorted according to id, the number of the virtual machines is y, traversing the y virtual machines from small to large, the variable is u, if the state of the u-th virtual machine is running, the host where the u-th virtual machine is located is inquired, the number of the virtual machines in the reverse affinity group p running on the host is added with 1, and if the number of the virtual machines in the reverse affinity group p running on the host is more than 1, the u-th virtual machine is a problem virtual machine.
The method adopts the automatic traversal mode of the computer, has less calculation times, and can accurately and quickly find the virtual machine violating the reverse affinity rule.
In a further embodiment, the method for managing the affinity group of the virtual machine further includes:
and when the affinity group is added, performing affinity rule conflict detection on the newly added affinity group and the existing affinity group, if the conflict exists, failing to add the affinity group, and prompting the reason of the failure to add. And after the abnormal prompt is received, the affinity rule is reconfigured, so that the influence of conflicting affinity rules on virtual machine deployment when a new rule is added is avoided.
Specifically, referring to fig. 6, when adding an affinity group, performing affinity rule conflict detection on the newly added affinity group and an existing affinity group includes the following steps:
301, sorting according to the forward affinity group id, wherein the number of the forward affinity groups is m;
step 302, obtaining a list of virtual machines of the unified affinity group: go through m forward affinity groups from small to large (variable i):
(1) unified affinity group kiIs equal to the virtual machine list of forward affinity group i
(2) Go through m-i forward affinity groups with group id larger than forward affinity group i from small to large (variable is j):
3) unified affinity group kiIntersect the virtual machine list of forward affinity group j
4) If the intersection is not null, then unified affinity group kiIs equal to the unified affinity group kiUnion of the list of virtual machines with forward affinity group j;
step 303, solving the intersection of the virtual machine lists of the unified affinity group and the reverse affinity group, and if the number of intersection elements is greater than 1, detecting that the affinity rules conflict.
To facilitate understanding of the management method implementation process in the above embodiments, a description will be given with reference to specific examples.
Example 1
Find the list of virtual machines of the unified affinity group, as shown in fig. 7:
there are two forward affinity groups, the list of virtual machines for forward affinity group 1 being { VM1, VM2}, and the list of virtual machines for forward affinity group 2 being { VM2, VM3 }.
First, the list of unified affinity group virtual machines equal to the list of virtual machines for forward affinity group 1 is { VM1, VM2 }.
Second, the intersection of the unified affinity group's list of virtual machines { VM1, VM2} with the forward affinity group 2's list of virtual machines { VM2, VM3} is not null, and the unified affinity group's list of virtual machines is equal to their union { VM1, VM2, VM3 }.
Example 2
Existing affinity rule conflict detection, as shown in fig. 8:
the first step and the second step are the same as those of example 1.
Thirdly, solving the intersection of the virtual machine list { VM1, VM2, VM3} of the unified affinity group and the virtual machine list { VM1, VM3} of the reverse affinity group 3, wherein the intersection is { VM1, VM3}, and the number of the intersection elements is more than 1, then throwing the exception: an affinity rule conflict is detected.
Example 3
And the forward affinity group enforces that the residual resources of the target host meet the requirements of the virtual machine to be migrated on the resources.
There are two hosts, host a running 2 virtual machines and host B running 1 virtual machine. A forward affinity group is added, forcing, containing 2 virtual machines on host a and 1 virtual machine on host B. The remaining resources on host a satisfy the resource requirements of the virtual machine running on host B.
Wait for a specified interval to see the virtual machine on host B migrated onto host a.
Example 4
And the forward affinity group enforces that the residual resources of the target host do not meet the requirements of the virtual machine to be migrated on the resources.
There are two hosts, host a running 2 virtual machines and host B running 1 virtual machine. A forward affinity group is added, forcing, containing 2 virtual machines on host a and 1 virtual machine on host B. The remaining resources on host a cannot meet the resource requirements of the virtual machine running on host B.
Wait for a specified interval to see that the virtual machine on host B is closed.
Example 5
And (4) forward affinity group, if not, the residual resources of the target host do not meet the requirement of the virtual machine to be migrated on the resources.
There are two hosts, host a running 2 virtual machines and host B running 1 virtual machine. One forward affinity group is added, optionally containing 2 virtual machines on host a and 1 virtual machine on host B. The remaining resources on host a cannot meet the resource requirements of the virtual machine running on host B.
Waiting for a specified interval, checking that the virtual machine on the host B is still in the running state, and not migrating.
Example 6
And forward affinity group, and forcing the residual resources of the target host to meet the requirement of the virtual machine to be started on the resources.
There are two hosts, host a running 1 virtual machine, and there is one virtual machine in the off state (not deployed to any host). A forward affinity group is added, forcing that includes the 1 virtual machine on host a and the virtual machine to be started. And the residual resources on the host A meet the requirement of the virtual machine to be started on the resources.
Starting the virtual machine, waiting for a specified interval, checking the state of the virtual machine, and successfully starting the virtual machine, wherein the virtual machine is deployed on the host A.
Example 7
And forward affinity group, and forcing that the residual resources of the target host do not meet the requirements of the virtual machine to be started on the resources.
There are two hosts, host a running 1 virtual machine, and there is one virtual machine in the off state (not deployed to any host). A forward affinity group is added, forcing that includes the 1 virtual machine on host a and the virtual machine to be started. The remaining resources on the host a cannot meet the resource requirements of the virtual machine to be started. And the residual resources on the host B meet the requirement of the virtual machine to be started on the resources.
Starting the virtual machine, waiting for a specified interval, checking the state of the virtual machine, and keeping the virtual machine in a closed state after the start fails.
Example 8
And forward affinity group, not mandatory, the residual resources of the target host do not meet the requirement of the virtual machine to be started on the resources.
There are two hosts, host a running 1 virtual machine, and there is one virtual machine in the off state (not deployed to any host). A forward affinity group is added, optionally containing 1 virtual machine on host A and the virtual machine to be started. The remaining resources on the host a cannot meet the resource requirements of the virtual machine to be started. And the residual resources on the host B meet the requirement of the virtual machine to be started on the resources.
And starting the virtual machine, waiting for a specified interval, checking the state of the virtual machine, successfully starting and deploying to the host B.
Example 9
And the affinity group is reversed, and the residual resources of the target host machine are forced to meet the requirements of the virtual machine to be migrated on the resources.
There are two hosts, host a running 2 virtual machines. Add a reverse affinity group, force, containing two virtual machines on host a. The remaining resources on host B satisfy the resource requirements of the virtual machine running on host a.
Waiting a specified interval to see which virtual machine on host a has the larger ID number to migrate to host B.
Example 10
And (4) inverting the affinity group, and forcing the residual resources of the target host not to meet the requirements of the virtual machine to be migrated on the resources.
There are two hosts, host a running 2 virtual machines. Add a reverse affinity group, force, containing two virtual machines on host a. The remaining resources on host B cannot meet the resource requirements of the virtual machine running on host a.
Waiting a specified interval to see that no virtual machine on host a has migrated and that virtual machine with a large ID number is closed.
Example 11
And (4) inverting the affinity group, and if not, enabling the residual resources of the target host not to meet the requirements of the virtual machine to be migrated on the resources.
There are two hosts, host a running 2 virtual machines. Add one reverse affinity group, not mandatory. Containing two virtual machines on host a. The remaining resources on host B cannot meet the resource requirements of the virtual machine running on host a.
Waiting a specified interval, checking the state of the two virtual machines on the host A as running and not migrating to the host B.
Example 12
Reversed phase affinity group, force, the residual resource of the target host meets the requirement of the virtual machine to be started on the resource
There are two hosts, host a running 1 virtual machine, and there is one virtual machine in the off state (not deployed to any host). Add a reverse affinity group, force, containing 1 virtual machine on host a and the virtual machine to be started. And the residual resources on the host B meet the requirements of the virtual machine to be started on the resources.
And starting the virtual machine, waiting for a specified interval, checking the state of the virtual machine, successfully starting and deploying on the host B.
Example 13
And (4) inverting the affinity group to force that the residual resources of the target host do not meet the requirements of the virtual machine to be started on the resources.
There are two hosts, host a running 1 virtual machine, and there is one virtual machine in the off state (not deployed to any host). Add a reverse affinity group, force, containing 1 virtual machine on host a and the virtual machine to be started. The remaining resources on the host B cannot meet the resource requirements of the virtual machine to be started. And the residual resources on the host A meet the requirement of the virtual machine to be started on the resources.
Starting the virtual machine, waiting for a specified interval, checking the state of the virtual machine, and keeping the virtual machine in a closed state after the start fails.
Example 14
And (4) inverting the affinity group, and if not, enabling the residual resources of the target host not to meet the requirements of the virtual machine to be started on the resources.
There are two hosts, host a running 1 virtual machine, and there is one virtual machine in the off state (not deployed to any host). Add a reverse affinity group, force, containing 1 virtual machine on host a and the virtual machine to be started. The remaining resources on the host B cannot meet the resource requirements of the virtual machine to be started. The residual resources on the host A meet the requirements of the virtual machine to be started on the resources.
Starting the virtual machine, waiting for a specified interval, checking the state of the virtual machine, successfully starting and deploying on the host A.
The management method for the affinity group of the virtual machine comprises the steps of configuring affinity rules and the affinity group for the virtual machine; and respectively carrying out affinity rule check on the running virtual machine and the virtual machine to be started, and carrying out virtual machine configuration according to the affinity rule. The virtual machines can be appointed to be deployed on one host computer as much as possible or to be deployed on different host computers as much as possible in a dispersed manner, and the virtual machines can also be appointed to be deployed on one host computer or to be deployed on different host computers in a dispersed manner.
The above embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions in the embodiments of the present application.

Claims (10)

1. A management method for affinity groups of virtual machines is characterized by comprising the following steps:
configuring affinity rules and affinity groups for the virtual machines;
checking whether the virtual machine has affinity rule conflict or not at intervals for the running virtual machine, and if so, selecting whether to migrate or close the virtual machine according to the type of the affinity rule with conflict and the remaining resources of other hosts;
the method comprises the steps of checking an affinity rule of a virtual machine to be started, selecting a target host to be deployed according to the affinity rule, judging whether the residual resources of the target host meet the requirements of the virtual machine to be started on the resources, if so, starting the virtual machine on the target host, and if not, selecting other hosts meeting the conditions to deploy the virtual machine or not to start the virtual machine.
2. The method for managing a virtual machine affinity group according to claim 1, wherein the affinity rules include a forward affinity rule and a reverse affinity rule, the forward affinity rule includes a forward affinity group forcing rule and a forward affinity group non-forcing rule, and the reverse affinity rule includes a reverse affinity group forcing rule and a reverse affinity group non-forcing rule; the affinity groups include a forward affinity group and a reverse affinity group.
3. The method according to claim 2, wherein for a running virtual machine, selecting whether to migrate or shut down the virtual machine according to the type to which the conflicting affinity rule belongs and the remaining resources of other hosts comprises: selecting a target host to be deployed by the problem virtual machine according to an affinity rule, detecting whether the residual resources of the target host meet the requirements of the problem virtual machine on the resources, if so, further judging whether other virtual machines which are migrating exist in the environment, starting to migrate the problem virtual machine when the environment does not have other virtual machines which are migrating, and if so, not migrating the virtual machine, and returning to a waiting detection interval;
if the requirement of the problem virtual machine on the resource is not met, further judging whether the violated affinity rule is mandatory, if so, closing the problem virtual machine, and if not, returning to the waiting detection interval.
4. The method for managing affinity groups of virtual machines according to claim 2, wherein the step of selecting other eligible hosts to deploy the virtual machine or not to start the virtual machine to be started when the destination host does not satisfy the requirement comprises:
judging whether the violated affinity rule is non-mandatory, if so, selecting other hosts meeting the conditions to deploy the virtual machine, and if so, not starting the virtual machine; and the other hosts meeting the conditions are other hosts selected according to the rest affinity rules after the violated non-mandatory affinity rules are eliminated.
5. The method for managing affinity groups of virtual machines according to claim 2, wherein checking whether the virtual machines have affinity rule conflicts comprises:
cycling through all affinity groups:
finding a virtual machine violating the forward affinity rule;
find a virtual machine that violates the reverse affinity rule.
6. The method for managing affinity groups of virtual machines according to claim 5, wherein the method for finding a virtual machine violating the forward affinity rule comprises:
101, sequencing according to the forward affinity groups id, wherein the number of the forward affinity groups is m, and the variable is i;
step 102, traversing the forward affinity group from small to large to obtain a uniform affinity group k corresponding to the forward affinity groupi
Step 103, finding a uniform affinity group kiThe problem virtual machine of (1), comprising:
step 1031, according to unified affinity group kiThe virtual machine ids are sequenced, and the number of the virtual machines is x;
step 1032, traversing the x virtual machines from small to large, wherein the variable is s, and if the state of the s-th virtual machine is running, inquiring a host where the s-th virtual machine is located;
step 1033, sequence the queried hosts, obtain deployment unified affinity group kiHost a having the most virtual machines;
step 1034, traversing the x virtual machines from small to large, wherein the variable is t, and if the tth virtual machine is in a running state and is not running on the host computer A, the problem virtual machine is determined.
7. The method for managing a virtual machine affinity group according to claim 6, wherein step 102 comprises:
step 1021, traversing the m forward affinity groups from small to large, wherein the variable is i, and the affinity groups k are unifiediIs equal to the virtual machine list of forward affinity group i;
step 1022, for each unified affinity group kiPerforming operations comprising: traversing m-i forward affinity groups with group id larger than the forward affinity group i from small to large, wherein the variable is j, and traversing the uniform affinity group kiThe intersection of the virtual machine list and the virtual machine list of the forward affinity group j is solved, and if the intersection is not null, the uniform affinity group kiUpdate the value of the virtual machine list to a unified affinity group kiUnion of the list of virtual machines with forward affinity group j.
8. The method for managing affinity groups of virtual machines according to claim 5, wherein the method for finding a virtual machine violating the reverse affinity rule comprises:
step 201, sorting according to a reverse affinity group id, wherein the number of the reverse affinity groups is n;
step 202, traversing the n reverse affinity groups from small to large, wherein a variable is p, the initial value of the number of virtual machines in the reverse affinity group p running on each host is set to be 0, the virtual machines of the reverse affinity group p are sorted according to id, the number of the virtual machines is y, traversing the y virtual machines from small to large, the variable is u, if the state of the u-th virtual machine is running, the host where the u-th virtual machine is located is inquired, the number of the virtual machines in the reverse affinity group p running on the host is added with 1, and if the number of the virtual machines in the reverse affinity group p running on the host is more than 1, the u-th virtual machine is a problem virtual machine.
9. The method for managing a virtual machine affinity group according to claim 2, further comprising:
and when the affinity group is added, performing affinity rule conflict detection on the newly added affinity group and the existing affinity group, if the conflict exists, failing to add the affinity group, and prompting the reason of the failure to add.
10. The method for managing affinity groups of a virtual machine according to claim 9, wherein the affinity rule conflict detection for the newly added affinity group and the existing affinity group when adding an affinity group includes the following steps:
301, sorting according to the forward affinity group id;
step 302, obtain unified affinity group ki
Step 303, for unified affinity group kiTraversing with variable i, and calculating a uniform affinity group kiIntersecting with the virtual machine list of the reverse affinity group, and if the number of intersection elements is greater than 1, detecting that the affinity rule conflicts.
CN202111105200.XA 2021-09-22 2021-09-22 Management method of virtual machine affinity group Pending CN113918278A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111105200.XA CN113918278A (en) 2021-09-22 2021-09-22 Management method of virtual machine affinity group

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111105200.XA CN113918278A (en) 2021-09-22 2021-09-22 Management method of virtual machine affinity group

Publications (1)

Publication Number Publication Date
CN113918278A true CN113918278A (en) 2022-01-11

Family

ID=79235409

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111105200.XA Pending CN113918278A (en) 2021-09-22 2021-09-22 Management method of virtual machine affinity group

Country Status (1)

Country Link
CN (1) CN113918278A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114816776A (en) * 2022-07-01 2022-07-29 锐盈云科技(天津)有限公司 Enterprise intelligent cloud asset management system
CN115269126A (en) * 2022-09-28 2022-11-01 中国人寿保险股份有限公司上海数据中心 Cloud platform inverse affinity scheduling system based on cosine similarity

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114816776A (en) * 2022-07-01 2022-07-29 锐盈云科技(天津)有限公司 Enterprise intelligent cloud asset management system
CN114816776B (en) * 2022-07-01 2022-09-23 锐盈云科技(天津)有限公司 Enterprise intelligent cloud asset management system
CN115269126A (en) * 2022-09-28 2022-11-01 中国人寿保险股份有限公司上海数据中心 Cloud platform inverse affinity scheduling system based on cosine similarity

Similar Documents

Publication Publication Date Title
US10205771B2 (en) System and method for deploying an application in a computer system
Zheng et al. An approach for cloud resource scheduling based on Parallel Genetic Algorithm
US9569245B2 (en) System and method for controlling virtual-machine migrations based on processor usage rates and traffic amounts
EP2898410B1 (en) Automated profiling of resource usage
US9135048B2 (en) Automated profiling of resource usage
US8914546B2 (en) Control method for virtual machine and management computer
US20150277952A1 (en) Rapid creation and reconfiguration of virtual machines on hosts
CN105429776B (en) Method and system for managing functions of virtual network
US10303450B2 (en) Systems and methods for a policy-driven orchestration of deployment of distributed applications
US10693806B2 (en) Network bandwidth reservations for system traffic and virtual computing instances
CN104270416A (en) Load balancing control method and management node
US9459898B2 (en) Virtual server processing control method, system, and virtual server processing control management server
US20140082165A1 (en) Automated profiling of resource usage
EP2879049A1 (en) Method and device for creating virtual machine
CN113918278A (en) Management method of virtual machine affinity group
US10069906B2 (en) Method and apparatus to deploy applications in cloud environments
JP5930048B2 (en) Operation management apparatus, operation management method, and operation management program
CN109960579B (en) Method and device for adjusting service container
US20170078372A1 (en) Breadth-First Resource Allocation System and Methods
CN105635285B (en) A kind of VM migration scheduling method based on state aware
KR101959055B1 (en) Cloud-to-Cloud migration of multiple virtual machines
WO2024001755A1 (en) Service chain allocation method and system, computer device, and storage medium
Jain et al. A threshold band based model for automatic load balancing in cloud environment
CN106325972B (en) Virtual machine management method and network equipment
CN107562510B (en) Management method and management equipment for application instances

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