运行将 Hyper-V VM 灾难恢复到辅助站点的演练Run a DR drill for Hyper-V VMs to a secondary site

本文介绍如何使用 Azure Site Recovery,执行将 System Center Virtual Machine Manager V(MM) 云中管理的 Hyper-V VM 灾难恢复 (DR) 到辅助本地站点的演练。This article describes how to do a disaster recovery (DR) drill for Hyper-V VMs that are managed in System Center Virtual Machine Manager V(MM) clouds, to a secondary on-premises site, using Azure Site Recovery.

需要运行测试故障转移,在不丢失任何数据或造成停机的情况下,验证复制策略或执行灾难恢复演练。You run a test failover to validate your replication strategy, and perform a DR drill without any data loss or downtime. 测试故障转移不会对进行中的复制或生产环境造成任何影响。A test failover doesn't have any impact on the ongoing replication, or on your production environment.

测试故障转移的工作原理How do test failovers work?

假设你要运行从主要站点到辅助站点的测试故障转移。You run a test failover from the primary to the secondary site. 如果只想检查 VM 的故障转移情况,则可以直接运行测试故障转移,而无需在辅助站点上进行任何设置。If you simply want to check that a VM fails over, you can run a test failover without setting anything up on the secondary site. 若要验证应用故障转移是否按预期进行,则需要在辅助位置设置网络和基础结构。If you want to verify app failover works as expected, you will need to set up networking and infrastructure in the secondary location.

  • 可以针对单个 VM 或恢复计划运行测试故障转移。You can run a test failover on a single VM, or on a recovery plan.
  • 可以不通过网络、使用现有网络或者使用自动创建的网络运行测试故障转移。You can run a test failover without a network, with an existing network, or with an automatically created network. 下表中提供了有关这些选项的更多详细信息。More details about these options are provided in the table below.
    • 可以不使用网络运行测试故障转移。You can run a test failover without a network. 如果只想检查 VM 是否能够故障转移,但无法验证任何网络配置,则此选项非常有用。This option is useful if you simply want to check that a VM was able to fail over, but you won't be able to verify any network configuration.
    • 使用现有网络运行故障转移。Run the failover with an existing network. 我们建议不要使用生产网络。We recommend you don't use a production network.
    • 运行故障转移,让 Site Recovery 自动创建测试网络。Run the failover and let Site Recovery automatically create a test network. 在此情况下,Site Recovery 将自动创建网络,并在测试故障转移完成时清理该网络。In this case Site Recovery will create the network automatically, and clean it up when test failover is complete.
  • 需要选择用于测试故障转移的恢复点:You need to select a recovery point for the test failover:
    • 最新处理:此选项将 VM 故障转移到由 Site Recovery 处理的最新恢复点。Latest processed: This option fails a VM over to the latest recovery point processed by Site Recovery. 此选项提供低 RTO(恢复时间目标),因为无需费时处理未经处理的数据。This option provides a low RTO (Recovery Time Objective), because no time is spent processing unprocessed data.
    • 最新的应用一致:此选项将 VM 故障转移到由 Site Recovery 处理的最新应用程序一致恢复点。Latest app-consistent: This option fail over a VM to the latest application-consistent recovery point processed by Site Recovery.
    • 最新:此选项首先处理已发送到 Site Recovery 服务的所有数据,为每个 VM 创建恢复点,然后将其故障转移到该恢复点。Latest: This option first processes all the data that has been sent to Site Recovery service, to create a recovery point for each VM before failing over to it. 此选项提供最低的 RPO(恢复点目标),因为故障转移后创建的 VM 具有触发故障转移时复制到 Site Recovery 的所有数据。This option provides the lowest RPO (Recovery Point Objective), because the VM created after failover will have all the data replicated to Site Recovery when the failover was triggered.
    • 最新处理的多 VM:适用于包含一个或多个已启用多 VM 一致性的 VM 的恢复计划。Latest multi-VM processed: Available for recovery plans that include one or more VMs that have multi-VM consistency enabled. 已启用该设置的 VM 会故障转移到最新的常用多 VM 一致恢复点。VMs with the setting enabled fail over to the latest common multi-VM consistent recovery point. 其他 VM 故障转移到最新的已处理恢复点。Other VMs fail over to the latest processed recovery point.
    • 最新的多 VM 应用一致:此选项适用于包含一个或多个已启用多 VM 一致性的 VM 的恢复计划。Latest multi-VM app-consistent: This option is available for recovery plans with one or more VMs that have multi-VM consistency enabled. 属于复制组的 VM 会故障转移到最新的常用多 VM 应用程序一致恢复点。VMs that are part of a replication group fail over to the latest common multi-VM application-consistent recovery point. 其他 VM 故障转移到其最新的应用程序一致恢复点。Other VMs fail over to their latest application-consistent recovery point.
    • 自定义:使用此选项可将特定的 VM 故障转移到特定的恢复点。Custom: Use this option to fail over a specific VM to a particular recovery point.

