将 Amazon Web Services (AWS) VM 迁移到 AzureMigrate Amazon Web Services (AWS) VMs to Azure

本教程介绍如何使用 Azure Site Recovery 将 Amazon Web Services (AWS) 虚拟机 (VM) 迁移到 Azure VM。This tutorial shows you how to migrate Amazon Web Services (AWS) virtual machines (VMs) to Azure VMs by using Azure Site Recovery. 将 AWS EC2 实例迁移到 Azure 时,VM 会被视作本地物理计算机。When you migrate AWS EC2 instances to Azure, the VMs are treated like physical, on-premises computers. 本教程介绍如何执行下列操作:In this tutorial, you learn how to:

  • 验证先决条件Verify prerequisites
  • 准备 Azure 资源Prepare Azure resources
  • 为迁移准备 AWS EC2 实例Prepare AWS EC2 instances for migration
  • 部署配置服务器Deploy a configuration server
  • 为 VM 启用复制Enable replication for VMs
  • 测试故障转移,确保一切正常运行Test the failover to make sure everything's working
  • 运行到 Azure 的一次性故障转移Run a onetime failover to Azure

如果没有 Azure 订阅,可在开始前创建一个试用帐户If you don't have an Azure subscription, create a trial account before you begin.


  • 确保要迁移的 VM 运行的是支持的 OS 版本。Ensure that the VMs that you want to migrate are running a supported OS version. 受支持的版本包括:Supported versions include:

    • Windows Server 2016Windows Server 2016
    • Windows Server 2012 R2Windows Server 2012 R2
    • Windows Server 2012Windows Server 2012
    • 64 位版本的 Windows Server 2008 R2 SP1 或更高版本64-bit version of Windows Server 2008 R2 SP1 or later
    • CentOS 6.4 到 6.10、7.1 到 7.6(仅限 HVM 虚拟化实例)CentOS 6.4 to 6.10, 7.1 to 7.6 (HVM virtualized instances only)
  • 必须在要复制的每个 VM 上安装移动服务。The Mobility service must be installed on each VM that you want to replicate.


    为 VM 启用复制后,Site Recovery 会自动安装此服务。Site Recovery installs this service automatically when you enable replication for the VM. 若要进行自动安装,必须在 EC2 实例上准备一个帐户,Site Recovery 将使用该帐户访问 VM。For automatic installation, you must prepare an account on the EC2 instances that Site Recovery will use to access the VM. 可以使用域帐户或本地帐户。You can use a domain or local account.

    • 对于 Linux VM,该帐户应是源 Linux 服务器上的根帐户。For Linux VMs, the account should be root on the source Linux server.

    • 对于 Windows VM,如果使用的不是域帐户,则在本地计算机上禁用远程用户访问控制:For Windows VMs, if you're not using a domain account, disable Remote User Access control on the local machine:

      在注册表的 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System 下,添加 DWORD 项 LocalAccountTokenFilterPolicy 并将值设为 1 。In the registry, under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System, add the DWORD entry LocalAccountTokenFilterPolicy and set the value to 1.

  • 一个单独的 EC2 实例,可以用作 Site Recovery 配置服务器。A separate EC2 instance that you can use as the Site Recovery configuration server. 此实例必须运行 Windows Server 2012 R2。This instance must be running Windows Server 2012 R2.

准备 Azure 资源Prepare Azure resources

必须在 Azure 中准备一些资源,供迁移后的 EC2 实例使用。You must have a few resources ready in Azure for the migrated EC2 instances to use. 其中包括存储帐户、保管库和虚拟网络。These include a storage account, a vault, and a virtual network.

创建存储帐户Create a storage account

已复制计算机的映像保存在 Azure 存储中。Images of replicated machines are held in Azure Storage. 在从本地故障转移到 Azure 时,会从存储中创建 Azure VM。Azure VMs are created from storage when you fail over from on-premises to Azure.

  1. Azure 门户的左菜单中,选择“创建资源” > “存储” > “存储帐户” 。In the Azure portal, in the left menu, select Create a resource > Storage > Storage account.
  2. 输入存储帐户的名称。Enter a name for your storage account. 在这些教程中,我们使用名称 awsmigrated2017In these tutorials, we use the name awsmigrated2017. 名称必须符合以下条件:The name must:
    • 在 Azure 中唯一Be unique in Azure
    • 长度为 3 到 24 个字符Be between 3 and 24 characters
    • 仅包含数字和小写字母Contain only numbers and lowercase letters
  3. 保留“部署模型”、“帐户类型”、“性能”和“需要安全转移”的默认值。Leave the defaults for Deployment model, Account kind, Performance, and Secure transfer required.
  4. 为“复制”选择默认的“RA-GRS” 。For Replication, select the default RA-GRS.
  5. 选择要用于本教程的订阅。Select the subscription that you want to use for this tutorial.
  6. 对于“资源组”,选择“新建”。For Resource group, select Create new. 在本示例中,使用 migrationRG 作为资源组名称。In this example, we use migrationRG for the resource group name.
  7. 选择“中国北部”作为“位置”。For Location, select China North.
  8. 选择“创建”以创建存储帐户。Select Create to create the storage account.

