您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

将本地 Linux 应用程序 Rehost 到 Azure Vm 和 Azure Database for MySQLRehost an on-premises Linux application to Azure VMs and Azure Database for MySQL

本文介绍如何使用 Azure 虚拟机 (Vm) 和 Azure Database for MySQL,使虚构公司 Contoso 原名不同一种基于双层 灯泡 的应用程序并将其从本地迁移到 azure。This article shows how the fictional company Contoso rehosts a two-tier LAMP-based application and migrates it from on-premises to Azure by using Azure Virtual Machines (VMs) and Azure Database for MySQL.

本示例中使用的 osTicket 服务应用程序作为开放源代码提供。The service desk application used in this example, osTicket, is provided as open source. 如果要将其用于自己的测试,可以从 GitHub下载。If you want to use it for your own testing, you can download it from GitHub.

业务驱动因素Business drivers

IT 领先团队与业务合作伙伴密切合作,以了解他们要实现的功能:The IT leadership team has worked closely with business partners to understand what they want to achieve:

  • 解决业务增长。Address business growth. Contoso 在不断壮大,这给本地系统和基础结构造成了压力。Contoso is growing, and as a result there's pressure on the on-premises systems and infrastructure.
  • 限制风险。Limit risk. 服务台应用程序对于企业至关重要。The service desk application is critical for the business. Contoso 希望在不遭受任何风险的情况下将其迁移到 Azure。Contoso wants to move it to Azure with zero risk.
  • 扩展.Extend. Contoso 目前不想更改应用程序。Contoso doesn't want to change the application right now. 公司希望使应用程序保持稳定。The company wants to keep the application stable.

迁移目标Migration goals

Contoso 云团队已为此迁移固定目标,以确定最佳迁移方法:The Contoso cloud team has pinned down goals for this migration to determine the best migration method:

  • 迁移后,Azure 中的应用程序应具有与当今公司本地 VMware 环境相同的性能功能。After migration, the application in Azure should have the same performance capabilities as it does today in the company's on-premises VMware environment. 当应用程序在本地时,应用程序将在云中保持重要。The application will remain as critical in the cloud as it is on-premises.
  • Contoso 不希望投资此应用程序。Contoso doesn't want to invest in this application. 这对于业务是很重要的,但在其当前的窗体中,Contoso 只需将它安全地移到云中。It's important to the business, but in its current form Contoso simply wants to move it safely to the cloud.
  • Contoso 已经完成了几个 Windows 应用程序迁移,因此需要了解如何在 Azure 中使用基于 Linux 的基础结构。Having completed a couple of Windows application migrations, Contoso wants to learn how to use a Linux-based infrastructure in Azure.
  • Contoso 希望,将应用程序移动到云之后,可以最大程度地减轻数据库管理员任务。Contoso wants to minimize database admin tasks after the application is moved to the cloud.

建议的体系结构Proposed architecture

在本方案中:In this scenario:

  • 目前,应用程序跨两个 Vm 进行分层 (OSTICKETWEBOSTICKETMYSQL) 。Currently the application is tiered across two VMs (OSTICKETWEB and OSTICKETMYSQL).

  • 这两个 VM 位于 VMware ESXi 主机 contosohost1.contoso.com(版本 6.5)上。The VMs are located on VMware ESXi host contosohost1.contoso.com (version 6.5).

  • VMware 环境由 vCenter Server 6.5 (vcenter.contoso.com) 管理,并在 VM 上运行。The VMware environment is managed by vCenter Server 6.5 (vcenter.contoso.com) and runs on a VM.

  • Contoso 有本地数据中心 (contoso-datacenter),其中包含本地域控制器 (contosodc1)。Contoso has an on-premises datacenter (contoso-datacenter), with an on-premises domain controller (contosodc1).

  • 上的 web 应用程序 OSTICKETWEB 将作为 (IaaS) VM 的服务迁移到 Azure 基础结构即服务。The web application on OSTICKETWEB will be migrated to an Azure infrastructure as a service (IaaS) VM.

  • 应用程序数据库将作为服务迁移到 Azure Database for MySQL 平台。The application database will be migrated to the Azure Database for MySQL platform as a service.

  • 由于 Contoso 正在迁移生产工作负荷,因此资源将驻留在生产资源组中 ContosoRGBecause Contoso is migrating a production workload, the resources will reside in the production resource group ContosoRG.

  • OSTICKETWEB资源将被复制到主要区域 (美国东部 2) 并放置在生产网络中 (VNET-PROD-EUS2) :The OSTICKETWEB resource will be replicated to the primary region (East US 2) and placed in the production network (VNET-PROD-EUS2):

    • Web VM 将驻留在前端子网 (PROD-FE-EUS2) 中。The web VM will reside in the front-end subnet (PROD-FE-EUS2).
  • 应用程序数据库将迁移到使用 Azure 数据库迁移服务Azure Database for MySQL。The application database will be migrated to Azure Database for MySQL by using Azure Database Migration Service.

  • 迁移完成后,Contoso 数据中心的本地 VM 将停止使用。The on-premises VMs in the Contoso datacenter will be decommissioned after the migration is done.

    方案体系结构的关系图。

