迁移到新硬件上的 Azure Stack HCIMigrate to Azure Stack HCI on new hardware

适用于 Azure Stack HCI,版本 20H2;Windows Server 2019,Windows Server 2016,Windows Server 2012 R2,Windows Server 2008 R2Applies to Azure Stack HCI, version 20H2; Windows Server 2019, Windows Server 2016, Windows Server 2012 R2, Windows Server 2008 R2

本主题介绍如何使用 Windows PowerShell 和 Robocopy 将 Windows Server 2012 R2、Windows Server 2016 或 Windows Server 2019 上的虚拟机 (VM) 文件迁移到新的 Azure Stack HCI 服务器硬件。This topic describes how to migrate virtual machine (VM) files on Windows Server 2012 R2, Windows Server 2016, or Windows Server 2019 to new Azure Stack HCI server hardware using Windows PowerShell and Robocopy. Robocopy 是一种用于将文件从一台服务器复制到另一台服务器的强大方法。Robocopy is a robust method for copying files from one server to another. 如果断开连接并继续从其最后已知状态运行,则会恢复。It resumes if disconnected and continues to work from its last known state. Robocopy 还支持通过服务器消息块 (SMB) 进行多线程文件复制。Robocopy also supports multi-threaded file copy over Server Message Block (SMB). 有关详细信息,请参阅 RobocopyFor more information, see Robocopy.

备注

不支持从 Windows Server 到 Azure Stack HCI 的 hyper-v 实时迁移和 Hyper-v 副本。Hyper-V Live Migration and Hyper-V Replica from Windows Server to Azure Stack HCI is not supported.

如果要迁移的 Windows 2012 R2 或更早版本上有 Vm,请参阅 迁移旧 vmIf you have VMs on Windows 2012 R2 or older that you want to migrate, see Migrating older VMs.

若要使用相同的硬件迁移到 Azure Stack HCI,请参阅 在同一硬件上迁移到 AZURE STACK hciTo migrate to Azure Stack HCI using the same hardware, see Migrate to Azure Stack HCI on the same hardware.

下图显示了一个 Windows Server 源群集和一个 Azure Stack 的 HCI 目标群集作为示例。The following diagram shows a Windows Server source cluster and an Azure Stack HCI destination cluster as an example. 也可以在独立服务器上迁移 Vm。You can also migrate VMs on stand-alone servers as well.

将群集迁移到 Azure Stack HCI

根据预期停机时间,在群集之间使用具有双 40 GB RDMA East-West 网络的单个 NIC,并为 32 multithreads 配置 Robocopy,可实现每小时 1.9 TB 的传输速度。In terms of expected downtime, using a single NIC with a dual 40 GB RDMA East-West network between clusters, and Robocopy configured for 32 multithreads, you can realize transfer speeds of 1.9 TB per hour.

备注

本文未介绍迁移延伸群集的 Vm 的情况。Migrating VMs for stretched clusters is not covered in this article.

在开始之前Before you begin

