A kind of monitoring method of virtual machine, device, equipment and mediumTechnical field
The present invention relates to computer communication fields, more particularly to a kind of monitoring method of virtual machine, device, equipment and JieMatter.
Background technique
Cloud computing has been increasingly becoming the data processing means universal in one of big data era, a mature cloud meterThe bottom of service is calculated, often by hundreds of physical server and huge Cloud Server group as support, and eachOften operation has a certain number of virtual machines to carry out data processing all in the form of cluster in physical server, therefore in cloud meterIt calculates under service, generated communication flows is very large between virtual machine.
In order to guarantee the safe and reliable of cloud computing, it usually needs carry out phase to the operating status of virtual machine in physical serverThe monitoring answered.Currently employed method is usually the monitoring for being directed to physical server operating status, for the money of virtualizationSource monitoring mainly utilizes the monitoring software being used on physical server in the past there is no a mature solution is formedAdaptability configuration is carried out on a virtual machine, but is required to arrange monitoring agent on monitored virtual machine, such as make instantlyWith very extensive nagios monitoring system, can complete to the Host Status and interchanger of the systems such as windows, linux, roadBy the monitoring of the network configurations such as device, but operation is required in each monitored object corresponding client-side program, is monitoredObject needs to install nsclient++ client-side program when being windows system, then needs to install nagios when being Linux systemNrpe plug-in unit, therefore using virtual machine as when monitored object, needing to configure corresponding program or plug-in unit in virtual machine, undoubtedlyThe load of virtual machine will be increased, reduces the service quality of virtual machine.
It can be seen that providing a kind of monitoring method of virtual machine, with the load of opposite mitigation virtual machine, and then guarantee virtualThe service quality of machine is those skilled in the art's urgent problem to be solved.
Summary of the invention
The object of the present invention is to provide a kind of monitoring method of virtual machine, device, equipment and media, virtual with opposite mitigationThe load of machine, and then guarantee the service quality of virtual machine.
In order to solve the above technical problems, the present invention provides a kind of monitoring method of virtual machine characterized by comprising
Libvirt tool is disposed in physical server;Wherein, operation has cluster virtual machine in physical server;
The corresponding virtual machine manager of cluster virtual machine is set in the virConnect interface that Libvirt tool providesLocation, to establish the correspondence of Libvirt tool and cluster virtual machine;
The target virtual machine in cluster virtual machine is chosen, and is called the characteristic information of target virtual machine as parameterThe monitoring resource interface that Libvirt tool provides, to obtain the running state information of target virtual machine.
Preferably, the corresponding virtual machine of setting cluster virtual machine in the virConnect interface that Libvirt tool providesManager address, after establishing the correspondence of Libvirt tool and cluster virtual machine, this method further comprises:
SFlow agreement is run under correspondence using Libvirt tool, to obtain the network state letter of cluster virtual machineBreath.
Preferably, this method further comprises:
Running state information and network state information are recorded with JSON format to Redis database respectively.
Preferably, monitoring resource interface includes virNetwork interface, virDomain interface and virStorageVolInterface.
Preferably, cluster virtual machine is specially the cluster virtual machine set up based on SDN network.
In addition, the present invention also provides a kind of monitoring devices of virtual machine, comprising:
Tool deployment module, for disposing Libvirt tool in physical server;Wherein there is operation in physical serverCluster virtual machine;
Communication building block, for cluster virtual machine pair to be arranged in the virConnect interface that Libvirt tool providesThe virtual machine manager address answered, to establish the correspondence of Libvirt tool and cluster virtual machine;
Operating status obtains module, for choosing the target virtual machine in cluster virtual machine, and by the spy of target virtual machineThe monitoring resource interface that reference breath calls Libvirt tool to provide as parameter, to obtain the operating status letter of target virtual machineBreath.
Preferably, which further comprises:
Network state obtains module, for running sFlow agreement under correspondence using Libvirt tool, to obtainThe network state information of cluster virtual machine.
In addition, the present invention also provides a kind of monitoring devices of virtual machine, comprising:
Memory, for storing computer program;
Processor, when for executing computer program the step of the realization such as monitoring method of above-mentioned virtual machine.
In addition, being stored with meter on computer readable storage medium the present invention also provides a kind of computer readable storage mediumCalculation machine program, when computer program is executed by processor the step of the realization such as monitoring method of above-mentioned virtual machine.
The monitoring method of virtual machine provided by the present invention, in advance in the middle part of the physical server that operation has cluster virtual machineLibvirt tool is affixed one's name to, and then right by the way that cluster virtual machine institute is arranged in the virConnect interface that Libvirt tool providesCorrespondence between Libvirt tool and cluster virtual machine is established with this in the address for the virtual machine manager answered, and then virtualThe target virtual machine for needing to monitor is chosen in machine cluster, and using the characteristic information of the target virtual machine as input parameter to callThe monitoring resource interface of Libvirt tool, the final acquisition realized to the running state information of target virtual machine.This method passes throughLibvirt tool is disposed in physical server, and then on the basis for establishing Libvirt tool Yu cluster virtual machine correspondenceOn, the monitoring to virtual machine in cluster virtual machine can be realized by the monitoring resource interface for calling Libvirt tool to provide, byIn being not necessarily to arrangement monitoring agent program or plug-in unit on monitored virtual machine, therefore the opposite load for mitigating virtual machine, in turnIt ensure that the service quality of virtual machine.In addition, the present invention also provides a kind of monitoring device of virtual machine, equipment and medium, it is beneficialEffect is same as above.
Detailed description of the invention
In order to illustrate the embodiments of the present invention more clearly, attached drawing needed in the embodiment will be done simply belowIt introduces, it should be apparent that, drawings in the following description are only some embodiments of the invention, for ordinary skill peopleFor member, without creative efforts, it is also possible to obtain other drawings based on these drawings.
Fig. 1 is a kind of flow chart of the monitoring method of virtual machine provided in an embodiment of the present invention;
Fig. 2 is the flow chart of the monitoring method of another virtual machine provided in an embodiment of the present invention;
Fig. 3 is a kind of structure chart of the monitoring device of virtual machine provided in an embodiment of the present invention.
Specific embodiment
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention carries out clear, completeSite preparation description, it is clear that described embodiments are only a part of the embodiments of the present invention, rather than whole embodiments.Based on thisEmbodiment in invention, those of ordinary skill in the art are without making creative work, obtained every otherEmbodiment belongs to the scope of the present invention.
Core of the invention is to provide a kind of monitoring method of virtual machine, with the load of opposite mitigation virtual machine, Jin ErbaoDemonstrate,prove the service quality of virtual machine.Another core of the invention is to provide monitoring device, equipment and the medium of a kind of virtual machine.
In order to enable those skilled in the art to better understand the solution of the present invention, with reference to the accompanying drawings and detailed descriptionThe present invention is described in further detail.
Embodiment one
Fig. 1 is a kind of flow chart of the monitoring method of virtual machine provided in an embodiment of the present invention.Referring to FIG. 1, virtual machineThe specific steps of monitoring method include:
Step S10: Libvirt tool is disposed in physical server.
Wherein, operation has cluster virtual machine in physical server.
It should be noted that the physical server in this step is to run and carry the property server of virtual machine to setIt is standby, in addition, Libvirt tool provides the mode of relatively convenient management virtual machine and the software with virtualization.In Libvirt tool include an API library, a finger daemon (Libvirtd) and a command line utility (virsh),Wherein, multiple monitoring resource interfaces are stored in API library, for the operation shape according to different needs to virtual machine different aspectState is monitored accordingly.Since Libvirt tool is the monitoring realized by way of calling interface to virtual machine, and connectMouth itself has the characteristics that coupling is lower, therefore will not be to physical server own resources when using Libvirt toolExcessive occupancy is caused, and then the available resources in physical server can more distribute to the Virtual Service run thereonDevice, this has also further ensured that the service quality of virtual machine.
Step S11: the corresponding virtual machine of setting cluster virtual machine in the virConnect interface that Libvirt tool providesManager address, to establish the correspondence of Libvirt tool and cluster virtual machine.
It should be noted that could be managed virtual machine manager after only establishing connection with virtual machine managerVirtual machine be monitored operation, so the virConnect interface of connecting virtual machine manager is that other all monitoring resources connectThe precondition that mouth can be used normally.In addition, including a series of relevant to connection is established in virConnect interfaceFunction passes through since the calling to virConnect interface is content well-known to those skilled in the artVirConnect interface is established the function that correspondence specifically uses between Libvirt tool and cluster virtual machine and is not done hereinIt repeats.
Step S12: the target virtual machine in cluster virtual machine is chosen, and using the characteristic information of target virtual machine as parameterThe monitoring resource interface for calling Libvirt tool to provide, to obtain the running state information of target virtual machine.
Monitoring resource interface in Libvirt tool generally can be divided into five parts, i.e. virtual machine monitor connectsAPI, domain API, network AP I, storage volume API and storage pool API.Characteristic information in this step is can uniquely to correspond to characterizationThe mark of target virtual machine needs to provide it the characteristic information of target virtual machine, feature letter when using monitoring resource interfaceThe type of breath may include the path of target virtual machine, ID etc., and user can set the specific of characteristic information according to actual needsType, but it is necessary to ensure that monitoring resource interface can find target virtual machine that is unique and determining according to characteristic information, and then rightTarget virtual machine carries out the acquisition of running state information, and as monitored results.
The monitoring method of virtual machine provided by the present invention, in advance in the middle part of the physical server that operation has cluster virtual machineLibvirt tool is affixed one's name to, and then right by the way that cluster virtual machine institute is arranged in the virConnect interface that Libvirt tool providesCorrespondence between Libvirt tool and cluster virtual machine is established with this in the address for the virtual machine manager answered, and then virtualThe target virtual machine for needing to monitor is chosen in machine cluster, and using the characteristic information of the target virtual machine as input parameter to callThe monitoring resource interface of Libvirt tool, the final acquisition realized to the running state information of target virtual machine.This method passes throughLibvirt tool is disposed in physical server, and then on the basis for establishing Libvirt tool Yu cluster virtual machine correspondenceOn, the monitoring to virtual machine in cluster virtual machine can be realized by the monitoring resource interface for calling Libvirt tool to provide, byIn being not necessarily to arrangement monitoring agent program or plug-in unit on monitored virtual machine, therefore the opposite load for mitigating virtual machine, in turnIt ensure that the service quality of virtual machine.
Embodiment two
On the basis of the above embodiments, the present invention also provides a series of preferred embodiments.
Fig. 2 is the flow chart of the monitoring method of another virtual machine provided in an embodiment of the present invention.Step S10- in Fig. 2S12 is identical as Fig. 1, and details are not described herein.
As shown in Fig. 2, as a preferred embodiment, in the virConnect interface that Libvirt tool providesThe corresponding virtual machine manager address of cluster virtual machine is set, to establish the correspondence of Libvirt tool and cluster virtual machineAfterwards, this method further comprises:
Step S20: sFlow agreement is run under correspondence using Libvirt tool, to obtain the net of cluster virtual machineNetwork status information.
It should be noted that sFlow agreement is a kind of Network Monitoring Protocol, essence is using data flow stochastical sampling skillArt, provides the second layer in complete ICP/IP protocol model to the flow information within the scope of the 4th layer or even whole network, can be withThe flow analysis under large network traffic environment is adapted to, be able to use family in further detail and analyzes the property of network transmission stream in real timeCan, trend and there are the problem of.And present embodiment is based on the Libvirt tool established in step before and virtual machineThe correspondence of cluster runs sFlow agreement, and then can be by Libvirt tool further to virtual in physical serverThe network state information of machine cluster is obtained, and it is comprehensive to further increase the content being monitored to virtual machine with this,And then user can in conjunction with each virtual machine in cluster virtual machine running state information and cluster virtual machine it is network-likeState information carries out the resource allocation of adaptability to cluster virtual machine, so as to improve the service reliability of entire cluster virtual machine.
On the basis of the above embodiment, as a preferred embodiment, this method further comprises:
Running state information and network state information are recorded with JSON format to Redis database respectively.
It should be noted that in view of JSON (JavaScript Object Notation, JS object numbered musical notation) format isA kind of data interchange format of lightweight stores using the text formatting for being totally independent of programming language and indicates data, andAnd the data of JSON format have succinct and clearly hierarchical structure, therefore are readily able to the reading of user and write, whileIt is easy to machine parsing and generates, can effectively promotes network transmission efficiency and service efficiency.In addition, Redis database isThe memory database of Key-Value type, therefore match with the data structure of JSON format, and " Value " can beThe data structure of the types such as String, List, Set, Sorted Set or Hash, it is ensured that using for Redis database is moreSample, and since Redis database is the data read-write operation realized by memory, the performance phase of Redis databaseTo outstanding, it can be ensured that the subsequent whole efficiency for obtaining running state information and network state information of user.
In addition, as a preferred embodiment, monitoring resource interface includes virNetwork interface, virDomainInterface and virStorageVol interface.
In view of the network information, cpu resource information and the storage resource information by virtual machine can be relatively accurateReflect integrality of the virtual machine when providing cloud computing service, therefore the network information, cpu resource information and storage resource letterBreath is the content that emphasis required for being monitored to virtual machine obtains, and then in the present embodiment, is connect by virNetworkThe related letter that mouth is managed virtual machine network relevant information, is used by the available virtual machine CPU of virDomain interfaceBreath by virStorageVol interface is monitored storage condition, with this can according to the network information, cpu resource information withAnd the virtual machine state determined in cluster virtual machine that storage resource information is relatively accurate.
In addition, as a preferred embodiment, cluster virtual machine is specially the virtual machine collection set up based on SDN networkGroup.
Due to consideration that the network characteristics of SDN type are that control plane separates with data plane, therefore in the cluster of SDNUnder network foundation, for that can ensure that the acquisition to data information is more flexible, therefore in the virtual machine set up based on SDN networkIn cluster, the data information transfer between virtual machine more quickly and efficiently, and then in cluster virtual machine work, can have moreHigh data interaction efficiency;And when the monitoring of cluster virtual machine response Libvirt tool is to provide corresponding data information, it canWith higher data acquisition efficiency.
Embodiment three
Hereinbefore the embodiment of the monitoring method of virtual machine is described in detail, the present invention also provides one kindThe monitoring device of virtual machine corresponding with this method, since the embodiment of device part and the embodiment of method part are mutually rightIt answers, therefore the embodiment of device part refers to the description of the embodiment of method part, wouldn't repeat here.
Fig. 3 is a kind of structure chart of the monitoring device of virtual machine provided in an embodiment of the present invention.The embodiment of the present invention providesVirtual machine monitoring device, comprising:
Tool deployment module 10, for disposing Libvirt tool in physical server;Wherein run in physical serverThere is cluster virtual machine.
Communication building block 11, for cluster virtual machine to be arranged in the virConnect interface that Libvirt tool providesCorresponding virtual machine manager address, to establish the correspondence of Libvirt tool and cluster virtual machine.
Operating status obtains module 12, for choosing the target virtual machine in cluster virtual machine, and by target virtual machineThe monitoring resource interface that characteristic information calls Libvirt tool to provide as parameter, to obtain the operating status of target virtual machineInformation.
The monitoring device of virtual machine provided by the present invention, in advance in the middle part of the physical server that operation has cluster virtual machineLibvirt tool is affixed one's name to, and then right by the way that cluster virtual machine institute is arranged in the virConnect interface that Libvirt tool providesCorrespondence between Libvirt tool and cluster virtual machine is established with this in the address for the virtual machine manager answered, and then virtualThe target virtual machine for needing to monitor is chosen in machine cluster, and using the characteristic information of the target virtual machine as input parameter to callThe monitoring resource interface of Libvirt tool, the final acquisition realized to the running state information of target virtual machine.The present apparatus passes throughLibvirt tool is disposed in physical server, and then on the basis for establishing Libvirt tool Yu cluster virtual machine correspondenceOn, the monitoring to virtual machine in cluster virtual machine can be realized by the monitoring resource interface for calling Libvirt tool to provide, byIn being not necessarily to arrangement monitoring agent program or plug-in unit on monitored virtual machine, therefore the opposite load for mitigating virtual machine, in turnIt ensure that the service quality of virtual machine.
On the basis of embodiment three, the device further include:
Network state obtains module, for running sFlow agreement under correspondence using Libvirt tool, to obtainThe network state information of cluster virtual machine.
Example IV
The present invention also provides a kind of monitoring devices of virtual machine, comprising:
Memory, for storing computer program;
Processor, when for executing computer program the step of the realization such as monitoring method of above-mentioned virtual machine.
The monitoring device of virtual machine provided by the present invention, in advance in the middle part of the physical server that operation has cluster virtual machineLibvirt tool is affixed one's name to, and then right by the way that cluster virtual machine institute is arranged in the virConnect interface that Libvirt tool providesCorrespondence between Libvirt tool and cluster virtual machine is established with this in the address for the virtual machine manager answered, and then virtualThe target virtual machine for needing to monitor is chosen in machine cluster, and using the characteristic information of the target virtual machine as input parameter to callThe monitoring resource interface of Libvirt tool, the final acquisition realized to the running state information of target virtual machine.This equipment passes throughLibvirt tool is disposed in physical server, and then on the basis for establishing Libvirt tool Yu cluster virtual machine correspondenceOn, the monitoring to virtual machine in cluster virtual machine can be realized by the monitoring resource interface for calling Libvirt tool to provide, byIn being not necessarily to arrangement monitoring agent program or plug-in unit on monitored virtual machine, therefore the opposite load for mitigating virtual machine, in turnIt ensure that the service quality of virtual machine.
In addition, being stored with meter on computer readable storage medium the present invention also provides a kind of computer readable storage mediumCalculation machine program, when computer program is executed by processor the step of the realization such as monitoring method of above-mentioned virtual machine.
Computer readable storage medium provided by the present invention, in advance in the physical server that operation has cluster virtual machineLibvirt tool is disposed, and then by the way that the cluster virtual machine institute is arranged in the virConnect interface that Libvirt tool providesCorrespondence between Libvirt tool and cluster virtual machine is established with this in the address of corresponding virtual machine manager, and then in voidThe target virtual machine for needing to monitor is chosen in quasi- machine cluster, and using the characteristic information of the target virtual machine as input parameter to adjustWith the monitoring resource interface of Libvirt tool, the final acquisition realized to the running state information of target virtual machine.This computerReadable storage medium storing program for executing is establishing Libvirt tool and cluster virtual machine by disposing Libvirt tool in physical serverOn the basis of correspondence, it can be realized by the monitoring resource interface for calling Libvirt tool to provide in cluster virtual machineThe monitoring of virtual machine, since without arranging monitoring agent program or plug-in unit on monitored virtual machine, opposite mitigation is emptyThe load of quasi- machine, and then ensure that the service quality of virtual machine.
Detailed Jie has been carried out to a kind of monitoring method of virtual machine provided by the present invention, device, equipment and medium aboveIt continues.Each embodiment is described in a progressive manner in specification, the highlights of each of the examples are with other embodimentsDifference, the same or similar parts in each embodiment may refer to each other.For device, equipment disclosed in embodiment andFor medium, since it is corresponded to the methods disclosed in the examples, so being described relatively simple, related place is referring to method portionIt defends oneself bright.It should be pointed out that for those skilled in the art, in the premise for not departing from the principle of the inventionUnder, it can be with several improvements and modifications are made to the present invention, these improvement and modification also fall into the protection of the claims in the present inventionIn range.
It should also be noted that, in the present specification, relational terms such as first and second and the like be used merely to byOne entity or operation are distinguished with another entity or operation, without necessarily requiring or implying these entities or operationBetween there are any actual relationship or orders.Moreover, the terms "include", "comprise" or its any other variant meaningCovering non-exclusive inclusion, so that the process, method, article or equipment for including a series of elements not only includes thatA little elements, but also including other elements that are not explicitly listed, or further include for this process, method, article orThe intrinsic element of equipment.In the absence of more restrictions, the element limited by sentence "including a ...", is not arrangedExcept there is also other identical elements in the process, method, article or apparatus that includes the element.