创建保管库Create a vault

  1. Azure 门户中,选择“所有服务”。In the Azure portal, select All services. 搜索“恢复服务保管库”,然后将其选中。Search for and then select Recovery Services vaults.
  2. 在“Azure 恢复服务保管库”页中,选择“添加”。On the Azure Recovery Services vaults page, select Add.
  3. 对于“名称”,请输入 myVaultFor Name, enter myVault.
  4. 对于“订阅”,请选择要使用的订阅。For Subscription, select the subscription that you want to use.
  5. 对于“资源组”,请选择“使用现有”,然后选择“migrationRG”。For Resource Group, select Use existing, and then select migrationRG.
  6. 选择“中国北部”作为“位置”。For Location, select China North.
  7. 选择“固定到仪表板”即可从仪表板快速访问新的保管库。Select Pin to dashboard to be able to quickly access the new vault from the dashboard.
  8. 完成操作后,选择“创建” 。When you're done, select Create.

若要查看新保管库,请转到“仪表板” > “所有资源”。To see the new vault, go to Dashboard > All resources. 新保管库也显示在“恢复服务保管库”主页上。The new vault also appears on the main Recovery Services vaults page.

设置 Azure 网络Set up an Azure network

在迁移(故障转移)后创建的 Azure VM 会加入此 Azure 网络。When Azure VMs are created after the migration (failover), they're joined to this Azure network.

  1. Azure 门户中,选择“创建资源”****>“网络”****> “虚拟网络”****。In the Azure portal, select Create a resource > Networking > Virtual network.

  2. 对于“名称”,请输入 myMigrationNetworkFor Name, enter myMigrationNetwork.

  3. 保留“地址空间”的默认值(必须输入值)。Leave the default value for Address space (must enter value).

  4. 对于“订阅”,请选择要使用的订阅。For Subscription, select the subscription that you want to use.

  5. 对于“资源组”,请选择“使用现有”,然后选择“migrationRG”。For Resource group, select Use existing, and then select migrationRG.

  6. 选择“中国北部”作为“位置”。For Location, select China North.

  7. 在“子网”下,保留“名称”和“IP 范围”的默认值(必须输入值)。Under Subnet, leave the default values for Name and IP range (must enter value).

  8. 让“服务终结点”选项保持禁用状态。Leave the Service Endpoints option disabled.

  9. 完成操作后,选择“创建”。When you're done, select Create.

准备基础结构Prepare the infrastructure

在 Azure 门户的保管库页的“入门”部分选择“Site Recovery”,然后选择“准备基础结构”。 On your vault page in the Azure portal, in the Getting Started section, select Site Recovery, and then select Prepare Infrastructure. 完成以下步骤。Complete the following steps.

1:保护目标1: Protection goal

在“保护目标”页上选择以下值:On the Protection Goal page, select the following values:

计算机位于何处?Where are your machines located? 选择“本地”。Select On-premises.
要将计算机复制到何处?Where do you want to replicate your machines? 选择“到 Azure”。Select To Azure.
计算机是否已虚拟化?Are your machines virtualized? 选择“未虚拟化/其他”。Select Not virtualized / Other.

完成后,选择“确定”即可转到下一部分。When you're done, select OK to move to the next section.

2:选择部署规划2: Select deployment planning

在“是否已完成部署规划”中选择“我将稍后进行”,然后选择“确定”。In Have you completed deployment planning, select I will do it later, and then select OK.

3:准备源3: Prepare source

