教程:使用 DMS(预览版)将 Oracle 联机迁移到 Azure Database for PostgreSQLTutorial: Migrate Oracle to Azure Database for PostgreSQL online using DMS (Preview)

可以使用 Azure 数据库迁移服务在尽量缩短停机时间的情况下,将本地或虚拟机中的 Oracle 数据库迁移到 Azure Database for PostgreSQLYou can use Azure Database Migration Service to migrate the databases from Oracle databases hosted on-premises or on virtual machines to Azure Database for PostgreSQL with minimal downtime. 换而言之,完成这种迁移只会对应用程序造成极短暂的停机。In other words, you can complete the migration with minimal downtime to the application. 本教程介绍如何使用 Azure 数据库迁移服务中的联机迁移活动,将 HR 示例数据库从 Oracle 11g 的本地或虚拟机实例迁移到 Azure Database for PostgreSQL。In this tutorial, you migrate the HR sample database from an on-premises or virtual machine instance of Oracle 11g to Azure Database for PostgreSQL by using the online migration activity in Azure Database Migration Service.

本教程介绍如何执行下列操作:In this tutorial, you learn how to:

  • 使用 ora2pg 工具评估迁移工作量。Assess the migration effort using the ora2pg tool.
  • 使用 ora2pg 工具迁移示例架构。Migrate the sample schema using the ora2pg tool.
  • 创建 Azure 数据库迁移服务的实例。Create an instance of Azure Database Migration Service.
  • 使用 Azure 数据库迁移服务创建迁移项目。Create a migration project by using Azure Database Migration Service.
  • 运行迁移。Run the migration.
  • 监视迁移。Monitor the migration.

备注

使用 Azure 数据库迁移服务执行联机迁移需要基于“高级”定价层创建实例。Using Azure Database Migration Service to perform an online migration requires creating an instance based on the Premium pricing tier.

重要

为获得最佳迁移体验,Azure 建议在目标数据库所在的 Azure 区域中创建 Azure 数据库迁移服务的实例。For an optimal migration experience, Azure recommends creating an instance of Azure Database Migration Service in the same Azure region as the target database. 跨区域或地理位置移动数据可能会减慢迁移过程并引入错误。Moving data across regions or geographies can slow down the migration process and introduce errors.

提示

使用 Azure 数据库迁移服务将数据库迁移到 Azure 时,可以进行脱机或联机迁移。 When you migrate databases to Azure by using Azure Database Migration Service, you can do an offline or an online migration. 使用脱机迁移时,应用程序停机时间从迁移开始时算起。With an offline migration, application downtime starts when the migration starts. 使用联机迁移时,停机时间仅限在迁移结束时进行转换的那段时间。With an online migration, downtime is limited to the time to cut over at the end of migration. 建议对脱机迁移进行测试,以便确定其停机时间是否可以接受;如果不能接受,请进行联机迁移。We suggest that you test an offline migration to determine whether the downtime is acceptable; if not, do an online migration.

本文介绍如何从 Oracle 联机迁移到 Azure Database for PostgreSQL。This article describes how to perform an online migration from Oracle to Azure Database for PostgreSQL.

先决条件Prerequisites

