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

本文介绍如何使用 Azure Site Recovery 将 SQL Server 虚拟机 (VM) 从 Azure 中的一个区域迁移到另一个区域。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 需是 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 failover 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 trial 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 into the Azure portal.

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

  3. 依次选择“监视 + 管理”、“备份和 Site Recovery (OMS)”。 Select Monitoring + Management and then select Backup and Site Recovery (OMS).

  4. 在“名称”下指定保管库的名称。 Under Name, specify a name for your vault.

  5. 在“资源组”下,在目标区域中创建新资源组,或选择目标区域中的现有资源组。 Under Resource Group, either create a new resource group in the target region, or select an existing resource group in the target region.

  6. 在“位置”下,从下拉列表中选择目标位置。 Under Location, select your target location from the drop-down.

  7. 选择“创建”以创建恢复服务保管库。 Select Create to create your Recovery Services vault.

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

  9. 在“概述”窗格中选择“复制”。 On the Overview pane, select Replicate.

    配置复制

  10. 选择“源”,然后选择“Azure”作为源。 Select Source and then select Azure as the source. 为其他下拉字段(例如源 VM 的位置)选择适当的值。Select the appropriate values for the other drop-down fields, such as the location for your source VMs. “源资源组”字段中只会显示位于“源位置”区域中的资源组。 Only resources groups located in the Source location region will be visible in the Source resource group field.

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

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

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

  14. 资源创建完成后,选择“启用复制”开始将 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.

  15. 可以检查复制状态,方法是导航到你的恢复保管库,选择“复制的项”,然后查看 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 checkbox 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. 即使关闭 VM 失败,故障转移也仍会继续。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: