CN108897603B - Memory resource management method and device - Google Patents

Memory resource management method and device Download PDF

Info

Publication number
CN108897603B
CN108897603B CN201810711039.2A CN201810711039A CN108897603B CN 108897603 B CN108897603 B CN 108897603B CN 201810711039 A CN201810711039 A CN 201810711039A CN 108897603 B CN108897603 B CN 108897603B
Authority
CN
China
Prior art keywords
memory
virtual machine
release
amount
resource management
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.)
Active
Application number
CN201810711039.2A
Other languages
Chinese (zh)
Other versions
CN108897603A (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.)
Zhengzhou Yunhai Information Technology Co Ltd
Original Assignee
Zhengzhou Yunhai Information Technology 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 Zhengzhou Yunhai Information Technology Co Ltd filed Critical Zhengzhou Yunhai Information Technology Co Ltd
Priority to CN201810711039.2A priority Critical patent/CN108897603B/en
Publication of CN108897603A publication Critical patent/CN108897603A/en
Application granted granted Critical
Publication of CN108897603B publication Critical patent/CN108897603B/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/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/45583Memory management, e.g. access or allocation

Abstract

The invention discloses a memory resource management method and device. The method relates to a virtual machine technology, and solves the problem of interruption of client service caused by restarting and releasing the memory. The method comprises the following steps: obtaining the memory usage amount inside the virtual machine; acquiring the occupied physical memory of the virtual machine process; and executing memory release when the memory usage and the physical memory occupation reach preset memory release conditions. The technical scheme provided by the invention is suitable for the virtual machine management platform, and realizes automatic execution of memory release.

Description