在“准备源”页上,选择“+ 配置服务器”。On the Prepare source page, select + Configuration Server.

  1. 使用运行 Windows Server 2012 R2 的 EC2 实例创建配置服务器,并将它注册到恢复保管库。Use an EC2 instance that's running Windows Server 2012 R2 to create a configuration server and register it with your recovery vault.

  2. 在用作配置服务器的 EC2 实例 VM 上配置代理,以便它可以访问服务 URLConfigure the proxy on the EC2 instance VM you're using as the configuration server so that it can access the service URLs.

  3. 下载 Azure Site Recovery 统一安装程序Download Azure Site Recovery Unified Setup. 可以将它下载到本地计算机,然后复制到用作配置服务器的 VM。You can download it to your local machine and then copy it to the VM you're using as the configuration server.

  4. 选择“下载”按钮,下载保管库注册密钥。Select the Download button to download the vault registration key. 将下载的文件复制到用作配置服务器的 VM。Copy the downloaded file to the VM you're using as the configuration server.

  5. 在该 VM 上,右键单击为 Azure Site Recovery 统一安装程序下载的安装程序,然后选择“以管理员身份运行”。On the VM, right-click the installer you downloaded for Azure Site Recovery Unified Setup, and then select Run as administrator.

    1. 在“准备工作”下选择“安装配置服务器和进程服务器”,然后选择“下一步”。Under Before You Begin, select Install the configuration server and process server, and then select Next.
    2. 在“第三方软件许可证”中选择“我接受第三方许可协议”,然后选择“下一步”。In Third-Party Software License, select I accept the third-party license agreement, and then select Next.
    3. 在“注册”中选择“浏览”,然后转到保管库注册密钥文件所在的位置。In Registration, select Browse, and then go to where you put the vault registration key file. 选择“下一步”。Select Next.
    4. 在“Internet 设置”中选择“在不使用代理服务器的情况下连接到 Azure Site Recovery”,然后选择“下一步”。In Internet Settings, select Connect to Azure Site Recovery without a proxy server, and then select Next.
    5. “先决条件检查”页运行多个项的检查。The Prerequisites Check page runs checks for several items. 完成后,选择“下一步”。When it's finished, select Next.
    6. 在“MySQL 配置”中提供所需的密码,然后选择“下一步”。In MySQL Configuration, provide the required passwords, and then select Next.
    7. 在“环境详细信息”中选择“否”。 In Environment Details, select No. 无需保护 VMware 计算机。You don't need to protect VMware machines. 然后,选择“下一步”。Then, select Next.
    8. 在“安装位置”中选择“下一步”,接受默认值。In Install Location, select Next to accept the default.
    9. 在“网络选择”中选择“下一步”,接受默认值。In Network Selection, select Next to accept the default.
    10. 在“摘要”中选择“安装” 。In Summary, select Install.
    11. “安装进度”显示有关安装过程的信息。Installation Progress shows you information about the installation process. 完成后,选择“完成”。When it's finished, select Finish. 此时会出现一个显示重启消息的窗口。A window displays a message about a reboot. 选择“确定” 。Select OK. 接下来会出现一个窗口,显示有关配置服务器连接通行短语的消息。Next, a window displays a message about the configuration server connection passphrase. 将通行短语复制到剪贴板,然后保存到其他安全位置。Copy the passphrase to your clipboard and save it somewhere safe.
  6. 在 VM 上运行 cspsconfigtool.exe,以在配置服务器上创建一个或多个管理帐户。On the VM, run cspsconfigtool.exe to create one or more management accounts on the configuration server. 请确保管理帐户在要迁移的 EC2 实例上具有管理员权限。Make sure that the management accounts have administrator permissions on the EC2 instances that you want to migrate.

完成配置服务器设置后,请返回门户,选择为配置服务器创建的服务器。When you're done setting up the configuration server, go back to the portal and select the server that you created for Configuration Server. 选择“确定”以转到“3:准备目标”。Select OK to go to 3: Prepare target.

4:准备目标4: Prepare target

在本部分,请输入在本教程前面的准备 Azure 资源中创建的资源的相关信息。In this section, you enter information about the resources that you created in Prepare Azure resources earlier in this tutorial.

  1. 在“订阅”中,选择用于准备 Azure教程的 Azure 订阅。In Subscription, select the Azure subscription that you used for the Prepare Azure tutorial.
  2. 选择 Resource Manager 作为部署模型。Select Resource Manager as the deployment model.
  3. Site Recovery 会验证你是否有一个或多个兼容的 Azure 存储帐户和网络。Site Recovery verifies that you have one or more compatible Azure storage account and network. 这些应该是在本教程前面的准备 Azure 资源中创建的资源。These should be the resources that you created in Prepare Azure resources earlier in this tutorial.
  4. 完成后,请选择“确定”。When you're done, select OK.

5:准备复制设置5: Prepare replication settings

必须先创建复制策略,然后才能启用复制。Before you can enable replication, you must create a replication policy.

  1. 选择“创建并关联”。Select Create and Associate.
  2. 在“名称”中输入 myReplicationPolicyIn Name, enter myReplicationPolicy.
  3. 其余选项均保留默认设置,然后选择“确定”以创建策略。Leave the rest of the default settings, and then select OK to create the policy. 新策略会自动与配置服务器关联。The new policy is automatically associated with the configuration server.

