我是靠谱客的博主 可耐发带,最近开发中收集的这篇文章主要介绍Esxi主机配置文件备份及还原介绍,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

对于Vmware产品接触还是相当少的,因为公司的主要使用的是Microsoft产品,近期公司上线的OA系统就要创建在Vmware Vsphere主机上,所以公司采购了一台HP 最新的4U(580G9)服务器作为运行ESXI主机的物理设备,当然配置也不会太低,内存:256GB,磁盘:本地2块300G磁盘,用于安装系统,配置Raid1,然后挂载存储链路1T磁盘空间,所有虚拟机都安装在独立磁盘中--存储。主要的问题是仅仅这一台Vsphere Host,所以对于日常的备份相当重要。网上很多帖子说,如果ESXI系统崩溃了,一般都是重装(30分钟),但是重装后,系统很多配置就没了,所以在维护过程中,我们建议是备份一下ESXI主机的配置文件,这样重装后,然后把备份的配置文件导入后我们会少很多工作量的。所以下面我们就介绍一下如何备份ESXI主机的配置文件及还原。

Esxi主机配置文件备份及还原介绍_文件备份

我们此次使用powercli进行ESXI主机的备份及还原。首先是需要下载powercli工具;首先需要通过vmware注册的账户登录,然后单点下载---搜索powercli 进行相关版本下载

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

Esxi主机配置文件备份及还原介绍_文件备份_02

Esxi主机配置文件备份及还原介绍_主机配置_03

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.0

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

Esxi主机配置文件备份及还原介绍_Esxi_04

下载后,我们准备安装在windows server2012r2上

Esxi主机配置文件备份及还原介绍_Esxi_05

Esxi主机配置文件备份及还原介绍_Esxi_06

Esxi主机配置文件备份及还原介绍_主机配置_07

开始安装

Esxi主机配置文件备份及还原介绍_Esxi_08

Esxi主机配置文件备份及还原介绍_Esxi_09

Esxi主机配置文件备份及还原介绍_主机配置_10

所需组件安装

Esxi主机配置文件备份及还原介绍_Esxi_11

开始安装

Esxi主机配置文件备份及还原介绍_文件备份_12

安装完成

Esxi主机配置文件备份及还原介绍_文件备份_13

安装后会有两个组件,一个是x86,一个是64位的,所以我们一般运行x64位的

Esxi主机配置文件备份及还原介绍_文件备份_14

运行成功

Esxi主机配置文件备份及还原介绍_Esxi_15

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

Esxi主机配置文件备份及还原介绍_文件备份_16

Esxi主机配置文件备份及还原介绍_主机配置_17

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

所以我们使用

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

Esxi主机配置文件备份及还原介绍_主机配置_18

Esxi主机配置文件备份及还原介绍_Esxi_19

接下来我们可以判断是否连接成功,可以使用get-vm查看当前主机下的所以vm

Esxi主机配置文件备份及还原介绍_主机配置_20

成功连接到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

Esxi主机配置文件备份及还原介绍_文件备份_21

导出成功

Esxi主机配置文件备份及还原介绍_主机配置_22

如果要还原的话,还是一样的方式,先连接,然后再还原;

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:

  • Backing Up Configuration Information with vicfg-cfgbackup section in the vSphere 5.1 Command Line Documentation

  • Get-VMHostFirmware section in the vSphere PowerCLI Reference

  • Set-VMHostFirmware section in the vSphere PowerCLI Reference

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.

最后

以上就是可耐发带为你收集整理的Esxi主机配置文件备份及还原介绍的全部内容,希望文章能够帮你解决Esxi主机配置文件备份及还原介绍所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(53)

评论列表共有 0 条评论

立即
投稿
返回
顶部