Memory resource management method and device
Technical Field
The present invention relates to virtual machine technologies, and in particular, to a method and an apparatus for managing memory resources.
Background
Through the linux virtual machine created by Libvirt and Qemu, in the running process, the occupied memory can be gradually increased along with the increase of the internal service volume of the virtual machine, when the service volume is reduced, the internal memory utilization rate of the virtual machine can be gradually reduced, but the memory occupied by the corresponding Qemu process on the host cannot be reduced, namely the memory occupied by the Qemu is not released, so that the available memory on the host is less and less, and the resources are more and less tense.
Generally, changing the host memory occupied by a client is implemented by first shutting down the client, modifying the memory configuration at startup, and then restarting the client. This requires interruption of customer service, which affects the user experience.
Disclosure of Invention
In order to solve the technical problem, the invention provides a memory resource management method and device. The internal memory and the physical memory use condition of the virtual machine are monitored in real time, the memory release is automatically executed, and the problem of client service interruption caused by the memory release through restarting is solved.
In order to achieve the object of the present invention, the present invention provides a memory resource management method, including:
obtaining the memory usage amount inside the virtual machine;
acquiring the occupied physical memory of the virtual machine process;
and executing memory release when the memory usage and the physical memory occupation reach preset memory release conditions.
Preferably, when the memory usage amount and the physical memory occupation amount reach a preset memory release condition, the step of executing memory release includes:
calculating the amount of releasable memory according to the following expression:
the releasable memory amount is the memory usage amount- (memory specification value-physical memory occupied amount),
the memory specification value is a preset amount of memory available for the virtual machine;
and executing memory release when the releasable memory amount reaches a preset memory release threshold.
Preferably, the method further comprises:
and setting the memory specification value.
Preferably, the method further comprises:
and setting the memory release threshold.
Preferably, before the step of obtaining the memory usage amount inside the virtual machine, the method further includes:
and obtaining the type of the operating system of the virtual machine, and judging whether the operating system of the virtual machine can support memory release.
The invention also provides a memory resource management device, which comprises:
the internal memory detection module is used for acquiring the memory usage amount inside the virtual machine;
the physical memory detection module is used for acquiring the occupied physical memory occupied by the virtual machine process;
and the memory release module is used for executing memory release when the memory usage and the physical memory occupation reach preset memory release conditions.
Preferably, the memory releasing module includes:
a releasable memory calculating unit, configured to calculate a releasable memory amount according to the following expression:
the releasable memory amount is the memory usage amount- (memory specification value-physical memory occupied amount),
the memory specification value is a preset amount of memory available for the virtual machine;
and the release execution unit is used for executing the memory release when the releasable memory amount reaches a preset memory release threshold.
Preferably, the apparatus further comprises:
and the first configuration module is used for setting the memory specification value.
Preferably, the apparatus further comprises:
and the second configuration module is used for setting the memory release threshold.
Preferably, the apparatus further comprises:
and the system access module is used for acquiring the type of the operating system of the virtual machine and judging whether the operating system of the virtual machine can support memory release.
The invention provides a memory resource management method and a memory resource management device, which are used for acquiring the memory usage amount in a virtual machine, acquiring the physical memory occupation amount occupied by the progress of the virtual machine, and then executing memory release when the memory usage amount and the physical memory occupation amount reach preset memory release conditions. The method realizes the memory resource adjustment without restarting and solves the problem of interruption of client service caused by the memory release through restarting.
Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. The objectives and other advantages of the invention will be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.
Drawings
The accompanying drawings are included to provide a further understanding of the invention and are incorporated in and constitute a part of this specification, illustrate embodiments of the invention and together with the example serve to explain the principles of the invention and not to limit the invention.
Fig. 1 is a flowchart illustrating a memory resource management method according to an embodiment of the present invention;
fig. 2 is a flowchart illustrating another memory resource management method according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of a memory resource management device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, embodiments of the present invention will be described in detail below with reference to the accompanying drawings. It should be noted that the embodiments and features of the embodiments in the present application may be arbitrarily combined with each other without conflict.
The steps illustrated in the flow charts of the figures may be performed in a computer system such as a set of computer-executable instructions. Also, while a logical order is shown in the flow diagrams, in some cases, the steps shown or described may be performed in an order different than here.
Generally, changing the host memory occupied by a client is implemented by first shutting down the client, modifying the memory configuration at startup, and then restarting the client. This requires interruption of customer service, which affects the user experience.
In order to solve the above problem, embodiments of the present invention provide a memory resource management method and apparatus. Firstly, acquiring the current physical memory occupation amount of a virtual machine process corresponding to a virtual machine on a host, and then acquiring the memory usage amount in the virtual machine through virtual machine tools; the size of the released memory is calculated according to the size of the memory occupied by the virtual machine process and the use condition of the real memory inside the virtual machine, and then the redundant memory occupied by the virtual machine process is released according to the calculation result, so that the utilization rate of the memory resources of the host is reduced.
An embodiment of the present invention provides a method for managing memory resources, where a process of completing memory release by using the method is shown in fig. 1, and the method includes:
and step 101, carrying out system configuration.
In this step, a memory specification value is set to indicate the highest available memory resource amount; a memory release threshold needs to be set to refer to a standard for whether to initiate a memory release operation.
Step 102, obtaining the operating system type of the virtual machine, and judging whether the operating system of the virtual machine can support memory release.
In the step, the type of the virtual machine operating system is obtained through tools, and if the type of the virtual machine operating system is windows, the type of the virtual machine operating system is skipped; if the result is linux, the following steps are continuously executed.
And 103, acquiring the memory usage amount inside the virtual machine.
In this step, the memory usage (via tools) inside the virtual machine is obtained.
And step 104, acquiring the occupied physical memory of the virtual machine process.
And 105, executing memory release when the memory usage amount and the physical memory occupation amount reach preset memory release conditions.
The method specifically comprises the following steps:
1. calculating the amount of releasable memory according to the following expression:
the releasable memory amount is the memory usage amount- (memory specification value-physical memory occupied amount),
the memory specification value is a preset amount of memory available for the virtual machine;
2. and executing memory release when the releasable memory amount reaches a preset memory release threshold.
For example, memory release may be achieved using balloon (balloon) technology. When the use of the memory of the host computer is tense and the spare memory is not enough, the client computer can be requested to recycle part of the memory allocated to the client computer, the client computer can release the spare memory of the client computer, at the moment, if the spare memory of the client computer is not enough, part of the memory in use can be recycled, and part of the memory can be exchanged into a swap partition (swap) of the client computer, so that the memory balloon is inflated, and the memory in the memory recycle balloon of the host computer can be used for other processes (or other client computers). Conversely, when the memory in the client is insufficient, the memory balloon of the client can be compressed to release part of the memory in the memory balloon, so that the client uses more memory.
An embodiment of the present invention further provides a memory resource management method, which is described by taking a Qemu process as a virtual machine process and a Linux system as a virtual machine operating system as an example.
In the embodiment of the invention, qemu is used for creating the virtual machine, and libvirt is used for calling a kvmballoon virtualization interface to manage the virtual machine. In the running process of the virtual machine, the using condition of an internal memory of the virtual machine and the size of the memory occupied by the corresponding qemu process on the host are obtained through tools, so that whether the memory release of the qemu process is needed or not is judged.
The memory release of the qemu process is realized through the balloon, the memory utilization rate of the host is reduced, the performance of the host is obviously improved, the management and the scheduling of host resources are perfected, meanwhile, the balloon mechanism for effectively monitoring and automating the virtual machine is realized through the tools, and the balloon is suitable for large-scale automatic deployment in a production environment. Because the mode only relates to scheme optimization and modification of the software part, the upgrading and maintenance of the later-stage virtualization product are facilitated.
The specific implementation process is as follows: firstly, acquiring the memory size occupied by a qemu process corresponding to a virtual machine on a host at present, and then acquiring the memory use condition inside the virtual machine through virtual machine tools; calculating the size of the released memory according to the size of the memory occupied by the virtual machine process and the use condition of the real memory inside the virtual machine; according to the calculated value, the surplus memory occupied by the qemu process is released through balloon, and the utilization rate of the memory resources of the host is reduced; and the memory specification value configured by the virtual machine is recovered, and the service operation of the virtual machine is not influenced.
The realization mainly comprises the following steps:
the method comprises the following steps: obtaining the type of the virtual machine operating system through tools, and if the type is windows, skipping; if the result is linux, the following steps are continuously executed
Step two: obtaining the memory use condition (through tools) inside the virtual machine:
a.free–m;
b. the value of available is obtained.
Step three: acquiring the current memory occupied by the virtual machine process on the host:
a. acquiring a qemu process id of the virtual machine on the host according to the virtual machine id;
b. acquiring the size of the physical memory occupied currently according to the qemu process id corresponding to the virtual machine,
cat/proc/pid/status// VmRSS is the physical memory size actually occupied by the process.
Step four: and setting the size of the released memory according to the size of the memory occupied by the virtual machine process and the use condition of the real memory inside the virtual machine.
a. Calculating the size of a memory value which can be increased by the qemu process, wherein the memory specification value is that the process occupies a memory;
b. calculating the size of the memory releasable by the qemu process: an available memory (memory specification value-process memory).
Step five: and if the calculated mem _ free value is larger than 512M (the specific value can be set), executing memory release.
Step six: and restoring the memory specification value configured by the virtual machine.
An embodiment of the present invention further provides a memory resource management device, whose structure is shown in fig. 2, including:
an internal memory detection module 201, configured to obtain a memory usage amount inside a virtual machine;
the physical memory detection module 202 is configured to obtain an occupied amount of a physical memory occupied by a virtual machine process;
the memory release module 203 is configured to execute memory release when the memory usage amount and the physical memory occupancy amount reach a preset memory release condition.
Preferably, the structure of the memory releasing module 203 is shown in fig. 3, and includes:
a releasable memory calculating unit 2031 configured to calculate a releasable memory amount according to the following expression:
the releasable memory amount is the memory usage amount- (memory specification value-physical memory occupied amount),
the memory specification value is a preset amount of memory available for the virtual machine;
a release execution unit 2032, configured to execute memory release when the amount of the releasable memory reaches a preset memory release threshold.
Preferably, the apparatus further comprises:
a first configuration module 204, configured to set the memory specification value.
Preferably, the apparatus further comprises:
a second configuration module 205, configured to set the memory release threshold.
Preferably, the apparatus further comprises:
the system access module 206 is configured to obtain an operating system type of the virtual machine, and determine whether the operating system of the virtual machine can support memory release.
The embodiment of the invention provides a memory resource management method and a memory resource management device, which are used for acquiring the memory usage amount in a virtual machine, acquiring the physical memory occupation amount occupied by the progress of the virtual machine, and then executing memory release when the memory usage amount and the physical memory occupation amount reach preset memory release conditions. The method realizes the memory resource adjustment without restarting and solves the problem of interruption of client service caused by the memory release through restarting.
In the embodiment of the invention, qemu is mainly used for creating the virtual machine, libvirt is used for calling a kvmballoon virtualization interface to manage the virtual machine, the size of the memory occupied by the qemu process of the virtual machine and the size of the current available memory of the host are obtained in the running process of the virtual machine, and the redundant memory occupied by the qemu process is released in real time. The memory of the virtual machine can be changed when the balloon is adjusted through the command line, the system memory can be monitored, the change caused by the balloon can be verified, and meanwhile, a large amount of memory of the host can be saved.
The method reduces the utilization rate of the host memory, remarkably improves the performance of the host, perfects the management and scheduling of host resources, realizes effective monitoring and automatic balloon mechanism of the virtual machine through tools, and is suitable for large-scale automatic deployment in a production environment. Because the mode only relates to scheme optimization and modification of the software part, the upgrading and maintenance of the later-stage virtualization product are facilitated.
It will be understood by those of ordinary skill in the art that all or some of the steps of the methods, systems, functional modules/units in the devices disclosed above may be implemented as software, firmware, hardware, and suitable combinations thereof. In a hardware implementation, the division between functional modules/units mentioned in the above description does not necessarily correspond to the division of physical components; for example, one physical component may have multiple functions, or one function or step may be performed by several physical components in cooperation. Some or all of the components may be implemented as software executed by a processor, such as a digital signal processor or microprocessor, or as hardware, or as an integrated circuit, such as an application specific integrated circuit. Such software may be distributed on computer readable media, which may include computer storage media (or non-transitory media) and communication media (or transitory media). The term computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data, as is well known to those of ordinary skill in the art. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, Digital Versatile Disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to store the desired information and which can accessed by a computer. In addition, communication media typically embodies computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism and includes any information delivery media as known to those skilled in the art.