在开始迁移之前,需要考虑几个要求和事项:There are several requirements and things to consider before you begin migration:

  • 必须以管理员身份运行所有 Windows PowerShell 命令。All Windows PowerShell commands must be run As Administrator.

  • 对于源和目标群集,你必须拥有具有管理员权限的域凭据,对源和目标组织单位具有完全权限, (OU) 包含两个群集。You must have domain credentials with administrator permissions for both source and destination clusters, with full rights to the source and destination Organizational Unit (OU) that contains both clusters.

  • 这两个群集必须位于同一个 Active Directory 林和域中,以便在群集之间进行 Kerberos 身份验证,以便迁移 Vm。Both clusters must be in the same Active Directory forest and domain to facilitate Kerberos authentication between clusters for migration of VMs.

  • 这两个群集必须位于 Active Directory OU 中,此 ou 组策略对象 (GPO) 阻止继承在此 OU 上设置。Both clusters must reside in an Active Directory OU with Group Policy Object (GPO) Block inheritance set on this OU. 这可确保没有域级 Gpo 和安全策略会影响迁移。This ensures no domain-level GPOs and security policies can impact the migration.

  • 这两个群集都必须连接到同一时间源,以支持群集之间一致的 Kerberos 身份验证。Both clusters must be connected to the same time source to support consistent Kerberos authentication between clusters.

  • 记下源群集上的 Vm 所使用的 Hyper-v 虚拟交换机名称。Make note of the Hyper-V virtual switch name used by the VMs on the source cluster. 导入 Vm 之前,必须为 Azure Stack HCI 目标群集 "虚拟机网络" 使用相同的虚拟交换机名称。You must use the same virtual switch name for the Azure Stack HCI destination cluster "virtual machine network" prior to importing VMs.

  • 删除源 Vm 的所有 ISO 映像文件。Remove any ISO image files for your source VMs. 这是使用 硬件部分VM 属性 中的 hyper-v 管理器完成的。This is done using Hyper-V Manager in VM Properties in the Hardware section. 对于任何虚拟 CD/DVD 驱动器,请选择 " 删除 "。Select Remove for any virtual CD/DVD drives.

  • 关闭源群集上的所有 Vm。Shutdown all VMs on the source cluster. 这是确保在整个迁移过程中保持版本控制和状态所必需的。This is required to ensure version control and state are maintained throughout the migration process.

  • 检查 Azure Stack HCI 是否支持你的 Vm 版本,以根据需要导入和更新 Vm。Check if Azure Stack HCI supports your version of the VMs to import and update your VMs as needed. 请参阅 VM 版本支持和更新 部分,了解如何执行此操作。See the VM version support and update section on how to do this.

  • 备份源群集上的所有 Vm。Backup all VMs on your source cluster. 完成所有应用程序和数据的崩溃一致性备份,以及所有数据库的应用程序一致性备份。Complete a crash-consistent backup of all applications and data and an application-consistent backup of all databases. 若要备份到 Azure,请参阅 使用 Azure 备份To backup to Azure, see Use Azure Backup.

  • 为源群集 Vm 和域控制器创建检查点,以防必须回滚到之前的状态。Make a checkpoint of your source cluster VMs and domain controller in case you have to roll back to a prior state. 这不适用于物理服务器。This is not applicable for physical servers.

  • 请确保源和目标群集存储网络之间的最大巨型帧大小相同,特别是 RDMA 网络适配器及其各自的交换机网络端口,以便提供最有效的端到端传输数据包大小。Ensure the maximum Jumbo frame sizes are the same between source and destination cluster storage networks, specifically the RDMA network adapters and their respective switch network ports to provide the most efficient end-to-end transfer packet size.

  • 请记下源群集上的 Hyper-v 虚拟交换机名称。Make note of the Hyper-V virtual switch name on the source cluster. 你需要在目标群集上重复使用它。You will reuse it on the destination cluster.

  • Azure Stack HCI 硬件的容量和配置应至少等于源硬件。The Azure Stack HCI hardware should have at least equal capacity and configuration as the source hardware.

  • 最大程度地减少源群集和目标群集之间的网络跃点数或物理距离,以加快文件传输速度。Minimize the number of network hops or physical distance between the source and destination clusters to facilitate the fastest file transfer.

VM 版本支持和更新VM version support and update

下表列出了 Windows Server 操作系统版本及其 VM 版本。This table lists the Windows Server OS versions and their VM versions.

无论 VM 可能运行于哪个操作系统版本,直接迁移到 Azure Stack HCI 支持的最低 VM 版本都是版本5.0。Regardless of the OS version a VM may be running on, the minimum VM version supported for direct migration to Azure Stack HCI is version 5.0. 这表示 Windows Server 2012 R2 上 Vm 的默认版本。This represents the default version for VMs on Windows Server 2012 R2. 因此,在版本2.0、3.0 或4.0 上运行的任何 Vm 都必须在迁移之前更新为版本5.0。So any VMs running at version 2.0, 3.0, or 4.0 for example must be updated to version 5.0 before migration.

OS 版本OS version VM 版本VM version
Windows Server 2008 SP1Windows Server 2008 SP1 2.02.0
Windows Server 2008 R2Windows Server 2008 R2 3.03.0
Windows Server 2012Windows Server 2012 4.04.0
Windows Server 2012 R2Windows Server 2012 R2 5.05.0
Windows Server 2016Windows Server 2016 8.08.0
Windows Server 2019Windows Server 2019 9.09.0
Azure Stack HCIAzure Stack HCI 9.09.0

对于 Windows Server 2012 R2、Windows Server 2016 和 Windows Server 2019 上的 Vm,请先将所有 Vm 更新为源硬件上支持的最新 VM 版本,然后再运行 Robocopy 迁移脚本。For VMs on Windows Server 2012 R2, Windows Server 2016, and Windows Server 2019, update all VMs to the latest VM version supported on the source hardware first before running the Robocopy migration script. 这可确保成功导入 VM 的所有 Vm 至少5.0 版。This ensures all VMs are at least at version 5.0 for a successful VM import.

对于 Windows Server 2008 SP1、Windows Server 2008 R2-SP1 和 Windows 2012 上的 Vm,VM 版本将低于版本5.0。For VMs on Windows Server 2008 SP1, Windows Server 2008 R2-SP1, and Windows 2012, the VM version will be less than version 5.0. 这些 Vm 还使用 .xml 文件进行配置,而不是使用 vcmx 文件。These VMs also use an .xml file for configuration instead of an .vcmx file. 因此,不支持将 VM 直接导入 Azure Stack HCI。As such, a direct import of the VM to Azure Stack HCI is not supported. 在这些情况下,可以使用两个选项,如 迁移较旧的 vm中所述。In these cases, you have two options, as detailed in Migrating older VMs.

正在更新 VM 版本Updating the VM version

以下命令适用于 Windows Server 2012 R2 及更高版本。The following commands apply to Windows Server 2012 R2 and later. 使用以下命令显示单个服务器上的所有 VM 版本:Use the following command to show all VM versions on a single server:

Get-VM * | Format-Table Name,Version

显示群集上所有服务器中的所有 VM 版本:To show all VM versions across all servers on a cluster:

Get-VM –ComputerName (Get-ClusterNode)

将所有 Vm 更新到所有服务器上支持的最新版本:To update all VMs to the latest supported version on all servers:

Get-VM –ComputerName (Get-ClusterNode) | Update-VMVersion -Force

RDMA 建议RDMA recommendations

如果 (RDMA) 使用远程直接内存访问,则 Robocopy 可以利用它在群集之间复制 Vm。If you are using Remote Direct Memory Access (RDMA), Robocopy can leverage it for copying your VMs between clusters. 下面是有关使用 RDMA 的一些建议:Here are some recommendations for using RDMA:

  • 将两个群集连接到机架 (ToR) 交换机,以便使用源和目标群集之间最快的网络路径。Connect both clusters to the same top of rack (ToR) switch to use the fastest network path between source and destination clusters. 对于存储网络路径,这通常支持 10GbE/25GbE 或更高的速度,并利用 RDMA。For the storage network path this typically supports 10GbE/25GbE or higher speeds and leverages RDMA.

  • 如果源群集和目标群集之间的 RDMA 适配器或标准不同 (ROCE vs iWARP) ,则 Robocopy 将通过最快的可用网络来利用 TCP/IP 上的 SMB。If the RDMA adapter or standard is different between source and destination clusters (ROCE vs iWARP), Robocopy will instead leverage SMB over TCP/IP via the fastest available network. 这通常是 East-West 网络的双 10Gbe/25Gbe 或更快的速度,提供在群集之间复制 VM VHDX 文件的最佳方法。This will typically be a dual 10Gbe/25Gbe or higher speed for the East-West network, providing the most optimal way to copy VM VHDX files between clusters.

  • 若要确保 Robocopy 可以在群集 (东-西网络) 间利用 RDMA,请配置 RDMA 存储网络,使其在源群集和目标群集之间路由。To ensure Robocopy can leverage RDMA between clusters (East-West network), configure RDMA storage networks so they are routeable between the source and destination clusters.