要完成本教程,需要:To complete this tutorial, you need to:

  • 下载并安装 Oracle 11g 发行版 2(Standard Edition、Standard Edition One 或 Enterprise Edition)Download and install Oracle 11g Release 2 (Standard Edition, Standard Edition One, or Enterprise Edition).

  • 此处下载示例 HR 数据库。Download the sample HR database from here.

  • 下载 ora2pg 并将其安装在 Windows 或 Linux 上Download and install ora2pg on either Windows or Linux.

  • 在 Azure Database for PostgreSQL 中创建实例Create an instance in Azure Database for PostgreSQL.

  • 参考此文档中的说明连接到该实例并创建数据库。Connect to the instance and create a database using the instruction in this document.

  • 使用 Azure 资源管理器部署模型创建 Azure 数据库迁移服务的 Azure 虚拟网络,它将使用 ExpressRouteVPN 为本地源服务器提供站点到站点连接。Create an Azure Virtual Network for Azure Database Migration Service by using the Azure Resource Manager deployment model, which provides site-to-site connectivity to your on-premises source servers by using either ExpressRoute or VPN. 有关创建虚拟网络的详细信息,请参阅虚拟网络文档,尤其是提供了分步详细信息的快速入门文章。For more information about creating a virtual network, see the Virtual Network Documentation, and especially the quickstart articles with step-by-step details.

    备注

    在设置虚拟网络期间,如果将 ExpressRoute 与 Azure 的网络对等互连一起使用,请将以下服务终结点添加到将在其中预配服务的子网:During virtual network setup, if you use ExpressRoute with network peering to Azure, add the following service endpoints to the subnet in which the service will be provisioned:

    • 目标数据库终结点(例如,SQL 终结点、Cosmos DB 终结点等)Target database endpoint (for example, SQL endpoint, Cosmos DB endpoint, and so on)
    • 存储终结点Storage endpoint
    • 服务总线终结点Service bus endpoint

    Azure 数据库迁移服务缺少 Internet 连接,因此必须提供此配置。This configuration is necessary because Azure Database Migration Service lacks internet connectivity.

  • 确保虚拟网络网络安全组 (NSG) 规则未阻止到 Azure 数据库迁移服务的以下入站通信端口:443、53、9354、445、12000。Ensure that your virtual network Network Security Group (NSG) rules don't block the following inbound communication ports to Azure Database Migration Service: 443, 53, 9354, 445, 12000. 有关虚拟网络 NSG 流量筛选的更多详细信息,请参阅使用网络安全组筛选网络流量一文。For more detail on virtual network NSG traffic filtering, see the article Filter network traffic with network security groups.

  • 配置针对数据库引擎访问的 Windows 防火墙Configure your Windows Firewall for database engine access.

  • 打开 Windows 防火墙,使 Azure 数据库迁移服务能够访问源 Oracle 服务器(默认使用 TCP 端口 1521)。Open your Windows firewall to allow Azure Database Migration Service to access the source Oracle server, which by default is TCP port 1521.

  • 在源数据库的前面使用了防火墙设备时,可能需要添加防火墙规则以允许 Azure 数据库迁移服务访问要迁移的源数据库。When using a firewall appliance in front of your source database(s), you may need to add firewall rules to allow Azure Database Migration Service to access the source database(s) for migration.

  • 为 Azure Database for PostgreSQL 创建服务器级防火墙规则,以允许 Azure 数据库迁移服务访问目标数据库。Create a server-level firewall rule for Azure Database for PostgreSQL to allow Azure Database Migration Service access to the target databases. 提供用于 Azure 数据库迁移服务的虚拟网络子网范围。Provide the subnet range of the virtual network used for Azure Database Migration Service.

  • 启用对源 Oracle 数据库的访问。Enable access to the source Oracle databases.

    备注

    用户需有 DBA 角色才能连接到 Oracle 源。The DBA role is required for a user to connect to the Oracle source.

    • 需要在 Azure 数据库迁移服务中为增量同步启用存档重做日志,以捕获数据更改。Archive Redo Logs is required for incremental sync in Azure Database Migration Service to capture data change. 遵循以下步骤配置 Oracle 源:Follow these steps to configure the Oracle source:

      • 运行以下命令,使用 SYSDBA 特权登录:Sign in using SYSDBA privilege by running the following command:

        sqlplus (user)/(password) as sysdba
        
      • 运行以下命令关闭数据库实例。Shut down the database instance by running the following command.

        SHUTDOWN IMMEDIATE;
        

        等待出现确认消息 'ORACLE instance shut down'Wait for the confirmation 'ORACLE instance shut down'.

      • 运行以下命令启动新实例并装载(但不要打开)数据库,以启用或禁用存档:Start the new instance and mount (but don't open) the database to enable or disable archiving bu running the following command:

        STARTUP MOUNT;
        

        必须装载数据库;等待出现确认消息“Oracle 实例已启动”。The database must be mounted; wait for confirmation 'Oracle instance started'.

      • 运行以下命令更改数据库存档模式:Change the database archiving mode by running the following command:

        ALTER DATABASE ARCHIVELOG;
        
      • 运行以下命令打开数据库以进行正常操作:Open the database for normal operations by running the following command:

        ALTER DATABASE OPEN;
        

        可能需要重启才能显示 ARC 文件。You may need to restart for the ARC file to show up.

      • 若要验证,请运行以下命令:To verify, run the following command:

        SELECT log_mode FROM v$database;
        

        应会收到响应 'ARCHIVELOG'You should receive a response 'ARCHIVELOG'. 如果响应为 'NOARCHIVELOG',则表示不符合要求。If the response is 'NOARCHIVELOG', then the requirement isn't met.

    • 使用以下选项之一为复制启用补充日志记录。Enable supplemental logging for replication using one of the following options.

      • 选项 1Option 1. 更改数据库级别补充日志记录,以涵盖包含 PK 和唯一索引的所有表。Change the database level supplemental logging to cover all the tables with PK and unique index. 检测查询将返回 'IMPLICIT'The detection query will return 'IMPLICIT'.

        ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (PRIMARY KEY, UNIQUE) COLUMNS;
        

        更改表级别补充日志记录。Change the table level supplemental logging. 仅针对包含数据操作但不包含 PK 或唯一索引的表运行。Run only for tables that have data manipulation and don't have PKs or unique indexes.

        ALTER TABLE [TABLENAME] ADD SUPPLEMENTAL LOG DATA (ALL) COLUMNS;
        
      • 选项 2Option 2. 更改数据库级别补充日志记录以涵盖所有表,检测查询将返回 'YES'Change the database level supplemental logging to cover all the tables, and the detection query returns 'YES'.

        ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;
        

        更改表级别补充日志记录。Change the table level supplemental logging. 遵循以下逻辑,针对每个表仅运行一条语句。Follow the logic below to run only one statement for every table.

        如果表包含主键:If the table has a primary key:

        ALTER TABLE xxx ADD SUPPLEMENTAL LOG DATA (PRIMARY KEY) COLUMNS;
        

        如果表包含唯一索引:If the table has a unique index:

        ALTER TABLE xxx ADD SUPPLEMENTAL LOG GROUP (first unique index columns) ALWAYS;
        

        否则,请运行以下命令:Otherwise, run the following command:

        ALTER TABLE xxx ADD SUPPLEMENTAL LOG DATA (ALL) COLUMNS;
        

      若要验证,请运行以下命令:To verify, run the following command:

      SELECT supplemental_log_data_min FROM v$database;
      

      应会收到响应 'YES'You should receive a response 'YES'.

评估将 Oracle 迁移到 Azure Database for PostgreSQL 所要投入的工作量Assess the effort for an Oracle to Azure Database for PostgreSQL migration

我们建议使用 ora2pg 来评估从 Oracle 迁移到 Azure Database for PostgreSQL 所要投入的工作量。We recommend using ora2pg to assess the effort required to migrate from Oracle to Azure Database for PostgreSQL. 使用 ora2pg -t SHOW_REPORT 指令创建一份报告,以列出所有 Oracle 对象、估算的迁移成本(以开发人员天数为单位),以及在转换过程中可能需要特别注意的某些数据库对象。Use the ora2pg -t SHOW_REPORT directive to create a report listing all the Oracle objects, the estimated migration cost (in developer days), and certain database objects that may require special attention as part of the conversion.

大多数客户会花费相当多的时间来审阅评估报告以及考虑自动和手动转换工作量。Most customers will spend a considerable amount time reviewing the assessment report and considering the automatic and manual conversion effort.

若要配置并运行 ora2pg 来创建评估报告,请参阅 有关从 Oracle 迁移到 Azure Database for PostgreSQL 的 Cookbook中的“迁移前:评估”部分。To configure and run ora2pg to create an assessment report, see the Premigration: Assessment section of the Oracle to Azure Database for PostgreSQL Cookbook. 此处提供了一份示例 ora2pg 评估报告用于参考。A sample ora2pg assessment report is available for reference here.

导出 Oracle 架构Export the Oracle schema

我们建议使用 ora2pg 将 Oracle 架构和其他 Oracle 对象(类型、过程、函数等)转换为与 Azure Database for PostgreSQL 兼容的架构。We recommend that you use ora2pg to convert the Oracle schema and other Oracle objects (types, procedures, functions, etc.) to a schema that is compatible with Azure Database for PostgreSQL. ora2pg 中的许多指令可帮助你预定义某些数据类型。ora2pg includes many directives to help you pre-define certain data types. 例如,可以使用 DATA_TYPE 指令将所有 NUMBER(*,0) 替换为 bigint 而不是 NUMERIC(38)。For example, you can use the DATA_TYPE directive to replace all NUMBER(*,0) with bigint rather than NUMERIC(38).

可以运行 ora2pg 导出 .sql 文件中的每个数据库对象。You can run ora2pg to export each of the database objects in .sql files. 然后,可以先检查 .sql 文件,再使用 psql 将其导入到 Azure Database for PostgreSQL;也可以在 PgAdmin 中执行 .SQL 脚本。You can then review the .sql files before importing them to Azure Database for PostgreSQL using psql or you can execute the .SQL script in PgAdmin.

psql -f [FILENAME] -h [AzurePostgreConnection] -p 5432 -U [AzurePostgreUser] -d database 

例如:For example:

psql -f %namespace%\schema\sequences\sequence.sql -h server1-server.postgres.database.chinacloudapi.cn -p 5432 -U username@server1-server -d database

若要配置并运行 ora2pg 来转换架构,请参阅 有关从 Oracle 迁移到 Azure Database for PostgreSQL 的 Cookbook中的“迁移:架构和数据”部分。To configure and run ora2pg for schema conversion, see the Migration: Schema and data section of the Oracle to Azure Database for PostgreSQL Cookbook.

在 Azure Database for PostgreSQL 中设置架构Set up the schema in Azure Database for PostgreSQL

在 Azure 数据库迁移服务中开始迁移管道之前,可以选择转换 Oracle 表架构、存储过程、包和其他数据库对象,通过使用 ora2pg 使它们与 Postgres 兼容。You can choose to convert Oracle table schemas, stored procedures, packages, and other database objects to make them Postgres compatible by using ora2pg before starting a migration pipeline in Azure Database Migration Service. 有关如何使用 ora2pg 的详细说明,请参阅以下链接:See the links below for how to work with ora2pg:

Azure 数据库迁移服务还可以创建 PostgreSQL 表架构。Azure Database Migration Service can also create the PostgreSQL table schema. 该服务访问已连接 Oracle 源中的表架构,并在 Azure Database for PostgreSQL 中创建一个兼容的表架构。The service accesses the table schema in the connected Oracle source and creates a compatible table schema in Azure Database for PostgreSQL. 请确保在 Azure 数据库迁移服务完成创建架构和移动数据的操作后,在 Azure Database for PostgreSQL 中验证和检查架构格式。Be sure to validate and check the schema format in Azure Database for PostgreSQL after Azure Database Migration Service finishes creating the schema and moving the data.

重要

Azure 数据库迁移服务仅创建表架构;不会创建其他数据库对象,如存储过程、包、索引等。Azure Database Migration Service only creates the table schema; other database objects such as stored procedures, packages, indexes, etc., are not created.

同时确保删除目标数据库中的外键,以运行完全加载。Also be sure to drop the foreign key in the target database for the full load to run. 有关可用于删除外键的脚本,请参阅此文中的“迁移示例架构”部分。 Refer to the Migrate the sample schema section of the article here for a script that you can use to drop the foreign key. 使用 Azure 数据库迁移服务运行完整加载和同步。Use Azure Database Migration Service to run for full load and sync.

如果已存在 PostgreSQL 表架构When the PostgreSQL table schema already exists

如果在使用 Azure 数据库迁移服务开始数据移动之前使用 ora2pg 等工具创建 PostgreSQL 架构,请将源表映射到 Azure 数据库迁移服务中的目标表。If you create a PostgreSQL schema using tools such as ora2pg before starting the data movement with Azure Database Migration Service, map the source tables to the target tables in Azure Database Migration Service.

  1. 当你创建新的 Oracle 到 Azure Database for PostgreSQL 迁移项目时,系统将提示你在“选择架构”步骤中选择“目标数据库”和“目标架构”。When you create a new Oracle to Azure Database for PostgreSQL migration project, you're prompted to select target database and target schema in Select schemas step. 填写目标数据库和目标架构。Fill in the target database and target schema.

    显示门户订阅

  2. “迁移设置” 屏幕将显示 Oracle 源中的表的列表。The Migration settings screen presents a list of tables in the Oracle source. Azure 数据库迁移服务将尝试基于表名称匹配源表和目标表。Azure Database Migration Service tries to match tables in the source and the target tables based on table name. 如果存在多个具有不同大小写的匹配目标表,你可以选择要映射到的目标表。If multiple matching target tables with different casing exist, you can select which target table to map to.

    显示门户订阅

如果不存在 PostgreSQL 表架构When the PostgreSQL table schema doesn’t exist

如果目标 PostgreSQL 数据库不包含任何表架构信息,Azure 数据库迁移服务将转换源架构,并在目标数据库中重新创建它。If the target PostgreSQL database doesn’t contain any table schema information, Azure Database Migration Service converts the source schema and recreates it in the target database. 请记住,Azure 数据库迁移服务仅创建表架构;不会创建其他数据库对象,如存储过程、包、索引等。Remember, Azure Database Migration Service creates only the table schema, not other database objects such as stored procedures, packages, and indexes. 若要让 Azure 数据库迁移服务为你创建架构,请确保目标环境包含的架构没有现有表。To have Azure Database Migration Service create the schema for you, ensure that your target environment includes a schema with no existing tables. 如果 Azure 数据库迁移服务发现任何表,则该服务会假定该架构是由外部工具(如 ora2pg)创建的。If Azure Database Migration Service discovers any table, the service assumes that the schema was created by an external tool such as ora2pg.

重要

Azure 数据库迁移服务要求使用 Azure 数据库迁移服务或 ora2pg 等工具(而非同时使用两者)以相同的方式创建所有表。Azure Database Migration Service requires that all tables be created the same way, by using either Azure Database Migration Service or a tool such as ora2pg, but not both.

开始操作:To get started:

  1. 根据应用程序的要求,在目标数据库中创建架构。Create a schema in the target database based on your application requirements. 默认情况下,PostgreSQL 表架构和列名称采用小写。By default, PostgreSQL table schema and columns names are lower cased. 而 Oracle 表架构和列默认全部采用大写。Oracle table schema and columns, on the other hand, are by default in all capital case.

  2. 在“选择架构”步骤中,指定目标数据库和目标架构。In Select schemas step, specify the target database and the target schema.

  3. 根据在 Azure Database for PostgreSQL 中创建的架构,Azure 数据库迁移服务使用以下转换规则:Based on the schema you create in Azure Database for PostgreSQL, Azure Database Migration Service uses the following transformation rules:

    如果 Oracle 源中的架构名称与 Azure Database for PostgreSQL 中的架构名称匹配,则 Azure 数据库迁移服务将使用与目标相同的大小写来创建表架构If the schema name in the Oracle source and matches that in Azure Database for PostgreSQL, then Azure Database Migration Service creates the table schema using the same case as in the target.

    例如:For example:

    源 Oracle 架构Source Oracle schema 目标 PostgreSQL 数据库架构Target PostgreSQL Database.Schema DMS 已创建 schema.table.columnDMS created schema.table.column
    HRHR targetHR.publictargetHR.public public.countries.country_idpublic.countries.country_id
    HRHR targetHR.trgthrtargetHR.trgthr trgthr.countries.country_idtrgthr.countries.country_id
    HRHR targetHR.TARGETHRtargetHR.TARGETHR "TARGETHR"."COUNTRIES"."COUNTRY_ID""TARGETHR"."COUNTRIES"."COUNTRY_ID"
    HRHR targetHR.HRtargetHR.HR "HR"."COUNTRIES"."COUNTRY_ID""HR"."COUNTRIES"."COUNTRY_ID"
    HRHR targetHR.HrtargetHR.Hr *无法映射混合大小写*Unable to map mixed cases

注册 Microsoft.DataMigration 资源提供程序Register the Microsoft.DataMigration resource provider

  1. 登录到 Azure 门户,选择“所有服务” ,然后选择“订阅” 。Sign in to the Azure portal, select All services, and then select Subscriptions.

    显示门户订阅

  2. 选择要在其中创建 Azure 数据库迁移服务实例的订阅,再选择“资源提供程序” 。Select the subscription in which you want to create the instance of the Azure Database Migration Service, and then select Resource providers.

    显示资源提供程序

  3. 搜索“迁移”,然后选择“注册” 。Search for migration, and then select Register.

    注册资源提供程序

创建 DMS 实例Create a DMS instance

  1. 在 Azure 门户中,选择 + 创建资源,搜索 Azure 数据库迁移服务,然后从下拉列表选择Azure 数据库迁移服务In the Azure portal, select + Create a resource, search for Azure Database Migration Service, and then select Azure Database Migration Service from the drop-down list.

    Azure 市场

  2. 在“Azure 数据库迁移服务”屏幕上,选择“创建” 。On the Azure Database Migration Service screen, select Create.

    创建 Azure 数据库迁移服务实例

  3. 在“创建迁移服务”屏幕上,为服务、订阅以及新的或现有资源组指定名称 。On the Create Migration Service screen, specify a name for the service, the subscription, and a new or existing resource group.

  4. 选择现有虚拟网络或新建一个。Select an existing virtual network or create a new one.

    虚拟网络为 Azure 数据库迁移服务提供源 Oracle 和目标 Azure Database for PostgreSQL 实例的访问权限。The virtual network provides Azure Database Migration Service with access to the source Oracle and the target Azure Database for PostgreSQL instance.

    有关如何在 Azure 门户中创建虚拟网络的详细信息,请参阅使用 Azure 门户创建虚拟网络一文。For more information about how to create a virtual network in the Azure portal, see the article Create a virtual network using the Azure portal.

  5. 选择定价层。Select a pricing tier.

    有关成本和定价层的详细信息,请参阅价格页For more information on costs and pricing tiers, see the pricing page.

    配置 Azure 数据库迁移服务实例设置

  6. 选择“创建” 来创建服务。Select Create to create the service.

创建迁移项目Create a migration project

创建服务后,在 Azure 门户中找到并打开它,然后创建一个新的迁移项目。After the service is created, locate it within the Azure portal, open it, and then create a new migration project.

  1. 在 Azure 门户中,选择“所有服务” ,搜索 Azure 数据库迁移服务,然后选择“Azure 数据库迁移服务” 。In the Azure portal, select All services, search for Azure Database Migration Service, and then select Azure Database Migration Services.

    查找 Azure 数据库迁移服务的所有实例

  2. 在“Azure 数据库迁移服务”屏幕上,搜索你创建的 Azure 数据库迁移服务实例名称,然后选择该实例 。On the Azure Database Migration Services screen, search for the name of the Azure Database Migration Service instance that you created, and then select the instance.

    查找 Azure 数据库迁移服务实例

  3. 选择“+ 新建迁移项目” 。Select + New Migration Project.

  4. 在“新建迁移项目”屏幕上指定项目名称,在“源服务器类型”文本框中选择“Oracle”,在“目标服务器类型”文本框中选择“Azure Database for PostgreSQL”。 On the New migration project screen, specify a name for the project, in the Source server type text box, select Oracle, in the Target server type text box, select Azure Database for PostgreSQL.

  5. 在“选择活动类型”部分选择“联机数据迁移”。 In the Choose type of activity section, select Online data migration.

    创建数据库迁移服务项目

    备注

    也可以现在就选择“仅创建项目”来创建迁移项目,在以后再执行迁移。 Alternately, you can choose Create project only to create the migration project now and execute the migration later.

  6. 选择“保存”,注意成功使用 Azure 数据库迁移服务执行联机迁移所要满足的要求,然后选择“创建并运行活动”。 Select Save, note the requirements to successfully use Azure Database Migration Service to perform an online migration, and then select Create and run activity.

指定源详细信息Specify source details

  • 在“添加源详细信息”屏幕上,指定源 Oracle 实例的连接详细信息。 On the Add Source Details screen, specify the connection details for the source Oracle instance.

    “添加源详细信息”屏幕

上传 Oracle OCI 驱动程序Upload Oracle OCI driver

  1. 选择“保存”,然后在“安装 OCI 驱动程序”屏幕上,登录到你的 Oracle 帐户并 从此处下载驱动程序“instantclient-basiclite-windows.x64-12.2.0.1.0.zip”(37,128,586 字节)(SHA1 校验和:865082268)。Select Save, and then on the Install OCI driver screen, sign into your Oracle account and download the driver instantclient-basiclite-windows.x64-12.2.0.1.0.zip (37,128,586 Byte(s)) (SHA1 Checksum: 865082268) from here.

  2. 将该驱动程序下载到某个共享文件夹中。Download the driver to a shared folder.

    确保该文件夹已与使用最低只读访问权限指定的用户名共享。Make sure the folder is shared with the username that you specified with minimum Read-only access. Azure 数据库迁移服务将访问并读取该共享,以通过模拟指定的用户名将 OCI 驱动程序上传到 Azure。Azure Database Migration Service accesses and reads from the share to upload the OCI driver to Azure by impersonating the username you specify.

    指定的用户名必须是 Windows 用户帐户。The username you specify must be a Windows user account.

    OCI 驱动程序安装

指定目标详细信息Specify target details

  1. 选择“保存”,然后在“目标详细信息”屏幕上指定目标 Azure Database for PostgreSQL 服务器的连接详细信息,这是 HR 架构已部署到的 Azure Database for PostgreSQL 的提前预配实例 。Select Save, and then on the Target details screen, specify the connection details for the target Azure Database for PostgreSQL server, which is the pre-provisioned instance of Azure Database for PostgreSQL to which the HR schema was deployed.

    “目标详细信息”屏幕

  2. 选择“保存”,然后在“映射到目标数据库”屏幕上,映射源和目标数据库以进行迁移。 Select Save, and then on the Map to target databases screen, map the source and the target database for migration.

    如果目标数据库包含的数据库名称与源数据库的相同,则 Azure 数据库迁移服务默认会选择目标数据库。If the target database contains the same database name as the source database, Azure Database Migration Service selects the target database by default.

    映射到目标数据库

  3. 选择“保存”,在“迁移摘要”屏幕上的“活动名称”文本框中指定迁移活动的名称,然后查看摘要,确保源和目标详细信息与此前指定的信息相符 。Select Save, on the Migration summary screen, in the Activity name text box, specify a name for the migration activity, and then review the summary to ensure that the source and target details match what you previously specified.

    迁移摘要

运行迁移Run the migration

  • 选择“运行迁移” 。Select Run migration.

    迁移活动窗口随即出现,活动的“状态”为“正在初始化” 。The migration activity window appears, and the Status of the activity is initializing.

监视迁移Monitor the migration

  1. 在迁移活动屏幕上选择“刷新” ,以便更新显示,直到迁移的“状态” 显示为“正在运行” 。On the migration activity screen, select Refresh to update the display until the Status of the migration shows as Running.

    活动状态 - 正在运行

  2. 在“数据库名称”下选择特定数据库即可转到“完整数据加载”和“增量数据同步”操作的迁移状态。 Under Database Name, select a specific database to get to the migration status for Full data load and Incremental data sync operations.

    完整数据加载会显示初始加载迁移状态,而增量数据同步则会显示变更数据捕获 (CDC) 状态。Full data load will show the initial load migration status while Incremental data sync will show change data capture (CDC) status.

    活动状态 - 完整加载已完成

    活动状态 - 增量数据同步

执行迁移直接转换Perform migration cutover

完成初始的完整加载以后,数据库会被标记为“直接转换可供执行”。 After the initial Full load is completed, the databases are marked Ready to cutover.

  1. 如果准备完成数据库迁移,请选择“启动直接转换”。 When you're ready to complete the database migration, select Start Cutover.

  2. 确保停止传入源数据库的所有事务;等到“挂起的更改”计数器显示 0Make sure to stop all the incoming transactions to the source database; wait until the Pending changes counter shows 0.

    启动直接转换

  3. 依次选择“确认”、“应用” 。Select Confirm, and then select Apply.

  4. 当数据库迁移状态显示“已完成”后,请将应用程序连接到新的目标 Azure Database for PostgreSQL 实例。 When the database migration status shows Completed, connect your applications to the new target Azure Database for PostgreSQL instance.

备注

由于 PostgreSQL 的 schema.table.column 默认采用小写,你可以使用本文前面的“在 Azure Database for PostgreSQL 中设置架构”部分中的脚本,将大写转换为小写。 Since PostgreSQL by default has schema.table.column in lower case, you can revert from upper case to lower case by using the script in the Set up the schema in Azure Database for PostgreSQL section earlier in this article.

后续步骤Next steps