A method and system for obtaining virtual machine host IP

By obtaining the virtual host table and obtaining the virtual host network card address information, the problem of virtual IP switching host judgment in the cloud host environment is solved, the processing process is simplified, the accuracy and efficiency are improved, and resource consumption and lag are avoided.

CN112433820BActive Publication Date: 2025-02-21UNIV OF SCI & TECH OF CHINA
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202011415525.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-03
Publication Date
2025-02-21
Estimated Expiration
2040-12-03

AI Technical Summary

Technical Problem

In the cloud host environment, it is difficult for the existing technology to effectively determine which host the virtual IP has been switched to, and the processing process is complicated and resource consumption is large, which can easily cause lag.

Method used

By acquiring the virtual host table and obtaining the virtual host network card address information based on the table, the processing process is simplified and two search operations for large amounts of data are omitted. The specific steps include sending a hypertext transmission protocol request to the computing control component of the cloud computing management platform, finding the virtual host and its host, and reading the system network card IP address information through the computing service component.

Benefits of technology

It improves the accuracy of obtaining virtual host IP usage information, simplifies the processing process, reduces resource consumption, avoids lag, and improves the efficiency of obtaining virtual host IP usage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112433820B_ABST
    Figure CN112433820B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and system for obtaining a virtual machine host IP, the method comprising: obtaining a virtual host table; obtaining virtual host network card address information based on the obtained virtual host table. The present invention can solve the problem of data missing possibility, improve the accuracy of obtaining virtual host IP usage information; and simplify the processing process, omitting two large amounts of data search operations compared to the prior art, and improving the efficiency of obtaining virtual host IP usage.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of cloud computing technology, and in particular to a method and system for obtaining an IP address of a virtual machine host. Background Art

[0002] Virtual IP (hereinafter referred to as VIP) is a common technology for network high availability (hereinafter referred to as HA). To implement HA, two hosts are generally used to complete a function at the same time. For example, for a database service host, usually only one host, hostA, provides services to the outside world, and the other host, hostB, is used as a hot standby. When hostA fails, business access is automatically and dynamically switched to the other hot standby host, hostB.

[0003] VIP is an IP that is not strongly bound to the host. It is usually configured on host hostA. It can also switch back and forth between the primary and backup servers. That is to say, in addition to a real IP, host hostA that provides database to the outside world also has a virtual IP. Either of these two IPs can be used to connect to this host. The database link in all projects is configured with this VIP. When host hostA fails and cannot provide services to the outside world, this VIP is dynamically switched to the backup host hostB, thus achieving the purpose of switching the network access target to the backup host hostB.

[0004] In the above usage scenario, there needs to be an effective method to determine which host the virtual IP has switched to, so that the administrator can track the host providing the service. Especially in the cloud host environment, determining which virtual host the VIP has switched to is a problem that needs to be solved.

[0005] In the cloud host environment, the current common solution is to use OpenStack's network control component Neutron to obtain records in the neighbor resolution table, find the physical address MAC corresponding to the VIP, and then compare the physical address MAC with the virtual host's network card MAC information one by one to determine whether the virtual host is using a virtual IP.

[0006] For example, if the MAC record used by VIP is the same as the MAC of the network card of hostA, it means that the network card of hostA is using VIP. The overall process is as follows Figure 1 As shown. The "Neighbor Resolution Table" data obtained in Step 1 is generated when the virtual host accesses the external network. If the VIP does not access the external network after switching the virtual host, there may be no VIP data record, resulting in the inability to locate the virtual host. Step 2 and Step 4 require two traversal searches, which consumes a lot of resources when there is a lot of data and easily causes freezes.

[0007] Therefore, how to solve the problem of possible data missing to improve the accuracy of obtaining virtual host IP usage information; and how to simplify the processing process to improve the efficiency of obtaining virtual host IP usage is an urgent problem to be solved. Summary of the invention

[0008] In view of this, the present invention provides a method for obtaining the IP address of a virtual machine host, which can solve the problem of possible data missing and improve the accuracy of obtaining the virtual host IP usage information; and can simplify the processing process, omit two large-scale data search operations, and improve the efficiency of obtaining the virtual host IP usage.

[0009] The present invention provides a method for obtaining a virtual machine host IP, comprising:

[0010] Get the virtual host table;

[0011] The virtual host network card address information is obtained based on the obtained virtual host table.

[0012] Preferably, the acquiring virtual host network card address information based on the acquired virtual host table includes:

[0013] Sending a hypertext transfer protocol request to a computing control component of an open source cloud computing management platform;

[0014] The computing control component searches for a corresponding virtual host and a host computer where the virtual host is located based on the received hypertext transfer protocol request;

