使用 Azure Site Recovery 将 SQL Server VM 移到 Azure 中的另一个区域Move a SQL Server VM to another region within Azure with Azure Site Recovery

适用于: Azure VM 上的 SQL Server

本文介绍如何使用 Azure Site Recovery 在 Azure 中将 SQL Server 虚拟机 (VM) 从一个区域迁移到另一个区域。This article teaches you how to use Azure Site Recovery to migrate your SQL Server virtual machine (VM) from one region to another within Azure.

将 SQL Server VM 移到另一个区域需要执行以下操作:Moving a SQL Server VM to a different region requires doing the following:

  1. 准备:确认源 SQL Server VM 和目标区域都已做好充分的迁移准备。Preparing: Confirm that both your source SQL Server VM and target region are adequately prepared for the move.
  2. 配置:如果要移动 SQL Server VM,该 VM 必须是 Azure Site Recovery 保管库中的复制对象。Configuring: Moving your SQL Server VM requires that it is a replicated object within the Azure Site Recovery vault. 需要将 SQL Server VM 添加到 Azure Site Recovery 保管库中。You need to add your SQL Server VM to the Azure Site Recovery vault.
  3. 测试:如果要迁移 SQL Server VM,必须将它从源区域故障转移到复制的目标区域。Testing: Migrating the SQL Server VM requires failing it over from the source region to the replicated target region. 为了确保移动过程成功,首先需要测试 SQL Server VM 是否可以成功故障转移到目标区域。To ensure that the move process will succeed, you need to first test that your SQL Server VM can successfully fail over to the target region. 这将有助于发现任何问题,并在执行实际移动时避免这些问题。This will help expose any issues and avoid them when performing the actual move.
  4. 移动:如果测试故障转移通过,并且你知道可以安全地迁移 SQL Server VM,就可以将 VM 移动到目标区域。Moving: Once your test failover passed, and you know that you are safe to migrate your SQL Server VM, you can perform the move of the VM to the target region.
  5. 清理:若要避免计费,请从保管库中删除 SQL Server VM,并删除资源组中留下的所有不必要的资源。Cleaning up: To avoid billing charges, remove the SQL Server VM from the vault, and any unnecessary resources that are left over in the resource group.

验证先决条件Verify prerequisites

  • 确认支持从源区域移动到目标区域。Confirm that moving from your source region to your target region is supported.
  • 查看方案体系结构和组件以及支持限制和要求Review the scenario architecture and components as well as the support limitations and requirements.
  • 验证帐户权限。Verify account permissions. 如果你创建了免费 Azure 帐户,那么你就是订阅的管理员。If you created your free Azure account, you're the administrator of your subscription. 如果你不是订阅管理员,请要求管理员分配你所需的权限。If you're not the subscription administrator, work with the administrator to assign the permissions that you need. 若要为 VM 启用复制,并使用 Azure Site Recovery 复制数据,必须:To enable replication for a VM and copy data using Azure Site Recovery, you must have:
    • 创建 VM 的权限。Permissions to create a VM. “虚拟机参与者”内置角色具有这些权限,这包括:The Virtual Machine Contributor built-in role has these permissions, which include:
      • 在所选资源组中创建 VM 的权限。Permissions to create a VM in the selected resource group.
      • 在所选虚拟网络中创建 VM 的权限。Permissions to create a VM in the selected virtual network.
      • 向所选存储帐户进行写入的权限。Permissions to write to the selected storage account.
      • 管理 Azure Site Recovery 操作的权限。Permissions to manage Azure Site Recovery operations. “Site Recovery 参与者”角色拥有管理恢复服务保管库中 Site Recovery 操作所需的全部权限。The Site Recovery Contributor role has all the permissions that are required to manage Site Recovery operations in a Recovery Services vault.

准备移动Prepare to move

为移动准备源 SQL Server VM 和目标区域。Prepare both the source SQL Server VM and the target region for the move.

