In purchasing the server, the general will consider whether to support virtualization, server virtualization mainly related to CPU, and motherboard whether to support virtualization, the best companies in the industry is overtaken by the virtual VMware, the major server supports ESXI system They are generally support virtualization. Benefits of virtualization is a physical machine can be virtualized into a plurality of separate virtual servers, virtual servers are independent, non-interfering. As the author of the company's servers are equipped with ESXI systems, and virtualization management through VMware vSphere, but the problem is encountered: When there is a large number of virtual machines, manual snapshot policy becomes a waste of time, and not friendly. Focus of this paper is to introduce a batch snapshot policy to virtual machines with VMware's tools VMware PowerCli.
VMware PowerCli
VMware PowerCLI is in a command-line management tools. General management uses vSphrere Client or VMware vSphere Web Client, vSphere PowerCLI you can manage VMware vSphere or VMware vCenter host through the command line. In analogy to be here, PowerCLI equivalent dos command in the windows below, you can call directly to the underlying VMware's snapshot, etc., with high flexibility and programmability
Traditional snapshot of the virtual machine is performed by manually, as shown below
When the number of virtual machines is relatively small when the snapshot test by manual approach is relatively straightforward, but more the number of virtual machines (such as the author of the company's virtual machine 60, if all manually operated, will crazy), then how to achieve volume snapshots of virtual machines strategy?
VMware PowerCli installation
VMware PowerCli installation package I share in Baidu cloud disk ( https://pan.baidu.com/s/1fFm9jh8PJXBuqXJ3wEewTQ extract password: akux) versions exist, if interested can go to VMware's official website to download, but it looks like Charges. Employed herein is for the installation of VMware-PowerCLI6.5.
VMware-PowerCLI6.5 installation depends on the version 3.0 or more windows management framework, if the version is less than 3.0 in the installation process an error prompt information. windows management framework 3.0 can be installed on the windows of the official website to download, address: https://www.microsoft.com/en-us/download/details.aspx?id=34595 (here omitted the process windows management framework 3.0 directly next to it, need to restart after installation)
Double-click the installation file to start the installation, it will install the VIX and related plug-ins, as shown below:
Followed by installation of a PowerCLI
After installation is complete, create two shortcut on the desktop, a 30 and a 64, as in FIG.
Startup Configuration VMware PowerCli
As the author is using 64-bit system, so using a shortcut into the 64-bit, double-click to enter:
The reason given is due to the system default script execution policy to Restricted, at this time Powercli not function properly, you need to modify the execution policy RemoteSigned, of which there are two commands are as follows:
get-executionpolicy ### Viewing System script execution policy way
set-executionpolicy remotesigned ### remotesigned way to modify the test
Restart the interface you can enter the following window interface
VMware PowerCli achieve volume virtual machine management
power shell login server: connect-viserver 192.168.1.201 -user 'root' -password 'password'
192.168.1.201 IP address of the physical server
-user login username physical server
-password password for the corresponding
After logging interface may look as follows, indicating a successful login server
(1), view the server all the virtual machines: get-vm
(2) for all server snapshot, snapshot name is: 20180906:
get-vm | New-Snapshot -Name "20180906-2"
In PowerCli shown below:
Corresponding to the following information VMware vSphere console:
Similarly, on the boot of a virtual machine snapshot:
get-vm |where {$_.PowerState -eq "PoweredOn"} |New-Snapshot -Name "20180906"
(3) delete the snapshot of 20,180,906:
get-vm | get-snapshot -name "20180906" | remove-snapshot
Can be integrated on a physical server virtual machine for batch snapshot policy by the above command, on the adoption of the timing script execution and timing of the snapshot deletion policy, will be explained in the second part
PS: The official address of VMware powerCli: https://www.vmware.com/support/developer/PowerCLI/index.html
VMware PowerCli official official document: https://docs.microsoft.com/zh-cn/powershell/scripting/getting-started/cookbooks/using-format-commands-to-change-output-view?view=powershell-5.1