创建新群集Create the new cluster

在创建 Azure Stack HCI 群集之前,需要在将位于群集中的每台新服务器上安装 Azure Stack HCI OS。Before you can create the Azure Stack HCI cluster, you need to install the Azure Stack HCI OS on each new server that will be in the cluster. 有关如何执行此操作的信息,请参阅 部署 AZURE STACK HCI 操作系统For information on how to do this, see Deploy the Azure Stack HCI operating system.

使用 Windows 管理中心或 Windows PowerShell 创建新群集。Use Windows Admin Center or Windows PowerShell to create the new cluster. 有关如何执行此操作的详细信息,请参阅 使用 Windows 管理中心创建 AZURE STACK hci 群集使用 windows POWERSHELL 创建 Azure Stack hci 群集For detailed information on how to do this, see Create an Azure Stack HCI cluster using Windows Admin Center and Create an Azure Stack HCI cluster using Windows PowerShell.

重要

Hyper-v 虚拟交换机在 VMSwitch 群集之间 () 名称必须相同。Hyper-V virtual switch (VMSwitch) names between clusters must be the same. 请确保在目标群集上创建的虚拟交换机名称与在所有服务器上的源群集中使用的名称相匹配。Make sure that virtual switch names created on the destination cluster match those used on the source cluster across all servers. 请在导入 Vm 之前验证开关名称是否相同。Verify the switch names for the same before you import the VMs.

备注

必须先将 Azure Stack HCI 群集注册到 Azure,然后才能在该群集上创建新的 Vm。You must register the Azure Stack HCI cluster with Azure before you can create new VMs on it. 有关详细信息,请参阅 向 Azure 注册For more information, see Register with Azure.

运行迁移脚本Run the migration script

下面的 PowerShell 脚本 Robocopy_Remote_Server_.ps1 使用 Robocopy 将 VM 文件及其从属目录和元数据从源复制到目标群集。The following PowerShell script Robocopy_Remote_Server_.ps1 uses Robocopy to copy VM files and their dependent directories and metadata from the source to the destination cluster. 此脚本已从 TechNet 上的原始脚本修改 ,使用 PowerShell 和 robocopy 从: Robocopy 文件到远程服务器This script has been modified from the original script on TechNet at: Robocopy Files to Remote Server Using PowerShell and RoboCopy.

此脚本将所有 VM VHD、VHDX 和 .VMCX 文件复制到目标群集, (CSV) 指定群集共享卷。The script copies all VM VHD, VHDX, and VMCX files to your destination cluster for a given Cluster Shared Volume (CSV). 一次迁移一个 CSV。One CSV is migrated at a time.

迁移脚本在每个源服务器上本地运行,以利用 RDMA 和快速网络传输的好处。The migration script is run locally on each source server to leverage the benefit of RDMA and fast network transfer. 要执行此操作:To do this:

  1. 请确保将每个目标群集节点设置为目标 CSV 的 CSV 所有者。Make sure each destination cluster node is set to the CSV owner for the destination CSV.

  2. 若要确定要复制的所有 VM VHD 和 VHDX 文件的位置,请使用以下 cmdlet。To determine the location of all VM VHD and VHDX files to be copied, use the following cmdlet. 查看 C:\vmpaths.txt 文件以确定 Robocopy 的最顶层源文件路径,步骤4:Review the C:\vmpaths.txt file to determine the topmost source file path for Robocopy to start from for step 4:

    Get-ChildItem -Path "C:\Clusterstorage\Volume01\*.vhd*" -Recurse > c:\vmpaths.txt
    

    备注

    如果 VHD 和 VHDX 文件位于同一卷上的不同路径,则需要为每个不同的路径运行迁移脚本,以将它们全部复制。If your VHD and VHDX files are located in different paths on the same volume, you will need to run the migration script for each different path to copy them all.

  3. 更改以下三个变量,使源群集 VM 路径与目标群集 VM 路径匹配:Change the following three variables to match the source cluster VM path with the destination cluster VM path:

    • $Dest_Server = "Node01"
    • $source = "C:\Clusterstorage\Volume01"
    • $dest = "\\$Dest_Server\C$\Clusterstorage\Volume01"
  4. 在每个 Windows Server 源服务器上运行以下脚本:Run the following script on each Windows Server source server:

