Mar 19

[原]配置Vmware vSphere 5.0 Auto Deploy服务:配置Auto Deploy 服务 晴

linuxing , 15:32 , 网络服务 » 虚拟机 , 评论(0) , 引用(0) , 阅读(28188) , Via 本站原创 | |
    前文使用若干工具把第三方驱动集成到脱机文件库,并生成自定义主机镜像文件。接下来,就是把该文件部署到Auto Deploy 服务器上,以便物理ESXi 主机访问读取。Auto Deploy 依赖TFTP、DHCP 等服务,其本身提供身份鉴别、健康监测及基于HTTP的下载工作。当物理主机从电源启动到ESXi 加载,其过程可简略为:
引用
1.设置从网卡引导后,以PXE 方式激活,从DHCP服务器获得动态IP地址;
2.从TFTP服务器获得PXE 引导启动文件;
3.启动文件切换到gPXE 引导模型,访问Auto Deploy 服务器;
4.下载主机镜像文件到内存,然后进行ESXi 服务的启动工作。

所以,要完成整个配置过程,需要从TFTP等服务的配置开始。

五、配置DHCP和TFTP 服务
1.配置TFTP服务
这里使用红旗 DC Server 5.0 提供的TFTP服务,其托管在xinetd 服务下面,修改/etc/xinetd.d/tftp文件,把disable从yes 改为no:
引用
service tftp
{
  disable  = no
......}

2.配置DHCP服务
按标准的DHCP服务修改/etc/dhcpd.conf 配置文件,其中:
引用
class "pxeclients" {
    match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
    option vendor-class-identifier "PXEClient";
    vendor-option-space PXE;

    option PXE.mtftp-ip 0.0.0.0;

    # This is the name of the file the boot ROMs should download.
    # 指定PXE启动后下载的文件名,与后面的设定相匹配
    filename "undionly.kpxe.vmw-hardwired";

    # This is the name of the server they should get it from.
    # 这里指定TFTP服务器IP地址
    next-server 192.168.228.153;
}
option routers 192.168.228.153;
subnet 192.168.228.0 netmask 255.255.255.0 {
range 192.168.228.220 192.168.228.225;
}
#根据需要安装机器的网卡地址定义IP,并记录下来
host test {
hardware ethernet 00:50:56:AC:7B:84;
  fixed-address 192.168.228.165;
}

这里的192.168.228.153 就是提供DHCP 和TFTP 服务的机器IP,物理ESXi 主机从PXE引导后,就会从该服务器得到IP地址,然后访问指定的TFTP服务器下的undionly.kpxe.vmw-hardwired 文件。
可以通过绑定网卡MAC 地址给物理主机分配固定的IP,以避免动态IP带来的管理问题。

六、安装及配置Auto Deploy 服务
1.安装
直接运行安装程序,根据提示输出vCenter Server 的相关信息。在安装完毕后,使用vSphere Client 访问vCenter Server ,可以看到Auto Deploy 的图标:
点击在新窗口中浏览此图片

点击图标进入,从Actions 栏下面的“Download TFTP Boot Zip” 连接下载TFTP 引导所需的deploy-tftp.zip 文件:
点击在新窗口中浏览此图片