准备源 SQL Server VMPrepare the source SQL Server VM

  • 请确保要移动的 SQL Server VM 上存在所有最新的根证书。Ensure that all the latest root certificates are on the SQL Server VM that you want to move. 如果不存在最新的根证书,则安全性约束将阻止数据复制到目标区域。If the latest root certificates are not there, security constraints will prevent data copy to the target region.
  • 对于 Windows VM,请在 VM 上安装所有最新的 Windows 更新,使所有受信任的根证书位于该计算机上。For Windows VMs, install all of the latest Windows updates on the VM, so that all the trusted root certificates are on the machine. 在离线环境中,请遵循组织的标准 Windows 更新和证书更新过程。In a disconnected environment, follow the standard Windows Update and certificate update process for your organization.
  • 对于 Linux VM,请遵循 Linux 分销商提供的指导,在 VM 上获取最新的受信任根证书和证书吊销列表。For Linux VMs, follow the guidance provided by your Linux distributor to get the latest trusted root certificates and certificate revocation list on the VM.
  • 确保未使用身份验证代理来控制要移动的 VM 的网络连接。Make sure you're not using an authentication proxy to control network connectivity for the VMs that you want to move.
  • 如果尝试移动的 VM 无法访问 Internet,或使用防火墙代理来控制出站访问,请检查要求。If the VM that you're trying to move doesn't have access to the internet, or it's using a firewall proxy to control outbound access, check the requirements.
  • 确定源网络布局和当前正在使用的所有资源。Identify the source networking layout and all the resources that you're currently using. 这包括但不限于负载均衡器、网络安全组 (NSG) 和公共 IP。This includes but isn't limited to load balancers, network security groups (NSGs), and public IPs.

准备目标区域Prepare the target region

  • 验证 Azure 订阅是否允许在用于灾难恢复的目标区域中创建 VM。Verify that your Azure subscription allows you to create VMs in the target region that's used for disaster recovery. 请联系支持部门,启用所需配额。Contact support to enable the required quota.
  • 请确保订阅中有足够的资源,能够支持大小与源 VM 匹配的 VM。Make sure that your subscription has enough resources to support VMs with size that match your source VMs. 如果使用 Site Recovery 将数据复制到目标区域,Site Recovery 会为目标 VM 选择相同的大小或尽可能接近的大小。If you're using Site Recovery to copy data to the target, Site Recovery chooses the same size, or the closest possible size for the target VM.
  • 请确保为源网络布局中标识的每个组件创建目标资源。Make sure that you create a target resource for every component that's identified in the source networking layout. 此步骤对于确保目标区域中具有与源区域中相同的所有功能很重要。This step is important to ensure that your VMs have all the functionality and features in the target region that you had in the source region.
    • 为源 VM 启用复制时,Azure Site Recovery 会自动发现并创建虚拟网络。Azure Site Recovery automatically discovers and creates a virtual network when you enable replication for the source VM. 此外可以预先创建网络,并将其分配到用户流中的 VM 以启用复制。You can also pre-create a network and assign it to the VM in the user flow for enabling replication. 需要手动创建目标区域中的其他任何资源。You need to manually create any other resources in the target region.
  • 若要根据源 VM 配置创建最常用的相关网络资源,请参阅以下文档:To create the most commonly used network resources that are relevant for you based on the source VM configuration, see the following documentation:
  • 若要在最终移动到目标区域之前测试配置,请在目标区域中手动创建非生产网络。Manually create a non-production network in the target region if you want to test the configuration before you perform the final move to the target region. 我们建议执行此步骤,因为这可以确保尽量减少对生产网络造成的干扰。We recommend this step because it ensures minimal interference with the production network.

配置 Azure Site Recovery 保管库Configure Azure Site Recovery vault

