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

使用 Azure App Service、流量管理器和 Azure Database for MySQL 重构 Linux 应用程序Refactor a Linux application by using Azure App Service, Traffic Manager, and Azure Database for MySQL

本文介绍了虚构的公司 Contoso 如何重构一种基于双层 灯泡 的应用程序,通过使用具有 GitHub 集成和 Azure Database for MySQL 的 Azure App Service 将其从本地迁移到 Azure。This article shows how the fictional company Contoso refactors a two-tier LAMP-based application, migrating it from on-premises to Azure by using Azure App Service with GitHub integration and Azure Database for MySQL.

本示例中使用的 osTicket 服务应用程序作为开源软件提供。osTicket, the service desk application that we use in this example, is provided as open-source software. 如果要将其用于自己的测试目的,可以从 GitHub 中的 osTicket存储库下载。If you want to use it for your own testing purposes, you can download it from the osTicket repo in 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 moving into new markets. 他们需要更多的客户服务代理。It needs additional customer service agents.
  • 纵向.Scale. 构建的解决方案应当使 Contoso 能够随业务扩展添加更多的客户服务代理。The solution should be built so that Contoso can add more customer service agents as the business scales.
  • 提高复原能力。Improve resiliency. 过去,系统仅影响内部用户的问题。In the past, issues with the system affected internal users only. 对于新的业务模型,外部用户将受到影响,并且 Contoso 始终都需要运行该应用程序。With the new business model, external users will be affected, and Contoso needs the application up and running at all times.

迁移目标Migration goals

为了确定最佳迁移方法,Contoso 云团队已将其目标固定下来:To determine the best migration method, the Contoso cloud team has pinned down their goals for this migration:

  • 应用程序应能够缩放,以超越当前的本地容量和性能。The application should scale beyond current on-premises capacity and performance. Contoso 将移动应用程序以利用 Azure 的按需缩放功能。Contoso is moving the application to take advantage of Azure's on-demand scaling.
  • Contoso 想要将应用程序代码库移到持续交付管道。Contoso wants to move the application code base to a continuous delivery pipeline. 当应用程序更改推送到 GitHub 时,Contoso 希望在不为操作人员提供任务的情况下部署这些更改。As application changes are pushed to GitHub, Contoso wants to deploy those changes without tasks for operations staff.
  • 应用程序必须具有复原能力和增长和故障转移功能。The application must be resilient, with capabilities for growth and failover. Contoso 希望在两个不同的 Azure 区域中部署应用程序,并将其设置为自动缩放。Contoso wants to deploy the application in two different Azure regions and set it up to scale automatically.
  • Contoso 希望,将应用程序移动到云之后,可以最大程度地减轻数据库管理员任务。Contoso wants to minimize database admin tasks after the application is moved to the cloud.

解决方案设计Solution design

在确定其目标和要求后,Contoso 设计并审查部署解决方案,确定迁移流程,包括将用于迁移的 Azure 服务。After pinning down their goals and requirements, Contoso designs and reviews a deployment solution, and identifies the migration process, including the Azure services that will be used for the migration.