然后,解压并放到TFTP 服务器的根目录下。(Linux 下就是/tftp_boot
点击在新窗口中浏览此图片

至此,TFTP 服务准备工作完成,通过dhcpd 和 xinetd 启动两服务:

# service dhcpd restart
# service xinetd restart


2.准备ESXi 软件库
这工作在第一部分的操作时已经完成,但如果您保存自定义主机镜像库后已退出PowerCLI ,那么,则需要再次进入,并使用Get-DeployCommand 命令确认Auto Deploy 工具的cmdlet 是否可用:
点击在新窗口中浏览此图片

接着,连接vCenter Server,导入自定义的软件库:

Connect-VIServer -Server 192.168.228.155 -User hyphen -Password xxxxx
Add-EsxSoftwareDepot d:\VMware-ESXi-5.1.0-799733-with-Intel-82579LM-depot.zip

点击在新窗口中浏览此图片
(如果您在保存主机镜像库后没有退出PowerCLI,那么可以跳过这一步)

3.使用主机镜像配置文件创建Delpy 规则

New-DeployRule -Name "BootRule" -Item "NewAsyncProfile" -AllHosts

点击在新窗口中浏览此图片
创建新部署规则BootRule 的过程中,会将主机镜像配置文件解压上传到Auto Deploy 的Cache 目录中,以便物理主机在后续通过HTTP 服务获取。(其中的NewAsyncProfile就是Get-EsxImageProfile 查看的主机镜像文件)

确认新部署规则创建完成:
点击在新窗口中浏览此图片

最后,将新规则添加到活动规则集,以使该规则可用于Auto Deploy 服务器:

Add-DeployRule -DeployRule "BootRule"

点击在新窗口中浏览此图片
至此,Auto Delpy 服务配置完成。

七、物理主机引导进入ESXi
修改物理主机Bios 配置或敲热键使其通过网络引导,将获得动态IP及gPXE 启动:
点击在新窗口中浏览此图片

启动完成,会从Auto Deploy 下载对应的主机镜像配置文件:
点击在新窗口中浏览此图片

加载ESXi 完成:
点击在新窗口中浏览此图片

点击在新窗口中浏览此图片
与交互式安装到本地磁盘不同,相关模块加载到内存后,不用再进行安装配置过程,直接就可以访问控制台,或通过vSphere Clinet 访问。(默认访问用户名root ,密码为空。注意,因为配置是从Auto Deploy 服务器获取的,而当前ESXi 主机的配置文件是加载到内存中的。所以,修改当前主机配置文件,在服务器重启后将失效。我们应该把配置做成自定义主机镜像文件,上传到Auto Deploy ,以便实现持久化)

八、附录
1.AcceptanceLevel 接受程度 问题
每个释放的 VIB 都具有无法更改的接受程度。主机接受程度决定了能够在该主机上安装哪些 VIB。类似的,不同接受程度的VIB 无法混装在一起。如果在使用Add-EsxSoftwarePackage 为某个主机镜像添加软件包时报错:
引用
Add-EsxSoftwarePackage : VIB Intel_bootbank_Net-82579LM_2.0.12's acceptance level is community, which is not compliant with the ImageProfile acceptance level partner

点击在新窗口中浏览此图片
这有可能是因为使用tgz2vib5.cmd 创建的第三方驱动VIB 包级别与克隆的主机镜像级别不一致。解决办法就是在克隆主机镜像时指定接受程度级别:
引用
删除旧库:
PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> Remove-EsxImageProfile "NewAsyncProfile"
PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> Get-EsxImageProfile

Name                           Vendor          Last Modified   Acceptance Level
----                           ------          -------------   ----------------
ESXi-5.1.0-799733-no-tools     VMware, Inc.    2012-8-2 3:0... PartnerSupported
ESXi-5.1.0-799733-standard     VMware, Inc.    2012-8-2 3:0... PartnerSupported
创建:
PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> New-EsxImageProfile -CloneProfile "ESXi-5.1.0-799733-standard" -name "NewAsyncProfile" -Vendor "MyCorp" -AcceptanceLevel "CommunitySupported"

Name                           Vendor          Last Modified   Acceptance Level
----                           ------          -------------   ----------------
NewAsyncProfile                MyCorp          2012-8-2 3:0... CommunitySupp...

同样的原因,如果我们为现有ESXi 主机添加软件包,也可能会遇到相同的问题:
引用
要安装接受程度限制比主机少的 VIB,则可以使用 vSphere Client 或通过运行 esxcli software acceptance 命令来更改主机的接受程度。

最佳做法是设置主机接受程度,这样您就可以指定可以安装在主机上并与映像配置文件配合使用的 VIB,并且还可以指定期望的 VIB 接受程度。可通过打开ESXi 的ESXCLI 远程访问,通过esxcli 命令实现:

# esxcli software acceptance set --level=CommunitySupported
# esxcli software vib install -d /path/to/zip-file

或者用vSphere Client 修改:
点击在新窗口中浏览此图片

点击在新窗口中浏览此图片

点击在新窗口中浏览此图片

参考:了解 VIB 和主机的接受程度

2.管理部署规则
vSphere PowerCLI 的命令通常以New、Add、Get、Remove开头表示创建、添加、查询、删除的功能。例如部署规则是不能重复的,所以,创建相同名字的部署规则时,需要先删除,然后再创建:
引用
PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> Get-DeployRule -name "InitialBootRule"

Name        : InitialBootRule
PatternList :
ItemList    : {NewAsyncProfile }

PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> Remove-DeployRule "InitialBootRule" -Delete

PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> Get-DeployRule

PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> Get-EsxImageProfile -name "InitialBootRule"

Name                           Vendor          Last Modified   Acceptance Level
----                           ------          -------------   ----------------
NewAsyncProfile                MyCorp          2013-3-13 13... CommunitySupp...

PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> New-DeployRule -Name "InitialBootRule" -Item "NewAsyncProfile" -AllHosts

Name        : InitialBootRule
PatternList :
ItemList    : {NewAsyncProfile}

PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> Add-DeployRule -DeployRule "InitialBootRule"

Name        : InitialBootRule
PatternList :
ItemList    : {NewAsyncProfile}

Remove 中-Delete 表示完全删除,并提交,参考:
vSphere PowerCLI Reference Remove-DeployRule

3.排错
Troubleshooting vSphere Auto Deploy
Tags:
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]