准备网络Prepare networking

运行测试故障转移时,系统将要求为测试副本计算机选择网络设置。请参阅表中的摘要。When you run a test failover, you're asked to select network settings for test replica machines, as summarized in the table.

选项Option 详细信息Details
None 将在副本 VM 所在的主机上创建测试 VM。The test VM is created on the host on which the replica VM is located. 该 VM 不会添加到云中,且不会连接到任何网络。It isn't added to the cloud, and isn't connected to any network.

创建 VM 后,可将它连接到 VM 网络。You can connect the machine to a VM network after it has been created.
使用现有项Use existing 将在副本 VM 所在的主机上创建测试 VM。The test VM is created on the host on which the replica VM is located. 该 VM 不会添加到云中。It isn't added to the cloud.

创建与生产网络隔离的 VM 网络。Create a VM network that's isolated from your production network.

如果使用基于 VLAN 的网络,建议在 VMM 中创建一个单独逻辑网络(不在生产中使用)以实现此目的。If you're using a VLAN-based network, we recommend that you create a separate logical network (not used in production) in VMM for this purpose. 此逻辑网络用于创建实现测试故障转移所需的 VM 网络。This logical network is used to create VM networks for test failovers.

逻辑网络应至少与所有托管虚拟机的 Hyper-V 服务器中的一个网络适配器关联。The logical network should be associated with at least one of the network adapters of all the Hyper-V servers that are hosting virtual machines.

对于 VLAN 逻辑网络,应隔离添加到逻辑网络中的网络站点。For VLAN logical networks, the network sites that you add to the logical network should be isolated.

如果使用基于 Windows 网络虚拟化的逻辑网络,Azure Site Recovery 将自动创建隔离的 VM 网络。If you're using a Windows Network Virtualization-based logical network, Azure Site Recovery automatically creates isolated VM networks.
创建网络Create a network 根据在“逻辑网络”及其相关网站中指定的设置,自动创建一个临时测试网络。A temporary test network is created automatically based on the setting that you specify in Logical Network and its related network sites.

故障转移会检查是否已创建 VM。Failover checks that VMs are created.

最佳实践Best practices

  • 测试生产网络会导致生产工作负荷出现停机。Testing a production network causes downtime for production workloads. 灾难恢复演练进行期间,要求用户不要使用相关应用。Ask your users not to use related apps when the disaster recovery drill is in progress.

  • 测试网络无需与用于测试故障转移的 VMM 逻辑网络类型匹配。The test network doesn't need to match the VMM logical network type used for test failover. 但是,某些组合不起作用:But, some combinations don't work:

    • 如果副本使用 DHCP 和基于 VLAN 的隔离,则副本的 VM 网络不需要静态 IP 地址池。If the replica uses DHCP and VLAN-based isolation, the VM network for the replica doesn't need a static IP address pool. 因此,无法为测试故障转移使用 Windows 网络虚拟化,因为没有任何可用的地址池。So using Windows Network Virtualization for the test failover won't work because no address pools are available.

    • 如果副本网络使用“无隔离”并且测试网络使用“Windows 网络虚拟化”,则测试故障转移不起作用。Test failover won't work if the replica network uses no isolation, and the test network uses Windows Network Virtualization. 因为无隔离网络不具备创建 Windows 网络虚拟化网络所需的子网。This is because the no-isolation network doesn't have the subnets required to create a Windows Network Virtualization network.

  • 我们建议不要将所选的网络用于网络映射、测试故障转移。We recommend that you don't use the network you selected for network mapping, for test failover.

  • 故障转移后副本虚拟机连接到映射 VM 网络的方式取决于 VMM 控制台中 VM 网络的配置方式。How replica virtual machines are connected to mapped VM networks after failover depends on how the VM network is configured in the VMM console.

使用无隔离或 VLAN 隔离配置的 VM 网络VM network configured with no isolation or VLAN isolation