<#
#===========================================================================  
# Script: Robocopy_Remote_Server_.ps1
#===========================================================================  
.DESCRIPTION:
Change the following variables to match your source cluster VM path with the destination cluster VM path. Then run this script on each source Cluster Node CSV owner and make sure the destination cluster node is set to the CSV owner for the destination CSV.

        Change $Dest_Server = "Node01"
        Change $source  = "C:\Clusterstorage\Volume01"
        Change $dest = "\\$Dest_Server\C$\Clusterstorage\Volume01"
#>

$Space       = Write-host ""
$Dest_Server = "Node01"
$source      = "C:\Clusterstorage\Volume01"
$dest        = "\\$Dest_Server\C$\Clusterstorage\Volume01"
$Logfile     = "c:\temp\Robocopy1-$date.txt"
$date        = Get-Date -UFormat "%Y%m%d"
$cmdArgs     = @("$source","$dest",$what,$options)  
$what        = @("/COPYALL")
$options     = @("/E","/MT:32","/R:0","/W:1","/NFL","/NDL","/LOG:$logfile","/xf")
 
## Get Start Time
$startDTM = (Get-Date)
 
$Dest_Server     = "Node01"
$TARGETDIR   = \\$Dest_Server\C$\Clusterstorage\Volume01
$Space
Clear
## Provide Information
Write-host ".....Copying Virtual Machines FROM $Source to $TARGETDIR ....................." -fore Green -back black
Write-Host "........................................." -Fore Green

## Kick off the copy with options defined  
robocopy @cmdArgs
 
## Get End Time
$endDTM = (Get-Date)
 
## Echo Time elapsed
$Time = "Elapsed Time: = $(($endDTM-$startDTM).totalminutes) minutes"  
## Provide time it took
Write-host ""
Write-host " Copy Virtual Machines to $Dest_Server has been completed......" -fore Green -back black
Write-host " Copy Virtual Machines to $Dest_Server took $Time        ......" -fore Cyan

导入 VmImport the VMs

最佳做法是为每个群集节点至少创建一个群集共享卷 (CSV) ,以便为每个 CSV 所有者启用虚拟机平衡,从而提高 VM 工作负荷的复原能力、性能和规模。A best practice is to create at least one Cluster Shared Volume (CSV) per cluster node to enable an even balance of VMs for each CSV owner for increased resiliency, performance, and scale of VM workloads. 默认情况下,此平衡每五分钟自动发生一次,并需要在源群集节点和目标群集节点之间使用 Robocopy 来确保源和目标 CSV 所有者匹配以提供最理想的传输路径和速度。By default, this balance occurs automatically every five minutes and needs to be considered when using Robocopy between a source cluster node and the destination cluster node to ensure source and destination CSV owners match to provide the most optimal transfer path and speed.

在 Azure Stack HCI 群集上执行以下步骤以导入 Vm,使其高度可用,并启动这些 Vm:Perform the following steps on your Azure Stack HCI cluster to import the VMs, make them highly available, and start them:

  1. 运行以下 cmdlet 以显示所有 CSV 所有者节点:Run the following cmdlet to show all CSV owner nodes:

    Get-ClusterSharedVolume
    
  2. 对于每个服务器节点,请参阅 C:\Clusterstorage\Volume 并设置所有 vm 的路径(例如) C:\Clusterstorage\volume01For each server node, go to C:\Clusterstorage\Volume and set the path for all VMs - for example C:\Clusterstorage\volume01.

  3. 在每个 CSV 所有者节点上运行以下 cmdlet,以在导入 VM 之前显示每个卷的所有 VM .VMCX 文件的路径。Run the following cmdlet on each CSV owner node to display the path to all VM VMCX files per volume prior to VM import. 修改路径,使其与你的环境匹配:Modify the path to match your environment:

    Get-ChildItem -Path "C:\Clusterstorage\Volume01\*.vmcx" -Recurse
    

    备注

    Windows Server 2012 R2 和更低版本的 Vm 使用 XML 文件而不是 VCMX 文件。Windows Server 2012 R2 and older VMs use an XML file instead of a VCMX file. 有关详细信息,请参阅 迁移较旧的 vm 部分。Fore more information, see the section Migrating older VMs.

  4. 为每个服务器节点运行以下 cmdlet,以导入、注册每个 CSV 所有者节点并使这些 Vm 高度可用。Run the following cmdlet for each server node to import, register, and make the VMs highly available on each CSV owner node. 这可确保虚拟机的分配实现最佳处理器和内存分配:This ensures an even distribution of VMs for optimal processor and memory allocation:

    Get-ChildItem -Path "C:\Clusterstorage\Volume01\*.vmcx" -Recurse | Import-VM -Register | Get-VM | Add-ClusterVirtualMachineRole
    
  5. 在每个节点上启动每个目标 VM:Start each destination VM on each node:

    Start-VM -Name
    
  6. 登录并验证所有 Vm 是否正在运行,以及你的所有应用和数据是否都存在:Log on and verify that all VMs are running and that all your apps and data are there:

    Get-VM -ComputerName Server01 | Where-Object {$_.State -eq 'Running'}
    
  7. 将 Vm 更新到最新版本,以便 Azure Stack HCI 充分利用所有改进:Update your VMs to the latest version for Azure Stack HCI to take advantage of all the advancements:

    Get-VM | Update-VMVersion -Force
    
  8. 脚本完成后,检查 Robocopy 日志文件中是否列出了列出的任何错误,并验证是否已成功复制所有 Vm。After the script has completed, check the Robocopy log file for any errors listed and to verify that all VMs are copied successfully.

迁移较旧的 VmMigrating older VMs

如果你有 Windows Server 2008 SP1、Windows Server 2008 R2-SP1、Windows Server 2012 或 Windows Server 2012 R2 Vm,则本部分适用于你。If you have Windows Server 2008 SP1, Windows Server 2008 R2-SP1, Windows Server 2012, or Windows Server 2012 R2 VMs, this section applies to you. 可以使用两个选项来处理这些 Vm:You have two options for handling these VMs:

  • 首先将这些 Vm 迁移到 Windows Server 2012 R2、Windows Server 2016 或 Windows Server 2019,更新 VM 版本,然后开始迁移过程。Migrate these VMs to Windows Server 2012 R2, Windows Server 2016, or Windows Server 2019 first, update the VM version, then begin the migration process.

  • 使用 Robocopy 将所有 VM Vhd 复制到 Azure Stack HCI。Use Robocopy to copy all VM VHDs to Azure Stack HCI. 然后创建新的 Vm,并将复制的 Vhd 附加到 Azure Stack HCI 中的 Vm。Then create new VMs and attach the copied VHDs to the VMs in Azure Stack HCI. 这会绕过这些较旧 Vm 的 VM 版本限制。This bypasses the VM version limitation for these older VMs.

