实战使用ADS&VSMT将物理机迁移到虚拟机(Virtual Server 2005)

我的环境:
需要迁移的物理机: Dell PowerEdge 850 OS: Windows Server 2003 SP1 简体中文标准版
安装有 ADS, Virtual Server 2005 R2 和 VSMT 的宿主机: PowerEdge 860 OS:Windows Server 2003 SP1 英文企业版
在该环境中另外还有一台DHCP Server

废话少说,开始!
一.安装

除了需要迁移的物理机以外,我们需要另外一台安装有 ADS 和 VSMT 的Windows Server 2003

Enterprise Edition 的服务器.
1. 安装 ADS 1.1
下载页面: http://www.microsoft.com/downloads/d...displaylang=en

系统需求
• 支持的操作系统: Windows Server 2003
ADS 1.1 只能安装在 Windows Server 2003 企业版上,不支持标准版.
具体的系统需求可以在 Automated Deployment Services System Requirements page 找.






2. 安装 VSMT
Note: VSMT 不支持 64bit 的平台.


3. 安装 ADS Agent
为了完成迁移动作,我们需要在物理机上安装 ADS Agent.


二.迁移
整个迁移过程可以归纳为以下三步:抓取物理机镜像,创建虚拟机,部署虚拟机.一共可以分为六个步骤(如下图所示)


首先,我们利用 GatherHW.exe 收集源系统的配置信息并且输出到一个 XML 文件中.
其次,通过 VMScript.exe 来执行硬件信息的验证和检查工作.另外, VMScript.exe 也会生成一些脚本文件通过 ADS task sequences 来执行迁移动作.
第三步,VMScript.exe 也会生成一些命令行脚本, Capture.cmd 和 Createvm.cmd 分别用来抓取物理机镜像和在 Virtual Server 2005 的宿主服务器上创建虚拟机. Deployvm.cmd则在宿主机上利用抓取到的镜像文件在刚刚创建好的虚拟机上去部署.
最后,会有一些部署后的调整,包括网络,存储,以及安装 Virtual Machine Additions 等等.

具体步骤如下(假设所有路径都是默认安装路径):
Step1 :
如果你的网络环境中的 DHCP 服务器是和 ADS 安装在同一台服务器上的,请在宿主机上执行以下命令:
C:\Program Files\Microsoft ADS\bin\ADSdhcpconfig.wsf /add

Step 2 :
在 VSMT 安装目录下有个 samples 目录,在宿主机上执行 CreateVirtualNetwork.vbs, 将会在 Virtual Server 2005 里面创建一个名为"VM0"的虚拟网络

以下所有的可执行文件都在宿主机 VSMT 的安装目录下:
Step 3 :
把 gatherhw.exe 从宿主机上复制到在需要迁移的物理机上,执行
GatherHW /f:<file.xml>
<file.xml> 即输出文件名
命令结果
 

引用:
Microsoft (R) Virtual Server Migration Toolkit - Gather H/W Tool version 541.0

Copyright (C) 2004 Microsoft Corporation. All rights reserved.

Writing configuration information to file: 'C:\file.xml'

Connected to WMI. Gathering Information. Please Wait.

Gathering System Summary.

Gathering Controller Info: 'IDE'.

Gathering Controller Info: 'SCSI'.

Gathering Disk Information

Gathering Logical Drive Information

Gathering Mounted Devices Information

Gathering Network Information

Gathering Video Information..

Gathering Parallel Port Information..

Gathering Sound Card Information..

Gathering CDROM Information..

Gathering Serial Port Information.

Gathering Services Information..

Gathering Driver Information.

Gathering Run Section Information

Gathering Hotfix Information..

Success.

Step 4:
将 file.xml 文件复制回宿主机的 VSMT 目录,执行 VMScript /hwvalidate /hwinfofile:<file.xml>
进行硬件的兼容性检查.
如果这一步检查通不过,那迁移过程就不能再继续了.

Note: 如果物理机上跑的是中文版(或者非英文版)的操作系统,你会看到类似如下的错误提示:
 

引用:
Parsing file: c:\file.xml
Checking configuration for incompatibilities.
Warning: A required patch file is missing. Refer to the
documentation for more info on how to provide this file.
File ntoskrnl.exe
Version 5.2.3790.1830
Language 2052
Potential source of this file is Service Pack 1.

Warning: A required patch file is missing. Refer to the
documentation for more info on how to provide this file.
File ntkrnlpa.exe
Version 5.2.3790.1830
Language 2052
Potential source of this file is Service Pack 1.

Error: Cannot find patch files for the operating system / service pack level in
the C:\Program Files\Microsoft VSMT\Patches\Source\ 5.2.3790.1830 (srv03_sp1_rtm.050324-1447) \sp1 directory.
ERROR: Configuration is not compatible.
Warning: Incompatibilities found in hardware config.
Error: Result Code:10

