CN108897603A - A kind of memory source management method and device - Google Patents

A kind of memory source management method and device Download PDF

Info

Publication number
CN108897603A
CN108897603A CN201810711039.2A CN201810711039A CN108897603A CN 108897603 A CN108897603 A CN 108897603A CN 201810711039 A CN201810711039 A CN 201810711039A CN 108897603 A CN108897603 A CN 108897603A
Authority
CN
China
Prior art keywords
memory
virtual machine
release
amount
occupancy
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
CN201810711039.2A
Other languages
Chinese (zh)
Other versions
CN108897603B (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

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 kind of memory source management method and devices.It is related to virtual machine technique, solves the problems, such as to cause customer service to be interrupted by restarting releasing memory.This method includes:Obtain the memory usage amount of virtual machine internal;Obtain the physical memory occupancy that virtual machine process occupies;When the memory usage amount and the physical memory occupancy reach preset memory release conditions, memory release is executed.Technical solution provided by the invention is suitable for virtual machine management platform, realizes the automatic memory that executes and discharges.

Description

A kind of memory source management method and device
Technical field
The present invention relates to virtual machine technique, espespecially a kind of memory source management method and device.
Background technique
The linux virtual machine created by Libvirt and Qemu, in the process of running, the memory of occupancy can be with virtual The rising of machine interior business amount and gradually increase, when portfolio decline when, virtual machine internal memory usage can be gradually reduced, but That the memory that corresponding Qemu process occupies on host will not decline, i.e. Qemu committed memory does not discharge, cause on host can Fewer and fewer with memory, resource is more and more nervous.
Usually, the host memory that change client computer occupancy, is first to close client computer, interior when modification starts Configuration is deposited, client computer is then restarted and is just able to achieve.Broken clients service is thus needed, user experience is affected.
Summary of the invention
In order to solve the above-mentioned technical problems, the present invention provides a kind of memory source management method and devices.By real-time Virtual machine internal memory and physical memory service condition are monitored, it is automatic to execute memory release, it solves by restarting releasing memory The problem of causing customer service to be interrupted.
In order to reach the object of the invention, the present invention provides a kind of memory source management methods, including:
Obtain the memory usage amount of virtual machine internal;
Obtain the physical memory occupancy that virtual machine process occupies;
When the memory usage amount and the physical memory occupancy reach preset memory release conditions, memory is executed Release.
Preferably, when the memory usage amount and the physical memory occupancy reach preset memory release conditions, Executing the step of memory discharges includes:
Releasable amount of ram is calculated according to following formula:
Releasable amount of ram=memory usage amount-(memory standards value-physical memory occupancy),
Wherein, the memory standards value is preset virtual machine free memory amount;
Reach preset memory release door in the releasable amount of ram to prescribe a time limit, executes memory release.
Preferably, this method further includes:
The memory standards value is set.
Preferably, this method further includes:
The memory release thresholding is set.
Preferably, before the step of memory usage amount for obtaining virtual machine internal, further include:
The OS Type for obtaining the virtual machine judges that can the operating system of the virtual machine support memory to release It puts.
The present invention also provides a kind of memory source managing devices, including:
Internal memory detection module, for obtaining the memory usage amount of virtual machine internal;
Physical memory detection module, for obtaining the physical memory occupancy of virtual machine process occupancy;
Memory release module is released for reaching preset memory in the memory usage amount and the physical memory occupancy When putting condition, memory release is executed.
Preferably, the memory release module includes:
Releasable memory computing unit, for calculating releasable amount of ram according to following formula:
Releasable amount of ram=memory usage amount-(memory standards value-physical memory occupancy),
Wherein, the memory standards value is preset virtual machine free memory amount;
Execution unit is discharged, is prescribed a time limit for reaching preset memory release door in the releasable amount of ram, memory is executed Release.
Preferably, which further includes:
First configuration module, for the memory standards value to be arranged.
Preferably, which further includes:
Second configuration module, for the memory release thresholding to be arranged.
Preferably, which further includes:
System access module judges the operation system of the virtual machine for obtaining the OS Type of the virtual machine Can system support memory to discharge.
The present invention provides a kind of memory source management method and devices, obtain the memory usage amount of virtual machine internal, obtain The physical memory occupancy for taking virtual machine process to occupy, then reaches in the memory usage amount and the physical memory occupancy When preset memory release conditions, memory release is executed.The memory source adjustment for being not required to restart is realized, is solved by restarting The problem of releasing memory causes customer service to be interrupted.
Other features and advantages of the present invention will be illustrated in the following description, also, partly becomes from specification It obtains it is clear that understand through the implementation of the invention.The objectives and other advantages of the invention can be by specification, right Specifically noted structure is achieved and obtained in claim and attached drawing.
Detailed description of the invention
Attached drawing is used to provide to further understand technical solution of the present invention, and constitutes part of specification, with this The embodiment of application technical solution for explaining the present invention together, does not constitute the limitation to technical solution of the present invention.
Fig. 1 is a kind of flow diagram for memory source management method that one embodiment of the invention provides;
Fig. 2 is the flow diagram for another memory source management method that one embodiment of the invention provides;
Fig. 3 is a kind of structural schematic diagram for memory source managing device that one embodiment of the invention provides.
Specific embodiment
To make the objectives, technical solutions, and advantages of the present invention clearer, below in conjunction with attached drawing to the present invention Embodiment be described in detail.It should be noted that in the absence of conflict, in the embodiment and embodiment in the application Feature can mutual any combination.
Step shown in the flowchart of the accompanying drawings can be in a computer system such as a set of computer executable instructions It executes.Also, although logical order is shown in flow charts, and it in some cases, can be to be different from herein suitable Sequence executes shown or described step.
Usually, the host memory that change client computer occupancy, is first to close client computer, interior when modification starts Configuration is deposited, client computer is then restarted and is just able to achieve.Broken clients service is thus needed, user experience is affected.
To solve the above-mentioned problems, the embodiment provides a kind of memory source management method and devices.First The corresponding virtual machine process of the virtual machine currently physical memory occupancy on host is obtained, is then obtained by virtual machine tools To the memory usage amount of virtual machine internal;Feelings are used according to virtual machine process committed memory size and virtual machine internal real memory Then condition discharges the spare memory that virtual machine process occupies according to calculated result to calculate releasing memory size, reduce in host Deposit resource utilization.
One embodiment of the invention provides a kind of memory source management method, and the stream of memory release is completed using this method Journey is as shown in Figure 1, include:
Step 101 carries out system configuration.
In this step, memory standards value is set, shows available highest memory source amount;It also needs that memory release door is arranged Limit, with for whether start memory discharge operation operation reference standard.
Step 102, the OS Type for obtaining virtual machine, judge that can the operating system of the virtual machine support memory Release.
In this step, VME operating system type is obtained by tools and is then skipped if windows;If Linux then continues to execute following steps.
Step 103, the memory usage amount for obtaining virtual machine internal.
In this step, the memory service condition (passing through tools) of virtual machine internal is obtained.
Step 104 obtains the physical memory occupancy that virtual machine process occupies.
Step 105, when the memory usage amount and the physical memory occupancy reach preset memory release conditions, Execute memory release.
This step specifically includes:
1, releasable amount of ram is calculated according to following formula:
Releasable amount of ram=memory usage amount-(memory standards value-physical memory occupancy),
Wherein, the memory standards value is preset virtual machine free memory amount;
2, reach preset memory release door in the releasable amount of ram to prescribe a time limit, execute memory release.
For example, balloon (Ballooning) technology can be used to realize memory release.It is vacant when host memory use anxiety When memory is few, the partial memory for having distributed to client computer can be recycled with requesting clients, client computer will discharge its sky Not busy memory, if client computer free memory is insufficient at this time, may can also memory in recovery section use, may swap out part It is inside stored in the exchange partition (swap) of client computer, so that memory balloon inflation expands, so that host be allowed to recycle balloon In memory can be used for other processes (or other client computer).Conversely, when low memory in client computer, client computer can also be allowed The compression of memory balloon, release the partial memory in memory balloon, allow client computer using more memories.
One embodiment of the invention additionally provides a kind of memory source management method, using Qemu process as virtual machine process, It is illustrated so that linux system is VME operating system as an example.
Virtual machine is created using qemu in the embodiment of the present invention, calls kvmballoon to virtualize using libvirt Interface is managed virtual machine.In virtual machine operational process, virtual machine internal memory is obtained by tools and uses feelings The memory size that condition and corresponding qemu process occupy on host, to determine whether needing to carry out memory to qemu process Release.
The memory release to qemu process is realized by balloon, is reduced host memory utilization rate, is obviously improved The performance of host, the perfect management and scheduling of host resource, while by tools realize effective monitoring to virtual machine and The balloon mechanism of automation is suitble to carry out extensive automatically dispose in production environment.Since this mode relates only to The modification of scheme optimization and software section facilitates the upgrading and maintenance of later period virtualization product.
Specific implementation process is as follows:Obtaining the corresponding qemu process of virtual machine first, currently committed memory is big on host It is small, the memory service condition of virtual machine internal is then got by virtual machine tools;It is big according to virtual machine process committed memory Small and virtual machine internal real memory service condition, to calculate releasing memory size;According to resulting value is calculated, pass through Balloon discharges the spare memory that qemu process occupies, and reduces host memory resource utilization;Restore the memory of virtual machine configuration Specification value does not influence the service operation of virtual machine.
Realization mainly includes the following steps that:
Step 1:VME operating system type is obtained by tools then to skip if windows;If linux, Then continue to execute following steps
Step 2:Obtain the memory service condition (passing through tools) of virtual machine internal:
a.free–m;
B. the value of available is obtained.
Step 3:Obtain the virtual machine process currently committed memory size on host:
A. according to virtual machine id, qemu process id of the virtual machine on host is obtained;
B. according to the corresponding qemu process id of virtual machine, the physical memory size currently occupied is obtained,
Cat/proc/pid/status//VmRSS is the practical physical memory size occupied of process.
Step 4:According to virtual machine process committed memory size and virtual machine internal real memory service condition, to be arranged Releasing memory size.
A. calculating qemu process can be with increased memory value size:Memory standards value-process committed memory;
B. the size of the releasable memory of qemu process is calculated:Mem_freed=available memory- (memory standards Value-process committed memory).
Step 5:If the mem_freed value calculated is greater than 512M (occurrence can be set), to execute memory release.
Step 6:Restore the memory standards value of virtual machine configuration.
One embodiment of the invention additionally provides a kind of memory source managing device, and structure is as shown in Fig. 2, include:
Internal memory detection module 201, for obtaining the memory usage amount of virtual machine internal;
Physical memory detection module 202, for obtaining the physical memory occupancy of virtual machine process occupancy;
Memory release module 203, within the memory usage amount and the physical memory occupancy reach preset When depositing release conditions, memory release is executed.
Preferably, the structure of the memory release module 203 is as shown in figure 3, include:
Releasable memory computing unit 2031, for calculating releasable amount of ram according to following formula:
Releasable amount of ram=memory usage amount-(memory standards value-physical memory occupancy),
Wherein, the memory standards value is preset virtual machine free memory amount;
Execution unit 2032 is discharged, is prescribed a time limit for reaching preset memory release door in the releasable amount of ram, is executed Memory release.
Preferably, which further includes:
First configuration module 204, for the memory standards value to be arranged.
Preferably, which further includes:
Second configuration module 205, for the memory release thresholding to be arranged.
Preferably, which further includes:
System access module 206 judges the operation of the virtual machine for obtaining the OS Type of the virtual machine Can system support memory to discharge.
The embodiment provides a kind of memory source management method and device, the memory for obtaining virtual machine internal makes Dosage obtains the physical memory occupancy that virtual machine process occupies, then accounts in the memory usage amount with the physical memory When dosage reaches preset memory release conditions, memory release is executed.The memory source adjustment for being not required to restart is realized, is solved By restarting the problem of releasing memory causes customer service to be interrupted.
Virtual machine mainly is created using qemu in the embodiment of the present invention, calls kvmballoon using libvirt Interface is virtualized to be managed to virtual machine, virtual machine qemu process committed memory size is obtained in virtual machine operational process With the currently available memory size of host, the spare memory that qemu process occupies is discharged in real time.The memory of virtual machine can pass through life It is changed when enabling row adjustment balloon, energy monitoring system memory simultaneously verifies the caused variation of balloon, while can save master The a large amount of memory of machine.
This method reduce host memory utilization rate, it is obviously improved the performance of host, the perfect management of host resource With scheduling, while the balloon mechanism of the effective monitoring and automation to virtual machine is realized by tools, is suitble to producing Extensive automatically dispose is carried out in environment.Since this mode relates only to the modification of scheme optimization and software section, side The upgrading and maintenance of phase virtualization product after an action of the bowels.
It will appreciated by the skilled person that whole or certain steps, system, dress in method disclosed hereinabove Functional module/unit in setting may be implemented as software, firmware, hardware and its combination appropriate.In hardware embodiment, Division between the functional module/unit referred in the above description not necessarily corresponds to the division of physical assemblies;For example, one Physical assemblies can have multiple functions or a function or step and can be executed by several physical assemblies cooperations.Certain groups Part or all components may be implemented as by processor, such as the software that digital signal processor or microprocessor execute, or by It is embodied as hardware, or is implemented as integrated circuit, such as specific integrated circuit.Such software can be distributed in computer-readable On medium, computer-readable medium may include computer storage medium (or non-transitory medium) and communication media (or temporarily Property medium).As known to a person of ordinary skill in the art, term computer storage medium is included in for storing information (such as Computer readable instructions, data structure, program module or other data) any method or technique in the volatibility implemented and non- Volatibility, removable and nonremovable medium.Computer storage medium include but is not limited to RAM, ROM, EEPROM, flash memory or its His memory technology, CD-ROM, digital versatile disc (DVD) or other optical disc storages, magnetic holder, tape, disk storage or other Magnetic memory apparatus or any other medium that can be used for storing desired information and can be accessed by a computer.This Outside, known to a person of ordinary skill in the art to be, communication media generally comprises computer readable instructions, data structure, program mould Other data in the modulated data signal of block or such as carrier wave or other transmission mechanisms etc, and may include any information Delivery media.

Claims (10)

1. a kind of memory source management method, which is characterized in that including:
Obtain the memory usage amount of virtual machine internal;
Obtain the physical memory occupancy that virtual machine process occupies;
When the memory usage amount and the physical memory occupancy reach preset memory release conditions, executes memory and release It puts.
2. memory source management method according to claim 1, which is characterized in that in the memory usage amount and the object When reason EMS memory occupation amount reaches preset memory release conditions, executing the step of memory discharges includes:
Releasable amount of ram is calculated according to following formula:
Releasable amount of ram=memory usage amount-(memory standards value-physical memory occupancy),
Wherein, the memory standards value is preset virtual machine free memory amount;
Reach preset memory release door in the releasable amount of ram to prescribe a time limit, executes memory release.
3. memory source management method according to claim 2, which is characterized in that this method further includes:
The memory standards value is set.
4. memory source management method according to claim 2, which is characterized in that this method further includes:
The memory release thresholding is set.
5. memory source management method according to claim 1, which is characterized in that the memory for obtaining virtual machine internal Before the step of usage amount, further include:
The OS Type for obtaining the virtual machine judges that can the operating system of the virtual machine support memory to discharge.
6. a kind of memory source managing device, which is characterized in that including:
Internal memory detection module, for obtaining the memory usage amount of virtual machine internal;
Physical memory detection module, for obtaining the physical memory occupancy of virtual machine process occupancy;
Memory release module, for reaching preset memory released strip in the memory usage amount and the physical memory occupancy When part, memory release is executed.
7. memory source managing device according to claim 6, which is characterized in that the memory release module includes:
Releasable memory computing unit, for calculating releasable amount of ram according to following formula:
Releasable amount of ram=memory usage amount-(memory standards value-physical memory occupancy),
Wherein, the memory standards value is preset virtual machine free memory amount;
Execution unit is discharged, is prescribed a time limit for reaching preset memory release door in the releasable amount of ram, memory release is executed.
8. memory source managing device according to claim 7, which is characterized in that the device further includes:
First configuration module, for the memory standards value to be arranged.
9. memory source managing device according to claim 7, which is characterized in that the device further includes:
Second configuration module, for the memory release thresholding to be arranged.
10. memory source managing device according to claim 6, which is characterized in that the device further includes:
System access module judges the operating system energy of the virtual machine for obtaining the OS Type of the virtual machine No 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 true CN108897603A (en) 2018-11-27
CN108897603B 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)