Windows Server 2012 R2 和更早版本的 Hyper-v 主机使用 XML 文件格式进行 VM 配置,这不同于用于 Windows Server 2016 和更高版本 Hyper-v 主机的 VCMX 文件格式。Windows Server 2012 R2 and older Hyper-V hosts use an XML file format for their VM configuration, which is different than the VCMX file format used for Windows Server 2016 and later Hyper-V hosts. 这需要不同的 Robocopy 命令以将这些 Vm 复制到 Azure Stack HCI。This requires a different Robocopy command to copy these VMs to Azure Stack HCI.

选项1:分阶段迁移Option 1: Staged migration

这是一个两阶段的迁移,适用于托管在 Windows Server 2008 SP1、Windows Server 2008 R2-SP 和 Windows Server 2012 上的 Vm。This is a two-stage migration used for VMs hosted on Windows Server 2008 SP1, Windows Server 2008 R2-SP, and Windows Server 2012. 下面是你使用的过程:Here is the process you use:

  1. 发现要复制的所有 VM VHD 和 VHDX 文件的位置,然后查看该 vmpaths.txt 文件以确定 Robocopy 要从其开始的最顶层源文件路径。Discover the location of all VM VHD and VHDX files to be copied, then review the vmpaths.txt file to determine the topmost source file path for Robocopy to start from. 使用以下 cmdlet:Use the following cmdlet:

    Get-ChildItem -Path "C:\Clusterstorage\Volume01\*.vhd*" -Recurse > c:\vmpaths.txt
    
  2. 使用以下示例 Robocopy 命令,首先使用步骤1中确定的最顶层路径将 Vm 复制到 Windows Server 2012 R2:Use the following example Robocopy command to copy VMs to Windows Server 2012 R2 first using the topmost path determined in step 1:

    Robocopy \\2012R2-Clus01\c$\clusterstorage\volume01\Hyper-V\ \\20H2-Clus01\c$\clusterstorage\volume01\Hyper-V\ /E /MT:32 /R:0 /w:1 /NFL /NDL /copyall /log:c:\log.txt /xf

  3. 验证 VMSwitch Windows server 2012 r2 群集上使用的虚拟交换机 () 名称是否与 windows 2008 r2 或 Windows server 2008 R2-SP1 源上使用的交换机名称相同。Verify the virtual switch (VMSwitch) name on used on the Windows Server 2012 R2 cluster is the same as the switch name used on the Windows 2008 R2 or Windows Server 2008 R2-SP1 source. 若要显示群集中所有服务器上使用的交换机名称,请使用以下命令:To display the switch names used across all servers in a cluster, use this:

    Get-VMSwitch -CimSession $Servers | Select-Object Name
    

    根据需要重命名 Windows Server 20212 R2 上的交换机名称。Rename the switch name on Windows Server 20212 R2 as needed. 若要在群集中的所有服务器之间重命名交换机名称,请使用以下命令:To rename the switch name across all servers in the cluster, use this:

    Invoke-Command -ComputerName $Servers -ScriptBlock {rename-VMSwitch -Name $using:vSwitcholdName -NewName $using:vSwitchnewname}
    
  4. 将 Vm 复制并导入到 Windows Server 2012 R2:Copy and import the VMs to Windows Server 2012 R2:

    Get-ChildItem -Path "c:\clusterstorage\volume01\Hyper-V\*.xml"-Recurse
    
    Get-ChildItem -Path "c:\clusterstorage\volume01\image\*.xml" -Recurse    | Import-VM -Register | Get-VM | Add-ClusterVirtualMachineRole  
    
  5. 在 Windows Server 2012 R2 上,为所有 Vm 将 VM 版本更新为5.0:On Windows Server 2012 R2, update the VM version to 5.0 for all VMs:

    Get-VM | Update-VMVersion -Force
    
  6. 运行迁移脚本 ,将 vm 复制到 Azure Stack HCI。Run the migration script to copy VMs to Azure Stack HCI.

  7. 按照 导入 vm中的过程操作,将步骤3和步骤4替换为以下内容,以处理 XML 文件并将 vm 导入 Azure Stack HCI:Follow the process in Import the VMs, replacing Step 3 and Step 4 with the following to handle the XML files and to import the VMs to Azure Stack HCI:

    Get-ChildItem -Path "c:\clusterstorage\volume01\Hyper-V\*.xml"-Recurse
    
    Get-ChildItem -Path "c:\clusterstorage\volume01\image\*.xml" -Recurse    | Import-VM -Register | Get-VM | Add-ClusterVirtualMachineRole  
    
  8. 完成 导入 vm中的其余步骤。Complete the remaining steps in Import the VMs.