迁移过程Migration process

Contoso 将按如下方式完成迁移进程:Contoso will complete the migration process as follows:

迁移 Web VM:To migrate the web VM:

  • 作为第一步,Contoso 设置部署 Azure Migrate 所需的 Azure 和本地基础结构。As a first step, Contoso sets up the Azure and on-premises infrastructure needed to deploy Azure Migrate.
  • 公司已经有了 Azure 基础结构 ,因此它只需通过 Azure Migrate:服务器迁移工具添加并配置 vm 的复制。The company already has the Azure infrastructure in place, so it just needs to add and configure the replication of the VMs through the Azure Migrate: Server Migration tool.
  • 完成所有准备工作后,Contoso 即可开始复制 VM。With everything prepared, Contoso can start replicating the VM.
  • 启用复制并工作后,Contoso 将使用 Azure Migrate 完成移动。After replication is enabled and working, Contoso will complete the move by using Azure Migrate.

迁移数据库:To migrate the database:

  1. Contoso 在 Azure 中设置 MySQL 实例。Contoso provisions a MySQL instance in Azure.

  2. Contoso 设置数据库迁移服务,确保访问本地数据库服务器。Contoso sets up Database Migration Service, ensuring access to the on-premises database server.

  3. Contoso 将数据库迁移到 Azure Database for MySQL。Contoso migrates the database to Azure Database for MySQL.

    迁移过程的示意图。

Azure 服务Azure services

服务Service 说明Description 成本Cost
Azure MigrateAzure Migrate Contoso 使用 Azure Migrate 对其 VMware Vm 进行评估。Contoso uses Azure Migrate to assess its VMware VMs. Azure Migrate 评估计算机是否适合迁移。Azure Migrate assesses the migration suitability of the machines. 它对在 Azure 中运行时的大小和成本进行估算。It provides sizing and cost estimates for running in Azure. Azure Migrate 免费提供。Azure Migrate is available at no additional charge. 你可能会产生费用,具体取决于你决定用于评估和迁移 (第一方或 ISV) 的工具。You might incur charges depending on the tools (first-party or ISV) you decide to use for assessment and migration.
Azure 数据库迁移服务Azure Database Migration Service 数据库迁移服务实现了从多个数据库源到 Azure 数据平台的无缝迁移,且停机时间最短。Database Migration Service enables seamless migration from multiple database sources to Azure data platforms with minimal downtime. 了解支持的区域数据库迁移服务定价Learn about supported regions and Database Migration Service pricing.
Azure Database for MySQLAzure Database for MySQL 数据库基于开源 MySQL 数据库引擎。The database is based on the open-source MySQL database engine. 它为应用程序开发和部署提供完全托管的企业就绪社区 MySQL 数据库。It provides a fully managed enterprise-ready community MySQL database for application development and deployment. 详细了解 Azure Database for MySQL 定价 和可伸缩性选项。Learn more about Azure Database for MySQL pricing and scalability options.

先决条件Prerequisites

对于此方案,Contoso 需具备以下项。Here's what Contoso needs for this scenario.

要求Requirements 详细信息Details
Azure 订阅Azure subscription 在前面的文章中,Contoso 已创建订阅。Contoso created subscriptions during an earlier article. 如果还没有 Azure 订阅,可以创建一个免费帐户If you don't have an Azure subscription, create a free account.

如果创建的是免费帐户,则你是自己的订阅的管理员,可以执行所有操作。If you create a free account, you're the administrator of your subscription and can perform all actions.

如果你使用现有的订阅,并且你不是管理员,请与管理员合作,为你分配所有者或参与者权限。If you use an existing subscription and you're not the administrator, work with the admin to assign you Owner or Contributor permissions.

如果需要更精细的权限,请参阅 使用基于角色的访问控制管理 Azure Site Recovery 访问 (RBAC) If you need more granular permissions, see Manage Azure Site Recovery access with role-based access control (RBAC).
Azure 基础结构Azure infrastructure Contoso 按照用于迁移的 Azure 基础结构中所述设置 Azure 基础结构。Contoso set up the Azure infrastructure as described in Azure infrastructure for migration.
本地服务器On-premises servers 本地 vCenter Server 应运行版本5.5、6.0、6.5 或6.7。The on-premises vCenter Server should be running version 5.5, 6.0, 6.5, or 6.7.