[0015] The computing control component sends the virtual host information and the event object type to the computing service component running at the host machine level;

[0016] The computing service component performs os-interface-address processing;

[0017] The computing service component calls the os-interface-address process and sends a guest-network-get-interfaces type message to the host machine;

[0018] Based on the received guest-network-get-interfaces type message, read the system network card IP address information.

[0019] Preferably, the computing control component searches for the corresponding virtual host and the host machine where the virtual host is located based on the received hypertext transfer protocol request, including:

[0020] The Hypertext Transfer Protocol request is processed through the ServersController class of the computing control component to find the corresponding virtual host and the host machine where it is located.

[0021] Preferably, the computing service component performs os-interface-address processing, including:

[0022] The os-interface-address processing is performed through the InstanceEvents class of the computing service component.

[0023] A system for obtaining a virtual machine host IP, comprising:

[0024] A first acquisition module is used to acquire a virtual host table;

[0025] The second acquisition module is used to acquire the virtual host network card address information based on the acquired virtual host table.

[0026] Preferably, the second acquisition module specifically includes:

[0027] A sending unit, used to send a hypertext transfer protocol request to a computing control component of an open source cloud computing management platform;

[0028] A computing control component, configured to find a corresponding virtual host and a host machine on which the virtual host is located based on the received hypertext transfer protocol request;

[0029] The computing control component is also used to send virtual host information and event object types to the computing service component running at the host level;

[0030] Compute service component, used for os-interface-address processing;

[0031] The computing service component is further used to call the os-interface-address process and send a guest-network-get-interfaces type message to the host machine;

[0032] The reading unit is used to read the system network card IP address information based on the received guest-network-get-interfaces type message.

[0033] Preferably, when the computing control component searches for the corresponding virtual host and the host machine where the virtual host is located based on the received hypertext transfer protocol request, it is specifically used to:

[0034] The Hypertext Transfer Protocol request is processed through the ServersController class of the computing control component to find the corresponding virtual host and the host machine where it is located.

[0035] Preferably, when the computing service component performs os-interface-address processing, it is specifically used to:

[0036] The os-interface-address is handled through the InstanceEvents class of the compute component.

[0037] In summary, the present invention discloses a method for obtaining a virtual machine host IP. When the virtual machine host IP needs to be obtained, the virtual host table is first obtained, and then the virtual host network card address information is obtained based on the obtained virtual host table. The present invention can solve the problem of data missing possibility, improve the accuracy of obtaining virtual host IP usage information; and can simplify the processing process, omit two large amounts of data search operations compared to the prior art, and improve the efficiency of obtaining virtual host IP usage. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0039] Figure 1 A flowchart of a method for obtaining a virtual machine host IP disclosed in the prior art;

[0040] Figure 2 A method flow chart of Embodiment 1 of a method for obtaining a virtual machine host IP disclosed in the present invention;

[0041] Figure 3 A method flow chart of Embodiment 2 of a method for obtaining a virtual machine host IP disclosed in the present invention;

[0042] Figure 4 This is a structural diagram of a system embodiment 1 for obtaining a virtual machine host IP disclosed in the present invention;

[0043] Figure 5 This is a structural diagram of a system embodiment 2 for obtaining the IP address of a virtual machine host disclosed in the present invention. DETAILED DESCRIPTION

[0044] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0045] like Figure 2 FIG. 1 is a flowchart of a method for obtaining a virtual machine host IP address according to an embodiment of the present invention. The method may include the following steps:

[0046] S201, obtaining a virtual host table;

[0047] When you need to obtain the IP address of a virtual machine host, first obtain the virtual host table.

[0048] S202: Acquire virtual host network card address information based on the acquired virtual host table.

[0049] Then, the virtual host network card address information is obtained according to the obtained virtual host table.

[0050] In summary, in the above embodiment, when it is necessary to obtain the IP address of the virtual machine host, the virtual host table is first obtained, and then the virtual host network card address information is obtained based on the obtained virtual host table. This can solve the problem of data missing possibility and improve the accuracy of obtaining the virtual host IP usage information; and it can simplify the processing process, and compared with the prior art, it omits two large-scale data search operations, thereby improving the efficiency of obtaining the virtual host IP usage.

[0051] like Figure 3 FIG. 1 is a flow chart of a method for obtaining a virtual machine host IP address according to Embodiment 2 of the present invention. The method may include the following steps:

[0052] S301, obtaining a virtual host table;

[0053] When you need to obtain the IP address of the virtual machine host, you first obtain the virtual host table. The virtual host is a virtual host that uses the qemu-kvm virtualization solution, the qemu-guest-agent software is installed inside the virtual host, and the operating system of the virtual host is Windows / Linux.