以下步骤演示如何使用 Azure Site Recovery 将数据复制到目标区域。The following steps show you how to use Azure Site Recovery to copy data to the target region. 在源区域以外的任何区域中创建恢复服务保管库。Create the Recovery Services vault in any region other than the source region.

  1. 登录 Azure 门户Sign in to the Azure portal.

  2. 从导航窗格的左上角选择“创建资源”。Choose to Create a resource from the upper-left hand corner of the navigation pane.

  3. 选择“监视和管理工具”,然后选择“备份和站点恢复”。 Select Monitoring & Management tools and then select Backup and Site Recovery.

  4. 在“基本”选项卡上的“项目详细信息”下,在目标区域中创建新的资源组或在目标区域中选择现有的资源组 。On the Basics tab, under Project details, either create a new resource group in the target region, or select an existing resource group in the target region.

  5. 在“实例详细信息”下,为保管库指定名称,然后从下拉列表中选择目标区域 。Under Instance Details, specify a name for your vault, and then select your target Region from the drop-down.

  6. 选择“查看 + 创建”,创建恢复服务保管库。Select Review + Create to create your Recovery Services vault.

  7. 从导航窗格的左上角选择“所有服务”,然后在搜索框中键入 recovery servicesSelect All services from the upper-left hand corner of the navigation pane and in the search box type recovery services.

  8. (可选)选择“恢复服务保管库”旁边的星号,将其添加到快速导航栏中。(Optionally) Select the star next to Recovery Services vaults to add it to your quick navigation bar.

  9. 选择“恢复服务保管库”,然后选择已创建的恢复服务保管库。Select Recovery services vaults and then select the Recovery Services vault you created.

  10. 在“复制的项”窗格中,选择“复制”。 On the Replicated Items pane, select Replicate.


  11. 选择“Azure 虚拟机”。Select Azure Virtual Machines. 仅位于“源位置”区域中的资源组才会显示在“源资源组”字段中 。Only resources groups located in the Source location region will be visible in the Source resource group field.

  12. 选择“虚拟机”,然后选择要迁移的虚拟机。Select Virtual machines and then choose the virtual machines you want to migrate. 选择“确定”以保存 VM 选择。Select OK to save your VM selection.

  13. 选择“设置”,然后从下拉列表中选择“目标位置” 。Select Settings, and then choose your Target location from the drop-down. 这应该是你之前准备的资源组。This should be the resource group you prepared earlier.

  14. 自定义复制后,选择“创建目标资源”,在新位置创建资源。Once you have customized replication, select Create target resources to create the resources in the new location.

  15. 资源创建完成后,选择“启用复制”,开始将 SQL Server VM 从源复制到目标区域。Once resource creation is complete, select Enable replication to start replication of your SQL Server VM from the source to the target region.

  16. 你可以通过导航到恢复保管库,选择“复制的项”,并查看 SQL Server VM 的状态来查看复制的状态 。You can check the status of replication by navigating to your recovery vault, selecting Replicated items and viewing the Status of your SQL Server VM. “受保护”状态指示复制已完成。A status of Protected indicates that replication has completed.


测试移动过程Test move process

以下步骤演示如何使用 Azure Site Recovery 测试移动过程。The following steps show you how to use Azure Site Recovery to test the move process.

  1. 导航到 Azure 门户的恢复服务保管库,选择“复制的项” 。Navigate to your Recovery Services vault in the Azure portal and select Replicated items.

  2. 选择要移动的SQL Server VM,确认“复制运行状况”显示为“正常”,然后选择“测试故障转移” 。Select the SQL Server VM you would like to move, verify that the Replication Health shows as Healthy and then select Test Failover.

    为 VM 测试故障转移

  3. 在“测试故障转移”页上,选择要用于故障转移的“最新的应用一致”恢复点,因为这是可以保证 SQL Server 数据一致性的唯一快照类型 。On the Test Failover page, select the Latest app-consistent recovery point to use for the failover, as that is the only type of snapshot that can guarantee SQL Server data consistency.

  4. 选择“Azure 虚拟网络”下的虚拟网络,然后选择“确定”以测试故障转移 。Select the virtual network under Azure virtual network and then select OK to test failover.


    我们建议使用单独的 Azure VM 网络进行故障转移测试。We recommend that you use a separate Azure VM network for the failover test. 不要使用在启用复制时设置的生产网络和最终要将 VM 移动到其中的生产网络。Don't use the production network that was set up when you enabled replication and that you want to move your VMs into eventually.

  5. 要监视进度,请导航到保管库,在“监视”下选择“Site Recovery 作业”,然后选择正在进行的“测试故障转移”作业 。To monitor progress, navigate to your vault, select Site Recovery jobs under Monitoring, and then select the Test failover job that's in progress.


  6. 测试完成后,导航至门户中的“虚拟机”并查看新创建的虚拟机。Once the test completes, navigate to Virtual machines in the portal and review the newly created virtual machine. 请确保 SQL Server VM 正在运行、大小适当并已连接到适当的网络。Make sure the SQL Server VM is running, is sized appropriately, and is connected to the appropriate network.

  7. 删除在测试中创建的 VM,因为在清理故障转移测试资源之前,“故障转移”选项将显示为灰色。Delete the VM that was created as part of the test, as the Failover option will be grayed out until the failover test resources are cleaned up. 导航回保管库,依次选择“复制的项”、“SQL Server VM”和“清理测试故障转移” 。Navigate back to the vault, select Replicated items, select the SQL Server VM, and then select Cleanup test failover. 在“备注”部分中记录并保存与测试相关的所有观察结果,然后选择“测试已完成”旁边的复选框。 删除测试故障转移虚拟机。Record and save any observations associated with the test in the Notes section and select the checkbox next to Testing is complete. Delete test failover virtual machines. 选择“确定”以在测试后清理资源。Select OK to clean up resources after the test.