选项2:直接 VHD 副本Option 2: Direct VHD copy

此方法使用 Robocopy 将 Windows 2008 SP1、Windows 2008 R2-SP1 和 Windows 2012 上承载的 VM Vhd 复制到 Azure Stack HCI。This method uses Robocopy to copy VM VHDs that are hosted on Windows 2008 SP1, Windows 2008 R2-SP1, and Windows 2012 to Azure Stack HCI. 这会绕过这些较旧 Vm 支持的最低 VM 版本限制。This bypasses the minimum supported VM version limitation for these older VMs. 对于托管在 Windows Server 2008 SP1 和 Windows Server 2008 R2-SP1 中的 Vm,建议选择此选项。We recommend this option for VMs hosted on Windows Server 2008 SP1 and Windows Server 2008 R2-SP1.

托管在 Windows 2008 SP1 和 Windows 2008 R2-SP1 上的 Vm 仅支持第1代 Vhd 的第1代 Vm。VMs hosted on Windows 2008 SP1 and Windows 2008 R2-SP1 support only Generation 1 VMs with Generation 1 VHDs. 因此,需要在 Azure Stack HCI 上创建相应的第1代 Vm,以便可以将复制的 Vhd 附加到新 Vm。As such, corresponding Generation 1 VMs need to be created on Azure Stack HCI so that the copied VHDs can be attached to the new VMs. 请注意,无法将这些 Vhd 升级到第2代 Vhd。Note that these VHDs cannot be upgraded to Generation 2 VHDs.

备注

Windows Server 2012 支持第1代和第2代 Vm。Windows Server 2012 supports both Generation 1 and Generation 2 VMs.

下面是你使用的过程:Here is the process you use:

  1. 使用示例 Robocopy 将 Vm Vhd 直接复制到 Azure Stack HCI:Use the example Robocopy to copy VMs VHDs directly to Azure Stack HCI:

    Robocopy \\2012R2-Clus01\c$\clusterstorage\volume01\Hyper-V\ \\20H2-Clus01\c$\clusterstorage\volume01\Hyper-V\ /E /MT:32 /R:0 /w:1 /NFL /NDL /copyall /log:c:\log.txt /xf

  2. 创建新的第1代 Vm。Create new Generation 1 VMs. 有关如何执行此操作的详细信息,请参阅 管理 vmFor detailed information on how to do this, see Manage VMs.

  3. 将复制的 VHD 文件附加到新的 Vm。Attach the copied VHD files to the new VMs. 有关详细信息,请参阅 管理虚拟硬盘 (VHD) For detailed information, see Manage Virtual Hard Disks (VHD)

作为一个仅供参考,以下 Windows Server 来宾操作系统支持第2代 Vm:As an FYI, the following Windows Server guest operating systems support Generation 2 VMs:

  • Windows Server 2019Windows Server 2019
  • Windows Server 2016Windows Server 2016
  • Windows Server 2012 R2Windows Server 2012 R2
  • Windows Server 2012Windows Server 2012
  • Windows 10Windows 10
  • 64位版本的 Windows 8.1 (64) 64-bit versions of Windows 8.1 (64-bit)
  • 64位版本的 Windows 8 (64) 64-bit versions of Windows 8 (64-bit)
  • Linux (请参阅 支持的 linux 和 FreeBSD vm) Linux (See Supported Linux and FreeBSD VMs)

后续步骤Next steps