[0054] S302, sending a hypertext transfer protocol request to a computing control component of an open source cloud computing management platform;

[0055] After obtaining the virtual host table, an http (Hypertext Transfer Protocol) request is sent to the computing control component Nova_api of openstack (open source cloud computing management platform) through the Restful API.

[0056] The request method is: POST; the request path is: / servers / <server id> / action; request parameters are: {"os-interface-address":null}.

[0057] S303, the computing control component searches for the corresponding virtual host and the host machine where the virtual host resides based on the received hypertext transfer protocol request;

[0058] Then, the computing control component nova_api finds the corresponding virtual host and the host machine where it is located according to the received hypertext transfer protocol request.

[0059] Specifically, the ServersController class of the computing control component nova_api implements the corresponding request processing by calling _get_instance according to<server id> , find the corresponding virtual host and the host machine where it is located.

[0060] S304, the computing control component sends the virtual host information and the event object type to the computing service component running at the host machine level;

[0061] Then, the computing control component nova_api sends the virtual host information and event type 'os-interface-address' to the computing service component nova_compute running at the host level through rabbitmq communication.

[0062] S305, the computing service component performs os-interface-address processing;

[0063] The computing service component nova_compute implements the corresponding 'os-interface-address' processing, which calls the dirver module processing.

[0064] Specifically, the InstanceEvents class of the computing service component nova_compute implements the corresponding 'os-interface-address' processing, and the dirver module is called in the processing.

[0065] S306. The computing service component calls the os-interface-address process and sends a guest-network-get-interfaces type message to the host machine.

[0066] In the dirver module of the computing service component nova_compute, the interfaceAddresses process in the libvirt open source library is called to send a 'guest-network-get-interfaces' type message to the qemu-kvm process running at the host level and wait for the return data.

[0067] S307. Based on the received guest-network-get-interfaces type message, read the system network card IP address information.

[0068] The virtual host maintained in the qemu-kvm process runs the qemu-guest-agent software, which periodically obtains messages from qemu-kvm. After receiving the 'guest-network-get-interfaces' type message, it reads the system network card IP address information, formats it into a string information, and returns it to the qemu-kvm process. The final data is passed back to nova_api to be displayed to the user.

[0069] To further explain the technical solution of the present invention in detail, a specific example is given below:

[0070] Example assumptions: In the qemu-kvm-based architecture, a Linux system virtual host is created in the computing server node. The virtual host id is AAAAAA-BBBBBB-CCCCCC, and the virtual host network card eth0 is configured with an IP address of 192.168.0.100 / 24.

[0071] Method example:

[0072] Run the computing control component Nova_api on the control server node (the node IP address is 172.18.16.1) and monitor the system port 8774, passively waiting for http requests.

[0073] Run the message communication component rabbitmq on the control server node, which is responsible for delivering messages to the Nova_api component.

[0074] Run the computing service component Nova_compute on the computing server node, receive the messages sent by rabbitmq, and perform corresponding processing based on the message content.

[0075] If the user wants to obtain the IP address information of the virtual host AAAAAA-BBBBBB-CCCCCC, he / she sends an http request to the control server node. For example: POST http: / / 172.18.16.1:8774 / v2.1 / servers / AAAAAA-BBBBBB-CCCCCC / action–data{"os-interface-address":null};

[0076] After waiting for the http request response, the IP address information data of the virtual host AAAAAA-BBBBBB-CCCCCC is obtained:

[0077]

[0078] In summary, the present invention can solve the problem of possible data missing and improve the accuracy of obtaining virtual host IP usage information; it can also simplify the processing process, omit two large-scale data search operations compared to the prior art, and improve the efficiency of obtaining virtual host IP usage.

[0079] like Figure 4 FIG. 1 is a schematic diagram of a structure of a system embodiment 1 for obtaining a virtual machine host IP disclosed in the present invention. The system may include:

[0080] The first acquisition module 401 is used to acquire a virtual host table;

[0081] When you need to obtain the IP address of a virtual machine host, first obtain the virtual host table.

[0082] The second acquisition module 402 is used to acquire the virtual host network card address information based on the acquired virtual host table.

[0083] Then, the virtual host network card address information is obtained according to the obtained virtual host table.

[0084] In summary, in the above embodiment, when it is necessary to obtain the IP address of the virtual machine host, the virtual host table is first obtained, and then the virtual host network card address information is obtained based on the obtained virtual host table. This can solve the problem of data missing possibility and improve the accuracy of obtaining the virtual host IP usage information; and it can simplify the processing process, and compared with the prior art, it omits two large-scale data search operations, thereby improving the efficiency of obtaining the virtual host IP usage.