完成“准备基础结构”下所有五个部分的操作后,请选择“确定”。 When you're finished with all five sections under Prepare Infrastructure, select OK.

启用复制Enable replication

为要迁移的各 VM 启用复制。Enable replication for each VM that you want to migrate. 启用复制后,Site Recovery 会自动安装移动服务。When replication is enabled, Site Recovery automatically installs the Mobility service.

  1. 转到 Azure 门户Go to the Azure portal.

  2. 在保管库相应页面的“入门”下,选择“Site Recovery”。On the page for your vault, under Getting Started, select Site Recovery.

  3. 在“适用于本地计算机和 Azure VM”下,选择“步骤 1:复制应用程序”Under For on-premises machines and Azure VMs, select Step 1: Replicate application. 使用以下信息完成向导页面。Complete the wizard pages with the following information. 完成后,在每个页面上选择“确定”:Select OK on each page when you're done:

    • 1:配置源1: Configure source

      源:Source: 选择“本地”。Select On Premises.
      源位置:Source location: 输入配置服务器 EC2 实例的名称。Enter the name of your configuration server EC2 instance.
      计算机类型:Machine type: 选择“物理计算机”。Select Physical machines.
      进程服务器:Process server: 从下拉列表中选择配置服务器。Select the configuration server from the drop-down list.
    • 2:配置目标2: Configure target

      目标:Target: 保留默认值。Leave the default.
      订阅:Subscription: 选择已在使用的订阅。Select the subscription that you have been using.
      故障转移后的资源组:Post-failover resource group: 使用在准备 Azure 资源中创建的资源组。Use the resource group you created in Prepare Azure resources.
      故障转移后的部署模型:Post-failover deployment model: 选择“Resource Manager”。Select Resource Manager.
      存储帐户:Storage account: 选择在准备 Azure 资源中创建的存储帐户。Select the storage account that you created in Prepare Azure resources.
      Azure 网络:Azure network: 选择“立即对选定的计算机进行配置”。Select Configure now for selected machines.
      故障转移后的 Azure 网络:Post-failover Azure network: 选择在准备 Azure 资源中创建的网络。Choose the network you created in Prepare Azure resources.
      子网:Subnet: 在下拉列表中选择“默认”。Select the default in the drop-down list.
    • 3:选择物理计算机3: Select physical machines

      选择“物理计算机”,然后输入要迁移的 EC2 实例的“名称”、“IP 地址”和“OS 类型”的值。Select Physical machine, and then enter the values for Name, IP Address, and OS Type of the EC2 instance that you want to migrate. 选择“确定” 。Select OK.

    • 4:配置属性4: Configure properties

      选择在配置服务器上创建的帐户,然后选择“确定”。Select the account that you created on the configuration server, and then select OK.

    • 5:配置复制设置5: Configure replication settings

      确保在下拉列表中选定的复制策略是“myReplicationPolicy”,然后选择“确定”。Make sure that the replication policy selected in the drop-down list is myReplicationPolicy, and then select OK.

  4. 向导完成后,选择“启用复制”。When the wizard is finished, select Enable replication.

若要跟踪“启用保护”作业的进度,请转到“监视和报告” > “作业” > “Site Recovery 作业”。To track the progress of the Enable Protection job, go to Monitoring and reports > Jobs > Site Recovery Jobs. 在“完成保护” 作业运行之后,计算机就可以进行故障转移了。After the Finalize Protection job runs, the machine is ready for failover.

为 VM 启用复制后,可能要等 15 分钟或更长时间,更改才会生效并显示在门户中。When you enable replication for a VM, changes can take 15 minutes or longer to take effect and appear in the portal.

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

运行测试故障转移时,会发生以下事件:When you run a test failover, the following events occur:

  • 运行先决条件检查,确保故障转移所需的所有条件都已就绪。A prerequisites check runs to make sure that all the conditions required for failover are in place.
  • 故障转移处理数据,以便创建 Azure VM。Failover processes the data so that an Azure VM can be created. 如果选择最新恢复点,则根据该数据创建恢复点。If you select the latest recovery point, a recovery point is created from the data.
  • 使用上一步中处理的数据创建 Azure VM。An Azure VM is created by using the data processed in the preceding step.

