Esxi主機配置文件備份及還原介紹

對於Vmware產品接觸仍是至關少的,由於公司的主要使用的是Microsoft產品,近期公司上線的OA系統就要建立在Vmware Vsphere主機上,因此公司採購了一臺HP 最新的4U(580G9)服務器做爲運行ESXI主機的物理設備,固然配置也不會過低,內存:256GB,磁盤:本地2塊300G磁盤,用於安裝系統,配置Raid1,而後掛載存儲鏈路1T磁盤空間,全部虛擬機都安裝在獨立磁盤中--存儲。主要的問題是僅僅這一臺Vsphere Host,因此對於平常的備份至關重要。網上不少帖子說,若是ESXI系統崩潰了,通常都是重裝(30分鐘),可是重裝後,系統不少配置就沒了,因此在維護過程當中,咱們建議是備份一下ESXI主機的配置文件,這樣重裝後,而後把備份的配置文件導入後咱們會少不少工做量的。因此下面咱們就介紹一下如何備份ESXI主機的配置文件及還原。html

wKioL1e1d_7DjBw8AAERjHKFz88917.png-wh_50

咱們這次使用powercli進行ESXI主機的備份及還原。首先是須要下載powercli工具;首先須要經過vmware註冊的帳戶登陸,而後單點下載---搜索powercli 進行相關版本下載shell

https://my.vmware.com/group/vmware/details?downloadGroup=PCLI630R1_OSS&productId=491windows

p_w_picpath

p_w_picpath

https://my.vmware.com/group/vmware/searchresults?client=my_download&site=my_download&proxystylesheet=my_download_en&gsa_lang=en&c=ALL&q=powercli+6.0bash

https://my.vmware.com/group/vmware/details?downloadGroup=PCLI630R1&productId=491服務器

p_w_picpath

下載後,咱們準備安裝在windows server2012r2上ide

p_w_picpath

p_w_picpath

p_w_picpath

開始安裝工具

p_w_picpath

p_w_picpath

p_w_picpath

所需組件安裝ui

p_w_picpath

開始安裝this

p_w_picpath

安裝完成3d

p_w_picpath

安裝後會有兩個組件,一個是x86,一個是64位的,因此咱們通常運行x64位的

p_w_picpath

運行成功

p_w_picpath

https://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&docType=kc&externalId=2042141&sliceId=1&docTypeID=DT_KB_1_1&dialogID=197519853&stateId=0%200%20197549962

注:若是運行powercli提示錯誤,咱們須要修改powercli的策略,相似windows powershell的命令同樣

使用get-executionpolicy查看狀態確實爲Restricted

使用set-executionpolicy將屬性從Restricted更改成remotesigned

咱們參考官方文檔,使用vsphere Powercli備份esxi主機的配置文件

Using the vSphere PowerCLI 備份

To back up the configuration data for an ESXi host using the vSphere PowerCLI, run this command:

Get-VMHostFirmware -VMHost ESXi_host_IP_address -BackupConfiguration -DestinationPath output_directory

Where ESXi_host_IP_address is the IP address of the ESXi host and output_directory is the name of the directory where the output file will be created.

For example:

Get-VMHostFirmware -VMHost 10.0.0.1 -BackupConfiguration -DestinationPath C:\Downloads

Note: A backup file is saved in the directory specified with the -DestinationPath option.

由於我當前只有一臺ESXI主機,192.168.5.188;在導出配置前,咱們須要鏈接到ESXI主機;

若是不會使用命令的話,咱們能夠先使用命令打開幫助文檔

get-powerCLIHelp connect-viserver

p_w_picpath

p_w_picpath

例子:Connect-VIServer ESXIHOST_IP -User 'root' -Password 'password'

因此咱們使用

Connect-VIServer 192.168.5.188 -User 'root' -Password 'password'

p_w_picpath

p_w_picpath

接下來咱們能夠判斷是否鏈接成功,可使用get-vm查看當前主機下的因此vm

p_w_picpath

成功鏈接到ESXI主機後,接下來咱們就是導出ESXI主機配置文件

咱們參考官方文檔,使用vsphere Powercli備份esxi主機的配置文件

Using the vSphere PowerCLI 備份

To back up the configuration data for an ESXi host using the vSphere PowerCLI, run this command:

Get-VMHostFirmware -VMHost ESXi_host_IP_address -BackupConfiguration -DestinationPath output_directory

Where ESXi_host_IP_address is the IP address of the ESXi host and output_directory is the name of the directory where the output file will be created.

For example:

Get-VMHostFirmware -VMHost 10.0.0.1 -BackupConfiguration -DestinationPath C:\Downloads

Note: A backup file is saved in the directory specified with the -DestinationPath option.

因此咱們運行

Get-VMHostFirmware -VMHost 192.168.5.188 -BackupConfiguration -DestinationPath d:\ESXIConfigurationBak

p_w_picpath

導出成功

p_w_picpath

若是要還原的話,仍是同樣的方式,先鏈接,而後再還原;

Using the vSphere PowerCLI 還原

Note: When restoring configuration data, the build number of the host must match the build number of the host that created the backup file. Use the -force option to override this requirement.

  1. Put the host into maintenance mode by running the command:    
         
    Where ESXi_host_IP_address is the IP address of the ESXi host.

  2. Set-VMHost -VMHost ESXi_host_IP_address -State 'Maintenance'
  3. Restore the configuration from the backup bundle by running the command:    

    Where ESXi_host_IP_address is the IP address of the ESXi host, backup_file is the name of the backup bundle to use for the restore, andusername and password are the credentials to use when authenticating with the host.      
    For example:      
    Set-VMHostFirmware -VMHost 10.0.0.1 -Restore -SourcePath c:\bundleToRestore.tgz -HostUser root -HostPassword exampleRootPassword

  4. Set-VMHostFirmware -VMHost ESXi_host_IP_address -Restore -SourcePath backup_file -HostUser username -HostPassword password

Additional Information

Note: The information about virtual machines is not stored in the config backup and the virtual machines must be re-inventoried from the datastore browser after a config backup restore. Also, bootbank information is not stored in a config backup. If needed, this must be backed up and downloaded separately in a compressed tar file.

For more information, see:

Note: if you have installed a version of vSphere later than 5.1, see the Command Line Document and PowerCLI Reference for that version in the VMware Documentation Library.

PowerCLI Notes:

  • Remember that the 64 bit version of PowerCLI is installed in C:\Program Files, and the 32 bit version is in C:\Program Files (x86).

  • You must always run PowerCLI as Administrator.

相關文章
相關標籤/搜索