迁移到新硬件上的 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 东-西网络的单个 NIC,并为 32 个多线程配置 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) 块继承。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.

  • 请确保源和目标群集存储网络之间的最大 Jumbo 帧大小相同,特别是 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 运行的 OS 版本是什么,直接迁移到 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 都至少为版本 5.0,以实现成功的 VM 导入。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.

  • 如果源群集和目标群集(ROCE 与 iWARP)之间的 RDMA 适配器或标准不同,则 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. 这通常是东-西网络的双 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 Admin Center 或 Windows PowerShell 创建新群集。Use Windows Admin Center or Windows PowerShell to create the new cluster. 有关如何执行此操作的详细信息,请参阅使用 Windows Admin Center 创建 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 注册 Azure Stack HCI 群集,然后才能在其上新建 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,从而提高 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,使其具有高可用性,然后启动它们: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,以导入和注册 VM,并使其在每个 CSV 所有者节点上具有高可用性。Run the following cmdlet for each server node to import, register, and make the VMs highly available on each CSV owner node. 这样可以确保 VM 的均匀分布,从而实现最佳处理器和内存分配: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. 然后,在 Azure Stack HCI 中新建 VM,并将复制的 VHD 附加到 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. 验证 Windows Server 2012 R2 群集上使用的虚拟交换机 (VMSwitch) 名称是否与 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 2012 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 VMLinux (See Supported Linux and FreeBSD VMs)

后续步骤Next steps