当前体系结构Current architecture

  • 应用程序在两个虚拟机之间分层 (Vm) (OSTICKETWEBOSTICKETMYSQL) 。The application is tiered across two virtual machines (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 环境由 VM 上运行的 vCenter Server 6.5 (vcenter.contoso.com) 托管。The VMware environment is managed by vCenter Server 6.5 (vcenter.contoso.com), running on a VM.
  • Contoso 有本地数据中心 (contoso-datacenter),其中包含本地域控制器 (contosodc1)。Contoso has an on-premises datacenter (contoso-datacenter), with an on-premises domain controller (contosodc1).

当前体系结构的关系图。

建议的体系结构Proposed architecture

下面是建议的体系结构:Here's the proposed architecture:

  • OSTICKETWEB将通过在两个 Azure 区域中生成一个 Azure App Service web 应用来迁移上的 web 层应用程序。The web tier application on OSTICKETWEB will be migrated by building an Azure App Service web app in two Azure regions. Contoso 团队将使用 PHP 7.0 Docker 容器实现 Linux Azure App Service。The Contoso team will implement Azure App Service for Linux by using the PHP 7.0 Docker container.
  • 应用程序代码将移至 GitHub,将配置 Azure App Service 的 web 应用,以便通过 GitHub 进行持续交付。The application code will be moved to GitHub, and the Azure App Service web app will be configured for continuous delivery with GitHub.
  • Azure App Service 将同时部署在主要区域中 (East US 2) 和次要区域 (Central US) 中。Azure App Service will be deployed in both the primary region (East US 2) and secondary region (Central US).
  • Azure 流量管理器将在两个区域的两个 web 应用前面设置。Azure Traffic Manager will be set up in front of the two web apps in both regions.
  • 流量管理器将在优先级模式下配置为强制流量通过 East US 2Traffic Manager will be configured in priority mode to force the traffic through East US 2.
  • 如果中的 Azure 应用服务器 East US 2 进入脱机状态,则用户可以在中访问故障转移的应用程序 Central USIf the Azure app server in East US 2 goes offline, users can access the failed over application in Central US.
  • 应用程序数据库将使用 Azure 数据库迁移服务迁移到 Azure Database for MySQL 服务。The application database will be migrated to the Azure Database for MySQL service by using Azure Database Migration Service. 本地数据库将在本地备份,并直接还原到 Azure Database for MySQL。The on-premises database will be backed up locally, and restored directly to Azure Database for MySQL.
  • 数据库将位于数据库子网中 () 的主要区域, East US 2 (PROD-DB-EUS2 生产网络 (VNET-PROD-EUS2) ) 。The database will reside in the primary region (East US 2) in the database subnet (PROD-DB-EUS2) of the production network (VNET-PROD-EUS2).
  • 由于它们在迁移生产工作负荷,因此该应用程序的 Azure 资源将驻留在生产资源组中 ContosoRGSince they're migrating a production workload, Azure resources for the application will reside in the production resource group ContosoRG.
  • 流量管理器资源将部署在 Contoso 的基础结构资源组中 ContosoInfraRGThe Traffic Manager resource will be deployed in Contoso's infrastructure resource group ContosoInfraRG.
  • 迁移完成后,Contoso 数据中心的本地 VM 将停止使用。The on-premises VMs in the Contoso datacenter will be decommissioned after the migration is done.

方案体系结构的关系图。

迁移过程Migration process

Contoso 完成迁移过程,如下所示:Contoso completes the migration process as follows:

  1. 作为第一步,Contoso 管理员设置 Azure 基础结构,包括设置 Azure App Service、设置流量管理器,以及预配 Azure Database for MySQL 实例。As a first step, Contoso admins set up the Azure infrastructure, including provisioning Azure App Service, setting up Traffic Manager, and provisioning an Azure Database for MySQL instance.
  2. 准备 Azure 基础结构后,它们使用 Azure 数据库迁移服务迁移数据库。After preparing the Azure infrastructure, they migrate the database by using Azure Database Migration Service.
  3. 在 Azure 中运行数据库后,它们将为带有持续交付的 Azure App Service 上传 GitHub 专用存储库,并将其加载到 osTicket 应用程序。After the database is running in Azure, they upload a GitHub private repository for Azure App Service with continuous delivery, and load it with the osTicket application.
  4. 在 Azure 门户中,它们通过运行 Azure App Service 将应用程序从 GitHub 加载到 Docker 容器。In the Azure portal, they load the application from GitHub to the Docker container by running Azure App Service.
  5. 它们会调整 DNS 设置并配置应用程序的自动缩放。They tweak DNS settings and configure autoscaling for the application.

Contoso 迁移过程的示意图。

Azure 服务Azure services

服务Service 说明Description 成本Cost
Azure 应用服务Azure App Service 该服务使用 Azure 平台即服务 (PaaS) 网站来运行和缩放应用程序。The service runs and scales applications by using Azure platform as a service (PaaS) for websites. 定价取决于实例的大小和所需的功能。Pricing is based on the size of the instances and the features required. 了解详细信息Learn more.
Azure 流量管理器Azure Traffic Manager 一种使用域名系统 (DNS) 将用户定向到 Azure 或外部网站和服务的负载均衡器。A load balancer that uses Domain Name System (DNS) to direct users to Azure or to external websites and services. 定价基于接收的 DNS 查询数和监视的终结点数。Pricing is based on the number of received DNS queries and the number of monitored endpoints. 了解详细信息Learn more.
Azure 数据库迁移服务Azure Database Migration Service Azure 数据库迁移服务实现了从多个数据库源到 Azure 数据平台的无缝迁移,且停机时间最短。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. 定价基于计算、存储和备份要求。Pricing is based on compute, storage, and backup requirements. 了解详细信息Learn more.

先决条件Prerequisites

若要运行此方案,Contoso 必须满足以下先决条件:To run this scenario, Contoso must meet the following prerequisites:

要求Requirements 详细信息Details
Azure 订阅Azure subscription 在前面的系列文章中,Contoso 已创建订阅。Contoso created subscriptions earlier in this article series. 如果还没有 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, you need to work with the admin to assign you Owner or Contributor permissions.
Azure 基础结构Azure infrastructure Contoso 按照用于迁移的 Azure 基础结构中所述设置其 Azure 基础结构。Contoso set up their Azure infrastructure as described in Azure infrastructure for migration.

方案步骤Scenario steps

下面是用于完成迁移的 Contoso 计划:Here's the Contoso plan for completing the migration:

  • 步骤1:设置 Azure App ServiceStep 1: Provision Azure App Service. Contoso 管理员将在主区域和次要区域中预配 Web 应用。Contoso admins will provision web apps in the primary and secondary regions.
  • 步骤2:设置流量管理器Step 2: Set up Traffic Manager. 他们在 Web 应用之前设置流量管理器,用于对流量进行路由和负载均衡。They set up Traffic Manager in front of the web apps, for routing and load balancing traffic.
  • 步骤3:设置 Azure Database for MySQLStep 3: Provision Azure Database for MySQL. 在 Azure 中,管理员预配 Azure Database for MySQL 实例。In Azure, they provision an instance of Azure Database for MySQL.
  • 步骤4:迁移数据库Step 4: Migrate the database. 它们使用 Azure 数据库迁移服务迁移数据库。They migrate the database by using Azure Database Migration Service.
  • 步骤5:设置 GitHubStep 5: Set up GitHub. 它们为应用程序网站和代码设置了本地 GitHub 存储库。They set up a local GitHub repository for the application web sites and code.
  • 步骤6:配置 web 应用Step 6: Configure the web apps. 它们通过 osTicket 网站配置 web 应用。They configure the web apps with the osTicket websites.

步骤1:设置 Azure App ServiceStep 1: Provision Azure App Service

Contoso 管理员通过使用 Azure App Service,将两个 web 应用分别 (每个区域) 。Contoso admins provision two web apps (one in each region) by using Azure App Service.

  1. 它们 osticket-eus2 通过 Azure Marketplace () 在主要区域中创建 () 的 web 应用资源 East US 2They create a web app resource (osticket-eus2) in the primary region (East US 2) via Azure Marketplace.

  2. 它们将资源放入生产资源组 ContosoRGThey put the resource in the production resource group ContosoRG.

    用于在 Linux 中创建 web 应用的 "Web 应用" 窗格的屏幕截图。

  3. 它们在主要区域中创建应用服务计划, APP-SVP-EUS2 并使用标准大小。They create an App Service plan, APP-SVP-EUS2, in the primary region, and they use the standard size.

    用于创建应用服务计划的 "新建应用服务计划" 窗格的屏幕截图。

  4. 选择包含 PHP 7.0 运行时堆栈(这是一个 Docker 容器)的 Linux OS。They select a Linux OS with PHP 7.0 runtime stack, which is a Docker container.

    选择 "Web 应用" 窗格的屏幕截图,其中包含 Linux OS、美国东部2位置和 PHP 7.0。

  5. 他们会创建第二个 web 应用, osticket-cus 并为 美国中部 Azure App Service 计划。They create a second web app, osticket-cus, and an Azure App Service plan for Central US.

    选择 "Web 应用" 窗格的屏幕截图,其中包含 Linux OS、美国中部位置和 PHP 7.0。

需要更多帮助?Need more help?

步骤 2:设置流量管理器Step 2: Set up Traffic Manager

Contoso 管理员设置流量管理器,以将入站 web 请求定向到在 osTicket web 层上运行的 web 应用。Contoso admins set up Traffic Manager to direct inbound web requests to the web apps that are running on the osTicket web tier.

  1. 在 Azure Marketplace 中,他们创建了流量管理器资源 osticket.trafficmanager.netIn Azure Marketplace, they create a Traffic Manager resource, osticket.trafficmanager.net. 它们使用优先级路由,以便 美国东部 2 是主站点。They use priority routing so that East US 2 is the primary site. 它们将资源置于其现有的基础结构资源组中 ContosoInfraRGThey place the resource in their existing infrastructure resource group, ContosoInfraRG. 请注意,流量管理器是全局性的,不绑定到特定位置。Note that Traffic Manager is global and not bound to a specific location.

    "创建流量管理器配置文件" 窗格的屏幕截图。

  2. 它们将流量管理器配置为终结点。They configure Traffic Manager with endpoints. 他们将美国东部2中的 web 应用添加为主站点, osticket-eus2 并将美国中部的 web 应用添加为辅助站点 osticket-cusThey add the web app in East US 2 as the primary site, osticket-eus2, and the web app in Central US as the secondary site, osticket-cus.

    流量管理器中的 "添加终结点" 窗格的屏幕截图。

  3. 添加终结点后,管理员可以对其进行监视。After they add the endpoints, the admins can monitor them.

    用于监视流量管理器中的终结点的 "终结点" 窗格的屏幕截图。

需要更多帮助?Need more help?

步骤 3:设置 Azure Database for MySQLStep 3: Provision Azure Database for MySQL

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

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

    Azure 门户中 Azure Database for MySQL 链接的屏幕截图。

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

  3. 本地 MySQL 数据库版本为 5.7,因此,他们选择此版本以便获得兼容性。The on-premises MySQL database is version 5.7, so they select this version for compatibility. 他们使用满足其数据库需求的默认大小。They use the default sizes, which match their database requirements.

    选择版本5.7 的 "MySQL Server * *" 窗格的屏幕截图。

  4. 对于 备份冗余选项,请选择 " 异地冗余"。For Backup Redundancy Options, they select Geo-Redundant. 如果发生中断,则使用此选项可将数据库还原到其次要区域中的数据库 (美国中部) 。This option allows them to restore the database in their secondary region (Central US) if an outage occurs. 只有在设置数据库时,才能配置此选项。They can configure this option only when they provision the database.

    "备份冗余选项" 窗格的屏幕截图,其中选择了 "Geo-Redundant" 选项。

  5. 设置连接安全性。They set up connection security. 在数据库中,它们选择 " 连接安全性 ",然后设置防火墙规则以允许数据库访问 Azure 服务。In the database, they select Connection security and then set up firewall rules to allow the database to access Azure services.

  6. 他们将本地工作站客户端 IP 地址添加到开始和结束 IP 地址。They add the local workstation client IP address to the start and end IP addresses. 这允许 Web 应用访问 MySQL 数据库,以及执行迁移的数据库客户端。This allows the web apps to access the MySQL database, along with the database client that's performing the migration.

    "连接安全" 窗格的屏幕截图,显示已打开 "对 Azure 服务的访问" 和所选的客户端 IP 地址。

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

可以通过多种方式来移动 MySQL 数据库。There are several ways to move the MySQL database. 每个选项都需要 Contoso 管理员为目标创建 Azure Database for MySQL 实例。Each option requires Contoso admins to create an Azure Database for MySQL instance for the target. 创建实例后,可以使用以下两个路径之一迁移数据库:After they create the instance, they can migrate the database by using either of two paths:

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

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

Contoso 管理员按照分步 迁移教程操作,通过 Azure 数据库迁移服务迁移数据库。Contoso admins migrate the database via Azure 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 does not yet support this version.

简而言之,Contoso 执行以下操作:In brief, Contoso does the following:

  • 它们确保满足所有迁移先决条件:They ensure that all migration prerequisites are met:

    • MySQL 数据库服务器源必须与 Azure Database for MySQL 支持的版本相匹配。The MySQL database server 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 source and target with the same versions.

    • 它们 my.ini (Windows) 或 my.cnf (Unix) 启用二进制日志记录。They enable binary logging in my.ini (Windows) or my.cnf (Unix). 如果无法执行此操作,则会导致迁移向导中出现以下错误: Error in binary logging. Variable binlog_row_image has value 'minimal'. Please change it to 'full'. 有关详细信息,请参阅 MySQL 文档Failure to do this will cause the following error in the Migration Wizard: Error in binary logging. Variable binlog_row_image has value 'minimal'. Please change it to 'full'. For more information, see the MySQL documentation.

    • 用户必须具有 ReplicationAdmin 角色。The user must have the ReplicationAdmin role.

    • 迁移没有外键和触发器的数据库架构。Migrate the database schemas without foreign keys and triggers.

  • 它们创建一个虚拟专用网络 (VPN) ,该网络通过 ExpressRoute 或 VPN 连接到本地网络。They create a virtual private network (VPN) that connects via ExpressRoute or VPN to the on-premises network.

  • 它们使用连接到虚拟网络的高级 SKU 创建 Azure 数据库迁移服务实例。They create an Azure Database Migration Service instance with a Premium SKU that's connected to the virtual network.

  • 它们确保 Azure 数据库迁移服务可通过虚拟网络访问 MySQL 数据库。They ensure that Azure Database Migration Service can access the MySQL database via the virtual network. 这需要确保在虚拟网络级别、网络 VPN 和托管 MySQL 的计算机上,允许所有传入端口从 Azure 到 MySQL。This entails ensuring that all incoming ports are allowed from Azure to MySQL at the virtual network level, the network VPN, and the machine that hosts MySQL.

  • 它们运行 "数据库迁移服务" 工具,然后执行以下操作:They run the Database Migration Service tool and then do the following:

    1. 创建基于高级 SKU 的迁移项目。Create a migration project that's based on the Premium SKU.

      MySQL 概述窗格屏幕截图,并显示一条消息,指出已成功创建迁移服务。

      MySQL * * "新建迁移项目" 窗格的屏幕截图。

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

      迁移向导的屏幕截图 * * "添加源详细信息" 窗格。

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

      迁移向导的屏幕截图 * * "目标详细信息" 窗格。

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

      迁移向导的屏幕截图 * * "映射到目标数据库" * * 窗格。

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

      迁移向导的屏幕截图 * * "迁移设置" * * 窗格。

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

      "服务器详细信息" 窗格的屏幕截图。

    7. 执行最终切换。Perform the final cutover.

      "OsTicket 详细信息" 窗格的屏幕截图。

      * * "完成转换" 窗格的屏幕截图。

      迁移活动状态表的屏幕截图。

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

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

      * * 迁移活动 * * 表的屏幕截图。

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

  1. Contoso 管理员检查 先决条件并下载 MySQL 工作台The Contoso admins check the prerequisites and downloads MySQL Workbench.

  2. 根据安装说明安装适用于 Windows 的 MySQL Workbench。They install MySQL Workbench for Windows in accordance with the installation instructions. 虚拟机和 Azure 上安装 MySQL 工作台的计算机必须可 osticketmysql 通过 internet 访问。The machine that they install MySQL Workbench on must be accessible to the osticketmysql VM and to Azure via the internet.

  3. 在 MySQL 工作台中,它们创建到的 MySQL 连接 osticketmysqlIn MySQL Workbench, they create a MySQL connection to osticketmysql.

    MySQL 工作台连接详细信息窗格的屏幕截图。

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

    MySQL 工作台 * * 数据导出 * * 窗格的屏幕截图。

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

    MySQL 工作台 * * "设置新连接" 窗格。

  6. 现在,他们可以从自包含文件中导入) Azure Database for MySQL 实例中的数据库 (还原。Now, they can 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.

    MySQL 工作台 * * 数据导入 * * 窗格的屏幕截图。

  7. 还原数据后,管理员可以使用 MySQL 工作台进行查询。After they've restored the data, the admins can query it by using MySQL Workbench. 数据显示在 Azure 门户中。The data is displayed in the Azure portal.

    显示已还原数据的 Azure 门户屏幕截图。

    "我的 SQL 数据库" 边栏选项卡的屏幕截图,其中箭头指向 osticket 数据库。

  8. 管理员更新 web 应用上的数据库信息。The admins update the database information on the web apps. 在 MySQL 实例上,他们打开“连接字符串”。On the MySQL instance, they open Connection Strings.

    MySQL 实例中的 "连接字符串" 链接的屏幕截图。

  9. 在 "连接字符串" 列表中,选择 "web 应用" 设置,然后选择 " 单击以复制" 进行复制。In the connection strings list, they select the web app settings and then copy them by selecting Click to copy.

    MySQL 实例中 web 应用设置的屏幕截图。

  10. 它们在记事本中打开一个新文件,将该字符串粘贴到该文件中,并更新字符串以匹配 osTicket 数据库、MySQL 实例和凭据设置。They open a new file in Notepad, paste the string into it, and update the string to match the osTicket database, MySQL instance, and credentials settings.

    粘贴到记事本文件中的连接字符串的屏幕截图。

  11. 他们可以通过 Azure 门户中 MySQL 实例的 " 概述 " 窗格验证服务器名称和登录名。They can verify the server name and sign-in via the Overview pane for the MySQL instance in the Azure portal.

    资源组窗格的屏幕截图,显示服务器名称和服务器管理员帐户名称。

步骤 5:设置 GitHubStep 5: Set up GitHub

Contoso 管理员创建新的专用 GitHub 存储库,并在 Azure Database for MySQL 中设置与 osTicket 数据库的连接。Contoso admins create a new private GitHub repo and set up a connection to the osTicket database in Azure Database for MySQL. 然后,它们会将 Web 应用加载到 Azure 应用服务中。Then, they load the web app into Azure App Service.

  1. 他们浏览到 osTicket software 公共 GitHub 存储库,并将其与 Contoso GitHub 帐户进行分支。They browse to the osTicket software public GitHub repo and fork it to the Contoso GitHub account.

    GitHub 存储库页的屏幕截图,突出显示 "分叉" 按钮。

  2. 在它们分叉了存储库后,它们将浏览到该 include 文件夹,然后选择该 ost-config.php 文件。After they fork the repo, they browse to the include folder and select the ost-config.php file.

    GitHub 中的 PHP 文件的屏幕截图。

  3. 文件将在浏览器中打开,并对其进行编辑。The file opens in the browser, and they edit it.

    GitHub 中的文件编辑 (铅笔) 图标的屏幕截图。

  4. 在编辑器中,管理员更新数据库详细信息,特别是针对 DBHOSTDBUSERIn the editor, the admins update the database details, specifically for DBHOST and DBUSER.

    GitHub 中 "文件编辑" 窗格的屏幕截图。

  5. 它们将提交更改。They commit the changes.

    显示 "编辑" 窗格上的 "提交更改" 按钮的屏幕截图。

  6. 对于每个 web 应用 (osticket-eus2osticket-cus) ,请在 Azure 门户中选择左窗格中的 " 应用程序设置 ",并修改设置。For each web app (osticket-eus2 and osticket-cus), in the Azure portal, they select Application settings on the left pane and then modify the settings.

    显示 Azure 门户中的 "应用程序设置" 链接的屏幕截图。

  7. 它们输入名称为的连接字符串 osticket ,并将字符串从记事本复制到 值区域They enter the connection string with the name osticket, and copy the string from Notepad into the value area. 他们从字符串旁边的下拉列表中选择 MySQL,然后保存设置。They select MySQL in the dropdown list next to the string, and save the settings.

    "连接字符串" 窗格的屏幕截图,突出显示 osTicket 连接字符串。

步骤6:配置 web 应用Step 6: Configure the web apps

作为迁移过程的最后一步,Contoso 管理员通过 osTicket 网站配置 web 应用。As the final step in the migration process, Contoso admins configure the web apps with the osTicket websites.

  1. 在主 web 应用中, osticket-eus2 它们打开 " 部署" 选项 ,然后将 "源" 设置为 " GitHub"。In the primary web app, osticket-eus2, they open Deployment option and then set the source to GitHub.

    "部署选项" 窗格的屏幕截图,其中选择了 "GitHub" 作为 "源"。

  2. 他们选择部署选项。They select the deployment options.

    "部署选项" 窗格中的选项详细信息的屏幕截图。

  3. 设置这些选项后,配置将在 Azure 门户中显示为 " 挂起 "。After they set the options, the configuration shows as Pending in the Azure portal.

    显示挂起站点状态的 "部署选项" 窗格的屏幕截图。

  4. 在配置更新并将 osTicket web 应用从 GitHub 加载到运行 Azure App Service 的 Docker 容器后,该站点会显示为 " 活动"。After the configuration is updated and the osTicket web app is loaded from GitHub to the Docker container that runs the Azure App Service, the site shows as Active.

    "部署选项" 窗格的屏幕截图。

  5. 它们为辅助 web 应用重复前面的步骤 osticket-cusThey repeat the preceding steps for the secondary web app, osticket-cus.

  6. 配置站点后,可以通过流量管理器配置文件访问它。After the site is configured, it's accessible via the Traffic Manager profile. DNS 名称是 osTicket 应用程序的新位置。The DNS name is the new location of the osTicket application. 了解详细信息Learn more.

    显示 DNS 名称的 "流量管理器配置文件" 窗格的屏幕截图。

  7. Contoso 希望使用易于记忆的 DNS 名称。Contoso wants to use a DNS name that's easy to remember. 在 " 新建资源记录 " 窗格中,它们创建一个别名、一个 CNAME 和一个完全限定的域名,它们 osticket.contoso.com 指向域控制器上 DNS 中的流量管理器名称。On the New Resource Record pane, they create an alias, a CNAME, and a fully qualified domain name, osticket.contoso.com, which points to the Traffic Manager name in the DNS on their domain controllers.

    "新建资源记录" 窗格的屏幕截图,显示别名和流量管理器的指针。

  8. 它们将 osticket-eus2osticket-cus web apps 配置为允许自定义主机名。They configure both the osticket-eus2 and osticket-cus web apps to allow the custom host names.

    "Ad 主机名" 窗格的屏幕截图,突出显示 "验证" 按钮。

设置自动缩放Set up autoscaling

最后,Contoso 管理员为应用程序设置自动缩放。Finally, the Contoso admins set up automatic scaling for the application. 自动缩放可确保当代理使用应用程序时,应用程序实例会根据业务需求增加和减少。Automatic scaling ensures that, as agents use the application, the application instances increase and decrease according to business needs.

  1. 在应用服务中 APP-SVP-EUS2 ,它们打开 缩放单位In App Service APP-SVP-EUS2, they open Scale Unit.

  2. 它们使用单个规则配置新的自动缩放设置,当当前实例的 CPU 使用率70超过10分钟时,将实例计数增加1。They configure a new autoscale setting with a single rule that increases the instance count by one when the CPU usage for the current instance is above 70 percent for 10 minutes.

    第一个区域的 "自动缩放设置" 页的屏幕截图。

  3. 它们配置相同的设置 APP-SVP-CUS ,以确保在应用程序故障转移到次要区域时,相同的行为也适用。They configure the same setting on APP-SVP-CUS to ensure that the same behavior applies if the application fails over to the secondary region. 唯一的区别是,它们将默认实例设置为1,因为这仅用于故障转移。The only difference is that they set the default instance to 1, because this is for failovers only.

    第二个区域的 "自动缩放设置" 页的屏幕截图。

迁移后的清理Clean up after migration

完成迁移后,osTicket 应用程序将重构,以便在使用专用 GitHub 存储库的持续交付的 Azure App Service web 应用中运行。With the migration complete, the osTicket application is refactored to run in an Azure App Service web app with continuous delivery by using a private GitHub repo. 应用程序在两个区域中运行,以提高恢复能力。The application runs in two regions for increased resilience. 迁移到 PaaS 平台后,osTicket 数据库在 Azure Database for MySQL 运行。The osTicket database runs in Azure Database for MySQL after migration to the PaaS platform.

若要在迁移后进行清理,Contoso 会执行以下操作:To clean up after the migration, Contoso does the following:

  • 它们将 VMware Vm 从 vCenter 清单中删除。They remove the VMware VMs from the vCenter inventory.
  • 从本地备份作业中删除本地 VM。They remove the on-premises VMs from local backup jobs.
  • 它们将更新内部文档以显示新的位置和 IP 地址。They update internal documentation to show new locations and IP addresses.
  • 它们查看与本地 Vm 交互的任何资源,并更新所有相关的设置或文档以反映新的配置。They review any resources that interact with the on-premises VMs, and update any relevant settings or documentation to reflect the new configuration.
  • 它们将监视重新配置为指向 osticket-trafficmanager.net URL,以跟踪应用程序是否已启动并正在运行。They reconfigure monitoring to point to the osticket-trafficmanager.net URL, to track that the application is up and running.

查看部署Review the deployment

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

安全性Security

Contoso 安全团队评审应用程序以确定任何安全问题。The Contoso security team reviews the application to determine any security issues. 它们确定未为 SSL 配置 osTicket 应用程序和 MySQL 数据库实例之间的通信。They identify that the communication between the osTicket application and the MySQL database instance isn't configured for SSL. 这一切都可以确保数据库的流量不受攻击。They do all this to ensure that the database traffic can't be hacked. 了解详细信息Learn more.

备份Backups

  • OsTicket web 应用不包含状态数据,因此不需要备份。The osTicket web apps don't contain state data and thus don't require backup.
  • Contoso 团队无需为数据库配置备份。The Contoso team doesn't need to configure backup for the database. Azure Database for MySQL 会自动创建并存储服务器备份。Azure Database for MySQL automatically creates server backups and stores. 此团队选择对数据库使用异地冗余,因此它具有复原能力和生产就绪性。The team elected to use geo-redundancy for the database, so it's resilient and production-ready. 备份可用于将其服务器还原到某个时间点。Backups can be used to restore their server to a point-in-time. 了解详细信息Learn more.

许可和成本优化Licensing and cost optimization

  • PaaS 部署不存在许可问题。There are no licensing issues for the PaaS deployment.
  • Contoso 将使用 Azure 成本管理 + 计费 ,以确保它们保持在其 IT 领导地位确立的预算内。Contoso will use Azure Cost Management + Billing to ensure that they stay within the budgets established by their IT leadership.