WO2021121407A1 - 一种虚拟机的容量更改方法及装置 - Google Patents

一种虚拟机的容量更改方法及装置 Download PDF

Info

Publication number
WO2021121407A1
WO2021121407A1 PCT/CN2020/137749 CN2020137749W WO2021121407A1 WO 2021121407 A1 WO2021121407 A1 WO 2021121407A1 CN 2020137749 W CN2020137749 W CN 2020137749W WO 2021121407 A1 WO2021121407 A1 WO 2021121407A1
Authority
WO
WIPO (PCT)
Prior art keywords
capacity
virtual machine
current
modified
cpu
Prior art date
Application number
PCT/CN2020/137749
Other languages
English (en)
French (fr)
Inventor
张洋洋
周亚国
李倩
雷平
陈斌
周继恩
陈煜�
戚跃民
Original Assignee
中国银联股份有限公司
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 中国银联股份有限公司 filed Critical 中国银联股份有限公司
Publication of WO2021121407A1 publication Critical patent/WO2021121407A1/zh

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

Definitions

  • the present invention relates to the field of computer technology, in particular to a method and device for changing the capacity of a virtual machine.
  • a virtual machine refers to a complete computer system with complete hardware system functions that is simulated by software and runs in a completely isolated environment. The work that can be done in the physical computer can be realized in the virtual machine.
  • part of the hard disk and memory capacity of the physical machine needs to be used as the hard disk and memory capacity of the virtual machine.
  • Each virtual machine has an independent CMOS (Complementary Metal Oxide Semiconductor), hard disk, and operating system, and can operate the virtual machine just like a physical machine.
  • CMOS Complementary Metal Oxide Semiconductor
  • the capacity of the virtual machine is sufficient to ensure the normal operation of the application, but if there is a marketing campaign, the CPU and memory usage of the virtual machine may be extremely high, which affects the normal delivery of the business. At this time, the virtual machine needs to be expanded. . In the prior art, in order to expand the capacity of a virtual machine, it is necessary to shut down the virtual machine and then rebuild the virtual machine. At this time, if a business program is running on the virtual machine, business continuity cannot be guaranteed.
  • This application provides a method and device for changing the capacity of a virtual machine to solve the problem that business continuity cannot be guaranteed when the capacity of the virtual machine is changed.
  • the virtual machine capacity change request is a hot expansion request or a hot shrinkage request, and the virtual machine capacity change request includes a virtual machine identifier and a modified capacity;
  • the capacity of the virtual machine is set from the current capacity to the changed capacity.
  • the modified capacity of the virtual machine includes a modified CPU (central processing unit) capacity and a modified memory capacity of the virtual machine
  • the current capacity of the virtual machine includes the current CPU capacity and the current memory capacity of the virtual machine
  • the modified CPU capacity is greater than the current CPU capacity and the modified memory capacity is greater than the current memory capacity; the modified CPU capacity is less than the current CPU capacity and the modified memory capacity is less than the current memory capacity; The modified CPU capacity is greater than the current CPU capacity and the modified memory capacity is equal to the current memory capacity; the modified CPU capacity is less than the current CPU capacity and the modified memory capacity is equal to the current memory capacity; the modified CPU The capacity is equal to the current CPU capacity and the modified memory capacity is greater than the current memory capacity; the modified CPU capacity is equal to the current CPU capacity and the modified memory capacity is less than the current memory capacity.
  • the specifications of the physical machine include the remaining capacity of the physical machine
  • the determining the feasibility of the modified capacity for the physical machine according to the modified capacity of the virtual machine, the current capacity, and the specifications of the physical machine includes:
  • the method further includes:
  • the setting the capacity of the virtual machine from the current capacity to the changed capacity includes:
  • the underlying software of the physical machine is invoked through the drive module to set the capacity of the virtual machine to the changed capacity .
  • a device for changing the capacity of a virtual machine includes:
  • a receiving unit configured to receive a virtual machine capacity change request, where the virtual machine capacity change request is a hot expansion request or a hot shrink capacity request, and the virtual machine capacity change request includes a virtual machine identifier and a modified capacity;
  • An operating unit configured to determine, according to the virtual machine identifier, that the state of the virtual machine is normal operation
  • An obtaining unit for obtaining the current capacity of the virtual machine and the specifications of the physical machine where the virtual machine is located;
  • a judging unit configured to determine the feasibility of the changed capacity according to the changed capacity, the current capacity of the virtual machine, and the specifications of the physical machine;
  • the setting unit is configured to set the capacity of the virtual machine from the current capacity to the changed capacity when the feasibility of changing the capacity is yes.
  • the modified capacity of the virtual machine includes a modified CPU (central processing unit) capacity and a modified memory capacity of the virtual machine, and the current capacity of the virtual machine includes the current CPU capacity and the current memory capacity of the virtual machine ;
  • the judgment unit is specifically used for:
  • the modified CPU capacity is greater than the current CPU capacity and the modified memory capacity is greater than the current memory capacity; the modified CPU capacity is less than the current CPU capacity and the modified memory capacity is less than the current memory capacity; The modified CPU capacity is greater than the current CPU capacity and the modified memory capacity is equal to the current memory capacity; the modified CPU capacity is less than the current CPU capacity and the modified memory capacity is equal to the current memory capacity; the modified CPU The capacity is equal to the current CPU capacity and the modified memory capacity is greater than the current memory capacity; the modified CPU capacity is equal to the current CPU capacity and the modified memory capacity is less than the current memory capacity.
  • the specifications of the physical machine include the remaining capacity of the physical machine
  • the judgment unit is specifically used for:
  • the virtual machine capacity change request is a heat shrinkable capacity request; the judging unit is specifically configured to:
  • an alarm unit for:
  • the setting unit is specifically used for:
  • the underlying software of the physical machine is invoked through the drive module to set the capacity of the virtual machine to the changed capacity .
  • the embodiment of the present invention also provides an electronic device, including:
  • At least one processor and,
  • a memory communicatively connected with the at least one processor; wherein,
  • the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor, so that the at least one processor can execute the method as described above.
  • the embodiment of the present invention also provides a non-transitory computer-readable storage medium, the non-transitory computer-readable storage medium storing computer instructions, and the computer instructions are used to make the computer execute the method as described above.
  • a physical machine receives a virtual machine capacity change request sent by a terminal.
  • the virtual machine capacity change request includes a virtual machine identifier and a capacity change.
  • the virtual machine capacity change request is a hot expansion request or a hot shrink capacity request.
  • the identification of the virtual machine the status of the virtual machine is determined as normal operation, and the current capacity of the virtual machine and the specifications of the physical machine where the virtual machine is located are obtained.
  • the feasibility of changing the capacity is yes, set the capacity of the virtual machine from the current capacity to the changed capacity.
  • the virtual machine when the virtual machine expands or shrinks, it does not need to be shut down. Instead, the capacity of the virtual machine is changed by direct thermal expansion or shrinking to meet business requirements without affecting the business running on the virtual machine. , To ensure business continuity.
  • the process of performing thermal expansion or thermal shrinkage of the virtual machine in the embodiment of the present invention is simple and easy to operate, which reduces the difficulty and cost of operation and maintenance, and at the same time reduces a large number of calls in the process, reduces the error rate, and improves the success of capacity changes. rate.
  • FIG. 1 is a schematic diagram of a system architecture to which an embodiment of the present invention is applicable;
  • FIG. 2 is a schematic flowchart of a method for changing the capacity of a virtual machine according to an embodiment of the present invention
  • FIG. 3 is an interactive schematic diagram of a method for changing the capacity of a virtual machine according to a specific embodiment of the present invention
  • FIG. 4 is a schematic flowchart of a method for changing the capacity of a virtual machine according to a specific embodiment of the present invention
  • FIG. 5 is a schematic structural diagram of an apparatus for changing the capacity of a virtual machine according to an embodiment of the present invention
  • FIG. 6 is a schematic structural diagram of an electronic device provided by an embodiment of the present invention.
  • a system architecture to which the embodiment of the present invention is applicable includes a terminal 101 and a server 102.
  • a client or browser is installed on the terminal 101, and the client is an application (Application, APP for short).
  • the business system on the server 102 is embedded with the virtual machine described in the embodiment of the present invention, where the number of virtual machines may be one or more.
  • the terminal 101 may be an electronic device with wireless communication functions such as a mobile phone, a tablet computer, or a dedicated handheld device, or may be a personal computer (PC), a notebook computer, a server and other wired access devices connected to the Internet.
  • the server 102 may be a network device such as a computer.
  • the server 102 may be an independent device or a server cluster formed by multiple servers.
  • the server 102 can use cloud computing technology for information processing.
  • the terminal 101 can communicate with the server 102 through the INTERNET network, or communicate with the server 102 through mobile communication systems such as the Global System for Mobile Communications (GSM), long term evolution (LTE) system, etc. .
  • GSM Global System for Mobile Communications
  • LTE long term evolution
  • the method for changing the capacity of a virtual machine includes the following steps:
  • Step 201 Receive a virtual machine capacity change request, where the virtual machine capacity change request is a hot expansion request or a hot shrink capacity request, and the virtual machine capacity change request includes a virtual machine identifier and a modified capacity.
  • the terminal or CLI Communication-Line Interface
  • the server initiates a virtual machine thermal expansion request or thermal shrinkage request
  • the server s API (Application Programming Interface, application program interface) receives the thermal expansion request or thermal expansion request. After shrinking the request, it will respond to it and call the computer service through RPC (Remote Procedure Call).
  • the hot expansion request or the hot shrinking request includes the identification of the virtual machine whose capacity needs to be changed, and the corresponding changed capacity.
  • Step 202 Determine, according to the virtual machine identifier, that the state of the virtual machine is normal operation.
  • the state of the virtual machine includes a normal running state, a shutdown state, a suspended state, and so on. Since the request in the embodiment of the present invention is a thermal expansion request or a thermal shrinking request, the state of the virtual machine needs to be in a normal operating state.
  • the state of the virtual machine can be obtained through the underlying software, such as Libvirt (virtualization management software), or the detailed information of the virtual machine can be obtained from the database of the virtual machine, and the detailed information includes the state information of the virtual machine.
  • the state of the virtual machine is obtained through Libvirt, and the state of the virtual machine is obtained from the database, and it is determined whether the state of the virtual machine obtained in the above two methods is a normal operating state. If both are in normal operation status, you can continue to perform the following steps; otherwise, exit the program and feed back an abnormal alarm to the terminal.
  • the status of the virtual machine obtained by Libvirt is normal operation, and the status of the virtual machine obtained in the database is not operating normally, it indicates that there is a problem with the state of the virtual machine at the platform layer; if the state of the virtual machine obtained by Libvirt is not running normally, The status of the virtual machine obtained in the database is running normally, which indicates that there may be a problem with Libvirt.
  • Step 203 Obtain the current capacity of the virtual machine and the specifications of the physical machine where the virtual machine is located.
  • the current capacity of the virtual machine can be found from the configuration file, including the current CPU capacity and current memory capacity of the virtual machine; the information about the virtual machine and the physical machine where the virtual machine is located can be obtained through the Hypervisor (virtual machine monitor) , Mainly to check the CPU (Central Processing Unit) capacity and memory capacity of the physical machine where the virtual machine is located.
  • the Hypervisor virtual machine monitor
  • Step 204 Determine the feasibility of the changed capacity according to the changed capacity, the current capacity of the virtual machine, and the specifications of the physical machine.
  • step 202 can be before step 203, step 202 can also be after step 203, or even after step 204.
  • the embodiment of the present invention is only an example and is not limited. .
  • Step 205 When the feasibility of changing the capacity is yes, set the capacity of the virtual machine from the current capacity to the changed capacity.
  • an application management component is embedded in the business system for publishing management services, receiving and processing management requests.
  • the application management component supports N types of protocols, that is to say, provides management services based on N types of protocols.
  • the application management component receives the application management request sent by the terminal according to the first protocol, where the format of the application management request satisfies any one of the N protocols.
  • the application management component parses the application management request into the first data according to the set management data structure.
  • the application management component sends the first data to the corresponding task processor. Since the structure of the first data satisfies the set management data structure, it can be recognized and processed by the task processor.
  • the application management component receives the processing result sent by the task processor and provides feedback to the terminal.
  • the management service of multiple protocols is provided to the outside through the application management component. Therefore, the maintenance personnel can choose one of the multiple protocols to send the application management request, thereby flexibly selecting the protocol according to the actual situation, which greatly reduces Restrictions due to the limitations of the agreement.
  • the modified capacity of the virtual machine includes the modified CPU capacity and the modified memory capacity of the virtual machine
  • the current capacity of the virtual machine includes the current CPU capacity and the current memory capacity of the virtual machine
  • the determining the feasibility of the modified capacity for the physical machine according to the modified capacity of the virtual machine, the current capacity, and the specifications of the physical machine includes:
  • the modified CPU capacity is greater than the current CPU capacity and the modified memory capacity is greater than the current memory capacity; the modified CPU capacity is less than the current CPU capacity and the modified memory capacity is less than the current memory capacity; The modified CPU capacity is greater than the current CPU capacity and the modified memory capacity is equal to the current memory capacity; the modified CPU capacity is less than the current CPU capacity and the modified memory capacity is equal to the current memory capacity; the modified CPU The capacity is equal to the current CPU capacity and the modified memory capacity is greater than the current memory capacity; the modified CPU capacity is equal to the current CPU capacity and the modified memory capacity is less than the current memory capacity.
  • the capacity of the virtual machine includes the CPU capacity and the memory capacity. Therefore, it is necessary to compare the CPU capacity and the memory capacity before and after the change.
  • the CPU capacity and memory capacity generally increase or decrease at the same time, or only one increases or decreases while the other remains unchanged. Therefore, when the CPU capacity and the memory capacity meet the above conditions, the subsequent steps can be continued; and if one increases and the other decreases, or both remain unchanged, the capacity change is considered abnormal, and an abnormal alarm is directly fed back.
  • an abnormal alarm is fed back, and the abnormal alarm includes abnormal content.
  • the changed CPU capacity is equal to the current CPU capacity and the changed memory capacity is equal to the current memory capacity, that is, there is no change before and after the capacity change, an abnormal alarm will be sent directly to the terminal, and the abnormal alarm contains the abnormal content and the same specification does not require hot expansion Or heat shrinkage.
  • the changed CPU capacity is less than the current CPU capacity and the changed memory capacity is greater than the current memory capacity, an abnormal alarm is sent directly to the terminal, and the abnormal alarm includes the abnormal content that the CPU and memory have not increased or decreased at the same time.
  • the specifications of the physical machine include the remaining capacity of the physical machine
  • the determining the feasibility of the modified capacity for the physical machine according to the modified capacity of the virtual machine, the current capacity, and the specifications of the physical machine includes:
  • the virtual machine before performing hot expansion, the virtual machine needs to determine whether the remaining capacity of the physical machine where the virtual machine is located is greater than the difference between the capacity before and after the change, so as to ensure that there is enough space in the physical machine to provide the virtual machine hot expansion to ensure the virtual machine.
  • the machine can run normally after thermal expansion. First obtain the information of the physical machine where the virtual machine is located through the Hypervisor, mainly to check the remaining CPU capacity C1 and the remaining memory capacity R1; then, the CPU capacity and memory capacity before and after the change are subtracted to obtain the CPU capacity difference C2 and the memory capacity difference. R2; Finally, compare C1 and C2, R1 and R2 respectively. Only when C1 is greater than or equal to C2 and R1 is greater than or equal to R2, can the subsequent steps continue.
  • the heat shrinkage of the virtual machine may have an impact on the business running on the virtual machine. Therefore, the virtual machine can be set to be heat-shrinkable or non-heat-shrinkable as required. That is, the request for changing the capacity of the virtual machine is a heat shrinking request; determining the feasibility of the changed capacity for the physical machine includes:
  • a configuration item can be added to indicate whether the virtual machine allows heat shrinkage. If this option is set to yes, then the virtual machine can perform heat shrinkage; if not, then heat shrinkage is not allowed.
  • the server receives the virtual machine heat shrinkage request, it obtains the configuration item from the configuration file according to the virtual machine ID, and determines whether the heat shrinkage can be performed. If it is, then continue to perform the subsequent steps; if not, it will feedback an abnormal alarm.
  • the content is that the virtual machine does not support heat shrinkage.
  • the virtual machine when the virtual machine starts, it needs a certain amount of memory resources to run the virtual machine. Therefore, you can also set the minimum memory capacity required for the virtual machine to start in the configuration file to prevent insufficient memory during heat shrinking.
  • the virtual machine is running abnormally. Compare the changed memory capacity with the minimum memory capacity read from the configuration file. If the changed memory capacity is greater than or equal to the minimum memory capacity, you can proceed to the next steps; otherwise, an abnormal alarm is sent to the terminal, and the abnormal content contained in the abnormal alarm is new The memory of the virtual machine is less than the minimum memory capacity.
  • setting the capacity of the virtual machine from the current capacity to the changed capacity includes:
  • the underlying software of the physical machine is invoked through the drive module to set the capacity of the virtual machine to the changed capacity .
  • the driver module is called to set the CPU capacity and memory capacity of the virtual machine.
  • For the CPU of the virtual machine set the CPU capacity of the virtual machine according to the changed CPU capacity. If the setting is successful, continue with the following steps; if the setting fails, an error log is generated and an exception alarm is sent.
  • the exception content is: the virtual machine CPU setting failed.
  • Regarding the memory of the virtual machine set the memory capacity of the virtual machine according to the changed memory capacity. If the setting is successful, continue with the next steps; if the setting fails, an error log is generated and an exception alarm is sent.
  • the exception content is: the virtual machine memory setting failed.
  • the driver module calls the Libvirt command of the physical machine where the virtual machine is located to set the CPU capacity and memory capacity of the virtual machine respectively.
  • the server includes four sub-modules, namely API, processing sub-module, and driver module (Driver). And virtualization management software (Libvirt) module.
  • the specific process includes the following steps:
  • Step 301 The terminal or the Client sends a virtual machine hot expansion request or hot shrinking request.
  • Step 302 The API calls the processing sub-module through RPC after receiving the virtual machine hot expansion request or hot shrinking request.
  • the processing sub-module determines whether the virtual machine thermal expansion request or the virtual machine thermal shrinking request is allowed to be executed according to the state of the virtual machine and the physical machine, if yes, execute step 303, otherwise execute step 305.
  • Step 303 The processing sub-module calls the driver module to set the CPU capacity and memory capacity of the virtual machine.
  • Step 304 The driver module calls the underlying Libvirt module commands to dynamically adjust the CPU capacity and memory capacity of the virtual machine, thereby completing the thermal expansion or thermal shrinkage of the virtual machine.
  • Step 305 Send an abnormal alarm to the terminal, and the abnormal alarm contains specific abnormal content.
  • Receive a hot expansion request which includes the changed CPU capacity and memory capacity.
  • the abnormal content is: only the memory and CPU are allowed to increase or decrease at the same time.
  • Driver calls the Libvirt command of the physical machine where the virtual machine is located to set the CPU and memory of the virtual machine respectively.
  • the embodiment of the present invention also provides a device for changing the capacity of a virtual machine, as shown in FIG. 5, including:
  • the receiving unit 501 is configured to receive a virtual machine capacity change request, where the virtual machine capacity change request is a hot expansion request or a hot shrink capacity request, and the virtual machine capacity change request includes a virtual machine identifier and a modified capacity;
  • the running unit 502 is configured to determine, according to the virtual machine identifier, that the state of the virtual machine is normal operation;
  • the obtaining unit 503 is configured to obtain the current capacity of the virtual machine and the specifications of the physical machine where the virtual machine is located;
  • the judging unit 504 is configured to determine the feasibility of the changed capacity according to the changed capacity of the virtual machine, the current capacity, and the specifications of the physical machine;
  • the setting unit 505 is configured to set the capacity of the virtual machine from the current capacity to the changed capacity when the feasibility of changing the capacity is yes.
  • the modified capacity of the virtual machine includes a modified CPU (central processing unit) capacity and a modified memory capacity of the virtual machine, and the current capacity of the virtual machine includes the current CPU capacity and the current memory capacity of the virtual machine ;
  • the judging unit 504 is specifically configured to:
  • the modified CPU capacity is greater than the current CPU capacity and the modified memory capacity is greater than the current memory capacity; the modified CPU capacity is less than the current CPU capacity and the modified memory capacity is less than the current memory capacity; The modified CPU capacity is greater than the current CPU capacity and the modified memory capacity is equal to the current memory capacity; the modified CPU capacity is less than the current CPU capacity and the modified memory capacity is equal to the current memory capacity; the modified CPU The capacity is equal to the current CPU capacity and the modified memory capacity is greater than the current memory capacity; the modified CPU capacity is equal to the current CPU capacity and the modified memory capacity is less than the current memory capacity.
  • the specifications of the physical machine include the remaining capacity of the physical machine
  • the judgment unit 504 is specifically configured to:
  • the virtual machine capacity change request is a heat shrinkable capacity request; the judging unit 504 is specifically configured to:
  • the setting unit 505 is specifically configured to:
  • the underlying software of the physical machine is invoked through the drive module to set the capacity of the virtual machine to the changed capacity .
  • the present invention also provides an electronic device, as shown in FIG. 6, including:
  • It includes a processor 601, a memory 602, a transceiver 603, and a bus interface 604, wherein the processor 601, the memory 602 and the transceiver 603 are connected through the bus interface 604;
  • the processor 601 is configured to read the program in the memory 602 and execute the following method:
  • the virtual machine capacity change request is a hot expansion request or a hot shrinkage request, and the virtual machine capacity change request includes a virtual machine identifier and a modified capacity;
  • the capacity of the virtual machine is set from the current capacity to the changed capacity.
  • the modified capacity of the virtual machine includes a modified CPU (central processing unit) capacity and a modified memory capacity of the virtual machine, and the current capacity of the virtual machine includes the current CPU capacity and the current memory capacity of the virtual machine;
  • the processor 601 is specifically configured to:
  • the modified CPU capacity is greater than the current CPU capacity and the modified memory capacity is greater than the current memory capacity; the modified CPU capacity is less than the current CPU capacity and the modified memory capacity is less than the current memory capacity; The modified CPU capacity is greater than the current CPU capacity and the modified memory capacity is equal to the current memory capacity; the modified CPU capacity is less than the current CPU capacity and the modified memory capacity is equal to the current memory capacity; the modified CPU The capacity is equal to the current CPU capacity and the modified memory capacity is greater than the current memory capacity; the modified CPU capacity is equal to the current CPU capacity and the modified memory capacity is less than the current memory capacity.
  • the specifications of the physical machine include the remaining capacity of the physical machine; the processor 601 is specifically configured to:
  • the virtual machine capacity change request is a thermal shrinkage request; the processor 601 is specifically configured to:
  • processor 601 is specifically configured to:
  • processor 601 is specifically configured to:
  • the underlying software of the physical machine is invoked through the drive module to set the capacity of the virtual machine to the changed capacity .
  • These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing equipment to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction device.
  • the device implements the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
  • These computer program instructions can also be loaded on a computer or other programmable data processing equipment, so that a series of operation steps are executed on the computer or other programmable equipment to produce computer-implemented processing, so as to execute on the computer or other programmable equipment.
  • the instructions provide steps for implementing the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.

Abstract

一种虚拟机的容量更改方法及装置,用以解决虚拟机更改容量时,无法保证业务连续性的问题。所述方法包括:接收虚拟机容量改变请求,所述虚拟机容量改变请求为热扩容请求或热缩容请求,所述虚拟机容量改变请求中包含虚拟机标识以及更改容量(201);根据所述虚拟机标识,确定所述虚拟机的状态为正常运行(202);获取所述虚拟机的当前容量以及所述虚拟机所在物理机的规格(203);根据所述虚拟机的更改容量、当前容量以及所述物理机的规格,确定所述更改容量的可行性(204);当所述更改容量的可行性为是时,将所述虚拟机的容量由所述当前容量设置为所述更改容量(205)。

Description

一种虚拟机的容量更改方法及装置
相关申请的交叉引用
本申请要求在2019年12月20日提交中国专利局、申请号为201911327218.7、申请名称为“一种虚拟机的容量更改方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本发明涉及计算机技术领域,尤其涉及一种虚拟机的容量更改方法及装置。
背景技术
虚拟机是指通过软件模拟的具有完整硬件系统功能的、运行在一个完全隔离环境中的完整计算机系统。在实体计算机中能够完成的工作在虚拟机中都能够实现。在计算机中创建虚拟机时,需要将实体机的部分硬盘和内存容量作为虚拟机的硬盘和内存容量。每个虚拟机都有独立的CMOS(Complementary Metal Oxide Semiconductor,互补金属氧化物半导体)、硬盘和操作系统,可以像使用实体机一样对虚拟机进行操作。
一般情况下,虚拟机的容量足以保证应用正常运行,但如果遇到营销活动,虚拟机的CPU和内存的占用可能会出现飚高,影响业务的正常下发,这时需要对虚拟机进行扩容。现有技术为了实现虚拟机的扩容,需要将虚拟机进行关机操作,而后重建虚拟机,此时,若虚拟机上运行有业务程序,则无法保证业务的连续性。
发明内容
本申请提供一种虚拟机的容量更改方法及装置,用以解决虚拟机更改容量时,无法保证业务连续性的问题。
本发明实施例提供的一种虚拟机的容量更改方法,包括:
接收虚拟机容量改变请求,所述虚拟机容量改变请求为热扩容请求或热缩容请求,所述虚拟机容量改变请求中包含虚拟机标识以及更改容量;
根据所述虚拟机标识,确定所述虚拟机的状态为正常运行;
获取所述虚拟机的当前容量以及所述虚拟机所在物理机的规格;
根据所述虚拟机的更改容量、当前容量以及所述物理机的规格,确定所述更改容量的可行性;
当所述更改容量的可行性为是时,将所述虚拟机的容量由所述当前容量设置为所述更改容量。
可选的,所述虚拟机的更改容量包括所述虚拟机的更改CPU(中央处理单元)容量以及更改内存容量,所述虚拟机的当前容量包括所述虚拟机的当前CPU容量以及当前内存容量;所述根据所述虚拟机的更改容量、当前容量以及所述物理机的规格,确定所述更改容量针对所述物理机的可行性,包括:
确定所述更改容量与所述当前容量之间的关系是否满足以下条件之一:
所述更改CPU容量大于所述当前CPU容量且所述更改内存容量大于所述当前内存容量;所述更改CPU容量小于所述当前CPU容量且所述更改内存容量小于所述当前内存容量;所述更改CPU容量大于所述当前CPU容量且所述更改内存容量等于所述当前内存容量;所述更改CPU容量小于所述当前CPU容量且所述更改内存容量等于所述当前内存容量;所述更改CPU容量等于所述当前CPU容量且所述更改内存容量大于所述当前内存容量;所述更改CPU容量等于所述当前CPU容量且所述更改内存容量小于所述当前内存容量。
可选的,所述物理机的规格包括所述物理机的剩余容量;
所述根据所述虚拟机的更改容量、当前容量以及所述物理机的规格,确定所述更改容量针对所述物理机的可行性,包括:
计算所述物理机的剩余容量是否大于或等于所述虚拟机的更改容量与当前容量之间的差值。
可选的,所述虚拟机容量改变请求为热缩容请求;所述确定所述更改容 量针对所述物理机的可行性,包括:
确定所述虚拟机是否允许热缩容。
可选的,所述根据所述虚拟机的更改容量、当前容量以及所述物理机的规格,确定所述更改容量针对所述物理机的可行性之后,还包括:
当所述更改容量的可行性为否时,反馈异常告警,所述异常告警中包含异常内容。
可选的,所述将所述虚拟机的容量由所述当前容量设置为所述更改容量,包括:
调用驱动模块,将所述虚拟机的容量设置为所述更改容量;
在所述驱动模块成功将所述虚拟机的容量设置为所述更改容量的情况下,通过所述驱动模块调用所述物理机的底层软件,将所述虚拟机的容量设置为所述更改容量。
一种虚拟机的容量更改装置,包括:
接收单元,用于接收虚拟机容量改变请求,所述虚拟机容量改变请求为热扩容请求或热缩容请求,所述虚拟机容量改变请求中包含虚拟机标识以及更改容量;
运行单元,用于根据所述虚拟机标识,确定所述虚拟机的状态为正常运行;
获取单元,用于获取所述虚拟机的当前容量以及所述虚拟机所在物理机的规格;
判断单元,用于根据所述虚拟机的更改容量、当前容量以及所述物理机的规格,确定所述更改容量的可行性;
设置单元,用于当所述更改容量的可行性为是时,将所述虚拟机的容量由所述当前容量设置为所述更改容量。
可选的,所述虚拟机的更改容量包括所述虚拟机的更改CPU(中央处理单元)容量以及更改内存容量,所述虚拟机的当前容量包括所述虚拟机的当前CPU容量以及当前内存容量;所述判断单元,具体用于:
确定所述更改容量与所述当前容量之间的关系是否满足以下条件之一:
所述更改CPU容量大于所述当前CPU容量且所述更改内存容量大于所述当前内存容量;所述更改CPU容量小于所述当前CPU容量且所述更改内存容量小于所述当前内存容量;所述更改CPU容量大于所述当前CPU容量且所述更改内存容量等于所述当前内存容量;所述更改CPU容量小于所述当前CPU容量且所述更改内存容量等于所述当前内存容量;所述更改CPU容量等于所述当前CPU容量且所述更改内存容量大于所述当前内存容量;所述更改CPU容量等于所述当前CPU容量且所述更改内存容量小于所述当前内存容量。
可选的,所述物理机的规格包括所述物理机的剩余容量;
所述判断单元,具体用于:
计算所述物理机的剩余容量是否大于或等于所述虚拟机的更改容量与当前容量之间的差值。
可选的,所述虚拟机容量改变请求为热缩容请求;所述判断单元,具体用于:
确定所述虚拟机是否允许热缩容。
可选的,还包括告警单元,用于:
当所述更改容量的可行性为否时,反馈异常告警,所述异常告警中包含异常内容。
可选的,所述设置单元,具体用于:
调用驱动模块,将所述虚拟机的容量设置为所述更改容量;
在所述驱动模块成功将所述虚拟机的容量设置为所述更改容量的情况下,通过所述驱动模块调用所述物理机的底层软件,将所述虚拟机的容量设置为所述更改容量。
本发明实施例还提供一种电子设备,包括:
至少一个处理器;以及,
与所述至少一个处理器通信连接的存储器;其中,
所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所 述至少一个处理器执行,以使所述至少一个处理器能够执行如上所述的方法。
本发明实施例还提供一种非暂态计算机可读存储介质,所述非暂态计算机可读存储介质存储计算机指令,所述计算机指令用于使所述计算机执行如上所述的方法。
本发明实施例中,物理机接收终端发送的虚拟机容量改变请求,该虚拟机容量改变请求中包含虚拟机标识以及更改容量,其中,虚拟机容量改变请求为热扩容请求或热缩容请求。根据虚拟机标识,确定虚拟机的状态为正常运行,并获取虚拟机的当前容量以及虚拟机所在物理机的规格。根据虚拟机的更改容量、当前容量以及物理机的规格,确定更改容量的可行性。当更改容量的可行性为是时,将虚拟机的容量由当前容量设置为更改容量。本发明实施例中,虚拟机进行扩容或缩容时,无需关机,而是采用直接热扩容或热缩容的方式改变虚拟机的容量满足业务需求,不会对虚拟机上运行的业务产生影响,保证了业务的连续性。此外,本发明实施例中虚拟机完成热扩容或热缩容的过程简单易操作,降低了运维的难度和成本,同时减少了中间大量调用过程,降低了出错率,提高了容量改变的成功率。
附图说明
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简要介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域的普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。
图1为本发明实施例所适用的一种系统架构的示意图;
图2为本发明实施例提供的一种虚拟机的容量更改方法的流程示意图;
图3为本发明具体实施例提供的一种虚拟机的容量更改方法的交互示意图;
图4为本发明具体实施例提供的一种虚拟机的容量更改方法的流程示意图;
图5为本发明实施例提供的一种虚拟机的容量更改装置的结构示意图;
图6为本发明实施例提供的电子设备的结构示意图。
具体实施方式
为了使本发明的目的、技术方案和优点更加清楚,下面将结合附图对本发明作进一步地详细描述,显然,所描述的实施例仅仅是本发明一部份实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其它实施例,都属于本发明保护的范围。
如图1所示,本发明实施例所适用的一种系统架构,包括终端101和服务器102。终端101上安装有客户端或者浏览器,客户端为应用程序(Application,简称APP)。服务器102上的业务系统中嵌入有本发明实施例中描述的虚拟机,其中虚拟机的个数可以是一个,也可以是多个。
终端101可以是手机、平板电脑或者是专用的手持设备等具有无线通信功能的电子设备,也可以是个人计算机(personal computer,简称PC),笔记本电脑,服务器等有线接入方式连接上网的设备。服务器102可以是计算机等网络设备。服务器102可以是一个独立的设备,也可以是多个服务器所形成的服务器集群。优选地,服务器102可以采用云计算技术进行信息处理。
终端101可以通过INTERNET网络与服务器102进行通信,也可以通过全球移动通信系统(Global System for Mobile Communications,简称GSM)、长期演进(long term evolution,简称LTE)系统等移动通信系统与服务器102进行通信。
需要注意的是,上文提及的应用场景仅是为了便于理解本申请的精神和原理而示出,本申请实施例在此方面不受任何限制。相反,本申请实施例可以应用于适用的任何场景。
如图2所示,本发明实施例提供的虚拟机的容量更改方法,包括以下步 骤:
步骤201、接收虚拟机容量改变请求,所述虚拟机容量改变请求为热扩容请求或热缩容请求,所述虚拟机容量改变请求中包含虚拟机标识以及更改容量。
具体实施过程中,终端或者CLI(Command-Line Interface,命令行接口)发起虚拟机热扩容请求或者热缩容请求,服务器的API(Application Programming Interface,应用程序接口)在接收到热扩容请求或者热缩容请求后,会对其进行响应,并通过RPC(Remote Procedure Call,远程过程调用指令)调用计算机服务。其中,热扩容请求或者热缩容请求中,包含需要改变容量的虚拟机标识,以及对应的更改容量。
步骤202、根据所述虚拟机标识,确定所述虚拟机的状态为正常运行。
具体实施过程中,虚拟机的状态包括正常运行状态、关机状态、挂起状态等。由于本发明实施例中的请求为热扩容请求或者热缩容请求,因此,虚拟机的状态需要处于正常运行状态。
虚拟机状态可以通过底层软件,如Libvirt(虚拟化管理软件)获取,也可以从虚拟机的数据库中获取虚拟机的详细信息,该详细信息中包含虚拟机的状态信息。一种可选的实施例中,既通过Libvirt获取虚拟机的状态,又从数据库中获取虚拟机的状态,并分别判断上述两种方式获取的虚拟机状态是否为正常运行状态。若两者均为正常运行状态,则可继续执行后续步骤;否则退出程序,向终端反馈异常告警。
其中,若Libvirt获取的虚拟机的状态为正常运行,数据库中获取的虚拟机的状态不是正常运行,则表明虚拟机在平台层的状态有问题;若Libvirt获取的虚拟机的状态不是正常运行,数据库中获取的虚拟机的状态是正常运行,则说明Libvirt可能出现了问题。
步骤203、获取所述虚拟机的当前容量以及所述虚拟机所在物理机的规格。
具体实施过程中,可以从配置文件中查找出虚拟机的当前容量,包括虚拟机的当前CPU容量和当前内存容量;可以通过Hypervisor(虚拟机监视器) 获取虚拟机以及虚拟机所在物理机的信息,主要是查看虚拟机所在物理机的CPU(Central Processing Unit,中央处理单元)容量和内存容量。
步骤204、根据所述虚拟机的更改容量、当前容量以及所述物理机的规格,确定所述更改容量的可行性。
上述步骤202与步骤203之间的先后顺序仅为举例,步骤202可以在步骤203之前,步骤202也可以在步骤203之后,甚至在步骤204之后,本发明实施例中仅为举例,不做限制。
步骤205、当所述更改容量的可行性为是时,将所述虚拟机的容量由所述当前容量设置为所述更改容量。
本发明实施例中,在业务系统中嵌入应用管理组件,用于发布管理服务,接收并处理管理请求。应用管理组件支持N种协议,也就是说向外提供基于N种协议的管理服务。应用管理组件依据第一协议接收终端发送的应用管理请求,其中应用管理请求的格式满足N个协议中的任一协议即可。应用管理组件依据设定的管理数据结构,将应用管理请求解析为第一数据。应用管理组件将第一数据向对应的任务处理器发送,第一数据由于其结构满足设定的管理数据结构,因此可以被任务处理器识别并处理。应用管理组件接收任务处理器发送的处理结果,并向终端进行反馈。本发明实施例中,通过应用管理组件对外提供多种协议的管理服务,因此,维护人员可以从多种协议中任选一个发送应用管理请求,从而根据实际情况灵活选择协议,很大程度上减少了因协议局限性而存在的限制。
本发明实施例中,从多个方面进行确认,判断更改容量的可行性,下面对不同的对比方式分别介绍。
一种可选的实施例中,虚拟机的更改容量包括虚拟机的更改CPU容量以及更改内存容量,虚拟机的当前容量包括虚拟机的当前CPU容量以及当前内存容量。
所述根据所述虚拟机的更改容量、当前容量以及所述物理机的规格,确定所述更改容量针对所述物理机的可行性,包括:
确定所述更改容量与所述当前容量之间的关系是否满足以下条件之一:
所述更改CPU容量大于所述当前CPU容量且所述更改内存容量大于所述当前内存容量;所述更改CPU容量小于所述当前CPU容量且所述更改内存容量小于所述当前内存容量;所述更改CPU容量大于所述当前CPU容量且所述更改内存容量等于所述当前内存容量;所述更改CPU容量小于所述当前CPU容量且所述更改内存容量等于所述当前内存容量;所述更改CPU容量等于所述当前CPU容量且所述更改内存容量大于所述当前内存容量;所述更改CPU容量等于所述当前CPU容量且所述更改内存容量小于所述当前内存容量。
具体实施过程中,虚拟机的容量包括CPU容量以及内存容量,因此,需要将改变前后的CPU容量和内存容量分别进行比较。另一方面,虚拟机进行热扩容或者热缩容时,CPU容量和内存容量一般同时增加或者同时减少,或者仅有一个增加或减少另一个保持不变。因此,当CPU容量和内存容量满足上述条件时,可以继续后续步骤;而若一个增加而另一个减少,或者两个均不变时,则认为容量改变异常,直接反馈异常告警。
进一步地,本发明实施例中,若更改容量的可行性为否时,反馈异常告警,所述异常告警中包含异常内容。例如,更改CPU容量等于当前CPU容量且更改内存容量等于当前内存容量时,即容量更改前和更改后没有变化,则直接向终端发送异常告警,且异常告警中包含异常内容为相同规格无需热扩容或热缩容。又例如,若更改CPU容量小于当前CPU容量且更改内存容量大于当前内存容量,则直接向终端发送异常告警,且异常告警中包含异常内容为CPU和内存未同时增加或减少。
一种可选的实施例中,物理机的规格包括物理机的剩余容量;
所述根据所述虚拟机的更改容量、当前容量以及所述物理机的规格,确定所述更改容量针对所述物理机的可行性,包括:
计算所述物理机的剩余容量是否大于或等于所述虚拟机的更改容量与当前容量之间的差值。
具体实施过程中,虚拟机在执行热扩容前需要判断虚拟机所在物理机的 剩余容量是否大于更改前后容量的差值,以保证物理机中还存在足够的空间提供给虚拟机热扩容,保证虚拟机热扩容后可正常运行。首先通过Hypervisor获取虚拟机所在物理机的信息,主要是查看剩余CPU容量C1和剩余内存容量R1;而后将更改前后的CPU容量和内存容量分别相减,得到CPU容量差值C2和内存容量差值R2;最后分别比较C1和C2,R1和R2,只有当C1大于等于C2且R1大于等于R2时,才可继续执行后续步骤。
特殊地,虚拟机热缩容可能会对运行在虚拟机上的业务有影响,因此,虚拟机可以根据需要设置为可进行热缩容或不可进行热缩容。即,针对虚拟机容量改变请求为热缩容请求;确定所述更改容量针对所述物理机的可行性,包括:
确定所述虚拟机是否允许热缩容。
具体地,可以增加一个配置项,标示该虚拟机是否允许热缩容,若该选项设置为是,则该虚拟机可以进行热缩容;若为否,则不可进行热缩容。服务器接收到虚拟机热缩容请求后,根据虚拟机标识,从配置文件中获取该配置项,确定是否可以进行热缩容,若是,则继续执行后续步骤;若否,则反馈异常告警,异常内容为虚拟机不支持热缩容。
另一方面,虚拟机在启动时,需要一定的内存资源才足以虚拟机运行,因此在配置文件中还可以设置虚拟机启动所需的最小内存容量,防止在热缩容时因内存不够导致的虚拟机运行异常。比较更改内存容量和从配置文件中读取的最小内存容量,如果更改内存容量大于或者等于最小内存容量,则可继续执行后续步骤;否则向终端发送异常告警,且异常告警中包含异常内容为新的虚拟机内存小于最小内存容量。
进一步地,一种可选的实施例中,将所述虚拟机的容量由所述当前容量设置为所述更改容量,包括:
调用驱动模块,将所述虚拟机的容量设置为所述更改容量;
在所述驱动模块成功将所述虚拟机的容量设置为所述更改容量的情况下,通过所述驱动模块调用所述物理机的底层软件,将所述虚拟机的容量设置为 所述更改容量。
具体实施过程中,在上述更改容量全部被认定为都可以后,调用驱动模块设置虚拟机的CPU容量和内存容量。针对虚拟机的CPU,根据更改CPU容量设置虚拟机的CPU容量,如果设置成功,继续执行后续步骤;如果设置失败,即生成错误日志,并发送异常告警,异常内容为:虚拟机CPU设置失败。针对虚拟机的内存,根据更改内存容量设置虚拟机的内存容量,如果设置成功,继续执行后续步骤;如果设置失败,即生成错误日志,并发送异常告警,异常内容为:虚拟机内存设置失败。之后,驱动模块调用虚拟机所在物理机的Libvirt命令分别设置虚拟机的CPU容量和内存容量。
为了更清楚地理解本发明,下面以具体实施例对上述流程进行详细描述,如图3所示,具体实施例中,服务器包括四个子模块,分别为API、处理子模块、驱动模块(Driver)和虚拟化管理软件(Libvirt)模块。具体流程包括以下步骤:
步骤301:终端或者Client发出虚拟机热扩容请求或热缩容请求。
步骤302:API在收到虚拟机热扩容请求或热缩容请求后,通过RPC调用处理子模块。处理子模块根据虚拟机及物理机的状态,判断是否允许执行虚拟机热扩容请求或者虚拟机热缩容请求,若是,则执行步骤303,否则执行步骤305。
步骤303:处理子模块调用驱动模块设置虚拟机的CPU容量和内存容量。
步骤304:驱动模块调用底层Libvirt模块命令动态调整虚拟机的CPU容量和内存容量,从而完成虚拟机的热扩容或者热缩容。
步骤305:向终端发送异常告警,异常告警中包含具体的异常内容。
下面以热扩容为例,详细介绍执行过程,如图4所示,包括:
接收热扩容请求,该热扩容请求中包含更改后的CPU容量和内存容量。
将虚拟机当前容量和接收到的更改容量进行对比,若确定其中CPU容量和内存容量均相同,则直接终止程序,并发送异常告警,异常内容为:虚拟机的CPU和内存未发生改变,不可进行热扩容。若否,则执行后续步骤。
判断CPU容量与内存容量,是否均为增加,若是,则执行后续步骤;若否,则直接终止程序,并发送异常告警,异常内容为:仅允许内存和CPU同时增加或者减少。
获取虚拟机的状态,判断虚拟机是否处于正常运行状态,若是,则执行后续步骤;若否,则直接终止程序,并发送异常告警,异常内容为:虚拟机未处于正常运行状态。
通过Hypervisor获取虚机所在物理机的信息,包括剩余CPU容量C1和剩余内存容量R1。将接收到的和从虚拟机存储中获取的CPU容量和内存容量分别相减,得到CPU容量差值C2和内存容量差值R2。分别比较C1和C2,R1和R2,当C1大于等于C2且R1大于等于R2时,执行后续步骤;若否,则直接终止程序,并发送异常告警,异常内容为:物理剩余资源不足。
调用Driver设置虚拟机的CPU和内存。
Driver调用虚拟机所在物理机的Libvirt命令分别设置虚拟机的CPU和内存。
本发明实施例还提供了一种虚拟机的容量更改装置,如图5所示,包括:
接收单元501,用于接收虚拟机容量改变请求,所述虚拟机容量改变请求为热扩容请求或热缩容请求,所述虚拟机容量改变请求中包含虚拟机标识以及更改容量;
运行单元502,用于根据所述虚拟机标识,确定所述虚拟机的状态为正常运行;
获取单元503,用于获取所述虚拟机的当前容量以及所述虚拟机所在物理机的规格;
判断单元504,用于根据所述虚拟机的更改容量、当前容量以及所述物理机的规格,确定所述更改容量的可行性;
设置单元505,用于当所述更改容量的可行性为是时,将所述虚拟机的容量由所述当前容量设置为所述更改容量。
可选的,所述虚拟机的更改容量包括所述虚拟机的更改CPU(中央处理 单元)容量以及更改内存容量,所述虚拟机的当前容量包括所述虚拟机的当前CPU容量以及当前内存容量;所述判断单元504,具体用于:
确定所述更改容量与所述当前容量之间的关系是否满足以下条件之一:
所述更改CPU容量大于所述当前CPU容量且所述更改内存容量大于所述当前内存容量;所述更改CPU容量小于所述当前CPU容量且所述更改内存容量小于所述当前内存容量;所述更改CPU容量大于所述当前CPU容量且所述更改内存容量等于所述当前内存容量;所述更改CPU容量小于所述当前CPU容量且所述更改内存容量等于所述当前内存容量;所述更改CPU容量等于所述当前CPU容量且所述更改内存容量大于所述当前内存容量;所述更改CPU容量等于所述当前CPU容量且所述更改内存容量小于所述当前内存容量。
可选的,所述物理机的规格包括所述物理机的剩余容量;
所述判断单元504,具体用于:
计算所述物理机的剩余容量是否大于或等于所述虚拟机的更改容量与当前容量之间的差值。
可选的,所述虚拟机容量改变请求为热缩容请求;所述判断单元504,具体用于:
确定所述虚拟机是否允许热缩容。
可选的,还包括告警单元506,用于:
当所述更改容量的可行性为否时,反馈异常告警,所述异常告警中包含异常内容。
可选的,所述设置单元505,具体用于:
调用驱动模块,将所述虚拟机的容量设置为所述更改容量;
在所述驱动模块成功将所述虚拟机的容量设置为所述更改容量的情况下,通过所述驱动模块调用所述物理机的底层软件,将所述虚拟机的容量设置为所述更改容量。
基于相同的原理,本发明还提供一种电子设备,如图6所示,包括:
包括处理器601、存储器602、收发机603、总线接口604,其中处理器 601、存储器602与收发机603之间通过总线接口604连接;
所述处理器601,用于读取所述存储器602中的程序,执行下列方法:
接收虚拟机容量改变请求,所述虚拟机容量改变请求为热扩容请求或热缩容请求,所述虚拟机容量改变请求中包含虚拟机标识以及更改容量;
根据所述虚拟机标识,确定所述虚拟机的状态为正常运行;
获取所述虚拟机的当前容量以及所述虚拟机所在物理机的规格;
根据所述虚拟机的更改容量、当前容量以及所述物理机的规格,确定所述更改容量的可行性;
当所述更改容量的可行性为是时,将所述虚拟机的容量由所述当前容量设置为所述更改容量。
进一步地,所述虚拟机的更改容量包括所述虚拟机的更改CPU(中央处理单元)容量以及更改内存容量,所述虚拟机的当前容量包括所述虚拟机的当前CPU容量以及当前内存容量;所述处理器601具体用于:
确定所述更改容量与所述当前容量之间的关系是否满足以下条件之一:
所述更改CPU容量大于所述当前CPU容量且所述更改内存容量大于所述当前内存容量;所述更改CPU容量小于所述当前CPU容量且所述更改内存容量小于所述当前内存容量;所述更改CPU容量大于所述当前CPU容量且所述更改内存容量等于所述当前内存容量;所述更改CPU容量小于所述当前CPU容量且所述更改内存容量等于所述当前内存容量;所述更改CPU容量等于所述当前CPU容量且所述更改内存容量大于所述当前内存容量;所述更改CPU容量等于所述当前CPU容量且所述更改内存容量小于所述当前内存容量。
进一步地,所述物理机的规格包括所述物理机的剩余容量;所述处理器601具体用于:
计算所述物理机的剩余容量是否大于或等于所述虚拟机的更改容量与当前容量之间的差值。
进一步地,所述虚拟机容量改变请求为热缩容请求;所述处理器601具体用于:
确定所述虚拟机是否允许热缩容。
进一步地,所述处理器601具体用于:
当所述更改容量的可行性为否时,反馈异常告警,所述异常告警中包含异常内容。
进一步地,所述处理器601具体用于:
调用驱动模块,将所述虚拟机的容量设置为所述更改容量;
在所述驱动模块成功将所述虚拟机的容量设置为所述更改容量的情况下,通过所述驱动模块调用所述物理机的底层软件,将所述虚拟机的容量设置为所述更改容量。
本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
尽管已描述了本发明的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例作出另外的变更和修改。所以,所附权 利要求意欲解释为包括优选实施例以及落入本发明范围的所有变更和修改。
显然,本领域的技术人员可以对本发明进行各种改动和变型而不脱离本发明的精神和范围。这样,倘若本发明的这些修改和变型属于本发明权利要求及其等同技术的范围之内,则本发明也意图包括这些改动和变型在内。