运行版本5.5、6.0、6.5 或6.7 的 ESXi 主机。An ESXi host running version 5.5, 6.0, 6.5, or 6.7.

ESXi 主机上运行的一个或多个 VMware VM。One or more VMware VMs running on the ESXi host.
本地 VMOn-premises VMs 查看已获允在 Azure 上运行的 Linux 计算机Review Linux machines that are endorsed to run on Azure.

方案步骤Scenario steps

下面是 Contoso 管理员完成迁移的步骤:Here's how Contoso admins will complete the migration:

  • 步骤1:准备 Azure 以进行 Azure Migrate:服务器迁移。Step 1: Prepare Azure for Azure Migrate: Server Migration. 将服务器迁移工具添加到 Azure Migrate 项目。Add the server migration tool to the Azure Migrate project.
  • 步骤2:准备 Azure Migrate 的本地 VMware:服务器迁移。Step 2: Prepare on-premises VMware for Azure Migrate: Server Migration. 为 VM 发现准备帐户并准备在迁移后连接到 Azure 虚拟机。Prepare accounts for VM discovery and prepare to connect to Azure Virtual Machines after migrated.
  • 步骤3:复制 Vm。Step 3: Replicate VMs. 设置复制并开始将 Vm 复制到 Azure 存储。Set up replication and start replicating VMs to Azure Storage.
  • 步骤4:将应用程序 VM 迁移 Azure Migrate:服务器迁移。Step 4: Migrate the application VM with Azure Migrate: Server Migration. 运行测试迁移,确保一切正常运行,然后运行完全迁移将 VM 移到 Azure。Run a test migration to make sure everything's working, and then run a full migration to move the VM to Azure.
  • 步骤5:迁移数据库。Step 5: Migrate the database. 使用 Azure 数据库迁移服务设置迁移。Set up migration by using Azure Database Migration Service.

步骤1:为 Azure Migrate 准备 Azure:服务器迁移工具Step 1: Prepare Azure for the Azure Migrate: Server Migration tool

Contoso 需具备以下 Azure 组件才能将 VM 迁移到 Azure:Here are the Azure components Contoso needs to migrate the VMs to Azure:

  • 在迁移过程中创建 Azure Vm 时,Azure Vm 将位于其中的虚拟网络。A virtual network in which Azure VMs will be located when they're created during migration.
  • Azure Migrate:服务器迁移工具 (.OVA) 预配和配置。The Azure Migrate: Server Migration tool (OVA) provisioned and configured.

若要设置这些组件,Contoso 管理员请按照以下步骤操作:To set up the components, Contoso admins follow these steps:

  1. 设置网络。Set up a network. Contoso 已设置网络,该网络可用于在 部署 Azure 基础结构时进行 Azure Migrate:服务器迁移。Contoso already set up a network that can be used for Azure Migrate: Server Migration when it deployed the Azure infrastructure.

  2. 预配 Azure Migrate:服务器迁移工具。Provision the Azure Migrate: Server Migration tool.

    1. 从 Azure Migrate 下载 .OVA 映像,并将其导入到 VMware。From Azure Migrate, download the OVA image, and import it into VMware.

      显示下载 .OVA 文件的屏幕截图。

    2. 启动导入的映像,并使用以下步骤配置该工具:Start the imported image, and configure the tool by using the following steps:

      1. 设置先决条件。Set up the prerequisites.

        显示 "设置先决条件" 屏幕的屏幕截图。

      2. 将工具指向 Azure 订阅。Point the tool to the Azure subscription.

        显示配置订阅的屏幕截图

      3. 设置 VMware vCenter 凭据。Set the VMware vCenter credentials.

        显示配置凭据的屏幕截图。

      4. 添加任何基于 Linux 的凭据以用于发现。Add any Linux-based credentials for discovery.

        显示配置基于 Linux 的凭据的屏幕截图。

  3. 配置该工具后,该工具将需要一段时间来枚举所有虚拟机。After the tool is configured, it takes some time for the tool to enumerate all the virtual machines. 此过程完成后,Vm 将在 Azure 中的 Azure Migrate 工具中进行填充。After the process is finished, the VMs populate in the Azure Migrate tool in Azure.

需要更多帮助?Need more help?

了解如何设置 Azure Migrate:服务器迁移工具Learn about how to set up the Azure Migrate: Server Migration tool.

步骤2:准备 Azure Migrate 的本地 VMware:服务器迁移Step 2: Prepare on-premises VMware for Azure Migrate: Server Migration