Claims (8)

1. A memory resource management method is characterized by comprising the following steps:
obtaining the memory usage amount inside the virtual machine;
acquiring the occupied physical memory of the virtual machine process;
when the memory usage amount and the physical memory occupation amount reach preset memory release conditions, executing memory release;
when the memory usage amount and the physical memory occupation amount reach preset memory release conditions, the step of executing memory release comprises the following steps:
calculating the amount of releasable memory according to the following expression:
the releasable memory amount is the memory usage amount- (memory specification value-physical memory occupied amount),
the memory specification value is a preset amount of memory available for the virtual machine;
and executing memory release when the releasable memory amount reaches a preset memory release threshold.
2. The memory resource management method of claim 1, further comprising:
and setting the memory specification value.
3. The memory resource management method of claim 1, further comprising:
and setting the memory release threshold.
4. The memory resource management method according to claim 1, wherein before the step of obtaining the memory usage amount inside the virtual machine, the method further comprises:
and obtaining the type of the operating system of the virtual machine, and judging whether the operating system of the virtual machine can support memory release.
5. A memory resource management device, comprising:
the internal memory detection module is used for acquiring the memory usage amount inside the virtual machine;
the physical memory detection module is used for acquiring the occupied physical memory occupied by the virtual machine process;
the memory release module is used for executing memory release when the memory usage and the physical memory occupancy reach preset memory release conditions;
wherein, the memory release module comprises:
a releasable memory calculating unit, configured to calculate a releasable memory amount according to the following expression:
the releasable memory amount is the memory usage amount- (memory specification value-physical memory occupied amount),
the memory specification value is a preset amount of memory available for the virtual machine;
and the release execution unit is used for executing the memory release when the releasable memory amount reaches a preset memory release threshold.
6. The memory resource management device according to claim 5, further comprising:
and the first configuration module is used for setting the memory specification value.
7. The memory resource management device according to claim 5, further comprising:
and the second configuration module is used for setting the memory release threshold.
8. The memory resource management device according to claim 5, further comprising:
and the system access module is used for acquiring the type of the operating system of the virtual machine and judging whether the operating system of the virtual machine can support memory release.
CN201810711039.2A 2018-07-03 2018-07-03 Memory resource management method and device Active CN108897603B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810711039.2A CN108897603B (en) 2018-07-03 2018-07-03 Memory resource management method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810711039.2A CN108897603B (en) 2018-07-03 2018-07-03 Memory resource management method and device