如果在 VMM 中配置了无隔离或 VLAN 隔离的 VM 网络,请注意以下事项:If a VM network is configured in VMM with no isolation, or VLAN isolation, note the following:

  • 如果为 VM 网络定义了 DHCP,则副本虚拟机通过为关联逻辑网络中的网络站点指定的设置连接到 VLAN ID。If DHCP is defined for the VM network, the replica virtual machine is connected to the VLAN ID through the settings that are specified for the network site in the associated logical network. 虚拟机从可用的 DHCP 服务器接收其 IP 地址。The virtual machine receives its IP address from the available DHCP server.
  • 无需为目标 VM 网络定义静态 IP 地址池。You don't need to define a static IP address pool for the target VM network. 如果为 VM 网络使用了静态 IP 地址池,则副本虚拟机通过为关联逻辑网络中的网络站点指定的设置连接到 VLAN ID。If a static IP address pool is used for the VM network, the replica virtual machine is connected to the VLAN ID through the settings that are specified for the network site in the associated logical network.
  • 虚拟机从为 VM 网络定义的池接收其 IP 地址。The virtual machine receives its IP address from the pool that's defined for the VM network. 如果未在目标 VM 网络上定义静态 IP 地址池,则 IP 地址分配会失败。If a static IP address pool isn't defined on the target VM network, IP address allocation will fail. 同时在将用于保护和恢复的源和目标 VMM 服务器上创建 IP 地址池。Create the IP address pool on both the source and target VMM servers that you will use for protection and recovery.

使用 Windows 网络虚拟化的 VM 网络VM network with Windows Network Virtualization

如果在 VMM 中配置了具有 Windows 网络虚拟化的 VM 网络,请注意以下事项:If a VM network is configured in VMM with Windows Network Virtualization, note the following:

  • 应为目标 VM 网络定义静态池,无论源 VM 网络是配置为使用 DHCP 还是静态 IP 地址池。You should define a static pool for the target VM network, regardless of whether the source VM network is configured to use DHCP or a static IP address pool.
  • 如果定义 DHCP,则目标 VMM 服务器会充当 DHCP 服务器,并从为目标 VM 网络定义的池中提供 IP 地址。If you define DHCP, the target VMM server acts as a DHCP server and provides an IP address from the pool that's defined for the target VM network.
  • 如果为源服务器定义了使用静态 IP 地址池,则目标 VMM 服务器将从池中分配 IP 地址。If use of a static IP address pool is defined for the source server, the target VMM server allocates an IP address from the pool. 在这两种情况下,如果未定义静态 IP 地址池,则 IP 地址分配会失败。In both cases, IP address allocation will fail if a static IP address pool is not defined.

准备基础结构Prepare the infrastructure

如果只想检查 VM 是否能够故障转移,可以直接运行测试故障转移,而无需准备基础结构。If you simply want to check that a VM can fail over, you can run a test failover without an infrastructure. 若要执行测试应用故障转移的完整灾难恢复演练,则需要在辅助站点中准备基础结构:If you want to do a full DR drill to test app failover, you need to prepare the infrastructure at the secondary site:

  • 若要使用现有网络运行测试故障转移,则应在该网络中准备 Active Directory、DHCP 和 DNS。If you run a test failover using an existing network, prepare Active Directory, DHCP, and DNS in that network.
  • 若要使用自动创建 VM 网络的选项运行测试故障转移,则需要先将基础结构资源添加到自动创建的网络,然后再运行测试故障转移。If you run a test failover with the option to create a VM network automatically, you need to add infrastructure resources to the automatically created network, before you run the test failover. 在恢复计划中用于测试故障转移的组 1 前面添加一个手动步骤可以简化此操作。In a recovery plan, you can facilitate this by adding a manual step before Group-1 in the recovery plan that you're going to use for the test failover. 然后向自动创建的网络添加基础结构资源,之后再运行测试故障转移。Then, add the infrastructure resources to the automatically created network before you run the test failover.

准备 DHCPPrepare DHCP

如果测试故障转移中涉及的虚拟机使用 DHCP,则应在隔离网络中创建测试 DHCP 服务器,以便进行测试故障转移。If the virtual machines involved in test failover use DHCP, create a test DHCP server within the isolated network for the purpose of test failover.

准备 Active DirectoryPrepare Active Directory

要运行测试故障转移以进行应用程序测试,测试环境中需要具有生产用 Active Directory 环境的副本。To run a test failover for application testing, you need a copy of the production Active Directory environment in your test environment. 有关详细信息,请参阅 Active Directory 的测试故障转移注意事项For more information, review the test failover considerations for Active Directory.

准备 DNSPrepare DNS