迁移到 Azure 后,Contoso 希望能够连接到 Azure 中的已复制 Vm。After migrating to Azure, Contoso wants to be able to connect to the replicated VMs in Azure. Contoso 管理员需要执行几项操作:There are a couple of things that the Contoso admins need to do:

  • 若要访问 Azure Vm,请在迁移前在本地 Linux VM 上启用 SSH。To access Azure VMs, they enable SSH on the on-premises Linux VM before migration. 对于 Ubuntu,可以使用以下命令完成此步骤: sudo apt-get ssh install -yFor Ubuntu, this step can be completed by using the following command: sudo apt-get ssh install -y.
  • 管理员运行迁移后,可以查看 启动诊断 以查看 VM 的屏幕截图。After the admins run the migration, they can check boot diagnostics to view a screenshot of the VM.
  • 如果此操作不起作用,则需要检查 VM 是否正在运行,并查看这些 故障排除提示If it doesn't work, they'll need to check that the VM is running, and review these troubleshooting tips.
  • 安装 Azure Linux 代理Install the Azure Linux agent.

需要更多帮助?Need more help?

了解如何准备要 迁移的 vmLearn about how to prepare VMs for migration.

步骤3:复制 VmStep 3: Replicate VMs

在迁移到 Azure 之前,Contoso 管理员需要设置并启用复制。Before Contoso admins can run a migration to Azure, they need to set up and enable replication.

完成发现后,可以开始将应用程序 VM 复制到 Azure。With discovery finished, they can begin replication of the application VM to Azure.

  1. 在 Azure Migrate 项目中转到 "服务器 > Azure Migrate:服务器迁移",然后选择 "复制"。In the Azure Migrate project, go to Servers > Azure Migrate: Server Migration, and select Replicate.

    显示复制选项的屏幕截图。

  2. 在 "复制 > 源设置" " > 虚拟机" 中,选择 "是",并 VMware vSphereIn Replicate > Source settings > Are your machines virtualized?, select Yes, with VMware vSphere.

  3. "本地设备" 中,选择设置的 Azure Migrate 设备的名称,然后选择 "确定"In On-premises appliance, select the name of the Azure Migrate appliance that you set up, and then select OK.

    显示 "源设置" 选项卡的屏幕截图。

  4. 在 " 虚拟机" 中,选择要复制的计算机:In Virtual machines, select the machines you want to replicate:

    • 如果已针对 VM 运行评估,则可以应用评估结果中提供的 VM 大小和磁盘类型(高级/标准)建议。If you've run an assessment for the VMs, you can apply VM sizing and disk type (premium/standard) recommendations from the assessment results. 在 " 从 Azure Migrate 评估中导入迁移设置?" 中,选择 " 是" 选项。In Import migration settings from an Azure Migrate assessment?, select the Yes option.
    • 如果未运行评估,或者不想使用评估设置,请选择 " " 选项。If you didn't run an assessment, or you don't want to use the assessment settings, select the No option.
    • 如果选择使用评估,请选择 VM 组和评估名称。If you selected to use the assessment, select the VM group and assessment name.

    显示选择评估的屏幕截图。

  5. 在 " 虚拟机" 中,根据需要搜索 vm,并选择要迁移的每个虚拟机。In Virtual machines, search for VMs as needed, and select each VM you want to migrate. 然后选择 " 下一步:目标设置"。Then select Next: Target settings.

  6. 在 " 目标设置" 中,选择要迁移到的订阅和目标区域。In Target settings, select the subscription and target region to which you'll migrate. 指定迁移之后 Azure Vm 所在的资源组。Specify the resource group in which the Azure VMs will reside after migration. 在 " 虚拟网络" 中,选择 azure vm 在迁移后要连接到的 azure 虚拟网络/子网。In Virtual Network, select the Azure virtual network/subnet to which the Azure VMs will be joined after migration.

  7. 在“Azure 混合权益”中:In Azure Hybrid Benefit:

    • 如果你不想要应用 Azure 混合权益,请选择“否”。Select No if you don't want to apply Azure Hybrid Benefit. 然后,选择“下一步”。Then select Next.
  8. 在“计算”中,查看 VM 名称、大小、OS 磁盘类型和可用性集。In Compute, review the VM name, size, OS disk type, and availability set. VM 必须符合 Azure 要求VMs must conform with Azure requirements.

    • VM 大小: 如果使用评估建议,"VM 大小" 下拉列表将包含建议的大小。VM size: If you use assessment recommendations, the VM size drop-down list contains the recommended size. 否则,Azure Migrate 会根据 Azure 订阅中最接近的匹配项选择大小。Otherwise, Azure Migrate picks a size based on the closest match in the Azure subscription. 或者,请在“Azure VM 大小”中的手动选择一个大小。Alternatively, pick a manual size in Azure VM size.
    • OS 磁盘: 为 VM 指定 OS (boot) 磁盘。OS disk: Specify the OS (boot) disk for the VM. OS 磁盘是包含操作系统引导加载程序和安装程序的磁盘。The OS disk is the disk that has the operating system bootloader and installer.
    • 可用性集: 如果迁移后 VM 应在 Azure 可用性集中,请指定集。Availability set: If the VM should be in an Azure availability set after migration, specify the set. 该集必须位于为迁移指定的目标资源组中。The set must be in the target resource group you specify for the migration.
  9. 在 " 磁盘" 中,指定是否应将 VM 磁盘复制到 Azure。In Disks, specify whether the VM disks should be replicated to Azure. 然后在 Azure 中选择 (标准 SSD/HDD 或高级托管磁盘) 的磁盘类型,然后选择 " 下一步"。Then select the disk type (standard SSD/HDD or premium-managed disks) in Azure, and select Next.

    • 可以从复制中排除磁盘。You can exclude disks from replication.
    • 如果你排除磁盘,则在迁移后它们将不会出现在 Azure VM 中。If you exclude disks, they won't be present on the Azure VM after migration.
  10. 在 " 检查 + 开始复制" 中,查看设置。In Review + Start replication, review the settings. 然后选择 " 复制 ",为服务器启动初始复制。Then select Replicate to start the initial replication for the servers.

备注

管理复制计算机之前,你可以随时更新复制设置 > Replicating machinesYou can update replication settings any time before replication starts in Manage > Replicating machines. 开始复制后无法更改设置。Settings can't be changed after replication starts.

步骤4:迁移 VM 并 Azure Migrate:服务器迁移Step 4: Migrate the VM with Azure Migrate: Server Migration

Contoso 管理员先运行快速测试迁移,然后运行完整的迁移来移动 web VM。Contoso admins run a quick test migration and then a full migration to move the web VM.

运行测试迁移Run a test migration

  1. 在 "迁移目标 > 服务器 > Azure Migrate:服务器迁移中,选择"测试迁移的服务器"。In Migration goals > Servers > Azure Migrate: Server Migration, select Test migrated servers.

    显示 "测试已迁移的服务器" 选项的屏幕截图。

  2. 选择并按住 (或右键单击要测试) VM,然后选择 " 测试迁移"。Select and hold (or right-click) the VM to test, and then select Test migrate.

    显示测试迁移项的屏幕截图。

  3. 在“测试迁移”中,选择 Azure VM 在迁移后所在的 Azure 虚拟网络。In Test Migration, select the Azure virtual network in which the Azure VM will be located after the migration. 建议使用非生产虚拟网络。We recommend you use a nonproduction virtual network.

  4. “测试迁移”作业随即启动。The Test migration job starts. 在门户通知中监视该作业。Monitor the job in the portal notifications.

  5. 迁移完成后,在 Azure 门户上的“虚拟机”中查看已迁移的 Azure VM。After the migration finishes, view the migrated Azure VM in Virtual Machines in the Azure portal. 计算机名称带有 -Test 后缀。The machine name has a suffix -Test.

  6. 测试完成后,选择并按住 (或右键单击) Azure VM 复制计算机After the test is done, select and hold (or right-click) the Azure VM in Replicating machines. 然后选择 " 清理测试迁移"。Then select Clean up test migration.

    显示 "清理测试" 迁移项的屏幕截图。

迁移 VMMigrate the VM

Contoso 管理员现在可以运行完整的迁移来完成移动。Now Contoso admins run a full migration to complete the move.

  1. 在 Azure Migrate 项目中转到 "服务器 > Azure Migrate:服务器迁移",然后选择 "复制服务器"。In the Azure Migrate project, go to Servers > Azure Migrate: Server Migration, and select Replicating servers.

    显示 "复制服务器" 选项的屏幕截图。

  2. 在 " 复制计算机" 中,选择并按住 (或右键单击 VM) ,然后选择 " 迁移"。In Replicating machines, select and hold (or right-click) the VM, and then select Migrate.

  3. 在“迁移” > “关闭虚拟机并执行计划迁移(不会丢失任何数据)”中,选择“是” > “确定”。 In Migrate > Shut down virtual machines and perform a planned migration with no data loss, select Yes > OK.

    • 默认情况下,Azure Migrate 关闭本地 VM 并运行按需复制,以便同步自上次复制发生以来发生的任何 VM 更改。By default, Azure Migrate shuts down the on-premises VM and runs an on-demand replication to synchronize any VM changes that occurred since the last replication occurred. 此操作可确保不会丢失数据。This action ensures no data loss.
    • 如果你不想要关闭 VM,请选择“否”。If you don't want to shut down the VM, select No.
  4. 随即会针对该 VM 启动一个迁移作业。A migration job starts for the VM. 在 Azure 通知中跟踪该作业。Track the job in Azure notifications.

  5. 该作业完成后,可以从“虚拟机”页查看和管理该 VM。After the job finishes, you can view and manage the VM from the Virtual Machines page.

步骤5:预配 Azure Database for MySQLStep 5: Provision Azure Database for MySQL

Contoso 管理员在主要区域中预配 MySQL 数据库实例 (East US 2) 。Contoso admins provision a MySQL database instance in the primary region (East US 2).

  1. 在 Azure 门户中创建一个 Azure Database for MySQL 资源。In the Azure portal, create an Azure Database for MySQL resource.

    显示 Azure Database for MySQL 选项的屏幕截图。

  2. 添加 contosoosticket Azure 数据库的名称。Add the name contosoosticket for the Azure database. 将数据库添加到生产资源组 ContosoRG ,并为其指定凭据。Add the database to the production resource group ContosoRG, and specify credentials for it.

  3. 本地 MySQL 数据库的版本为5.7,因此请选择此版本以实现兼容性。The on-premises MySQL database is version 5.7, so select this version for compatibility. 使用与数据库要求匹配的默认大小。Use the default sizes, which match database requirements.

    显示 MySQL 凭据的屏幕截图。

  4. 对于 备份冗余选项,请选择 " 异地冗余"。For Backup Redundancy Options, select Geo-Redundant. 使用此选项可以将辅助区域中的数据库还原 (Central US) 出现故障时。This option allows you to restore the database in the secondary region (Central US) if an outage occurs. 仅当设置数据库时,才能配置此选项。You can configure this option only when you provision the database.

    显示异地冗余选项的屏幕截图。

  5. VNET-PROD-EUS2 网络中,使用 " 服务终结点",并向 SQL 服务的数据库子网) 添加一个服务终结点 (。In the VNET-PROD-EUS2 network, go to Service endpoints, and add a service endpoint (a database subnet) for the SQL service.

    显示添加服务终结点的屏幕截图。

  6. 添加子网后,创建允许从生产网络中的数据库子网进行访问的虚拟网络规则。After adding the subnet, create a virtual network rule that allows access from the database subnet in the production network.

    显示创建虚拟网络规则的屏幕截图。

步骤 6:迁移数据库Step 6: Migrate the database

可以通过多种方式来移动 MySQL 数据库。There are several ways to move the MySQL database. 每个选项都要求 Contoso 管理员为目标创建 Azure Database for MySQL 实例。Each option requires the Contoso admins to create an Azure Database for MySQL instance for the target. 创建完成后,可以使用以下步骤中所述的两个路径来执行迁移:After it's created, they can perform the migration by using two paths that are described in the following steps:

  • 6a:数据库迁移服务6a: Database Migration Service
  • 6b: MySQL 工作台备份和还原6b: MySQL Workbench backup and restore

步骤6a:通过数据库迁移服务迁移数据库Step 6a: Migrate the database via Database Migration Service

Contoso 管理员按照分步 迁移教程操作,通过数据库迁移服务迁移数据库。Contoso admins migrate the database via Database Migration Service by following the step-by-step migration tutorial. 他们可以使用 MySQL 5.6 或5.7 执行联机、脱机和混合 (预览版) 迁移。They can perform online, offline, and hybrid (preview) migrations by using MySQL 5.6 or 5.7.

备注

Azure Database for MySQL 中支持 MySQL 8.0,但数据库迁移服务工具尚不支持该版本。MySQL 8.0 is supported in Azure Database for MySQL, but the Database Migration Service tool doesn't yet support that version.

作为摘要,Contoso 管理员必须执行以下任务:As a summary, Contoso admins must perform the following tasks:

  • 确保满足所有迁移先决条件:Ensure all migration prerequisites are met:
    • MySQL server 数据库源必须与 Azure Database for MySQL 支持的版本相匹配。The MySQL server database source must match the version that Azure Database for MySQL supports. Azure Database for MySQL 支持 MySQL 社区版、InnoDB 存储引擎,并在相同的版本中跨源和目标进行迁移。Azure Database for MySQL supports MySQL Community Edition, the InnoDB storage engine, and migration across the source and target with the same versions.
    • 启用 my.ini (Windows) 或 my.cnf (Unix) 中的二进制日志记录。Enable binary logging in my.ini (Windows) or my.cnf (Unix). 如果不这样做,将导致迁移向导中出现以下错误: "二进制日志记录错误"。Failure to do so will cause the following error in the Migration Wizard: "Error in binary logging. 变量 binlog_row_image 的值为 "最小值"。Variable binlog_row_image has value 'minimal.' 请将其更改为 "full"。Please change it to 'full.'" 有关详细信息,请参阅 MySQL 网站For more information, see the MySQL website.
    • 用户必须具有 ReplicationAdmin 角色。User must have ReplicationAdmin role.
    • 迁移没有外键和触发器的数据库架构。Migrate the database schemas without foreign keys and triggers.
  • 创建通过 Azure ExpressRoute 或 VPN 连接到本地网络的虚拟网络。Create a virtual network that connects via Azure ExpressRoute or a VPN to your on-premises network.
  • 使用连接到虚拟网络的 SKU 创建数据库迁移服务实例 PremiumCreate a Database Migration Service instance by using a Premium SKU that's connected to the virtual network.
  • 确保实例可以通过虚拟网络访问 MySQL 数据库。Ensure that the instance can access the MySQL database via the virtual network. 确保在虚拟网络级别、网络 VPN 和托管 MySQL 的计算机上,允许所有传入端口从 Azure 到 MySQL。Ensure that all incoming ports are allowed from Azure to MySQL at the virtual network level, the network VPN, and the machine that hosts MySQL.
  • 运行数据库迁移服务工具:Run the Database Migration Service tool:
    • 创建迁移项目。Create a migration project.

      显示创建迁移项目的屏幕截图。

      显示 "新建迁移项目" 窗格的屏幕截图。

    • 添加源 (本地数据库) 。Add a source (on-premises database).

      显示 "添加源详细信息" 窗格的屏幕截图。

    • 选择一个目标。Select a target.

      显示 "目标详细信息" 窗格的屏幕截图。

    • 选择要迁移的数据库。Select the databases to migrate.

      显示 "映射到目标数据库" 窗格的屏幕截图。

    • 配置高级设置。Configure advanced settings.

      显示 "迁移设置" 窗格的屏幕截图。

    • 开始复制并解决任何错误。Start the replication and resolve any errors.

      显示错误解决方法的屏幕截图。

    • 执行最终切换。Perform the final cutover. 显示最终转换的屏幕截图。

      显示完全切换窗格的屏幕截图。

      显示迁移活动列表的屏幕截图。

    • 恢复所有外键和触发器。Reinstate any foreign keys and triggers.

    • 修改应用程序以使用新的数据库。Modify applications to use the new database.

      屏幕截图,显示如何修改应用程序以使用新的数据库。

步骤6b:将数据库迁移 (MySQL 工作台) Step 6b: Migrate the database (MySQL Workbench)

Contoso 管理员通过使用备份和还原工具来迁移数据库。Contoso admins migrate the database by using backup and restore with MySQL tools. 它们安装 MySQL 工作台,从备份数据库 OSTICKETMYSQL ,然后将其还原到 Azure Database for MySQL。They install MySQL Workbench, back up the database from OSTICKETMYSQL, and then restore it to Azure Database for MySQL.

安装 MySQL WorkbenchInstall MySQL Workbench

  1. 检查 先决条件,并下载 MySQL 工作台Check the prerequisites, and download MySQL Workbench.

  2. 按照 安装说明安装适用于 Windows 的 MySQL 工作台。Install MySQL Workbench for Windows by following the installation instructions.

  3. 在 MySQL 工作台中,创建与 OSTICKETMYSQL 的 MySQL 连接。In MySQL Workbench, create a MySQL connection to OSTICKETMYSQL.

    显示 "连接" 选项卡的屏幕截图。

  4. 将数据库导出为 osticket 本地自包含的文件。Export the database as osticket to a local self-contained file.

    显示数据导出屏幕的屏幕截图。

  5. 在本地备份数据库后,创建与 Azure Database for MySQL 实例的连接。After the database is backed up locally, create a connection to the Azure Database for MySQL instance.

    显示成功连接弹出消息的屏幕截图。

  6. 现在,从自包含文件中导入 (还原) Azure Database for MySQL 实例中的数据库。Now, import (restore) the database in the Azure Database for MySQL instance from the self-contained file. 为实例创建新架构 (osticket) 。A new schema (osticket) is created for the instance.

    显示 "从自包含文件导入" 选项的屏幕截图。

将 VM 连接到数据库Connect the VM to the database

作为迁移过程的最后一步,Contoso 管理员将应用程序的连接字符串更新为指向 VM 上运行的应用程序数据库 OSTICKETMYSQLAs the final step in the migration process, Contoso admins update the connection string of the application to point to the application database running on the OSTICKETMYSQL VM.

  1. OSTICKETWEB使用 PuTTY 或其他 SSH 客户端建立到 VM 的 SSH 连接。Make an SSH connection to the OSTICKETWEB VM by using PuTTY or another SSH client. VM 是专用的,因此请使用专用 IP 地址进行连接。The VM is private, so connect by using the private IP address.

    显示 "连接到虚拟机" 窗格的屏幕截图。

    显示与数据库的连接的屏幕截图。

  2. 请确保 OSTICKETWEB vm 可以与 OSTICKETMYSQL vm 通信。Make sure that the OSTICKETWEB VM can communicate with the OSTICKETMYSQL VM. 目前,配置会硬编码为本地 IP 地址 172.16.0.43Currently, the configuration is hardcoded with the on-premises IP address 172.16.0.43.

    更新前:Before the update:

    显示更新之前的 IP 的屏幕截图。

    更新后:After the update:

    显示更新后的 IP 屏幕截图。

  3. 用重启服务 systemctl restart apache2Restart the service with systemctl restart apache2.

    显示服务重新启动的屏幕截图。

  4. 最后, OSTICKETWEB OSTICKETMYSQL 在某个 Contoso 域控制器上更新和的 DNS 记录。Finally, update the DNS records for OSTICKETWEB and OSTICKETMYSQL on one of the Contoso domain controllers.

    显示更新 DNS 记录的屏幕截图。

    显示更新 DNS 记录的屏幕截图。

需要更多帮助?Need more help?

查看部署Review the deployment

在应用程序现已运行的情况下,Contoso 需要完全操作并保护其新基础结构。With the application now running, Contoso needs to fully operationalize and secure its new infrastructure.

迁移后的清理Clean up after migration

完成迁移后,osTicket 应用程序层将在 Azure Vm 上运行。With migration complete, the osTicket application tiers are running on Azure VMs.

现在,Contoso 需要执行以下任务:Now, Contoso needs to do the following tasks:

  • 从 vCenter 清单中删除 VMware VM。Remove the VMware VMs from the vCenter inventory.
  • 从本地备份作业中删除本地 VM。Remove the on-premises VMs from local backup jobs.
  • 更新内部文档以显示新的位置和 IP 地址。Update internal documentation to show new locations and IP addresses.
  • 查看与本地 Vm 交互的任何资源。Review any resources that interact with the on-premises VMs. 更新任何相关设置或文档以反映新配置。Update any relevant settings or documentation to reflect the new configuration.
  • Contoso 使用了 Azure Migrate 与依赖关系映射来评估要 OSTICKETWEB 迁移的 VM。Contoso used Azure Migrate with dependency mapping to assess the OSTICKETWEB VM for migration.

安全性Security

Contoso 安全团队查看 VM 和数据库,以确定所有安全问题:The Contoso security team reviews the VM and database to determine any security issues:

  • 它们查看 VM 的网络安全组 (Nsg) ,以控制访问。They review the network security groups (NSGs) for the VM to control access. NSG 用于确保仅允许到应用程序的流量可以通过。NSGs are used to ensure that only traffic allowed to the application can pass.
  • 它们考虑使用 Azure 磁盘加密和 Azure Key Vault 来保护 VM 磁盘上的数据。They consider securing the data on the VM disks by using Azure Disk Encryption and Azure Key Vault.
  • SSL 未配置 VM 和数据库实例之间的通信。Communication between the VM and database instance isn't configured for SSL. 它们需要配置 SSL,以确保数据库的流量不受攻击。They'll need to configure SSL to ensure that database traffic can't be hacked.

有关详细信息,请参阅 Azure 中 IaaS 工作负荷的最佳安全方案For more information, see Security best practices for IaaS workloads in Azure.

业务连续性和灾难恢复Business continuity and disaster recovery

对于业务连续性和灾难恢复,Contoso 采取了以下措施:For business continuity and disaster recovery, Contoso takes the following actions:

  • 使数据保持安全。Keep data safe. Contoso 使用 AZURE VM 备份备份应用程序 VM 上的数据。Contoso backs up the data on the application VM by using Azure VM backup. 公司不需要为数据库配置备份。The company doesn't need to configure backup for the database. Azure Database for MySQL 会自动创建并存储服务器备份。Azure Database for MySQL automatically creates and stores server backups. Contoso 选择使用数据库的异地冗余,使其能够复原和生产就绪。Contoso selected to use geo-redundancy for the database so that it's resilient and production ready.
  • 使应用程序保持启动并运行。Keep applications up and running. Contoso 使用 Site Recovery 将 Azure 中的应用程序 Vm 复制到次要区域。Contoso replicates the application VMs in Azure to a secondary region by using Site Recovery. 有关详细信息,请参阅 快速入门:为 AZURE VM 设置到辅助 azure 区域的灾难恢复For more information, see Quickstart: Set up disaster recovery to a secondary Azure region for an Azure VM.

许可和成本优化Licensing and cost optimization

  • 部署资源后,Contoso 将 Azure 标记分配为 azure 基础结构 部署过程中定义的。After deploying resources, Contoso assigns Azure tags as defined during the Azure infrastructure deployment.
  • Contoso Ubuntu 服务器无授权问题。There are no licensing issues for the Contoso Ubuntu servers.
  • Contoso 将使用 Azure 成本管理和计费 来确保公司始终处于 IT 领导地位确立的预算范围内。Contoso will use Azure Cost Management and Billing to ensure the company stays within budgets established by the IT leadership.