CN111414236A - Online adjusting method and device for CPU and memory and virtual electronic equipment - Google Patents

Online adjusting method and device for CPU and memory and virtual electronic equipment Download PDF

Info

Publication number
CN111414236A
CN111414236A CN202010210515.XA CN202010210515A CN111414236A CN 111414236 A CN111414236 A CN 111414236A CN 202010210515 A CN202010210515 A CN 202010210515A CN 111414236 A CN111414236 A CN 111414236A
Authority
CN
China
Prior art keywords
virtual machine
memory
cpu
adjusting
adjusted
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010210515.XA
Other languages
Chinese (zh)
Other versions
CN111414236B (en
Inventor
赵文祥
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Jiaxun Feihong Beijing Intelligent Technology Research Institute Co ltd
Original Assignee
Jiaxun Feihong Beijing Intelligent Technology Research Institute 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 Jiaxun Feihong Beijing Intelligent Technology Research Institute Co ltd filed Critical Jiaxun Feihong Beijing Intelligent Technology Research Institute Co ltd
Priority to CN202010210515.XA priority Critical patent/CN111414236B/en
Priority claimed from CN202010210515.XA external-priority patent/CN111414236B/en
Publication of CN111414236A publication Critical patent/CN111414236A/en
Application granted granted Critical
Publication of CN111414236B publication Critical patent/CN111414236B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • 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/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • 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/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The invention provides a method and a device for online adjustment of a CPU (Central processing Unit) and a memory and virtual electronic equipment, wherein the method comprises the following steps: adjusting a configuration file of the cloud platform computing service; the configuration file is used for representing whether the CPU and the memory, the maximum memory supported by the virtual machine and the maximum CPU number supported by the virtual machine are allowed to be adjusted online; adjusting a starting file of the virtual machine; the method comprises the steps that a starting file is newly added with the number of memory slots for representing a virtual machine, the maximum memory supported by the virtual machine, the current memory size of the virtual machine, the maximum CPU number supported by the virtual machine and the current CPU number of the virtual machine; adjusting the topological structure of the virtual machine; receiving an adjusting instruction; and responding to the adjusting instruction, and adjusting the CPU and the memory of the virtual machine based on the configuration file, the starting file and the topological structure. In the mode, the CPU and the memory are adjusted on line without shutdown, the on-line service is not influenced, the stability of the system and the satisfaction degree of a user can be improved, and the advantages are highlighted in a single-point application scene.

Description

Online adjusting method and device for CPU and memory and virtual electronic equipment
Technical Field
The invention relates to the technical field of virtual machines, in particular to a method and a device for online adjustment of a CPU (Central processing Unit) and a memory and virtual electronic equipment.
Background
Openstack, as an open-source cloud computing management platform project, supports almost all types of virtualization technologies, and provides an Infrastructure As A Service (IAAS) solution through various cooperative services, wherein the computer service provided by the Nova module mainly focuses on managing the lifecycle, reconstruction, repair, lifting configuration and the like of a Virtual Machine, the full stack architecture of the Nova mainly comprises three parts, namely Openstack Nova, L ibvirt and Kernel-based Virtual Machine (KVM), and the computer service of the Openstack Nova completes the invocation of the KVM through L ibvirt virtualization management programs so as to complete the operation of the Virtual Machine.
In the related art, the Openstack function is already perfect, but not all functions of L ibvirt are completely realized, wherein online adjustment of a Central Processing Unit (CPU) and a memory is not realized, and many cloud manufacturers at home and abroad complete upgrading in a shutdown adjustment mode.
Disclosure of Invention
In view of this, an object of the present invention is to provide an online adjustment method and apparatus for a CPU and a memory, and a virtual electronic device, so as to adjust the CPU and the memory online without shutdown, without any influence on online services, and improve the satisfaction of users.
In a first aspect, an embodiment of the present invention provides an online adjustment method for a CPU and a memory, including: adjusting a configuration file of the cloud platform computing service; the configuration file is used for representing whether the CPU and the memory, the maximum memory supported by the virtual machine and the maximum CPU number supported by the virtual machine are allowed to be adjusted online; adjusting a starting file of the virtual machine; the starting file is used for representing the number of memory slots of the virtual machine, the maximum memory supported by the virtual machine, the current memory size of the virtual machine, the maximum CPU number supported by the virtual machine and the current CPU number of the virtual machine; adjusting the topological structure of the virtual machine; the topological structure is used for representing the mapping relation between the memory and the CPU; receiving an adjusting instruction; and responding to the adjusting instruction, and adjusting the CPU and the memory of the virtual machine based on the configuration file, the starting file, the topological structure and the received adjusting parameters.
In a preferred embodiment of the present invention, the configuration file includes a first variable, a second variable, and a third variable; the first variable is used for representing whether the CPU and the memory of the virtual machine are allowed to be adjusted online or not; the second variable is used for representing the maximum memory supported by the virtual machine; the third variable is used for representing the maximum CPU number supported by the virtual machine.
In a preferred embodiment of the present invention, the start-up file of the virtual machine includes a first tag, a second tag, a third tag, a fourth tag, and a fifth tag; the first label is used for representing the number of the memory slots of the virtual machine; the second label is used for representing the maximum memory supported by the virtual machine; the third label is used for representing the current memory size of the virtual machine; the fourth label is used for representing the maximum CPU number supported by the virtual machine; the fifth label is used for representing the current CPU number of the virtual machine.
In a preferred embodiment of the present invention, the step of adjusting the CPU and the memory of the virtual machine based on the configuration file, the startup file, and the topology structure in response to the adjustment instruction includes: creating a virtual machine to be adjusted based on a configuration file and a starting file in advance; and adjusting the CPU and the memory of the virtual machine to be adjusted based on the adjusting instruction and the topological structure.
In a preferred embodiment of the present invention, the step of creating the virtual machine to be adjusted in advance based on the configuration file and the startup file includes: calling a configuration file and a starting file; judging whether the CPU and the memory of the virtual machine are allowed to be adjusted online or not based on the configuration file; if so, setting the supported maximum memory of the virtual machine to be adjusted based on the starting file; setting the number of memory slots of the virtual machine to be adjusted based on the starting file; setting the supported maximum CPU number of the virtual machine to be adjusted and the current CPU number of the virtual machine to be adjusted based on the starting file; and creating the virtual machine to be adjusted based on the maximum memory supported by the virtual machine to be adjusted, the number of memory slots, the maximum CPU number supported and the current CPU number of the virtual machine to be adjusted.
In a preferred embodiment of the present invention, the step of adjusting the CPU and the memory of the virtual machine to be adjusted based on the adjustment instruction and the topology includes: performing basic check on the virtual machine to be adjusted based on the adjustment instruction; the basic check comprises checking quota, data validity and operation authority of the item to which the virtual machine to be adjusted belongs; physical resource verification is carried out on the virtual machine to be adjusted; deducting the quota of the item to which the virtual machine to be adjusted belongs; and adjusting the CPU and the memory of the virtual machine to be adjusted based on the topological structure and the received adjustment parameters.
In a preferred embodiment of the present invention, the method further includes: and if the basic verification or the physical resource verification fails, stopping adjusting the CPU and the memory of the virtual machine to be adjusted.
In a second aspect, an embodiment of the present invention further provides an online adjusting apparatus for a CPU and a memory, including: the configuration file adjusting module is used for adjusting the configuration file of the platform computing service; the configuration file is used for representing whether the CPU and the memory, the maximum memory supported by the virtual machine and the maximum CPU number supported by the virtual machine are allowed to be adjusted online; the starting file adjusting module is used for adjusting a starting file of the virtual machine; the starting file is used for representing the number of memory slots of the virtual machine, the maximum memory supported by the virtual machine, the current memory size of the virtual machine, the maximum CPU number supported by the virtual machine and the current CPU number of the virtual machine; the topological structure adjusting module is used for adjusting the topological structure of the virtual machine; the topological structure is used for representing the mapping relation between the memory and the CPU; the adjusting instruction receiving module is used for receiving an adjusting instruction; and the CPU and memory adjusting module is used for responding to the adjusting instruction and adjusting the CPU and the memory of the virtual machine based on the configuration file, the starting file, the topological structure and the received adjusting parameters.
In a third aspect, an embodiment of the present invention further provides a virtual electronic device, including a central processing unit and a storage, where the storage stores computer-executable instructions that can be executed by the central processing unit, and the central processing unit executes the computer-executable instructions to implement the steps of the method for adjusting the CPU and the memory online.
In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, where computer-executable instructions are stored, and when the computer-executable instructions are called and executed by a central processing unit, the computer-executable instructions cause the central processing unit to implement the steps of the above-mentioned method for online adjusting of a CPU and a memory.
The embodiment of the invention has the following beneficial effects:
according to the method and the device for online adjustment of the CPU and the memory and the virtual electronic equipment, which are provided by the embodiment of the invention, the configuration file, the starting file and the topological structure of the cloud platform computing service are adjusted, and the CPU and the memory of the virtual machine are adjusted according to the received adjustment instruction. The CPU and the memory are adjusted on line without shutdown, the line service is not affected, the system stability and the user satisfaction can be improved, and the advantages are highlighted in a single-point application scene.
Additional features and advantages of the disclosure will be set forth in the description which follows, or in part may be learned by the practice of the above-described techniques of the disclosure, or may be learned by practice of the disclosure.
In order to make the aforementioned objects, features and advantages of the present disclosure more comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1 is a flowchart of an online adjustment method for a CPU and a memory according to an embodiment of the present invention;
fig. 2 is a flowchart of another method for online adjusting a CPU and a memory according to an embodiment of the present invention;
fig. 3 is a schematic flowchart of a virtual machine creation method according to an embodiment of the present invention;
fig. 4 is a schematic diagram of a manner of updating information of a virtual machine according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of an online adjustment apparatus for a CPU and a memory according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of a virtual electronic device according to an embodiment of the present invention.
Detailed Description
To make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is apparent that the described embodiments are some, but not all embodiments of the present invention. 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 invention.
At present, many cloud manufacturers at home and abroad adjust a CPU and an internal memory in a shutdown adjustment mode, which inevitably causes some on-line service interruption, is not friendly to many clients running single-point applications in a cloud environment, influences the on-line service of the clients, and reduces the satisfaction degree of the users. Based on this, the method, the device and the virtual electronic device for online adjustment of the CPU and the memory provided by the embodiments of the present invention are applied to the technical field of virtual machines, and in particular, to a method for expanding an OpenstackNova interface to realize online adjustment of the CPU and the memory without shutdown of the virtual machine.
To facilitate understanding of the embodiment, first, a detailed description is given of an online adjustment method for a CPU and a memory according to the embodiment of the present invention.
Example 1
Referring to a flowchart of an online adjustment method for a CPU and a memory shown in fig. 1, the online adjustment method for a CPU and a memory according to an embodiment of the present invention includes the following steps:
step S102, adjusting a configuration file of the cloud platform computing service; the configuration file is used for representing whether the CPU and the memory, the maximum memory supported by the virtual machine and the maximum CPU number supported by the virtual machine are allowed to be adjusted online.
The virtual machine refers to a complete computer system which has complete hardware system functions and runs in a completely isolated environment through software simulation, and the work which can be completed in a physical computer can be realized in the virtual machine. In order to adjust the CPU and the memory of the virtual machine without stopping, the Nova code is modified, and a configuration file, a starting file and a topological structure of a cloud platform computing service are adjusted, so that the created virtual machine supports online adjustment of the CPU and the memory.
The configuration adjustment may be understood as adding some configuration groups to the native Openstack, where the configuration groups need to indicate whether to allow online adjustment of the CPU and the memory, the maximum memory supported by the virtual machine, and the maximum number of CPUs supported by the virtual machine.
Step S104, adjusting a starting file of the virtual machine; the starting file is used for representing the number of memory slots of the virtual machine, the maximum memory supported by the virtual machine, the current memory size of the virtual machine, the maximum CPU number supported by the virtual machine and the current CPU number of the virtual machine.
The startup file mainly adjusts a _ format _ basic _ pages function in nova/virt/libvirt/config.py, and the function defines basic information, a CPU and a memory of the virtual machine. In the native openstack, only memory and vcpu tags are defined for the CPU and the memory, and the embodiment provides a quantity tag representing a DIMM slot, a supported maximum memory tag, a current memory size tag, a maximum CPU number tag, and a current CPU number tag by modifying the function.
Step S106, adjusting the topological structure of the virtual machine; the topological structure is used for representing the mapping relation between the memory and the CPU.
The topology refers to a mapping relationship of several concepts in a Non Uniform Memory Access Architecture (NUMA) Architecture. In the native Openstack, there is no mapping relationship between the memory and the CPU. In the embodiment, the mapping relationship between the memory and the CPU can be represented by adjusting the topology structure, and when the mapping relationship between the memory and the CPU is calculated, the mapping relationship can be distributed according to the proportion.
Step S108, receiving an adjustment instruction.
The adjustment command is sent by the user, wherein the adjustment command is different from the existing shutdown-adjustment-startup cold adjustment command, but is not a shutdown-adjustment hot adjustment command.
Step S110, responding to the adjusting instruction, and adjusting the CPU and the memory of the virtual machine based on the configuration file, the starting file, the topological structure and the received adjusting parameters.
After receiving the adjustment instruction, the CPU and the memory of the virtual machine are adjusted according to the configuration file, the start-up file and the topology structure adjusted in the above steps.
According to the online adjusting method for the CPU and the memory, provided by the embodiment of the invention, the configuration file, the starting file and the topological structure of the cloud platform computing service are adjusted, and the CPU and the memory of the virtual machine are adjusted according to the received adjusting instruction. The CPU and the memory are adjusted on line without shutdown, the line service is not affected, the system stability and the user satisfaction can be improved, and the advantages are highlighted in a single-point application scene.
Example 2
The embodiment of the invention also provides another online adjusting method of the CPU and the memory; the method is realized on the basis of the method of the embodiment; the method mainly describes a concrete implementation mode of responding to an adjusting instruction and adjusting a CPU and a memory of a virtual machine based on a configuration file, a starting file and a topological structure.
As shown in fig. 2, another method for adjusting the CPU and the memory online includes the following steps:
step S202, adjusting a configuration file of the cloud platform computing service; the configuration file is used for representing whether the CPU and the memory, the maximum memory supported by the virtual machine and the maximum CPU number supported by the virtual machine are allowed to be adjusted online.
The configuration file of the cloud platform computing service may configure groups for libvirt _ live _ resize _ ops in ova/conf/libvirt. The configuration group is not present in native Openstack. The invention adds the configuration group, and the configuration group comprises three variables: a first variable enable _ live _ reset represents whether the virtual machine allows online adjustment of the CPU and the memory; a second variable virt _ domain _ mem _ maximum represents the maximum memory supported by the virtual machine; the third variable virt _ domain _ CPU _ maximum represents the maximum number of CPUs supported by the virtual machine.
For example, the configuration file nova. conf of nova _ composition may be modified, adding the following lines under the [ libvirt ] group:
enable _ live _ reset _ true (indicating that CPU and memory are allowed to be adjusted online);
virt _ domain _ mem _ maximum of 33554432 (indicating that the maximum memory of the virtual machine is allowed to be 32G);
virt _ domain _ CPU _ maximum ═ 16 (meaning that the maximum CPUs of the virtual machines are allowed to be 16).
The configuration files are not added in the native Openstack, and the configuration files are newly added in the embodiment, so that a switch is set for online adjustment, the switch can be automatically turned on or turned off according to requirements, meanwhile, the overflow of hardware resources is avoided, and the numerical values of a maximum internal memory and a CPU are limited.
Step S204, adjusting a starting file of the virtual machine; the starting file is used for representing the number of memory slots of the virtual machine, the maximum memory supported by the virtual machine, the current memory size of the virtual machine, the maximum CPU number supported by the virtual machine and the current CPU number of the virtual machine.
Adjusting the start-up file of the virtual machine can be understood as a _ format _ basic _ prop function in nova/virt/libvirt/config. In the native openstack, only memory and vcpu tags are defined for the CPU and the memory, and the function is modified to provide a first tag, a second tag, a third tag, a fourth tag and a fifth tag.
The first label slots are used for representing the number of Memory slots of the virtual machine, namely the number of DIMM (Dual-Inline-Memory-Modules) slots; the second tag maxMemory is used for representing the maximum memory supported by the virtual machine; the third tag memory is used for representing the current memory size of the virtual machine; the fourth label vcpu is used for representing the maximum CPU number supported by the virtual machine; the fifth label current is used for representing the current CPU number of the virtual machine.
In the embodiment, by modifying the function and judging the enable _ live _ reset variable, if the variable is True, three additional tags are defined on the original basis. Meanwhile, the meanings represented by the native memory and the vcpu label are also changed, the native memory label represents the maximum memory and the current memory of the virtual machine, the memory label after the invention only represents the current memory of the virtual machine, and the maximum memory is represented by the maxMemory expanded by the invention; the original vcpu represents the maximum CPU and the current CPU of the virtual machine, the vcpu after the invention only represents the current CPU of the virtual machine, and the maximum CPU is represented by the current expanded by the invention.
Step S206, adjusting the topological structure of the virtual machine; the topological structure is used for representing the mapping relation between the memory and the CPU.
Modifying the topology firstly modifies the function of _ get _ default _ cpu _ topologies in nova/virt/hardware. This function sets the topology of the cpu by the passed parameters. In native Openstack, the source of the vcpu number is a shader (specification), and in a native environment, the vcpu represents the current CPU number of the virtual machine and also represents the maximum CPU number supported by the virtual machine, and the virtual machine does not have an online adjustment function. After the method is used, if the online adjustment function is started, the corresponding vcpu is derived from the configuration file, after the virtual machine is generated, the vcpu represents the maximum CPU number supported by the virtual machine, and the current CPU number of the virtual machine is represented by current.
And then modifying a _ get _ guest _ NUMA _ config function in nova/virt/libvirt/driver. This function defines the NUMA structure of the virtual machine. In native Openstack, the function only sets contents related to cpsets, and does not set numconfig, which results in that the generated virtual machine does not have a mapping relationship between a memory and a CPU. In the native Openstack, when numa topology is not specified, all memories are mapped to a group of CPUs, and when memories and CPUs are newly added, the memories and the CPUs are remapped. According to the invention, by defining the guest _ CPU _ numa and the guest _ cell and setting the attributes of id, CPU, memory and the like of the guest _ cell, when the mapping relation between the memory and the CPU is calculated, the mapping can be allocated according to the proportion, and the purpose of doing so is that when the memory and the CPU are added, the allocated mapping is not affected, the newly added part can be subjected to demapping through a new cell, and the mapping relation does not need to be reallocated when not responding.
In step S208, an adjustment instruction is received.
Step S210, a virtual machine to be adjusted is created in advance based on the configuration file and the start file.
Firstly, a virtual machine to be adjusted needs to be created according to the adjusted configuration file and the adjusted start file, and the creation of the virtual machine can be performed through steps a 1-a 6: calling a configuration file and a starting file;
step A1, calling the configuration file and the starting file;
step A2, judging whether to allow the online adjustment of the CPU and the memory of the virtual machine based on the configuration file of the cloud platform computing service;
referring to a flow diagram of a virtual machine creation mode shown in fig. 3, after calling a _ format _ basic _ programs function in config.py, it needs to determine whether enable _ live _ reset in libvirt _ live _ reset _ ops is turned on, and if so, the configuration file allows adjusting a CPU and a memory of the virtual machine; and step A3 is executed, if the virtual machine is not started, the configuration file does not allow the CPU and the memory of the virtual machine to be adjusted, and the process of creating the virtual machine is directly finished.
Step A3, if yes, setting the supported maximum memory of the virtual machine to be adjusted based on the starting file;
the maxMemory attribute of the xml (eXtensible Markup L anguage) of the virtual machine is set, that is, the maximum memory supported by the virtual machine to be adjusted is set.
Step A4, setting the number of memory slots of the virtual machine to be adjusted based on the starting file;
and setting the slots attribute of the xml of the virtual machine, namely the number of the memory slots of the virtual machine to be adjusted.
Step A5, setting the supported maximum CPU number of the virtual machine to be adjusted and the current CPU number of the virtual machine to be adjusted based on the starting file;
and setting the vcpu and current attributes of the xml of the virtual machine, namely setting the supported maximum CPU number of the virtual machine to be adjusted and the current CPU number of the virtual machine to be adjusted.
Step a6, creating the virtual machine to be adjusted based on the supported maximum memory, the number of memory slots, the supported maximum CPU number, and the current CPU number of the virtual machine to be adjusted.
Creating a virtual machine requires generating a virtual machine xml file and creating the virtual machine through libvirt. The xml file comprises the maximum memory supported by the virtual machine to be adjusted, the number of memory slots, the maximum CPU number supported and the current CPU number of the virtual machine to be adjusted.
Step S212, the CPU and the memory of the virtual machine to be adjusted are adjusted based on the adjustment instruction and the topological structure.
Adjusting the CPU and the memory of the virtual machine to be adjusted needs to expand an interface, namely Nova API-live _ reset, to complete online adjustment, and the specific idea is as follows:
in the native Openstack, only a cold adjustment (power-off adjustment) CPU and a memory are provided, and no online adjustment is provided. The new live _ reset interface is added to the invention, and aims to facilitate online adjustment of the CPU and the memory of the virtual machine in an Openstack management page or a command line. May be performed by step B1-step B4:
step B1, performing basic check on the virtual machine to be adjusted based on the adjustment instruction; the basic check comprises checking quota, data validity and operation authority of the item to which the virtual machine to be adjusted belongs;
referring to a schematic diagram of a method for updating information of a virtual machine shown in fig. 4, as shown in fig. 4, after receiving a hot upgrade request (i.e., an online adjustment instruction of the present application), basic verification is first required to be performed, where the basic verification includes quota, data validity, and permission verification of an item to which the virtual machine belongs. If the basic check fails, the CPU and the memory of the virtual machine to be adjusted are stopped being adjusted. The basic check passes before step B2 is performed.
Step B2, performing physical resource check on the virtual machine to be adjusted;
and after the basic check is passed, physical resource check is required, and if the physical resource check is not passed, the adjustment of the CPU and the memory of the virtual machine to be adjusted is stopped. Step B3 will only continue to be performed after the physical resources have also passed.
Step B3, deducting the quota of the item to which the virtual machine to be adjusted belongs;
and calling setMemoryFlags and setVcpusFlags functions of libvirt, and deducting the quota of the virtual machine to be adjusted.
And step B4, adjusting the CPU and the memory of the virtual machine to be adjusted based on the topological structure and the received adjustment parameters.
And updating the virtual machine information through the adjusted topological structure, wherein the virtual machine information is the CPU, the memory and the NUMA topological structure of the virtual machine.
The method provided by the embodiment of the invention does not need to restart or stop the virtual machine, and does not need to stop the service of the virtual machine.
Example 3
Corresponding to the foregoing method embodiments, an embodiment of the present invention provides an online adjustment device for a CPU and a memory, as shown in fig. 5, where the online adjustment device for a CPU and a memory includes:
a configuration file adjusting module 51, configured to adjust a configuration file of the cloud platform computing service; the configuration file is used for representing whether the CPU and the memory, the maximum memory supported by the virtual machine and the maximum CPU number supported by the virtual machine are allowed to be adjusted online;
a start file adjusting module 52, configured to adjust a start file of the virtual machine; the method comprises the steps that a starting file is newly added with the number of memory slots for representing a virtual machine, the maximum memory supported by the virtual machine, the current memory size of the virtual machine, the maximum CPU number supported by the virtual machine and the current CPU number of the virtual machine;
a topology adjusting module 53, configured to adjust a topology of the virtual machine; the topological structure is used for representing the mapping relation between the memory and the CPU;
an adjustment instruction receiving module 54, configured to receive an adjustment instruction;
and a CPU and memory adjusting module 55, configured to adjust the CPU and the memory of the virtual machine based on the configuration file, the startup file, the topology, and the received adjustment parameter in response to the adjustment instruction.
The online adjusting device for the CPU and the memory, provided by the embodiment of the invention, firstly adjusts the configuration file, the starting file and the topological structure of the cloud platform computing service, and adjusts the CPU and the memory of the virtual machine according to the received adjusting instruction. The CPU and the memory are adjusted on line without shutdown, the line service is not affected, the system stability and the user satisfaction can be improved, and the advantages are highlighted in a single-point application scene.
In some embodiments, the configuration file includes a first variable, a second variable, and a third variable; the first variable is used for representing whether the CPU and the memory of the virtual machine are allowed to be adjusted online or not; the second variable is used for representing the maximum memory supported by the virtual machine; the third variable is used for representing the maximum CPU number supported by the virtual machine.
In some embodiments, the boot file of the virtual machine includes a first tag, a second tag, a third tag, a fourth tag, and a fifth tag; the first label is used for representing the number of the memory slots of the virtual machine; the second label is used for representing the maximum memory supported by the virtual machine; the third label is used for representing the current memory size of the virtual machine; the fourth label is used for representing the maximum CPU number supported by the virtual machine; the fifth label is used for representing the current CPU number of the virtual machine.
In some embodiments, the CPU and the memory adjustment module are configured to create a virtual machine to be adjusted in advance based on a configuration file and a start file; and adjusting the CPU and the memory of the virtual machine to be adjusted based on the adjusting instruction and the topological structure.
In some embodiments, the CPU and the memory adjustment module are configured to call a configuration file and a start file; judging whether the CPU and the memory of the virtual machine are allowed to be adjusted online or not based on the configuration file; if so, setting the supported maximum memory of the virtual machine to be adjusted based on the starting file; setting the number of memory slots of the virtual machine to be adjusted based on the starting file; setting the supported maximum CPU number of the virtual machine to be adjusted and the current CPU number of the virtual machine to be adjusted based on the starting file; and creating the virtual machine to be adjusted based on the maximum memory supported by the virtual machine to be adjusted, the number of memory slots, the maximum CPU number supported and the current CPU number of the virtual machine to be adjusted.
In some embodiments, the CPU and the memory adjustment module are configured to perform a basic check on the virtual machine to be adjusted based on the adjustment instruction; the basic check comprises checking quota, data validity and operation authority of the item to which the virtual machine to be adjusted belongs; physical resource verification is carried out on the virtual machine to be adjusted; deducting the quota of the item to which the virtual machine to be adjusted belongs; and adjusting the CPU and the memory of the virtual machine to be adjusted based on the topological structure and the received adjustment parameters.
In some embodiments, the CPU and memory adjustment module is configured to stop adjusting the CPU and the memory of the virtual machine to be adjusted if the basic check or the physical resource check fails.
The online adjustment device for the CPU and the memory provided in the embodiment of the present invention has the same technical features as the online adjustment method for the CPU and the memory provided in the above embodiment, so that the same technical problems can be solved, and the same technical effects can be achieved.
Example 4
The embodiment of the invention also provides a virtual electronic device which is used for operating the on-line adjustment method of the CPU and the memory; referring to fig. 6, a schematic structural diagram of a virtual electronic device includes a storage 100 and a central processing unit 101, where the storage 100 is used to store one or more computer instructions, and the one or more computer instructions are executed by the central processing unit 101 to implement the above-mentioned method for adjusting the CPU and the memory online.
Further, the virtual electronic device shown in fig. 6 further includes a bus 102 and a communication interface 103, and the central processor 101, the communication interface 103 and the memory 100 are connected through the bus 102.
The Memory 100 may include a high-speed Random Access Memory (RAM) and may further include a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. The communication connection between the network element of the system and at least one other network element is realized through at least one communication interface 103 (which may be wired or wireless), and the internet, a wide area network, a local network, a metropolitan area network, and the like can be used. The bus 102 may be an ISA bus, PCI bus, EISA bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one double-headed arrow is shown in FIG. 6, but that does not indicate only one bus or one type of bus.
The central processing unit 101 may be an integrated circuit chip having signal processing capability. In implementation, the steps of the method may be implemented by hardware integrated logic circuits in the central processing unit 101 or by instructions in the form of software. The central processing Unit 101 may be a general-purpose central processing Unit, and includes a Central Processing Unit (CPU), a Network central processing Unit (NP), and the like; the Integrated Circuit may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component. The various methods, steps and logic blocks disclosed in the embodiments of the present invention may be implemented or performed. The general purpose central processing unit may be a micro central processing unit or the central processing unit may be any conventional central processing unit or the like. The steps of the method disclosed by the embodiment of the invention can be directly implemented by a hardware decoding central processing unit, or implemented by combining hardware and software modules in the decoding central processing unit. The software module may be located in ram, flash memory, rom, prom, or eprom, registers, etc. storage media as is well known in the art. The storage medium is located in the memory 100, and the central processing unit 101 reads the information in the memory 100 and completes the steps of the method of the foregoing embodiment in combination with the hardware thereof.
The embodiment of the present invention further provides a computer-readable storage medium, where the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are called and executed by a central processing unit, the computer-executable instructions cause the central processing unit to implement the above-mentioned method for adjusting a CPU and a memory online.
The method and apparatus for online adjusting a CPU and a memory, and the computer program product of a virtual electronic device provided in the embodiments of the present invention include a computer-readable storage medium storing a program code, where instructions included in the program code may be used to execute the method in the foregoing method embodiments, and specific implementation may refer to the method embodiments, and will not be described herein again.
It can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working process of the apparatus and/or the virtual electronic device described above may refer to the corresponding process in the foregoing method embodiment, and is not described herein again.
Finally, it should be noted that: the above-mentioned embodiments are only specific embodiments of the present invention, which are used for illustrating the technical solutions of the present invention and not for limiting the same, and the protection scope of the present invention is not limited thereto, although the present invention is described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: any person skilled in the art can modify or easily conceive the technical solutions described in the foregoing embodiments or equivalent substitutes for some technical features within the technical scope of the present disclosure; such modifications, changes or substitutions do not depart from the spirit and scope of the embodiments of the present invention, and they should be construed as being included therein. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (10)

1. An online adjustment method for a CPU and a memory is characterized by comprising the following steps:
adjusting a configuration file of the platform computing service; the configuration file is used for representing whether the CPU and the memory, the maximum memory supported by the virtual machine and the maximum CPU number supported by the virtual machine are allowed to be adjusted online;
adjusting a starting file of the virtual machine; the starting file is used for representing the number of memory slots of the virtual machine, the maximum memory supported by the virtual machine, the current memory size of the virtual machine, the maximum CPU number supported by the virtual machine and the current CPU number of the virtual machine;
adjusting the topology of the virtual machine; the topological structure is used for representing the mapping relation between the memory and the CPU;
receiving an adjusting instruction;
and responding to the adjusting instruction, and adjusting the CPU and the memory of the virtual machine based on the configuration file, the starting file, the topological structure and the received adjusting parameters.
2. The method of claim 1, wherein the configuration file comprises a first variable, a second variable, and a third variable;
the first variable is used for representing whether the CPU and the memory of the virtual machine are allowed to be adjusted online or not;
the second variable is used for representing the maximum memory supported by the virtual machine;
the third variable is used for representing the maximum CPU number supported by the virtual machine.
3. The method of claim 1, wherein the boot file of the virtual machine comprises a first tag, a second tag, a third tag, a fourth tag, and a fifth tag;
the first label is used for representing the number of the memory slots of the virtual machine;
the second label is used for representing the maximum memory supported by the virtual machine;
the third tag is used for representing the current memory size of the virtual machine;
the fourth label is used for representing the maximum CPU number supported by the virtual machine;
the fifth label is used for representing the current CPU number of the virtual machine.
4. The method of claim 1, wherein adjusting the CPU and the memory of the virtual machine based on the configuration file, the startup file, the topology, and the received adjustment parameters in response to the adjustment instruction comprises:
creating a virtual machine to be adjusted in advance based on the configuration file and the starting file;
and adjusting the CPU and the memory of the virtual machine to be adjusted based on the adjusting instruction and the topological structure.
5. The method according to claim 4, wherein the step of creating the virtual machine to be adjusted based on the configuration file and the boot file in advance comprises:
calling the configuration file and the starting file;
judging whether the CPU and the memory of the virtual machine are allowed to be adjusted online or not based on the configuration file;
if so, setting the supported maximum memory of the virtual machine to be adjusted based on the starting file;
setting the number of memory slots of the virtual machine to be adjusted based on the starting file;
setting the supported maximum CPU number of the virtual machine to be adjusted and the current CPU number of the virtual machine to be adjusted based on the starting file;
and creating the virtual machine to be adjusted based on the maximum memory supported by the virtual machine to be adjusted, the number of memory slots, the maximum CPU number supported and the current CPU number of the virtual machine to be adjusted.
6. The method of claim 4, wherein the step of adjusting the CPU and the memory of the virtual machine to be adjusted based on the adjustment instructions and the topology comprises:
performing basic verification on the virtual machine to be adjusted based on the adjustment instruction; the basic check comprises checking quota, data validity and operation authority of the item to which the virtual machine to be adjusted belongs;
performing physical resource check on the virtual machine to be adjusted;
deducting the quota of the item to which the virtual machine to be adjusted belongs;
and adjusting the CPU and the memory of the virtual machine to be adjusted based on the topological structure and the received adjustment parameters.
7. The method of claim 6, further comprising:
and if the basic verification or the physical resource verification is not passed, stopping adjusting the CPU and the memory of the virtual machine to be adjusted.
8. An online adjustment device for a CPU and a memory, comprising:
the configuration file adjusting module is used for adjusting the configuration file of the platform computing service; the configuration file is used for representing whether the CPU and the memory, the maximum memory supported by the virtual machine and the maximum CPU number supported by the virtual machine are allowed to be adjusted online;
the starting file adjusting module is used for adjusting a starting file of the virtual machine; the starting file is used for representing the number of memory slots of the virtual machine, the maximum memory supported by the virtual machine, the current memory size of the virtual machine, the maximum CPU number supported by the virtual machine and the current CPU number of the virtual machine;
the topological structure adjusting module is used for adjusting the topological structure of the virtual machine; the topological structure is used for representing the mapping relation between the memory and the CPU;
the adjusting instruction receiving module is used for receiving an adjusting instruction;
and the CPU and memory adjusting module is used for responding to the adjusting instruction and adjusting the CPU and the memory of the virtual machine based on the configuration file, the starting file, the topological structure and the received adjusting parameters.
9. A virtual electronic device, comprising a central processing unit and a memory, wherein the memory stores computer-executable instructions executable by the central processing unit, and the central processing unit executes the computer-executable instructions to implement the steps of the method for online adjustment of the CPU and the memory according to any one of claims 1 to 7.
10. A computer-readable storage medium storing computer-executable instructions that, when invoked and executed by a central processing unit, cause the central processing unit to implement the steps of the method of online adjustment of a CPU and memory of any one of claims 1 to 7.
CN202010210515.XA 2020-03-23 Online adjustment method and device for CPU and memory and virtual electronic equipment Active CN111414236B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010210515.XA CN111414236B (en) 2020-03-23 Online adjustment method and device for CPU and memory and virtual electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010210515.XA CN111414236B (en) 2020-03-23 Online adjustment method and device for CPU and memory and virtual electronic equipment

Publications (2)

Publication Number Publication Date
CN111414236A true CN111414236A (en) 2020-07-14
CN111414236B CN111414236B (en) 2024-06-28

Family

ID=

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112286638A (en) * 2020-11-04 2021-01-29 浪潮云信息技术股份公司 Method for realizing hot plug between CPU and memory of Openstack virtual machine
CN113590313A (en) * 2021-07-08 2021-11-02 杭州朗和科技有限公司 Load balancing method and device, storage medium and computing equipment

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100287290A1 (en) * 2009-05-08 2010-11-11 Richard Bramley Virtual Hotplug Techniques
CN106648827A (en) * 2016-09-20 2017-05-10 国云科技股份有限公司 Method for online adding virtual machine resources
CN107368353A (en) * 2017-07-26 2017-11-21 郑州云海信息技术有限公司 A kind of method and apparatus for realizing virutal machine memory heat addition
WO2018077052A1 (en) * 2016-10-28 2018-05-03 阿里巴巴集团控股有限公司 Upgrading method and device for virtual switch
CN108196958A (en) * 2017-12-29 2018-06-22 北京泽塔云科技股份有限公司 Scheduling of resource distribution method, computer system and super fusion architecture system
CN109471702A (en) * 2018-11-15 2019-03-15 郑州云海信息技术有限公司 A kind of management method and device of virtual machine

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100287290A1 (en) * 2009-05-08 2010-11-11 Richard Bramley Virtual Hotplug Techniques
CN106648827A (en) * 2016-09-20 2017-05-10 国云科技股份有限公司 Method for online adding virtual machine resources
WO2018077052A1 (en) * 2016-10-28 2018-05-03 阿里巴巴集团控股有限公司 Upgrading method and device for virtual switch
CN107368353A (en) * 2017-07-26 2017-11-21 郑州云海信息技术有限公司 A kind of method and apparatus for realizing virutal machine memory heat addition
CN108196958A (en) * 2017-12-29 2018-06-22 北京泽塔云科技股份有限公司 Scheduling of resource distribution method, computer system and super fusion architecture system
CN109471702A (en) * 2018-11-15 2019-03-15 郑州云海信息技术有限公司 A kind of management method and device of virtual machine

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
赵旭彤;贾京峰;李志明;: "云主机秒级可用技术的设计与实现", 中小企业管理与科技(上旬刊), no. 05, 5 May 2018 (2018-05-05) *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112286638A (en) * 2020-11-04 2021-01-29 浪潮云信息技术股份公司 Method for realizing hot plug between CPU and memory of Openstack virtual machine
CN113590313A (en) * 2021-07-08 2021-11-02 杭州朗和科技有限公司 Load balancing method and device, storage medium and computing equipment
CN113590313B (en) * 2021-07-08 2024-02-02 杭州网易数之帆科技有限公司 Load balancing method, device, storage medium and computing equipment

Similar Documents

Publication Publication Date Title
US9729612B2 (en) Distributed stream processing
TWI622933B (en) Client update method and device
CN115204423A (en) Equipment management method and management server
CN112612214B (en) Method and system for generating functional interface and electronic equipment
US11036535B2 (en) Data storage method and apparatus
CN111563036B (en) Function logic judgment method and device, intelligent equipment and storage medium
CN112528619A (en) Page template file generation method and device, electronic equipment and storage medium
CN111124382A (en) Attribute assignment method and device in Java and server
US10467173B2 (en) Hot plugging of virtual bridges in a virtual PCI system
CN112306627A (en) Method and device for binding cloud host VCPU and host physical CPU
CN111984520A (en) Buried point testing method, computer device and computer-readable storage medium
CN113076099A (en) Page generation method, device, equipment and computer storage medium
CN106878082B (en) Virtual network card hot migration method and device
CN111414236B (en) Online adjustment method and device for CPU and memory and virtual electronic equipment
CN111414236A (en) Online adjusting method and device for CPU and memory and virtual electronic equipment
CN115495161B (en) BIOS option modification validation method and device and storage medium
CN105912357B (en) Starting method and device of hybrid application
CN112243033A (en) Method, device and equipment for acquiring memory information and computer readable storage medium
CN109039784B (en) Node deployment method and device of OpenStack
CN110795162A (en) Method and device for generating container mirror image file
CN111090442A (en) Application updating method and device and storage medium
CN113687908A (en) PMEM virtual machine creation method, device, equipment and readable storage medium
CN113434938A (en) BIM (building information modeling) model checking method and device, computer equipment and storage medium
CN111177624A (en) Website front-back end communication method and device, computer equipment and storage medium
CN114254232A (en) Cloud product page generation method and device, computer equipment and 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
GR01 Patent grant