Publications (2)

Publication Number Publication Date
CN108897603A CN108897603A (en) 2018-11-27
CN108897603B true CN108897603B (en) 2021-10-01

Family

ID=64347145

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810711039.2A Active CN108897603B (en) 2018-07-03 2018-07-03 Memory resource management method and device

Country Status (1)

Country Link
CN (1) CN108897603B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110275760A (en) * 2019-06-27 2019-09-24 深圳市网心科技有限公司 Process based on fictitious host computer processor hangs up method and its relevant device
CN110955518A (en) * 2019-10-31 2020-04-03 北京浪潮数据技术有限公司 Pressure load adjusting method of distributed storage management system
CN117075925A (en) * 2023-08-16 2023-11-17 中科驭数(北京)科技有限公司 Libvirt control surface unloading method, device, equipment and medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102193814A (en) * 2010-03-09 2011-09-21 上海拜翰网络科技有限公司 Method and system for dynamically distributing embedded virtual memory
CN102446115A (en) * 2012-01-09 2012-05-09 浙江大学 Dynamic deployment method for virtual machines
CN106407000A (en) * 2015-08-10 2017-02-15 联想移动通信科技有限公司 Terminal memory optimization method, apparatus and system
CN106502880A (en) * 2016-09-20 2017-03-15 东软集团股份有限公司 A kind of memory overflow adjustment method and device
CN107153618A (en) * 2016-03-02 2017-09-12 阿里巴巴集团控股有限公司 A kind of processing method and processing device of Memory Allocation
CN107943596A (en) * 2016-10-12 2018-04-20 阿里巴巴集团控股有限公司 Way of Process Communication, apparatus and system

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102193814A (en) * 2010-03-09 2011-09-21 上海拜翰网络科技有限公司 Method and system for dynamically distributing embedded virtual memory
CN102446115A (en) * 2012-01-09 2012-05-09 浙江大学 Dynamic deployment method for virtual machines
CN106407000A (en) * 2015-08-10 2017-02-15 联想移动通信科技有限公司 Terminal memory optimization method, apparatus and system
CN107153618A (en) * 2016-03-02 2017-09-12 阿里巴巴集团控股有限公司 A kind of processing method and processing device of Memory Allocation
CN106502880A (en) * 2016-09-20 2017-03-15 东软集团股份有限公司 A kind of memory overflow adjustment method and device
CN107943596A (en) * 2016-10-12 2018-04-20 阿里巴巴集团控股有限公司 Way of Process Communication, apparatus and system

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
使用virtio_balloon(KVM)中的Ballooning;ztsinghua;《CSDN》;20151112;第1-3部分 *