Cited By (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
ZTSINGHUA: "使用virtio_balloon(KVM)中的Ballooning", 《CSDN》 *

Cited By (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

Also Published As

Publication number Publication date
CN108897603B (en) 2021-10-01

Similar Documents

Publication Publication Date Title
CN107026802B (en) Resource management method and equipment
CN110888743B (en) GPU resource using method, device and storage medium
CN108897603A (en) A kind of memory source management method and device
CN110941481A (en) Resource scheduling method, device and system
EP2775399A1 (en) Resource management method of virtual machine system, virtual machine system, and apparatus
WO2022105440A1 (en) Hybrid quantum-classical cloud platform and task execution method
CN110609749B (en) Distributed task operation method, system and equipment
CN110413412A (en) A kind of method and apparatus based on GPU cluster resource allocation
CN112486642B (en) Resource scheduling method, device, electronic equipment and computer readable storage medium
CN109324893B (en) Method and device for allocating memory
CN110162396A (en) Method for recovering internal storage, device, system and storage medium
CN111343219A (en) Computing service cloud platform
CN113032102A (en) Resource rescheduling method, device, equipment and medium
CN110580195B (en) Memory allocation method and device based on memory hot plug
CN109992415B (en) Container dispatching method and dispatching system
CN115794306A (en) Resource allocation method and device based on preemption instance, electronic equipment and medium
CN110427245A (en) Manage virtual machine method and apparatus
CN109995571B (en) Method and device for matching server configuration and VNF application
CN115277398A (en) Cluster network configuration method and device
CN115904616A (en) Virtual machine live migration method, device, equipment and medium
CN115564635A (en) GPU resource scheduling method and device, electronic equipment and storage medium
CN108958889A (en) The management method and device of virtual machine in cloud data system
CN113254143B (en) Virtualized network function network element arrangement scheduling method, device and system
CN116795520A (en) Resource scheduling method, device, electronic equipment and storage medium
CN108334401B (en) System and method for realizing logic roll dynamic distribution and supporting virtual machine dynamic migration

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