移动 SQL Server VMMove the SQL Server VM

以下步骤演示如何将 SQL Server VM 从源区域移动到目标区域。The following steps show you how to move the SQL Server VM from your source region to your target region.

  1. 导航到“恢复服务”保管库,依次选择“复制的项”、VM、和“故障转移” 。Navigate to the Recovery Services vault, select Replicated items, select the VM, and then select Failover.


  2. 在“恢复点”下选择“最新的应用一致”恢复点 。Select the latest app-consistent recover point under Recovery Point.

  3. 选中“在开始故障转移之前关闭计算机”旁边的复选框。Select the check box next to Shut down the machine before beginning failover. Site Recovery 在触发故障转移之前会尝试关闭源 VM。Site Recovery will attempt to shut down the source VM before triggering the failover. 即使关闭失败,故障转移也仍会继续。Failover will continue even if shut down fails.

  4. 选择“确定”以启动故障转移。Select OK to start the failover.

  5. 可以从上一节中监视故障转移测试时查看的同一“Site Recovery 作业”页监视故障转移过程。You can monitor the failover process from the same Site Recovery jobs page you viewed when monitoring the failover test in the previous section.

  6. 该作业完成后,检查 SQL Server VM 是否按预期显示在目标区域中。After the job completes, check that the SQL Server VM appears in the target region as expected.

  7. 导航回保管库,依次选择“复制的项”、“SQL Server VM”和“提交”以完成到目标区域的移动过程 。Navigate back to the vault, select Replicated Items, select the SQL Server VM, and select Commit to finish the move process to the target region. 请等待提交作业完成。Wait until the commit job finishes.


只有应用一致的快照才能保证 SQL Server 数据一致性。SQL Server data consistency is only guaranteed with app-consistent snapshots. 最新处理的快照不能用于 SQL Server 故障转移,因为故障恢复快照不能保证 SQL Server 数据一致性。The latest processed snapshot can't be used for SQL Server failover as a crash recovery snapshot can't guarantee SQL Server data consistency.

清理源资源Clean up source resources

若要避免计费,请从保管库中删除 SQL Server VM,并删除任何不必要的关联资源。To avoid billing charges, remove the SQL Server VM from the vault, and delete any unnecessary associated resources.

  1. 导航回“Site Recovery”保管库,选择“复制的项”,然后选择“SQL Server VM” 。Navigate back to the Site Recovery vault, select Replicated items, and select the SQL Server VM.

  2. 选择“禁用复制”。Select Disable Replication. 选择禁用保护的原因,然后选择“确定”以禁用复制。Select a reason for disabling protection, and then select OK to disable replication.


    请务必执行此步骤,避免 Azure Site Recovery 复制产生费用。It is important to perform this step to avoid being charged for Azure Site Recovery replication.

  3. 如果没有计划重复使用源区域中的任何资源,请删除所有相关的网络资源和相应的存储帐户。If you have no plans to reuse any of the resources in the source region, delete all relevant network resources, and corresponding storage accounts.

后续步骤Next steps

有关详细信息,请参阅以下文章:For more information, see the following articles: