CN107885575B - Virtual machine migration method and device - Google Patents

Virtual machine migration method and device Download PDF

Info

Publication number
CN107885575B
CN107885575B CN201710147699.8A CN201710147699A CN107885575B CN 107885575 B CN107885575 B CN 107885575B CN 201710147699 A CN201710147699 A CN 201710147699A CN 107885575 B CN107885575 B CN 107885575B
Authority
CN
China
Prior art keywords
migration
migrated
virtual machine
virtual machines
storage
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201710147699.8A
Other languages
Chinese (zh)
Other versions
CN107885575A (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.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen 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 Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN201710147699.8A priority Critical patent/CN107885575B/en
Publication of CN107885575A publication Critical patent/CN107885575A/en
Application granted granted Critical
Publication of CN107885575B publication Critical patent/CN107885575B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • 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/4557Distribution of virtual machine instances; Migration and load balancing

Abstract

The invention discloses a method and a device for migrating a virtual machine, wherein the method comprises the following steps: collecting relevant information of all virtual machines in a monitoring range; determining virtual machines to be migrated and corresponding migration modes in all the virtual machines according to the relevant information and preset migration rules; and automatically migrating the virtual machine to be migrated according to the migration mode. According to the method and the device, relevant information of all virtual machines in a monitoring range is collected, the virtual machines to be migrated and the corresponding migration modes are determined according to preset migration rules, and the virtual machines to be migrated are automatically migrated according to the determined migration modes. Because the virtual machines do not need to be migrated one by one manually, the migration efficiency of the virtual machines is greatly improved; and the corresponding migration mode can be determined according to different virtual machines to be migrated to perform automatic migration, so that the migration accuracy is improved.

Description

Virtual machine migration method and device
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for migrating a virtual machine.
Background
At present, in a cloud environment, a large number of virtual machines (vm for short) are provided, and when vm needs to be migrated, generally, a mode of manually migrating vm one by one is adopted, so that the working period is long, and the efficiency is low; moreover, vm migration work is tedious and time-consuming, requirements for professional skills of migration personnel are high, mistakes are easy to make, and the risk of misoperation can be increased.
Disclosure of Invention
The invention mainly aims to provide a virtual machine migration method and a virtual machine migration device, and aims to efficiently and accurately automatically migrate a virtual machine.
In order to achieve the above object, the present invention provides a method for migrating a virtual machine, including the following steps:
A. collecting relevant information of all virtual machines in a monitoring range;
B. determining virtual machines to be migrated and corresponding migration modes in all the virtual machines according to the relevant information and preset migration rules;
C. and automatically migrating the virtual machine to be migrated according to the migration mode.
Preferably, the related information includes:
the running and storage states of the virtual machine and/or the running and storage states of the host machine in which the virtual machine is located.
Preferably, the step B includes:
if a plurality of virtual machines correspond to the same host and the number of the virtual machines corresponding to the host exceeds a preset first number, determining a preset second number of virtual machines in the virtual machines corresponding to the host as virtual machines to be migrated, and determining a corresponding migration mode as host migration;
the step C comprises the following steps:
migrating the preset second number of virtual machines from the host to other hosts.
Preferably, the step B includes:
if a first storage address where a configuration file of a virtual machine is located is different from a second storage address corresponding to the virtual machine, determining that the virtual machine is a virtual machine to be migrated, and determining that a corresponding migration mode is migration storage;
the step C comprises the following steps:
and migrating and storing the configuration file of the virtual machine from the first storage address to the second storage address.
Preferably, the step B includes:
if a plurality of virtual machines share the same storage space and the storage size of the storage space exceeds a preset storage threshold, determining a preset third number of virtual machines in the storage space as virtual machines to be migrated, and determining a corresponding migration mode as migration storage;
the step C comprises the following steps:
and migrating the preset third number of virtual machines from the storage space to other storage spaces.
In addition, to achieve the above object, the present invention further provides a virtual machine migration apparatus, including:
the acquisition module is used for acquiring relevant information of all virtual machines in a monitoring range;
the determining module is used for determining the virtual machines to be migrated and the corresponding migration modes in all the virtual machines according to the relevant information and a preset migration rule;
and the migration module is used for automatically migrating the virtual machine to be migrated according to the migration mode.
Preferably, the related information includes:
the running and storage states of the virtual machine and/or the running and storage states of the host machine in which the virtual machine is located.
Preferably, the determining module is further configured to:
if a plurality of virtual machines correspond to the same host and the number of the virtual machines corresponding to the host exceeds a preset first number, determining a preset second number of virtual machines in the virtual machines corresponding to the host as virtual machines to be migrated, and determining a corresponding migration mode as host migration;
the migration module is further to:
migrating the preset second number of virtual machines from the host to other hosts.
Preferably, the determining module is further configured to:
if a first storage address where a configuration file of a virtual machine is located is different from a second storage address corresponding to the virtual machine, determining that the virtual machine is a virtual machine to be migrated, and determining that a corresponding migration mode is migration storage;
the migration module is further to:
and migrating and storing the configuration file of the virtual machine from the first storage address to the second storage address.
Preferably, the determining module is further configured to:
if a plurality of virtual machines share the same storage space and the storage size of the storage space exceeds a preset storage threshold, determining a preset third number of virtual machines in the storage space as virtual machines to be migrated, and determining a corresponding migration mode as migration storage;
the migration module is further to:
and migrating the preset third number of virtual machines from the storage space to other storage spaces.
According to the virtual machine migration method and device, relevant information of all virtual machines in a monitoring range is collected, the virtual machines to be migrated and the corresponding migration modes are determined according to the preset migration rules, and the virtual machines to be migrated are automatically migrated according to the determined migration modes. Because the virtual machines do not need to be migrated one by one manually, the migration efficiency of the virtual machines is greatly improved; and the corresponding migration mode can be determined according to different virtual machines to be migrated to perform automatic migration, so that the migration accuracy is improved.
Drawings
FIG. 1 is a flowchart illustrating a migration method of a virtual machine according to an embodiment of the present invention;
fig. 2 is a functional module diagram of an embodiment of a migration apparatus of a virtual machine according to the present invention.
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
In order to make the technical problems, technical solutions and advantageous effects to be solved by the present invention clearer and clearer, the present invention is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The invention provides a migration method of a virtual machine.
Referring to fig. 1, fig. 1 is a flowchart illustrating a migration method of a virtual machine according to an embodiment of the present invention.
In an embodiment, the migration method of the virtual machine includes:
and step S10, collecting relevant information of all virtual machines in the monitoring range.
In this embodiment, a virtual machine auto-migration request sent by a user is received, for example, the virtual machine auto-migration request sent after the user inputs related information (for example, a range of a virtual machine that needs to be automatically migrated, a time period that needs to be automatically migrated, a condition that the virtual machine that needs to be automatically migrated needs to meet, a manner of automatically migrating the virtual machine, and the like) on a terminal such as a mobile phone, a tablet computer, and a control terminal device is received, for example, the virtual machine auto-migration request sent after the user inputs related information on an APP of the virtual machine auto-migration application that is pre-installed in the terminal such as the mobile phone, the tablet computer, and the control terminal device is received, or the virtual machine auto-migration request sent after the user inputs related information on a browser system in the terminal such as the mobile phone, the tablet computer, and the control terminal device is received.
After receiving a virtual machine automatic migration request sent by a user, automatically acquiring relevant information of all virtual machines in a monitoring range, wherein all virtual machines in the monitoring range can be all virtual machines in a virtual machine range which is set by the user to be required to be automatically migrated when the user sends the virtual machine automatic migration request. The collected relevant information of the virtual machine may include running and storage states of the virtual machine, such as memory occupancy rate of the virtual machine, number of background tasks running, storage location, storage size, and the like; the collected related information of the virtual machine may further include the running and storage states of the host machine where the virtual machine is located, for example, the memory usage rate of the host machine where the virtual machine is located, the number of all managed virtual machines, the current size of the storage space, the size of the remaining storage space, and the like.
In one embodiment, the writeable code calls the API of the vCenter to log in to the vCenter, and in the vCenter, according to its directory structure, the relevant information of all virtual machines vm in the monitoring range is acquired, and all the acquired vm information is packaged into one class and cached locally. When receiving an automatic migration request of a virtual machine sent by a user and needing to automatically acquire relevant information of all vms in a monitoring range, the virtual machine can be queried locally to acquire vm information cached to the local. If the attribute value of vm changes, the query can be sent to the server or vCenter, and the synchronous cache is locally stored, such as the synchronous cache through waitforupdate. When the information related to vm is automatically acquired, the operating status of vm (such as power _ on and power _ off), the utilization rate of cpu of host where vm is located, the readiness of cup, the utilization rate of memory, swap-in and swap-out of memory, the use condition of disk, etc. are automatically collected. And monitoring the relevant information of the vm, namely, automatically refreshing and synchronizing the set 20S, judging the running state of the vm according to the relevant information of the monitored vm, and generating an alarm and a log if the use conditions of the CPU, the memory, the disk and the network of the host in which the vm is positioned are abnormal, so as to facilitate subsequent processing.
And step S20, determining the virtual machines to be migrated and the corresponding migration modes in all the virtual machines according to the related information and preset migration rules.
After the relevant information of all the virtual machines in the monitoring range is collected, the virtual machines to be migrated in all the virtual machines can be determined according to a preset migration rule preset by a user, and migration modes corresponding to different virtual machines to be migrated are determined. For example, in an embodiment, the preset migration rule may be that a user presets to automatically remove a specific virtual machine within a certain specific time period, and when relevant information of all virtual machines within a monitoring range is continuously collected, if a current time reaches the specific time period preset by the user, the specific virtual machine in all virtual machines is found, and the specific virtual machine is used as a virtual machine to be migrated that needs to be migrated.
In another embodiment, the preset migration rule may also be that a user presets a specific virtual machine to run on the host 1 to a preset time point and then migrate the specific virtual machine to run on the host 2, so that when relevant information of all virtual machines in the monitoring range is continuously collected, if it is determined that the time that the specific virtual machine preset by the user runs on the host 1 reaches the preset time point, the specific virtual machine in all virtual machines is found, the specific virtual machine is used as a virtual machine to be migrated, and a migration manner corresponding to the specific virtual machine is determined as a virtual machine to be migrated from the host 1 to the host 2.
Certainly, the user may also preset other various preset migration rules, so as to determine the virtual machine to be migrated and the corresponding migration manner, such as host migration, migration storage, host migration and migration storage, which are matched with the preset migration rules, according to the collected related information of all the virtual machines, which is not limited herein.
And step S30, automatically migrating the virtual machine to be migrated according to the migration mode.
After the virtual machine to be migrated and the corresponding migration mode of the virtual machine to be migrated are determined according to the preset migration rule preset by the user, the determined virtual machine to be migrated can be automatically migrated according to the determined migration mode. For example, if it is determined that the migration mode corresponding to the virtual machine to be migrated is host migration, the virtual machine to be migrated may be automatically migrated from the current host to the target host; if the migration mode corresponding to the virtual machine to be migrated is determined to be migration storage, the virtual machine to be migrated can be automatically migrated from the current storage to the target storage.
In this embodiment, relevant information of all virtual machines within a monitoring range is collected, a virtual machine to be migrated and a corresponding migration mode are determined according to a preset migration rule, and the virtual machine to be migrated is automatically migrated according to the determined migration mode. The method comprises the steps that a user only needs to preset some basic parameters, such as the range of virtual machines needing to be automatically migrated, the time period needing to be automatically migrated, a preset migration rule used for determining the virtual machines to be migrated and the corresponding migration modes, and the like, so that the virtual machines to be migrated and the corresponding migration modes in all the virtual machines can be automatically determined, the virtual machines to be migrated are automatically migrated according to the migration modes, the virtual machines do not need to be manually migrated one by one, and the virtual machine migration efficiency is greatly improved; and the corresponding migration mode can be determined according to different virtual machines to be migrated to perform automatic migration, so that the flexibility and the accuracy of migration are improved.
Further, in other embodiments, the step S20 may include:
if a plurality of virtual machines correspond to the same host and the number of the virtual machines corresponding to the host exceeds a preset first number, determining a preset second number of virtual machines in the virtual machines corresponding to the host as virtual machines to be migrated, and determining a corresponding migration mode as host migration;
the step S30 may include:
migrating the preset second number of virtual machines from the host to other hosts.
In this embodiment, if there are multiple virtual machines corresponding to the same host, that is, one host manages the multiple virtual machines, if the number of virtual machines managed by the host at the same time exceeds a preset first number (for example, 10), it is difficult for the host to effectively manage the multiple virtual machines, and the services on the virtual machines may be affected. Therefore, the virtual machines with the preset second number in the plurality of virtual machines managed by the host are taken as the virtual machines to be migrated, the corresponding migration mode is determined to be host migration, and the virtual machines with the preset second number managed by the host are migrated from the host to other idle hosts for management, so that the number of the virtual machines managed by the same host is not excessive, each virtual machine can be effectively managed by the host, and the service on the virtual machine is prevented from being influenced.
Further, in other embodiments, the step S20 may include:
if a first storage address where a configuration file of a virtual machine is located is different from a second storage address corresponding to the virtual machine, determining that the virtual machine is a virtual machine to be migrated, and determining that a corresponding migration mode is migration storage;
the step S30 may include:
and migrating and storing the configuration file of the virtual machine from the first storage address to the second storage address.
In this embodiment, because it is often necessary to check or modify the configuration file of the virtual machine when the virtual machine is maintained, however, sometimes the configuration file of the virtual machine is inconsistent with the storage corresponding to the virtual machine, an operation and maintenance person usually does not know under which storage the configuration file is placed, and it is inconvenient for the operation and maintenance person to find and modify the configuration file in the operation and maintenance process. Therefore, if a first storage address where the configuration file of the virtual machine is located is different from a second storage address corresponding to the virtual machine, that is, the configuration file of the virtual machine is inconsistent with storage corresponding to the virtual machine, the virtual machine is determined to be a virtual machine to be migrated, and the configuration file of the virtual machine is migrated from the first storage address to the second storage address, so that the configuration file of each virtual machine is migrated to the storage corresponding to the virtual machine, and the configuration file is conveniently searched and modified in an operation and maintenance process.
In an embodiment, taking the example of migrating the vm's configuration file to the storage of the vm's hard disk 1 as an example, the following specific description is made:
(1) calling an API of the vCenter to obtain storage of a vm configuration file under the vCenter;
(2) calling the API of the vCenter to obtain the storage of the hard disk 1 of vm, and if the hard disk 1 does not exist, the configuration file exists at the original position;
(3) and judging whether the storage of the vm configuration file and the storage of the hard disk 1 are in the same position or not, and migrating when the storage of the vm configuration file and the storage of the hard disk 1 are not in the same position.
(4) And calling a migration API, adding the target storage of the configuration file to be migrated in the vm, namely the storage of the hard disk 1 into a migration function, adding other attributes of the vm, such as source storage of a disk not to be migrated in the vm into the migration function, and calling the migration function to realize migration.
Further, in other embodiments, the step S20 may include:
if a plurality of virtual machines share the same storage space and the storage size of the storage space exceeds a preset storage threshold, determining a preset third number of virtual machines in the storage space as virtual machines to be migrated, and determining a corresponding migration mode as migration storage;
the step S30 may include:
and migrating the preset third number of virtual machines from the storage space to other storage spaces.
In this embodiment, if a plurality of virtual machines share the same storage, which causes the storage to exceed a preset storage threshold, that is, to reach an upper storage limit, the virtual machines of a preset third number under the storage are migrated from the storage to other storages, so as to avoid occurrence of a situation that the running speed of the plurality of virtual machines or the service processing speed is slowed down under the same storage space due to the storage reaching the upper storage limit.
Further, in other embodiments, different migration operations may be performed on multiple virtual machines to be migrated simultaneously for different situations, for example, when a host migration operation is performed on a preset second number of virtual machines, if it is determined that a first storage address where a configuration file of a virtual machine is located is different from a second storage address corresponding to the virtual machine, it is determined that the virtual machine is a virtual machine to be migrated and a migration manner corresponding to the virtual machine is migration storage, and a migration storage operation of the configuration file of the virtual machine is performed simultaneously, where the virtual machine may be a virtual machine in the preset second number of virtual machines or another virtual machine in a monitoring range. That is, when performing migration operations in different manners, such as host migration, migration storage, and the like, on a plurality of virtual machines within a monitoring range, the migration operations in different manners, such as host migration, migration storage, and the like, may be executed simultaneously, or the migration operations in different manners, such as host migration, migration storage, and the like, may be executed in sequence, which is not limited herein.
Further, in other embodiments, the method further comprises:
and automatically migrating the determined virtual machines to be migrated according to a preset sequence, if one virtual machine to be migrated fails in the migration process, capturing the abnormal virtual machine to be migrated, namely the virtual machine to be migrated which fails in the migration, by using a preset abnormal capturing mechanism, and processing the virtual machine to be migrated which fails in the migration. And skipping the virtual machines to be migrated which are failed to be migrated, and continuously processing other virtual machines to be migrated so as to ensure that the virtual machines are mutually independent in the migration process, and the migration of other virtual machines cannot be influenced by the failure of single migration.
Further, in other embodiments, the method further comprises:
and generating a migration log in the automatic migration process of the virtual machine to be migrated. For example, the migration log may record all virtual machines to be migrated, virtual machines to be migrated that have completed migration, virtual machines to be migrated that have not completed migration, migration time of each virtual machine to be migrated, migration manner corresponding to each virtual machine to be migrated, and the like, so as to quickly locate an error according to the migration log when subsequent maintenance or an error occurs.
The invention further provides a virtual machine migration device.
Referring to fig. 2, fig. 2 is a functional module schematic diagram of an embodiment of a migration apparatus of a virtual machine according to the present invention.
In one embodiment, the migration apparatus of the virtual machine includes:
the acquisition module 01 is used for acquiring relevant information of all virtual machines in a monitoring range;
in this embodiment, a virtual machine auto-migration request sent by a user is received, for example, the virtual machine auto-migration request sent after the user inputs related information (for example, a range of a virtual machine that needs to be automatically migrated, a time period that needs to be automatically migrated, a condition that the virtual machine that needs to be automatically migrated needs to meet, a manner of automatically migrating the virtual machine, and the like) on a terminal such as a mobile phone, a tablet computer, and a control terminal device is received, for example, the virtual machine auto-migration request sent after the user inputs related information on an APP of the virtual machine auto-migration application that is pre-installed in the terminal such as the mobile phone, the tablet computer, and the control terminal device is received, or the virtual machine auto-migration request sent after the user inputs related information on a browser system in the terminal such as the mobile phone, the tablet computer, and the control terminal device is received.
After receiving a virtual machine automatic migration request sent by a user, automatically acquiring relevant information of all virtual machines in a monitoring range, wherein all virtual machines in the monitoring range can be all virtual machines in a virtual machine range which is set by the user to be required to be automatically migrated when the user sends the virtual machine automatic migration request. The collected relevant information of the virtual machine may include running and storage states of the virtual machine, such as memory occupancy rate of the virtual machine, number of background tasks running, storage location, storage size, and the like; the collected related information of the virtual machine may further include the running and storage states of the host machine where the virtual machine is located, for example, the memory usage rate of the host machine where the virtual machine is located, the number of all managed virtual machines, the current size of the storage space, the size of the remaining storage space, and the like.
In one embodiment, the writeable code calls the API of the vCenter to log in to the vCenter, and in the vCenter, according to its directory structure, the relevant information of all virtual machines vm in the monitoring range is acquired, and all the acquired vm information is packaged into one class and cached locally. When receiving an automatic migration request of a virtual machine sent by a user and needing to automatically acquire relevant information of all vms in a monitoring range, the virtual machine can be queried locally to acquire vm information cached to the local. If the attribute value of vm changes, the query can be sent to the server or vCenter, and the synchronous cache is locally stored, such as the synchronous cache through waitforupdate. When the information related to vm is automatically acquired, the operating status of vm (such as power _ on and power _ off), the utilization rate of cpu of host where vm is located, the readiness of cup, the utilization rate of memory, swap-in and swap-out of memory, the use condition of disk, etc. are automatically collected. And monitoring the relevant information of the vm, namely, automatically refreshing and synchronizing the set 20S, judging the running state of the vm according to the relevant information of the monitored vm, and generating an alarm and a log if the use conditions of the CPU, the memory, the disk and the network of the host in which the vm is positioned are abnormal, so as to facilitate subsequent processing.
The determining module 02 is configured to determine, according to the relevant information and according to a preset migration rule, a virtual machine to be migrated and a corresponding migration manner in all virtual machines;
after the relevant information of all the virtual machines in the monitoring range is collected, the virtual machines to be migrated in all the virtual machines can be determined according to a preset migration rule preset by a user, and migration modes corresponding to different virtual machines to be migrated are determined. For example, in an embodiment, the preset migration rule may be that a user presets to automatically remove a specific virtual machine within a certain specific time period, and when relevant information of all virtual machines within a monitoring range is continuously collected, if a current time reaches the specific time period preset by the user, the specific virtual machine in all virtual machines is found, and the specific virtual machine is used as a virtual machine to be migrated that needs to be migrated.
In another embodiment, the preset migration rule may also be that a user presets a specific virtual machine to run on the host 1 to a preset time point and then migrate the specific virtual machine to run on the host 2, so that when relevant information of all virtual machines in the monitoring range is continuously collected, if it is determined that the time that the specific virtual machine preset by the user runs on the host 1 reaches the preset time point, the specific virtual machine in all virtual machines is found, the specific virtual machine is used as a virtual machine to be migrated, and a migration manner corresponding to the specific virtual machine is determined as a virtual machine to be migrated from the host 1 to the host 2.
Certainly, the user may also preset other various preset migration rules, so as to determine the virtual machine to be migrated and the corresponding migration manner, such as host migration, migration storage, host migration and migration storage, which are matched with the preset migration rules, according to the collected related information of all the virtual machines, which is not limited herein.
And the migration module 03 is configured to automatically migrate the virtual machine to be migrated according to the migration manner.
After the virtual machine to be migrated and the corresponding migration mode of the virtual machine to be migrated are determined according to the preset migration rule preset by the user, the determined virtual machine to be migrated can be automatically migrated according to the determined migration mode. For example, if it is determined that the migration mode corresponding to the virtual machine to be migrated is host migration, the virtual machine to be migrated may be automatically migrated from the current host to the target host; if the migration mode corresponding to the virtual machine to be migrated is determined to be migration storage, the virtual machine to be migrated can be automatically migrated from the current storage to the target storage.
In this embodiment, relevant information of all virtual machines within a monitoring range is collected, a virtual machine to be migrated and a corresponding migration mode are determined according to a preset migration rule, and the virtual machine to be migrated is automatically migrated according to the determined migration mode. The method comprises the steps that a user only needs to preset some basic parameters, such as the range of virtual machines needing to be automatically migrated, the time period needing to be automatically migrated, a preset migration rule used for determining the virtual machines to be migrated and the corresponding migration modes, and the like, so that the virtual machines to be migrated and the corresponding migration modes in all the virtual machines can be automatically determined, the virtual machines to be migrated are automatically migrated according to the migration modes, the virtual machines do not need to be manually migrated one by one, and the virtual machine migration efficiency is greatly improved; and the corresponding migration mode can be determined according to different virtual machines to be migrated to perform automatic migration, so that the flexibility and the accuracy of migration are improved.
Further, in other embodiments, the determining module 02 may be further configured to:
if a plurality of virtual machines correspond to the same host and the number of the virtual machines corresponding to the host exceeds a preset first number, determining a preset second number of virtual machines in the virtual machines corresponding to the host as virtual machines to be migrated, and determining a corresponding migration mode as host migration;
the migration module 03 may further be configured to:
migrating the preset second number of virtual machines from the host to other hosts.
In this embodiment, if there are multiple virtual machines corresponding to the same host, that is, one host manages the multiple virtual machines, if the number of virtual machines managed by the host at the same time exceeds a preset first number (for example, 10), it is difficult for the host to effectively manage the multiple virtual machines, and the services on the virtual machines may be affected. Therefore, the virtual machines with the preset second number in the plurality of virtual machines managed by the host are taken as the virtual machines to be migrated, the corresponding migration mode is determined to be host migration, and the virtual machines with the preset second number managed by the host are migrated from the host to other idle hosts for management, so that the number of the virtual machines managed by the same host is not excessive, each virtual machine can be effectively managed by the host, and the service on the virtual machine is prevented from being influenced.
Further, in other embodiments, the determining module 02 may be further configured to:
if a first storage address where a configuration file of a virtual machine is located is different from a second storage address corresponding to the virtual machine, determining that the virtual machine is a virtual machine to be migrated, and determining that a corresponding migration mode is migration storage;
the migration module 03 may further be configured to:
and migrating and storing the configuration file of the virtual machine from the first storage address to the second storage address.
In this embodiment, because it is often necessary to check or modify the configuration file of the virtual machine when the virtual machine is maintained, however, sometimes the configuration file of the virtual machine is inconsistent with the storage corresponding to the virtual machine, an operation and maintenance person usually does not know under which storage the configuration file is placed, and it is inconvenient for the operation and maintenance person to find and modify the configuration file in the operation and maintenance process. Therefore, if a first storage address where the configuration file of the virtual machine is located is different from a second storage address corresponding to the virtual machine, that is, the configuration file of the virtual machine is inconsistent with storage corresponding to the virtual machine, the virtual machine is determined to be a virtual machine to be migrated, and the configuration file of the virtual machine is migrated from the first storage address to the second storage address, so that the configuration file of each virtual machine is migrated to the storage corresponding to the virtual machine, and the configuration file is conveniently searched and modified in an operation and maintenance process.
In an embodiment, taking the example of migrating the vm's configuration file to the storage of the vm's hard disk 1 as an example, the following specific description is made:
(5) calling an API of the vCenter to obtain storage of a vm configuration file under the vCenter;
(6) calling the API of the vCenter to obtain the storage of the hard disk 1 of vm, and if the hard disk 1 does not exist, the configuration file exists at the original position;
(7) and judging whether the storage of the vm configuration file and the storage of the hard disk 1 are in the same position or not, and migrating when the storage of the vm configuration file and the storage of the hard disk 1 are not in the same position.
(8) And calling a migration API, adding the target storage of the configuration file to be migrated in the vm, namely the storage of the hard disk 1 into a migration function, adding other attributes of the vm, such as source storage of a disk not to be migrated in the vm into the migration function, and calling the migration function to realize migration.
Further, in other embodiments, the determining module 02 may be further configured to:
if a plurality of virtual machines share the same storage space and the storage size of the storage space exceeds a preset storage threshold, determining a preset third number of virtual machines in the storage space as virtual machines to be migrated, and determining a corresponding migration mode as migration storage;
the migration module 03 may further be configured to:
and migrating the preset third number of virtual machines from the storage space to other storage spaces.
In this embodiment, if a plurality of virtual machines share the same storage, which causes the storage to exceed a preset storage threshold, that is, to reach an upper storage limit, the virtual machines of a preset third number under the storage are migrated from the storage to other storages, so as to avoid occurrence of a situation that the running speed of the plurality of virtual machines or the service processing speed is slowed down under the same storage space due to the storage reaching the upper storage limit.
Further, in other embodiments, different migration operations may be performed on multiple virtual machines to be migrated simultaneously for different situations, for example, when a host migration operation is performed on a preset second number of virtual machines, if it is determined that a first storage address where a configuration file of a virtual machine is located is different from a second storage address corresponding to the virtual machine, it is determined that the virtual machine is a virtual machine to be migrated and a migration manner corresponding to the virtual machine is migration storage, and a migration storage operation of the configuration file of the virtual machine is performed simultaneously, where the virtual machine may be a virtual machine in the preset second number of virtual machines or another virtual machine in a monitoring range. That is, when performing migration operations in different manners, such as host migration, migration storage, and the like, on a plurality of virtual machines within a monitoring range, the migration operations in different manners, such as host migration, migration storage, and the like, may be executed simultaneously, or the migration operations in different manners, such as host migration, migration storage, and the like, may be executed in sequence, which is not limited herein.
Further, in other embodiments, the migration module 03 may further be configured to:
and automatically migrating the determined virtual machines to be migrated according to a preset sequence, if one virtual machine to be migrated fails in the migration process, capturing the abnormal virtual machine to be migrated, namely the virtual machine to be migrated which fails in the migration, by using a preset abnormal capturing mechanism, and processing the virtual machine to be migrated which fails in the migration. And skipping the virtual machines to be migrated which are failed to be migrated, and continuously processing other virtual machines to be migrated so as to ensure that the virtual machines are mutually independent in the migration process, and the migration of other virtual machines cannot be influenced by the failure of single migration.
Further, in other embodiments, the migration module 03 may further be configured to:
and generating a migration log in the automatic migration process of the virtual machine to be migrated. For example, the migration log may record all virtual machines to be migrated, virtual machines to be migrated that have completed migration, virtual machines to be migrated that have not completed migration, migration time of each virtual machine to be migrated, migration manner corresponding to each virtual machine to be migrated, and the like, so as to quickly locate an error according to the migration log when subsequent maintenance or an error occurs.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better embodiment. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (such as a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present invention.
The preferred embodiments of the present invention have been described above with reference to the accompanying drawings, and are not to be construed as limiting the scope of the invention. The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments. Additionally, while a logical order is shown in the flow diagrams, in some cases, the steps shown or described may be performed in an order different than here.
Those skilled in the art can implement the invention in various modifications, such as features from one embodiment can be used in another embodiment to yield yet a further embodiment, without departing from the scope and spirit of the invention. Any modification, equivalent replacement and improvement made within the technical idea of using the present invention should be within the scope of the right of the present invention.

Claims (6)

1. A migration method of a virtual machine, the method comprising the steps of:
A. collecting relevant information of all virtual machines in a monitoring range, wherein the relevant information comprises: the method comprises the steps of running and storing states of a virtual machine and the running and storing states of a host machine of the virtual machine, wherein the running and storing states of the virtual machine comprise the memory occupancy rate of the virtual machine, the number of background tasks running, the storing position and the storing size, and the running and storing states of the host machine of the virtual machine comprise the memory utilization rate of the host machine of the virtual machine, the number of all managed virtual machines, the size of the current storing space and the size of the residual storing space;
B. determining virtual machines to be migrated and corresponding migration modes in all the virtual machines according to the relevant information and preset migration rules, wherein the migration modes comprise host migration, migration storage, and host migration and migration storage;
C. automatically migrating the virtual machine to be migrated according to the migration mode;
the step B comprises the following steps:
if a first storage address where a configuration file of a virtual machine is located is different from a second storage address corresponding to the virtual machine, determining that the virtual machine is a virtual machine to be migrated, and determining that a corresponding migration mode is migration storage;
the step C comprises the following steps:
migrating and storing the configuration file of the virtual machine from the first storage address to the second storage address;
the method further comprises the following steps:
when the determined multiple virtual machines to be migrated are automatically migrated according to a preset sequence, if one virtual machine to be migrated fails in the migration process, capturing the virtual machine to be migrated which fails to migrate by using a preset exception capture mechanism, performing exception processing on the virtual machine to be migrated which fails to migrate, skipping the virtual machine to be migrated which fails to migrate, and continuing to migrate other virtual machines to be migrated;
the method further comprises the following steps:
in the process of automatically migrating the virtual machines to be migrated, a migration log is generated, and the migration log records all the virtual machines to be migrated, the virtual machines to be migrated that have completed migration, the virtual machines to be migrated that have not completed migration, the migration time of each virtual machine to be migrated, and the migration mode corresponding to each virtual machine to be migrated.
2. The method for migrating a virtual machine according to claim 1, wherein the step B includes:
if a plurality of virtual machines correspond to the same host and the number of the virtual machines corresponding to the host exceeds a preset first number, determining a preset second number of virtual machines in the virtual machines corresponding to the host as virtual machines to be migrated, and determining a corresponding migration mode as host migration;
the step C comprises the following steps:
migrating the preset second number of virtual machines from the host to other hosts.
3. The method for migrating a virtual machine according to claim 1, wherein the step B includes:
if a plurality of virtual machines share the same storage space and the storage size of the storage space exceeds a preset storage threshold, determining a preset third number of virtual machines in the storage space as virtual machines to be migrated, and determining a corresponding migration mode as migration storage;
the step C comprises the following steps:
and migrating the preset third number of virtual machines from the storage space to other storage spaces.
4. A migration apparatus of a virtual machine, the migration apparatus of the virtual machine comprising:
the acquisition module is used for acquiring relevant information of all virtual machines in a monitoring range, wherein the relevant information comprises: the method comprises the steps of running and storing states of a virtual machine and the running and storing states of a host machine of the virtual machine, wherein the running and storing states of the virtual machine comprise the memory occupancy rate of the virtual machine, the number of background tasks running, the storing position and the storing size, and the running and storing states of the host machine of the virtual machine comprise the memory utilization rate of the host machine of the virtual machine, the number of all managed virtual machines, the size of the current storing space and the size of the residual storing space;
the determining module is used for determining virtual machines to be migrated and corresponding migration modes in all the virtual machines according to the relevant information and preset migration rules, wherein the migration modes comprise host migration, migration storage and host migration and migration storage;
the migration module is used for automatically migrating the virtual machine to be migrated according to the migration mode;
the determination module is further to:
if a first storage address where a configuration file of a virtual machine is located is different from a second storage address corresponding to the virtual machine, determining that the virtual machine is a virtual machine to be migrated, and determining that a corresponding migration mode is migration storage;
the migration module is further to:
migrating and storing the configuration file of the virtual machine from the first storage address to the second storage address;
the migration module is further to:
when the determined multiple virtual machines to be migrated are automatically migrated according to a preset sequence, if one virtual machine to be migrated fails in the migration process, capturing the virtual machine to be migrated which fails to migrate by using a preset exception capture mechanism, performing exception processing on the virtual machine to be migrated which fails to migrate, skipping the virtual machine to be migrated which fails to migrate, and continuing to migrate other virtual machines to be migrated;
the migration module is further to:
in the process of automatically migrating the virtual machines to be migrated, a migration log is generated, and the migration log records all the virtual machines to be migrated, the virtual machines to be migrated that have completed migration, the virtual machines to be migrated that have not completed migration, the migration time of each virtual machine to be migrated, and the migration mode corresponding to each virtual machine to be migrated.
5. The virtual machine migration apparatus according to claim 4, wherein the determining module is further configured to:
if a plurality of virtual machines correspond to the same host and the number of the virtual machines corresponding to the host exceeds a preset first number, determining a preset second number of virtual machines in the virtual machines corresponding to the host as virtual machines to be migrated, and determining a corresponding migration mode as host migration;
the migration module is further to:
migrating the preset second number of virtual machines from the host to other hosts.
6. The virtual machine migration apparatus according to claim 4, wherein the determining module is further configured to:
if a plurality of virtual machines share the same storage space and the storage size of the storage space exceeds a preset storage threshold, determining a preset third number of virtual machines in the storage space as virtual machines to be migrated, and determining a corresponding migration mode as migration storage;
the migration module is further to:
and migrating the preset third number of virtual machines from the storage space to other storage spaces.
CN201710147699.8A 2017-03-13 2017-03-13 Virtual machine migration method and device Active CN107885575B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710147699.8A CN107885575B (en) 2017-03-13 2017-03-13 Virtual machine migration method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710147699.8A CN107885575B (en) 2017-03-13 2017-03-13 Virtual machine migration method and device

Publications (2)

Publication Number Publication Date
CN107885575A CN107885575A (en) 2018-04-06
CN107885575B true CN107885575B (en) 2021-04-27

Family

ID=61780461

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710147699.8A Active CN107885575B (en) 2017-03-13 2017-03-13 Virtual machine migration method and device

Country Status (1)

Country Link
CN (1) CN107885575B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109783196B (en) * 2019-01-17 2021-03-12 新华三信息安全技术有限公司 Virtual machine migration method and device

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103399791A (en) * 2013-07-23 2013-11-20 北京华胜天成科技股份有限公司 Method and device for migrating virtual machines on basis of cloud computing
CN103810016A (en) * 2012-11-09 2014-05-21 北京华胜天成科技股份有限公司 Method and device for realizing virtual machine migration and cluster system
CN105260226A (en) * 2015-09-23 2016-01-20 浙江网新恒天软件有限公司 Method for automatically migrating virtual machine on the basis of cloud platform

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103810016A (en) * 2012-11-09 2014-05-21 北京华胜天成科技股份有限公司 Method and device for realizing virtual machine migration and cluster system
CN103399791A (en) * 2013-07-23 2013-11-20 北京华胜天成科技股份有限公司 Method and device for migrating virtual machines on basis of cloud computing
CN105260226A (en) * 2015-09-23 2016-01-20 浙江网新恒天软件有限公司 Method for automatically migrating virtual machine on the basis of cloud platform

Also Published As

Publication number Publication date
CN107885575A (en) 2018-04-06

Similar Documents

Publication Publication Date Title
US11048688B2 (en) Deleting configuration items in a configuration management database
CN110489391B (en) Data processing method and related equipment
EP3606008A1 (en) Method and device for realizing resource scheduling
US10365964B1 (en) Data processing platform monitoring
CN104360878B (en) A kind of method and device of application software deployment
US11550628B2 (en) Performing runbook operations for an application based on a runbook definition
JP2011175357A5 (en) Management device and management program
US10341253B2 (en) Automatic consolidation of network resources
CN107453932B (en) Distributed storage system management method and device
CN108306749B (en) Monitoring system alarming method, monitoring system and monitoring device
CN105516266A (en) Service monitoring methods and system, and related devices
CN110278101B (en) Resource management method and equipment
CN108540582B (en) Terminal identification processing method, server and terminal
CN107885575B (en) Virtual machine migration method and device
WO2016095716A1 (en) Fault information processing method and related device
CN111930565B (en) Process fault self-healing method, device and equipment for components in distributed management system
CN111478792B (en) Cutover information processing method, system and device
CN105511952B (en) Resource self-migration method and system based on cloud computing platform
CN105787359A (en) Course guarding method and device
CN108154343B (en) Emergency processing method and system for enterprise-level information system
CN108228272B (en) WEB container generation processing method, equipment and server
CN113656378A (en) Server management method, device and medium
CN112612578A (en) Virtual machine monitoring method and device
CN104808985B (en) The management method and device of object in application program
WO2021096346A1 (en) A computer-implemented system for management of container logs and its method thereof

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