在门户中运行测试故障转移:In the portal, run the test failover:

  1. 在保管库的相应页上,转到“受保护的项” > “复制的项”。On the page for your vault, go to Protected items > Replicated Items. 选择 VM,然后选择“测试故障转移”。Select the VM, and then select Test Failover.

  2. 选择要用于故障转移的恢复点:Select a recovery point to use for the failover:

    • 最新处理:将 VM 故障转移到由 Site Recovery 处理的最新恢复点。Latest processed: Fails over the VM to the latest recovery point that was processed by Site Recovery. 将显示时间戳。The time stamp is shown. 使用此选项时,无需费时处理数据,因此恢复时间目标 (RTO) 会较低。With this option, no time is spent processing data, so it provides a low recovery time objective (RTO).
    • 最新的应用一致:此选项将所有 VM 故障转移到最新的应用一致恢复点。Latest app-consistent: This option fails over all VMs to the latest app-consistent recovery point. 将显示时间戳。The time stamp is shown.
    • 自定义:选择任何恢复点。Custom: Select any recovery point.
  3. 在“测试故障转移”中,选择 Azure VM 在故障转移之后要连接到的目标 Azure 网络。In Test Failover, select the target Azure network to which Azure VMs will be connected after failover occurs. 它应该是在准备 Azure 资源中创建的网络。This should be the network you created in Prepare Azure resources.

  4. 选择“确定”,开始故障转移。Select OK to begin the failover. 若要跟踪进度,请选择要查看其属性的 VM。To track progress, select the VM to view its properties. 也可以在保管库的相应页面上选择“测试故障转移”作业。Or you can select the Test Failover job on the page for your vault. 为此,请选择“监视和报告” > “作业” > “Site Recovery 作业”。To do this, select Monitoring and reports > Jobs > Site Recovery jobs.

  5. 故障转移完成后,副本 Azure VM 会显示在 Azure 门户中。When the failover finishes, the replica Azure VM appears in the Azure portal. 若要查看该 VM,请选择“虚拟机”。To view the VM, select Virtual Machines. 请确保 VM 的大小适当、已连接到正确的网络,并且正在运行。Ensure that the VM is the appropriate size, that it's connected to the right network, and that it's running.

  6. 现在应该能够连接到 Azure 中复制的 VM。You should now be able to connect to the replicated VM in Azure.

  7. 若要删除在测试故障转移期间创建的 Azure VM,请在恢复计划中选择“清理测试故障转移”。To delete Azure VMs that were created during the test failover, select Cleanup test failover in the recovery plan. 在“说明”中,记录并保存与测试故障转移相关联的任何观测结果。In Notes, record and save any observations associated with the test failover.

在某些情况下,故障转移需要进行额外的处理。In some scenarios, failover requires additional processing. 完成处理需要 8 到 10 分钟的时间。Processing takes 8 to 10 minutes to finish.

迁移到 AzureMigrate to Azure

对 EC2 实例运行真正的故障转移,将其迁移到 Azure VM:Run an actual failover for the EC2 instances to migrate them to Azure VMs:

  1. 在“受保护的项” > “复制的项”中选择 AWS 实例,然后选择“故障转移”。In Protected items > Replicated items, select the AWS instances, and then select Failover.

  2. 在“故障转移”中,选择要故障转移到其中的“恢复点”。In Failover, select a Recovery Point to failover to. 选择最新的恢复点,然后启动故障转移。Select the latest recovery point, and start the failover. 可以在“作业”页上跟踪故障转移进度。 You can follow the failover progress on the Jobs page.

  3. 确保 VM 出现在“复制的项”中。Ensure that the VM appears in Replicated items.

  4. 右键单击每个 VM,然后选择“完成迁移”。Right-click each VM, and then select Complete Migration. 这样会执行以下操作:This does the following:

    • 此操作将完成迁移过程,停止 AWS VM 复制,并停止 VM 的 Site Recovery 计费。This finishes the migration process, stops replication for the AWS VM, and stops Site Recovery billing for the VM.

    • 此步骤清除复制数据。This step cleans up the replication data. 它不删除迁移的 VM。It doesn't delete the migrated VMs.



请勿取消正在进行的故障转移。Don't cancel a failover that is in progress. 在故障转移开始前,VM 复制已停止。Before failover is started, VM replication is stopped. 如果取消正在进行的故障转移,故障转移会停止,但 VM 将不再进行复制。If you cancel a failover that is in progress, failover stops, but the VM won't replicate again.

后续步骤Next steps

本文介绍了如何将 AWS EC2 实例迁移到 Azure VM。In this article, you learned how to migrate AWS EC2 instances to Azure VMs. 若要详细了解 Azure VM,请继续学习 Windows VM 的相关教程。To learn more about Azure VMs, continue to the tutorials for Windows VMs.