Claims (14)

  1. 一种虚拟机的容量更改方法,其特征在于,包括:
    接收虚拟机容量改变请求,所述虚拟机容量改变请求为热扩容请求或热缩容请求,所述虚拟机容量改变请求中包含虚拟机标识以及更改容量;
    根据所述虚拟机标识,确定所述虚拟机的状态为正常运行;
    获取所述虚拟机的当前容量以及所述虚拟机所在物理机的规格;
    根据所述虚拟机的更改容量、当前容量以及所述物理机的规格,确定所述更改容量的可行性;
    当所述更改容量的可行性为是时,将所述虚拟机的容量由所述当前容量设置为所述更改容量。
  2. 如权利要求1所述的方法,其特征在于,所述虚拟机的更改容量包括所述虚拟机的更改CPU(中央处理单元)容量以及更改内存容量,所述虚拟机的当前容量包括所述虚拟机的当前CPU容量以及当前内存容量;所述根据所述虚拟机的更改容量、当前容量以及所述物理机的规格,确定所述更改容量针对所述物理机的可行性,包括:
    确定所述更改容量与所述当前容量之间的关系是否满足以下条件之一:
    所述更改CPU容量大于所述当前CPU容量且所述更改内存容量大于所述当前内存容量;所述更改CPU容量小于所述当前CPU容量且所述更改内存容量小于所述当前内存容量;所述更改CPU容量大于所述当前CPU容量且所述更改内存容量等于所述当前内存容量;所述更改CPU容量小于所述当前CPU容量且所述更改内存容量等于所述当前内存容量;所述更改CPU容量等于所述当前CPU容量且所述更改内存容量大于所述当前内存容量;所述更改CPU容量等于所述当前CPU容量且所述更改内存容量小于所述当前内存容量。
  3. 如权利要求1所述的方法,其特征在于,所述物理机的规格包括所述物理机的剩余容量;
    所述根据所述虚拟机的更改容量、当前容量以及所述物理机的规格,确 定所述更改容量针对所述物理机的可行性,包括:
    计算所述物理机的剩余容量是否大于或等于所述虚拟机的更改容量与当前容量之间的差值。
  4. 如权利要求1所述的方法,其特征在于,所述虚拟机容量改变请求为热缩容请求;所述确定所述更改容量针对所述物理机的可行性,包括:
    确定所述虚拟机是否允许热缩容。
  5. 如权利要求1至4任一项所述的方法,其特征在于,所述根据所述虚拟机的更改容量、当前容量以及所述物理机的规格,确定所述更改容量针对所述物理机的可行性之后,还包括:
    当所述更改容量的可行性为否时,反馈异常告警,所述异常告警中包含异常内容。
  6. 如权利要求1至4任一项所述的方法,其特征在于,所述将所述虚拟机的容量由所述当前容量设置为所述更改容量,包括:
    调用驱动模块,将所述虚拟机的容量设置为所述更改容量;
    在所述驱动模块成功将所述虚拟机的容量设置为所述更改容量的情况下,通过所述驱动模块调用所述物理机的底层软件,将所述虚拟机的容量设置为所述更改容量。
  7. 一种虚拟机的容量更改装置,其特征在于,包括:
    接收单元,用于接收虚拟机容量改变请求,所述虚拟机容量改变请求为热扩容请求或热缩容请求,所述虚拟机容量改变请求中包含虚拟机标识以及更改容量;
    运行单元,用于根据所述虚拟机标识,确定所述虚拟机的状态为正常运行;
    获取单元,用于获取所述虚拟机的当前容量以及所述虚拟机所在物理机的规格;
    判断单元,用于根据所述虚拟机的更改容量、当前容量以及所述物理机的规格,确定所述更改容量的可行性;
    设置单元,用于当所述更改容量的可行性为是时,将所述虚拟机的容量由所述当前容量设置为所述更改容量。
  8. 如权利要求7所述的装置,其特征在于,所述虚拟机的更改容量包括所述虚拟机的更改CPU(中央处理单元)容量以及更改内存容量,所述虚拟机的当前容量包括所述虚拟机的当前CPU容量以及当前内存容量;所述判断单元,具体用于:
    确定所述更改容量与所述当前容量之间的关系是否满足以下条件之一:
    所述更改CPU容量大于所述当前CPU容量且所述更改内存容量大于所述当前内存容量;所述更改CPU容量小于所述当前CPU容量且所述更改内存容量小于所述当前内存容量;所述更改CPU容量大于所述当前CPU容量且所述更改内存容量等于所述当前内存容量;所述更改CPU容量小于所述当前CPU容量且所述更改内存容量等于所述当前内存容量;所述更改CPU容量等于所述当前CPU容量且所述更改内存容量大于所述当前内存容量;所述更改CPU容量等于所述当前CPU容量且所述更改内存容量小于所述当前内存容量。
  9. 如权利要求7所述的装置,其特征在于,所述物理机的规格包括所述物理机的剩余容量;
    所述判断单元,具体用于:
    计算所述物理机的剩余容量是否大于或等于所述虚拟机的更改容量与当前容量之间的差值。
  10. 如权利要求7所述的装置,其特征在于,所述虚拟机容量改变请求为热缩容请求;所述判断单元,具体用于:
    确定所述虚拟机是否允许热缩容。
  11. 如权利要求7至10任一项所述的装置,其特征在于,还包括告警单元,用于:
    当所述更改容量的可行性为否时,反馈异常告警,所述异常告警中包含异常内容。
  12. 如权利要求7至10任一项所述的装置,其特征在于,所述设置单元, 具体用于:
    调用驱动模块,将所述虚拟机的容量设置为所述更改容量;
    在所述驱动模块成功将所述虚拟机的容量设置为所述更改容量的情况下,通过所述驱动模块调用所述物理机的底层软件,将所述虚拟机的容量设置为所述更改容量。
  13. 一种电子设备,其特征在于,包括:
    至少一个处理器;以及,
    与所述至少一个处理器通信连接的存储器;其中,
    所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行权利要求1-6任一所述的方法。
  14. 一种非暂态计算机可读存储介质,其特征在于,所述非暂态计算机可读存储介质存储计算机指令,所述计算机指令用于使所述计算机执行权利要求1~6任一所述的方法。
PCT/CN2020/137749 2019-12-20 2020-12-18 一种虚拟机的容量更改方法及装置 WO2021121407A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201911327218.7A CN111143031A (zh) 2019-12-20 2019-12-20 一种虚拟机的容量更改方法及装置
CN201911327218.7 2019-12-20

Publications (1)

Publication Number Publication Date
WO2021121407A1 true WO2021121407A1 (zh) 2021-06-24

Family

ID=70519148

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/137749 WO2021121407A1 (zh) 2019-12-20 2020-12-18 一种虚拟机的容量更改方法及装置

Country Status (2)

Country Link
CN (1) CN111143031A (zh)
WO (1) WO2021121407A1 (zh)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111143031A (zh) * 2019-12-20 2020-05-12 中国银联股份有限公司 一种虚拟机的容量更改方法及装置
CN112564957B (zh) * 2020-12-01 2022-05-17 武汉绿色网络信息服务有限责任公司 虚拟网元的运行数据采集方法及装置
CN112433854A (zh) * 2020-12-02 2021-03-02 浪潮软件科技有限公司 一种在线调整OpenStack虚拟机规格的方法
CN113419811A (zh) * 2021-05-20 2021-09-21 曙光信息产业股份有限公司 Cpu添加方法、设备、计算机设备及可读存储介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110276951A1 (en) * 2010-05-05 2011-11-10 Microsoft Corporation Managing runtime execution of applications on cloud computing systems
CN107562520A (zh) * 2017-09-07 2018-01-09 郑州云海信息技术有限公司 扩容虚拟机的内存的方法和装置
CN109753342A (zh) * 2018-11-19 2019-05-14 顺丰科技有限公司 虚拟机在线扩容方法、装置、设备及存储介质
CN111143031A (zh) * 2019-12-20 2020-05-12 中国银联股份有限公司 一种虚拟机的容量更改方法及装置

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102983990A (zh) * 2012-11-07 2013-03-20 曙光云计算技术有限公司 虚拟机的管理方法和装置

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110276951A1 (en) * 2010-05-05 2011-11-10 Microsoft Corporation Managing runtime execution of applications on cloud computing systems
CN107562520A (zh) * 2017-09-07 2018-01-09 郑州云海信息技术有限公司 扩容虚拟机的内存的方法和装置
CN109753342A (zh) * 2018-11-19 2019-05-14 顺丰科技有限公司 虚拟机在线扩容方法、装置、设备及存储介质
CN111143031A (zh) * 2019-12-20 2020-05-12 中国银联股份有限公司 一种虚拟机的容量更改方法及装置

Also Published As

Publication number Publication date
CN111143031A (zh) 2020-05-12

Similar Documents

Publication Publication Date Title
WO2021121407A1 (zh) 一种虚拟机的容量更改方法及装置
US10127057B2 (en) Method and apparatus for dynamically implementing application function
US10796001B2 (en) Software verification method and apparatus
WO2017166446A1 (zh) 漏洞修复方法和装置
US10798218B2 (en) Environment isolation method and device
US20190158626A1 (en) Method, apparatus and computer readable storage medium for processing service
US10404568B2 (en) Agent manager for distributed transaction monitoring system
US20210240491A1 (en) System and method for runtime synchronization and authentication of pre-boot device drivers for a rescue operating system
WO2016202000A1 (zh) 差分回退升级方法及装置
CN109769010B (zh) 基于SDK访问CloudStack服务器的方法、装置、设备及存储介质
CN106576068A (zh) 一种软件安全验证方法、设备及系统
CN110134546B (zh) 批量重启windows系统方法、电子装置及存储介质
CN111563009A (zh) 一种基于双机冗余系统的文件同步方法、系统及存储介质
US20240045733A1 (en) Method and apparatus for deploying deep learning system
CN115454576A (zh) 一种虚拟机进程管理方法、系统及电子设备
WO2018233638A1 (zh) Ai软件系统安全状态的确定方法及装置
US20210357239A1 (en) Methods and systems for managing computing virtual machine instances
WO2020187008A1 (zh) 服务调用控制方法、服务调用方法、装置及终端
CN108063679B (zh) 一种云管理平台的升级方法及装置
CN113541987A (zh) 一种更新配置数据的方法和装置
CN110959151A (zh) 用于长期运行的软件操作的连接器租用
CN116089020B (zh) 虚拟机运行方法、扩容方法、扩容系统
CN113094211B (zh) 一种备份数据处理的方法和装置
CN115129469B (zh) 跨进程通信方法、装置、设备及存储介质
US11509738B2 (en) System for migration of data from legacy computer system using wireless peer-to-peer connection

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20901164

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20901164

Country of ref document: EP

Kind code of ref document: A1