Disclosure of Invention
The embodiment of the application provides a method and a device for controlling a virtual machine of a cloud operating system and a storage medium, so as to at least solve the problems of user information loss and low migration efficiency in virtual machine migration in the related art.
In a first aspect, an embodiment of the present application provides a method for controlling a virtual machine of a cloud operating system, where the cloud operating system is deployed in a container of each server operating system in a server cluster, and servers in the server cluster are connected in a star-shaped distribution via a TCP, and the method includes:
when receiving a request server resource sent by a non-first-time login client, a first server judges whether the hardware load of the first server exceeds a preset threshold, wherein if the hardware load of the first server is smaller than the preset threshold, the non-first-time login client allocates a first virtual machine resource generated by the first server;
if the hardware load of the first server is greater than or equal to the preset threshold, the cloud operating system searches a second server in the server cluster, the hardware load of which is less than the preset threshold, so as to import the user information of the first virtual machine to a second virtual machine newly created on the second server, and returns the second virtual machine to the client, wherein the user information of the first virtual machine is stored in the first operating system of the first server.
In some embodiments, each server in the server cluster has a record table of the IP and performance corresponding to the server, the record table includes user information on each server virtual machine, the user information includes user operation files and application data, and the record table is periodically synchronized.
In some embodiments, before receiving the request server resource sent by the non-first-login client, the method further includes:
when receiving a virtual machine request instruction sent by the client, the load balancing module searches a first server with a hardware load smaller than the preset threshold value in the server cluster, generates a first virtual machine configured corresponding to the virtual machine request instruction, and returns the first virtual machine to the client, so that the client is connected with the first virtual machine for the first time;
the cloud operating system periodically saves the user operating file on the first virtual machine and backs up the user operating file on the first virtual machine to the first operating system.
In some embodiments, after the generating the first virtual machine configured corresponding to the requesting virtual machine instruction, the method further comprises:
and when receiving an application instruction which is sent by the client and requests to add or delete the application, synchronously saving the application program data operated corresponding to the application instruction to the first operating system by the first virtual machine.
In some embodiments, when the first server with a hardware load smaller than the preset threshold is found in the server cluster, a vacant server is preferentially found as the first server.
In some embodiments, when a second server with a hardware load smaller than the preset threshold is searched in the server cluster, an empty server is preferentially searched as the second server.
In some embodiments, after generating the first virtual machine configured according to the request virtual machine instruction, the method further includes:
and when a configuration instruction which is sent by the client and requests upgrading or degrading the configuration of the operating system is received, the cloud operating system dynamically generates the operating system matched with the configuration instruction and imports a client configuration file.
In a second aspect, an embodiment of the present application provides a virtual machine control apparatus of a cloud operating system, where the apparatus includes a resource allocation module and a virtual machine migration module;
the resource allocation module is used for judging whether the hardware load of a first server exceeds a preset threshold value or not when receiving a request server resource sent by a non-first-login client, wherein if the hardware load of the first server is larger than the preset threshold value, the non-first-login client allocates a first virtual machine resource generated by the first server;
the virtual machine migration module is configured to, when it is determined that the hardware load of the first server is greater than or equal to the preset threshold, search for a second server in the server cluster, where the hardware load is less than the preset threshold, so as to import user information of the first virtual machine to a second virtual machine newly created on the second server, and return the second virtual machine to the client, where the user information of the first virtual machine is stored in a first operating system of the first server.
In some embodiments, the apparatus further includes a load balancing module, a virtual machine generation module, a data synchronization module, and a capacity expansion module;
the load balancing module is used for searching a first server in the server cluster, wherein the hardware load of the first server is smaller than the preset threshold value when a virtual machine request instruction sent by the client is received;
the virtual machine generation module is used for generating a first virtual machine configured corresponding to the request virtual machine instruction and returning the first virtual machine to the client so that the client is connected with the first virtual machine for the first time;
the data synchronization module is used for periodically saving the user operation files on the first virtual machine and backing up the user operation files on the first virtual machine to the first operating system;
and the capacity expansion module is used for dynamically generating an operating system matched with the configuration instruction and importing a client configuration file when receiving the configuration instruction which is sent by the client and requests upgrading or degrading the operating system configuration.
In a third aspect, an embodiment of the present application provides a computer storage medium, on which a computer program is stored, and the program, when executed by a processor, implements the virtual machine control method according to the first aspect.
Compared with the related art, in the virtual machine control method of the cloud operating system provided by the embodiment of the application, the cloud operating system is deployed in a container of each server operating system in a server cluster, each server in the server cluster is connected in a star-shaped distribution manner through a TCP, when a request server resource sent by a client which is not logged in for the first time is received, a first server judges whether the hardware load of the first server exceeds a preset threshold value, wherein if the hardware load of the first server is smaller than the preset threshold value, the client which is not logged in for the first time allocates a first virtual machine resource generated by the first server; if the first server judges that the hardware load of the first server exceeds a preset threshold value, the cloud operating system searches a second server in the server cluster, wherein the hardware load of the second server is smaller than the preset threshold value, so as to introduce the user information of the first virtual machine into a second virtual machine newly created on the second server, and return the second virtual machine to the client, wherein the user information of the first virtual machine is stored in the first operating system of the first server. The user information of the virtual machine is stored on the server, so that the data synchronization of the virtual machine and the server is realized, the rapid migration of the virtual machine can be realized without reinstalling software, the problems of user information loss and low migration efficiency in the migration of the virtual machine are solved, the migration efficiency is improved, and the user information cannot be lost.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application will be described and illustrated below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments provided in the present application without any inventive step are within the scope of protection of the present application.
It is obvious that the drawings in the following description are only examples or embodiments of the present application, and that it is also possible for a person skilled in the art to apply the present application to other similar contexts on the basis of these drawings without inventive effort. Moreover, it should be appreciated that in the development of any such actual implementation, as in any engineering or design project, numerous implementation-specific decisions must be made to achieve the developers' specific goals, such as compliance with system-related and business-related constraints, which may vary from one implementation to another.
Reference in the specification to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the specification. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. Those of ordinary skill in the art will explicitly and implicitly appreciate that the embodiments described herein may be combined with other embodiments without conflict.
Unless defined otherwise, technical or scientific terms referred to herein shall have the ordinary meaning as understood by those of ordinary skill in the art to which this application belongs. Reference to "a," "an," "the," and similar words throughout this application are not to be construed as limiting in number, and may refer to the singular or the plural. The present application is directed to the use of the terms "including," "comprising," "having," and any variations thereof, which are intended to cover non-exclusive inclusions; for example, a process, method, system, article, or apparatus that comprises a list of steps or modules (elements) is not limited to the listed steps or elements, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus. Reference to "connected," "coupled," and the like in this application is not intended to be limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The term "plurality" as referred to herein means two or more. "and/or" describes an association relationship of associated objects, meaning that three relationships may exist, for example, "A and/or B" may mean: a exists alone, A and B exist simultaneously, and B exists alone. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship. Reference herein to the terms "first," "second," "third," and the like, are merely to distinguish similar objects and do not denote a particular ordering for the objects.
The cloud operating system generally refers to a cloud platform integrated management system which is constructed on basic hardware resources such as servers, storage, networks and the like and basic software such as a stand-alone operating system, middleware, a database and the like and manages massive basic hardware and software resources. The cloud operating system (such as cloudnedeleos operating system) in this embodiment includes a Linux kernel module and a JSAPI module, where the Linux kernel module is configured to provide basic Linux commands, and the JSAPI module is configured to provide remote calls and driver calls of operating system applications. The cloud operating system is deployed in a container of each server operating system of the server cluster. Fig. 1 is a schematic diagram of a server cluster according to an embodiment of the present application, and as shown in fig. 1, servers in the server cluster are connected in a star distribution via TCP and record a user list. It should be noted that the number of servers in the figure is schematic. The server is provided with a record table of the corresponding IP and performance of the server, the record table comprises user information corresponding to a user list on each server virtual machine, the user information comprises user operation files and application program data on the virtual machines, and the record table is periodically synchronized, so that the timeliness of data synchronization on the virtual machines and the server can be improved.
The embodiment provides a virtual machine control method of a cloud operating system, fig. 2 is a flowchart of the virtual machine control method of the cloud operating system according to the embodiment of the application, and fig. 3 is an interaction schematic diagram of the virtual machine control method according to the embodiment of the application. As shown in fig. 2 and fig. 3, the process includes the following steps:
s210, the client sends a virtual machine request instruction to request for establishing the virtual machine.
S220, when the load balancing module receives the virtual machine request instruction, a first server with a hardware load smaller than a preset threshold value in the server cluster is searched, and a first virtual machine configured corresponding to the virtual machine request instruction is generated. The first virtual machine has a configuration corresponding to the request virtual machine instruction and imports a user information record of the client. The first server is an empty server or a server with a hardware load smaller than a preset threshold, namely the first server has enough resources to establish the virtual machine. Preferably, the server which is empty is preferentially searched as the first server, so that the first server can be used for a longer time, the migration time is delayed, the overall migration times of the virtual machines on the server cluster are reduced, and the efficiency is better.
And S230, returning the first virtual machine to the client.
S240, the client is connected with the first virtual machine for the first time. The virtual machine is generated on the first server with enough resources, so that the command sent by the client can be ensured to be responded quickly, and the user experience is improved.
Preferably, the cloud operating system periodically saves the user operation file on the first virtual machine at regular time, and backs up the user operation file on the first virtual machine to the first operating system. For example, the state of each server is synchronized once every 30 seconds, so that when a client has a connection request, the currently vacant server is preferentially inquired in the record table for distribution, and the hardware load of the server cluster is balanced. And the timeliness of data synchronization of the virtual machine and the server is ensured.
The embodiment provides a virtual machine control method for saving the state of a virtual machine. Fig. 4 is an interaction diagram of a virtual machine control method for saving a virtual machine state according to an embodiment of the present application, where as shown in fig. 4, a client connects with a first server and establishes a user list. The client presents an application instruction to the first virtual machine requesting addition or deletion of an application. And the first virtual machine responds to the application instruction, performs corresponding operation of adding or deleting the application, and synchronously stores the application program data of the corresponding operation to the first operating system so as to realize the application program data synchronization of the virtual machine and the server, and the server stores relevant information such as software list records and the like. When the cloud data is stored, the data is stored in the server instead of the virtual machine, so that when a client makes a connection request, the cloud operating system can allocate any operating system to the client, and simultaneously import user information such as user operating files, application program data and the like. And the cloud operating system monitors the service condition of the server cluster hardware, and if the load of certain server hardware exceeds a preset threshold, the cloud operating system automatically sends the request and the user information sent by the client to other servers with hardware loads smaller than the preset threshold or even vacant, so that the load balance of the server cluster can be achieved.
In order to improve capacity expansion efficiency and solve the problem of difficult capacity expansion, an embodiment of the present application provides a method for controlling a virtual machine of a cloud operating system for capacity expansion, where a client sends a configuration instruction requesting to upgrade or reduce configuration of the operating system, and when receiving the configuration instruction, the cloud operating system dynamically generates an operating system matched with the configuration instruction and imports a client configuration file into the operating system.
The present embodiment provides another method for controlling a virtual machine of a cloud operating system, fig. 5 is a flowchart of another method for controlling a virtual machine of a cloud operating system according to an embodiment of the present application, and fig. 6 is an interaction diagram of a case where a first server resource is fully loaded according to an embodiment of the present application. As shown in fig. 5 and fig. 6, the process includes the following steps:
s510, the client is not connected with the first virtual machine generated by the first server for the first time.
S520, the client sends a request server resource to the first server.
S530, when the first server receives the request server resource sent by the client, whether the hardware load of the first server exceeds a preset threshold value is judged.
And S540, if the hardware load of the first server exceeds the preset threshold, the cloud operating system searches a second server in the server cluster, wherein the hardware load of the second server is smaller than the preset threshold. Illustratively, in this embodiment, the server cluster further includes a second server, a third server, and a fourth server. In practice a server cluster may also comprise more servers. Preferably, the server with the empty space is preferentially searched as the second server, so that the hardware load of each server in the server cluster can be more balanced. If the server resources of the first server are full, calling a second server with the least resource utilization rate in the server cluster.
And S550, creating a second virtual machine on the second server, and importing the user information of the first virtual machine.
And S560, returning the second virtual machine to the client. The second virtual machine responds to the client with the data.
And S570, if the hardware load of the first server is smaller than a preset threshold, the client which is not logged in for the first time allocates the generated first virtual machine resource.
When the hardware resources of the first server are sufficient, the client which is not logged in for the first time can directly allocate the resources of the first virtual machine. When the hardware resources of the first server are insufficient, the user information of the first virtual machine is stored in the server cluster, so that the user information of the virtual machine can be quickly migrated under the condition of not reinstalling software, the user information cannot be lost, the quick migration of the virtual machine is realized on the server cluster, any virtual machine can be a virtual machine responding to the requirements of a client side in a short time, and meanwhile, the load balance of the virtual machines on all servers is considered through the communication among the servers.
Fig. 7 is a timing diagram illustrating the interaction between the client and the virtual machine and the server, and as shown in fig. 7, the message flow of the request information initiated by the client in the virtual machine and the server under different scenarios is shown. When the client requests to add or delete an application, the virtual machine performs a corresponding operation and synchronizes information to the server 1. When a client requests a virtual machine, the server 1 has enough resources, the server 1 generates the virtual machine and imports user information, the virtual machine is returned to the client, and the client is connected with the virtual machine generated by the server 1 for the first time. The client is not connected with the virtual machine generated by the server 1 for the first time and requests resources for the server 1, when the hardware load of the server 1 exceeds a preset threshold value, the server 2 with low load (the load is smaller than the preset threshold value) is searched, user information is sent to the server 2, the server 2 generates the virtual machine and imports the user information, and the virtual machine is returned to the client. By synchronizing the data of the virtual machine and the server, a user can quickly create an own operating system by using any virtual machine in a short time, and the problem of difficult migration of the virtual machine is solved. Meanwhile, through the communication among the servers, the load of the virtual machines on the servers of the server cluster can be balanced.
The embodiment of the application provides a virtual machine control device of a cloud operating system. Fig. 8 is a schematic structural diagram of a virtual machine control apparatus of a cloud operating system according to an embodiment of the present application, and as shown in fig. 8, the apparatus includes aresource allocation module 810 and a virtual machine migration module 820: theresource allocation module 810 is configured to, when receiving a request server resource sent by a non-first-login client, determine whether a hardware load of a first server exceeds a preset threshold, where, if the hardware load of the first server is greater than the preset threshold, the non-first-login client allocates a first virtual machine resource that has been generated by the first server; the virtualmachine migration module 820 is configured to, when it is determined that the hardware load of the first server exceeds a preset threshold, search a second server in the server cluster, where the hardware load is smaller than the preset threshold, so as to import user information of the first virtual machine to a second virtual machine newly created on the second server, and return the second virtual machine to the client, where the user information of the first virtual machine is stored in a first operating system of the first server.
In some other embodiments, fig. 9 is a schematic structural diagram of another virtual machine control apparatus of a cloud operating system according to an embodiment of the present application, as shown in fig. 9, the apparatus further includes aload balancing module 920, a virtualmachine generating module 930, adata synchronization module 940, and acapacity expansion module 950, where when receiving a virtual machine request instruction sent by a client, theload balancing module 920 searches for a first server in a server cluster whose hardware load is smaller than a preset threshold; the virtualmachine generation module 930 generates a first virtual machine configured corresponding to the request virtual machine instruction, and returns the first virtual machine to the client, so that the client connects the first virtual machine for the first time; thedata synchronization module 940 is configured to periodically save the user operation file on the first virtual machine, and backup the user operation file on the first virtual machine to the first operating system; thecapacity expansion module 950 is configured to, when receiving a configuration instruction requesting upgrading or degrading the operating system configuration sent by the client, dynamically generate an operating system matched with the configuration instruction, and import a client configuration file. It will be understood by those skilled in the art that the foregoing migration to the second virtual machine will also perform data synchronization and capacity expansion in response to the configuration instruction. Theload balancing module 920 receives clients that have not been connected to the system for which the system first allocates resources. Clients that are not logged on for the first time may directly connect to the server and allocate server resources without going through theload balancing module 920.
For specific limitations of the virtual machine control device of the cloud operating system, reference may be made to the above limitations of the virtual machine control method of the cloud operating system, and details are not repeated here. All or part of each module in the virtual machine control device of the cloud operating system can be realized by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In addition, in combination with the virtual machine control method of the cloud operating system in the foregoing embodiment, an embodiment of the present application may provide a storage medium to implement. The storage medium having stored thereon a computer program; the computer program, when executed by a processor, implements the virtual machine control method of the cloud operating system in any of the above embodiments.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
It should be understood by those skilled in the art that various features of the above-described embodiments can be combined in any combination, and for the sake of brevity, all possible combinations of features in the above-described embodiments are not described in detail, but rather, all combinations of features which are not inconsistent with each other should be construed as being within the scope of the present disclosure.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.