别担心.这不是什么大问题.因为 ADS 1.1 自带的这些 patch 文件都是英文版的,所以如果你的物理机跑的是非英文版的系统,就会出现这样的错误.解决方法:手动创建目录,并复制需要的文件,在这个例子里,我们需要创建"C:\Program Files\Microsoft VSMT\Patches\Cached\2052"目录及其子目录"5.2.3790.1830 (srv03_sp1_rtm.050324-1447)", 并且从简体中文版的 Windows Server 2003 SP1 的安装光盘中解压出 ntoskrnl.exe 和 ntkrnlpa.exe,复制到该目录下面.
如果一切正常,显示如下结果
 

引用:
Microsoft (R) Virtual Server Migration Toolkit - Vmscript Tool ver.6.0.541.0

Copyright (C) 2004 Microsoft Corporation. All rights reserved.

Parsing file: c:\file.xml

Checking configuration for incompatibilities.

No incompatibilities found.

Step 5:
在宿主机上执行:
 

引用:
VMScript /hwgeneratep2v /hwinfofile:<file.xml> /name:<VM_name> /vmConfigPath:<path to store VM config file> /virtualDiskPath:<path to store VM disks> /hwDestVS:<FQDN of Virtual Server host>

解释:
<VM_name> 就是虚拟机的名称
<task_path> 指定存储那些 ADS 任务序列和迁移脚本的路径
VMConfigPath and VirtualDiskPath 选项就是放虚拟机配置文件和虚拟磁盘的地方
hwDestVS 是宿主机的 FQDN .

Step 6:
所有的脚本都准备好了,开始迁移过程. 当然,你的物理机需要执行 PXE 启动.
在宿主机上执行命令:
C:\<VMST Directory>\p2v\<GuestMachine>\<GuestMachine>_Capture.cmd
然后重启物理机并且以 PXE 启动.

Note:如果物理机在启动过程中总是显示如下画面,


那么你很可能需要将如下两个驱动放到"Program Files\Microsoft
ADS\NBS\Repository\User\PreSystem"文件夹下面,并且重启 adsbuilder 服务.
这两个驱动是物理机的驱动,在这个例子里就是 PowerEdge 850 的驱动

1. 网卡驱动
2. SCSI 或者 RAID 驱动 (如果必要的话)



ADS内置的驱动不支持 PowerEdge 1750, 700 和 750 server 系列.而我的Server是 PowerEdge 850,也不支持,所以我们需要手工复制这些驱动到 ADS 的资料库.


 

引用:
Note: When supplementing NIC drivers, ensure that you have installed the hotfixes
referenced in Microsoft Knowledge Base articles 830413 and 829053 to fix the issue
relating to .inf file parsing.
BTW. These two hotfixs cannot download as a public user.

这些是微软的官方说明,不过我没装也通过了.

在抓取完成之后,你可以在宿主机的 ADS 管理界面中看到如下画面(一个镜像文件就是一个分区).


Step 7:
在 Virtual Server 2005 中创建虚拟机.
执行
C:\<VSMT Directory>\p2v\<GuestMachinet>\<GuestMachine>_CreateVM.cmd

Note: 该脚本创建的是固定大小的虚拟磁盘,所以最终的文件大小将和你的物理机的硬盘大小一致,如果你的物理机硬盘很大,比如300G,但是只使用了30G , 最终创建的磁盘大小也是300G而不是30G,这样就显得有些浪费空间,所以,我们可以修改一下脚本,来把这个磁盘减小一点.

打开 <GuestMachine>_CreateVM.cmd 查找:
 

引用:
echo Create disk:0 with size:302640MB
%VSMT_SRV_APP% -remoteVs:%VS_NAME% -CreateVirtualDisk -VirtualDiskPath:%VM_DISK_PATH%\<GuestMachine>_disk_1.vhd -VirtualDiskSize:302640 %VSMT_DEBUG_FLAGS% -nologo

把 302640 改小一点就成.

Step 8:
打开刚刚创建的虚拟机,准备开始部署.
Step 9.
执行命令
C:\<VSMT Directory>\p2v\<GuestMachine>\<GuestMachine>_DeployVM.cmd



在这一步完成之后,你就基本上已经将你的"实体机"虚拟化了.

如果这里出现错误,使用如下命令重新清空虚拟机,然后跳回 step 9 开始迁移过程:
C:\<VSMT Directory>\p2v\<GuestMachine>\<GuestMachine>_cleanupVM.cmd

剩下来的就是一些善后工作了,调整一下网络啦啥的,OK,Done!

参考文献:
WHITE PAPER VSMT
http://www.microsoft.com/windowsserv...hitepaper.mspx
VSMT FAQ
http://www.microsoft.com/windowsserv...on/vsmtfaq.msp

你可能感兴趣的:(虚拟机,职场,迁移,休闲)