按如下所述准备 DNS 服务器以进行测试故障转移:Prepare a DNS server for the test failover as follows:

  • DHCP:如果虚拟机使用 DHCP,则应在测试 DHCP 服务器上更新测试 DNS 的 IP 地址。DHCP: If virtual machines use DHCP, the IP address of the test DNS should be updated on the test DHCP server. 如果使用的网络类型为 Windows 网络虚拟化,则 VMM 服务器充当 DHCP 服务器。If you're using a network type of Windows Network Virtualization, the VMM server acts as the DHCP server. 因此,应在测试性故障转移网络中更新 DNS 的 IP 地址。Therefore, the IP address of DNS should be updated in the test failover network. 在这种情况下,虚拟机向相关的 DNS 服务器注册自身。In this case, the virtual machines register themselves to the relevant DNS server.

  • 静态地址:如果虚拟机使用静态 IP 地址,则应在测试故障转移网络中更新测试 DNS 服务器的 IP 地址。Static address: If virtual machines use a static IP address, the IP address of the test DNS server should be updated in test failover network. 可能需要使用测试虚拟机的 IP 地址更新 DNS。You might need to update DNS with the IP address of the test virtual machines. 可以使用以下示例脚本实现此目的:You can use the following sample script for this purpose:

      Param(
      [string]$Zone,
      [string]$name,
      [string]$IP
      )
      $Record = Get-DnsServerResourceRecord -ZoneName $zone -Name $name
      $newrecord = $record.clone()
      $newrecord.RecordData[0].IPv4Address  =  $IP
      Set-DnsServerResourceRecord -zonename $zone -OldInputObject $record -NewInputObject $Newrecord
    

运行测试故障转移Run a test failover

本过程描述如何对恢复计划运行测试故障转移。This procedure describes how to run a test failover for a recovery plan. 或者,可以在“虚拟机”选项卡上对单个虚拟机运行故障转移。Alternatively, you can run the failover for a single virtual machine on the Virtual Machines tab.

  1. 选择“恢复计划” > “recoveryplan_name”。Select Recovery Plans > recoveryplan_name. 单击“故障转移” > “测试故障转移”。Click Failover > Test Failover.
  2. 在“测试故障转移”边栏选项卡上,指定在测试故障转移后,副本 VM 应如何连接到网络。On the Test Failover blade, specify how replica VMs should be connected to networks after the test failover.
  3. 在“作业”选项卡上跟踪故障转移进度 。Track failover progress on the Jobs tab.
  4. 故障转移完成后,验证 VM 是否成功启动。After failover is complete, verify that the VMs start successfully.
  5. 完成后,在恢复计划上单击“清理测试故障转移”。When you're done, click Cleanup test failover on the recovery plan. 在“说明”中,记录并保存与测试故障转移相关联的任何观测结果。In Notes, record and save any observations associated with the test failover. 此步骤会删除在测试故障转移期间由 Site Recovery 创建的所有 VM 和网络。This step deletes any VMs and networks that were created by Site Recovery during test failover.

测试故障转移

Tip

如果 IP 地址可用于测试故障转移网络,则在测试故障转移期间指定给虚拟机的 IP 地址与在运行计划或非计划故障转移时虚拟机收到的 IP 地址相同。The IP address given to a virtual machine during test failover is the same IP address that the virtual machine would receive for a planned or unplanned failover (presuming that the IP address is available in the test failover network). 如果同一 IP 地址在测试性故障转移网络中不可用,那么虚拟机会收到可在测试故障转移网络中使用的其他 IP 地址。If the same IP address isn't available in the test failover network, the virtual machine receives another IP address that's available in the test failover network.

运行到生产网络的测试故障转移Run a test failover to a production network

我们建议不要针对网络映射期间指定的生产恢复站点网络运行测试故障转移。We recommend that you don't run a test failover to your production recovery site network that you specified during network mapping. 但是,如果确实需要在故障转移后的 VM 中验证端到端网络连接,请注意以下几点:But if you do need to validate end-to-end network connectivity in a failed-over VM, note the following points:

  • 确保在执行测试故障转移时主 VM 已关闭。Make sure that the primary VM is shut down when you're doing the test failover. 如果未关闭,则将同时在同一网络中运行两台具有相同标识的虚拟机。If you don't, two virtual machines with the same identity will be running in the same network at the same time. 这可能会导致意外后果。That situation can lead to undesired consequences.
  • 清理测试故障转移 VM 时,对测试故障转移虚拟机所做的全部更改都会丢失。Any changes that you make to the test failover VMs are lost when you clean up the test failover virtual machines. 这些更改不会复制回到主 VM。These changes are not replicated back to the primary VMs.
  • 以这种方式执行测试会导致生产应用程序发生停机。Testing like this leads to downtime for your production application. 告知应用程序的用户不要在灾难恢复演练过程中使用该应用程序。Ask users of the application not to use the application when the DR drill is in progress.

后续步骤Next steps

成功运行灾难恢复演练后,可以运行完整故障转移After you have successfully run a DR drill, you can run a full failover.