Also Published As

Publication number Publication date
CN108897603A (en) 2018-11-27

Similar Documents

Publication Publication Date Title
US8365009B2 (en) Controlled automatic healing of data-center services
CN108897603B (en) Memory resource management method and device
CN105049268A (en) Distributed computing resource allocation system and task processing method
CN110389843B (en) Service scheduling method, device, equipment and readable storage medium
WO2015132753A1 (en) Method for memory management in virtual machines, and corresponding system and computer program product
US11831410B2 (en) Intelligent serverless function scaling
CN110609749B (en) Distributed task operation method, system and equipment
CN103399781A (en) Cloud server and virtual machine management method thereof
CN110580195B (en) Memory allocation method and device based on memory hot plug
CN104753992A (en) Method, device and system for data storage and method and device for virtual platform failure recovery
US20210377370A1 (en) Method for implementing high availability of bare metal node based on openstack and electronic device using the same
CN112527450B (en) Super-fusion self-adaptive method, terminal and system based on different resources
CN113961353A (en) Task processing method and distributed system for AI task
US20220206836A1 (en) Method and Apparatus for Processing Virtual Machine Migration, Method and Apparatus for Generating Virtual Machine Migration Strategy, Device and Storage Medium
CN108958889A (en) The management method and device of virtual machine in cloud data system
CN115277398A (en) Cluster network configuration method and device
US20210173698A1 (en) Hosting virtual machines on a secondary storage system
CN115774614A (en) Resource regulation and control method, terminal and storage medium
CN109324871B (en) Virtual machine hardware configuration method and system
CN103562852B (en) A kind of method and apparatus for ensureing cloud application procedure service quality
CN110287066A (en) A kind of server partition moving method and relevant apparatus
CN110781115B (en) Modification method and device for field replaceable unit and storage medium
CN115794306A (en) Resource allocation method and device based on preemption instance, electronic equipment and medium
CN114647488A (en) Task training method, device, equipment and storage medium
CN116841789A (en) Memory fault processing method, device, equipment and 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
GR01 Patent grant