[0085] like Figure 5 FIG. 1 is a schematic diagram of a structure of a system embodiment 2 for obtaining a virtual machine host IP disclosed in the present invention. The system may include:

[0086] The first acquisition module 501 is used to acquire a virtual host table;

[0087] When you need to obtain the IP address of the virtual machine host, you first obtain the virtual host table. The virtual host is a virtual host that uses the qemu-kvm virtualization solution, the qemu-guest-agent software is installed inside the virtual host, and the operating system of the virtual host is Windows / Linux.

[0088] A sending unit 502, configured to send a hypertext transfer protocol request to a computing control component of an open source cloud computing management platform;

[0089] After obtaining the virtual host table, an http (Hypertext Transfer Protocol) request is sent to the computing control component Nova_api of openstack (open source cloud computing management platform) through the Restful API.

[0090] The request method is: POST; the request path is: / servers / <server id> / action; request parameters are: {"os-interface-address":null}.

[0091] The computing control component 503 is used to find the corresponding virtual host and the host machine where the virtual host is located based on the received hypertext transfer protocol request;

[0092] Then, the computing control component nova_api finds the corresponding virtual host and the host machine where it is located according to the received hypertext transfer protocol request.

[0093] The computing control component 503 is also used to send the virtual host information and the event object type to the computing service component 504 running at the host machine level;

[0094] Then, the computing control component nova_api sends the virtual host information and event type 'os-interface-address' to the computing service component nova_compute running at the host level through rabbitmq communication.

[0095] Compute service component 504, used for os-interface-address processing;

[0096] The computing service component nova_compute implements the corresponding 'os-interface-address' processing, which calls the dirver module processing.

[0097] The computing service component 504 is also used to call the os-interface-address process and send a guest-network-get-interfaces type message to the host machine;

[0098] In the dirver module of the computing service component nova_compute, the interfaceAddresses process in the libvirt open source library is called to send a 'guest-network-get-interfaces' type message to the qemu-kvm process running at the host level and wait for the return data.

[0099] The reading unit 505 is used to read the system network card IP address information based on the received guest-network-get-interfaces type message.

[0100] The virtual host maintained in the qemu-kvm process runs the qemu-guest-agent software, which periodically obtains messages from qemu-kvm. After receiving the 'guest-network-get-interfaces' type message, it reads the system network card IP address information, formats it into a string information, and returns it to the qemu-kvm process. The final data is passed back to nova_api to be displayed to the user.

[0101] In summary, the present invention can solve the problem of possible data missing and improve the accuracy of obtaining virtual host IP usage information; it can also simplify the processing process, omit two large-scale data search operations compared to the prior art, and improve the efficiency of obtaining virtual host IP usage.

[0102] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.

[0103] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0104] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0105] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for obtaining a virtual machine host IP, characterized in that: include: Get the virtual host table; Acquire virtual host network card address information based on the acquired virtual host table; The acquiring of the virtual host network card address information based on the acquired virtual host table includes: Send a Hypertext Transfer Protocol request to nova_api, a computing control component of the open source cloud computing management platform; The ServersController class of the computing control component nova_api implements the corresponding processing of the request by calling _get_instance according to<server id> , find the corresponding virtual host and its host machine; The computing control component sends the virtual host information and the event object type to the computing service component running at the host machine level; The InstanceEvents class of the computing service component performs os-interface-address processing; The computing service component calls the os-interface-address process to send a guest-network-get-interfaces type message to the qemu-kvm process running at the host level; Based on the received guest-network-get-interfaces type message, read the system network card IP address information.

2. A system for obtaining a virtual machine host IP, characterized in that: include: A first acquisition module is used to acquire a virtual host table; A second acquisition module, used for acquiring virtual host network card address information based on the acquired virtual host table; The second acquisition module specifically includes: A sending unit, used to send a hypertext transfer protocol request to nova_api, a computing control component of an open source cloud computing management platform; The computing control component is used to implement the corresponding request processing in the ServersController class of the computing control component nova_api, by calling _get_instance according to <serverid> , find the corresponding virtual host and its host machine;< / serverid> The computing control component is also used to send virtual host information and event object types to the computing service component running at the host level; A computing service component, used for os-interface-address processing of the InstanceEvents class of the computing service component; The computing service component is further used to call the os-interface-address process and send a guest-network-get-interfaces type message to the qemu-kvm process running at the host level; The reading unit is used to read the system network card IP address information based on the received guest-network-get-interfaces type message.

Citation Information

Patent Citations

  • IP address configuration method, cloud server, cloud platform and readable storage medium

    CN108347472A