迁移指南:从 IBM Db2 迁移到 Azure SQL 数据库Migration guide: IBM Db2 to Azure SQL Database

适用于: Azure SQL 数据库

本指南介绍如何使用适用于 Db2 的 SQL Server 迁移助手将 IBM Db2 数据库迁移到 Azure SQL 数据库。In this guide, you learn how to migrate your IBM Db2 databases to Azure SQL Database, by using SQL Server Migration Assistant for Db2.

有关其他迁移指南,请参阅 Azure 数据库迁移指南For other migration guides, see Azure Database Migration Guides.

必备条件Prerequisites

要将 Db2 数据库迁移到 SQL 数据库,需要:To migrate your Db2 database to SQL Database, you need:

预迁移Pre-migration

满足先决条件后,就已准备就绪,可以探索环境的拓扑并评估迁移的可行性了。After you have met the prerequisites, you're ready to discover the topology of your environment and assess the feasibility of your migration.

评估和转换Assess and convert

使用 SSMA for DB2 查看数据库对象和数据,并评估数据库是否适合迁移。Use SSMA for DB2 to review database objects and data, and assess databases for migration.

要创建评估,请执行以下步骤:To create an assessment, follow these steps:

  1. 打开 Db2 的 SSMAOpen SSMA for Db2.

  2. 选择“文件” > “新建项目” 。Select File > New Project.

  3. 提供项目名称和保存项目的位置。Provide a project name and a location to save your project. 然后从下拉列表中选择“Azure SQL 数据库”作为迁移目标,再选择“确定”。Then select Azure SQL Database as the migration target from the drop-down list, and select OK.

    显示要指定的项目详细信息的屏幕截图。

  4. 在“连接到 Db2”上,输入值以查看 Db2 连接详细信息。On Connect to Db2, enter values for the Db2 connection details.

    显示用于连接到 Db2 实例的选项的屏幕截图。

  5. 右键单击要迁移的 Db2 架构,然后选择“创建报表”。Right-click the Db2 schema you want to migrate, and then choose Create report. 这将生成一个 HTML 报表。This will generate an HTML report. 或者,可以在选择架构后,从导航栏中选择“创建报表”。Alternatively, you can choose Create report from the navigation bar after selecting the schema.

    屏幕截图,显示如何创建报表。

  6. 查看 HTML 报表,了解转换统计信息以及任何错误或警告。Review the HTML report to understand conversion statistics and any errors or warnings. 另外,还可以在 Excel 中打开报表以获取 Db2 对象的清单,以及执行架构转换所需的工作量。You can also open the report in Excel to get an inventory of Db2 objects and the effort required to perform schema conversions. 报表的默认位置在 SSMAProjects 内的报表文件夹中。The default location for the report is in the report folder within SSMAProjects.

    例如: drive:\<username>\Documents\SSMAProjects\MyDb2Migration\report\report_<date>For example: drive:\<username>\Documents\SSMAProjects\MyDb2Migration\report\report_<date>.

    该报表屏幕截图显示任何错误或警告。

验证数据类型Validate data types

验证默认数据类型映射,并根据需要对其进行更改(如有必要)。Validate the default data type mappings, and change them based on requirements if necessary. 为此,请执行下列步骤:To do so, follow these steps:

  1. 在菜单中,选择“工具”。Select Tools from the menu.

  2. 选择“项目设置”。Select Project Settings.

  3. 选择“类型映射”选项卡。Select the Type mappings tab.

    该屏幕截图显示如何选择架构和类型映射。

  4. 可通过在 Db2 元数据资源管理器中选择表来更改每个表的类型映射。You can change the type mapping for each table by selecting the table in the Db2 Metadata Explorer.

转换架构Convert schema

要转换架构,请执行以下步骤:To convert the schema, follow these steps:

  1. (可选)向语句中添加动态或临时查询。(Optional) Add dynamic or ad-hoc queries to statements. 右键单击节点,然后选择“添加语句”。Right-click the node, and then choose Add statements.

  2. 选择“连接到 Azure SQL 数据库”。Select Connect to Azure SQL Database.

    1. 输入连接详细信息以在 Azure SQL 数据库中连接数据库。Enter connection details to connect your database in Azure SQL Database.
    2. 从下拉菜单中选择目标 SQL 数据库,或者提供新名称;如果是提供新名称,则将在目标服务器上创建一个数据库。Choose your target SQL Database from the drop-down list, or provide a new name, in which case a database will be created on the target server.
    3. 提供身份验证详细信息。Provide authentication details.
    4. 选择“连接”。Select Connect.

    屏幕截图显示连接到 Azure 中的逻辑服务器所需的详细信息。

  3. 右键单击架构,然后选择“转换架构”。Right-click the schema, and then choose Convert Schema. 或者,可以在选择架构后,从顶部导航栏中选择“转换架构”。Alternatively, you can choose Convert Schema from the top navigation bar after selecting your schema.

    显示选择和转换架构的屏幕截图。

  4. 完成转换后,比较并查看架构的结构以识别潜在问题。After the conversion completes, compare and review the structure of the schema to identify potential problems. 根据建议解决问题。Address the problems based on the recommendations.

    显示比较并查看架构的结构以识别潜在问题的屏幕截图。

  5. 在“输出”窗格中,选择“查看结果” 。In the Output pane, select Review results. 在“错误列表”窗格中,查看错误。In the Error list pane, review errors.

  6. 在本地保存该项目以进行脱机架构修正练习。Save the project locally for an offline schema remediation exercise. 在“文件”菜单中,选择“保存项目” 。From the File menu, select Save Project. 这样,你就有机会在将架构发布到 SQL 数据库之前,先对源架构和目标架构进行离线评估并执行修正。This gives you an opportunity to evaluate the source and target schemas offline, and perform remediation before you can publish the schema to SQL Database.

MigrateMigrate

完成对数据库的评估并解决任何分歧后,下一步就是执行迁移过程。After you have completed assessing your databases and addressing any discrepancies, the next step is to execute the migration process.

要发布架构并迁移数据,请执行以下步骤:To publish your schema and migrate your data, follow these steps:

  1. 发布架构。Publish the schema. 在 Azure SQL 数据库元数据资源管理器的“数据库”节点中,右键单击数据库 。In Azure SQL Database Metadata Explorer, from the Databases node, right-click the database. 然后选择“与数据库同步”。Then select Synchronize with Database.

    显示“与数据库同步”选项的屏幕截图。

  2. 迁移数据。Migrate the data. 在 Db2 元数据资源管理器中,右键单击要迁移的数据库或对象,然后选择“迁移数据” 。Right-click the database or object you want to migrate in Db2 Metadata Explorer, and choose Migrate data. 或者,可在导航栏中选择“迁移数据”。Alternatively, you can select Migrate Data from the navigation bar. 若要迁移整个数据库的数据,请选中数据库名称旁边的复选框。To migrate data for an entire database, select the check box next to the database name. 若要从单个表中迁移数据,请展开数据库,展开“表”,然后选中表旁边的复选框。To migrate data from individual tables, expand the database, expand Tables, and then select the check box next to the table. 若要忽略单个表中的数据,请清除对应的复选框。To omit data from individual tables, clear the check box.

    显示选择架构和选择迁移数据的屏幕截图。

  3. 提供 Db2 和 Azure SQL 数据库的连接详细信息。Provide connection details for both Db2 and Azure SQL Database.

  4. 迁移完成后,查看数据迁移报表。After migration completes, view the Data Migration Report.

    显示在何处查看数据迁移报表的屏幕截图。

  5. 使用 SQL Server Management Studio 连接到 Azure SQL 数据库中的数据库。Connect to your database in Azure SQL Database by using SQL Server Management Studio. 通过查看数据和架构来验证迁移。Validate the migration by reviewing the data and schema.

    显示比较 SQL Server Management Studio 中的架构的屏幕截图。

迁移后Post-migration

成功完成迁移后还需要执行一系列的迁移后任务,以确保所有操作尽可能顺利高效。After the migration is complete, you need to go through a series of post-migration tasks to ensure that everything is functioning as smoothly and efficiently as possible.

修正应用程序Remediate applications

将数据迁移到目标环境后,以前使用源的所有应用程序都需要开始使用目标。After the data is migrated to the target environment, all the applications that formerly consumed the source need to start consuming the target. 在某些情况下,实现这一点需要对应用程序进行更改。Accomplishing this will in some cases require changes to the applications.

执行测试Perform tests

测试包括以下活动:Testing consists of the following activities:

  1. 开发验证测试:要测试数据库迁移,需要使用 SQL 查询。Develop validation tests: To test database migration, you need to use SQL queries. 必须创建针对源数据库和目标数据库运行的验证查询。You must create the validation queries to run against both the source and the target databases. 验证查询应涵盖已定义的范围。Your validation queries should cover the scope you have defined.
  2. 设置测试环境:测试环境应包含源数据库和目标数据库的副本。Set up the test environment: The test environment should contain a copy of the source database and the target database. 请确保隔离测试环境。Be sure to isolate the test environment.
  3. 运行验证测试:针对源和目标运行验证测试,然后分析结果。Run validation tests: Run the validation tests against the source and the target, and then analyze the results.
  4. 运行性能测试:针对源和目标运行性能测试,然后分析和比较结果。Run performance tests: Run performance tests against the source and the target, and then analyze and compare the results.

高级功能Advanced features

请确保利用 Azure SQL 数据库提供的基于云的高级功能,例如内置高可用性威胁检测以及监视和优化工作负荷Be sure to take advantage of the advanced cloud-based features offered by SQL Database, such as built-in high availability, threat detection, and monitoring and tuning your workload.

只有将数据库兼容性级别更改为最新的兼容性级别后,某些 SQL Server 功能才可用。Some SQL Server features are only available when the database compatibility level is changed to the latest compatibility level.

迁移资产Migration assets

如需更多帮助,请参阅以下资源,这些资源是为支持实际迁移项目而开发的:For additional assistance, see the following resources, which were developed in support of a real-world migration project engagement:

资产Asset 说明Description
数据工作负荷评估模型和工具Data workload assessment model and tool 此工具为给定的工作负荷提供了建议的“最佳匹配”目标平台、云就绪和应用程序/数据库修正级别。This tool provides suggested "best fit" target platforms, cloud readiness, and application/database remediation level for a given workload. 它提供简单的一键式计算和报表生成功能,通过提供统一的自动化目标平台决策过程,帮助加速大规模评估。It offers simple, one-click calculation and report generation that helps to accelerate large estate assessments by providing and automated and uniform target platform decision process.
Db2 zOS 数据资产发现和评估包Db2 zOS data assets discovery and assessment package 在数据库上运行 SQL 脚本后,可以将结果导出到文件系统上的文件。After running the SQL script on a database, you can export the results to a file on the file system. 支持多种文件格式(包括 *.csv),方便你在外部工具(如电子表格)中捕获结果。Several file formats are supported, including *.csv, so that you can capture the results in external tools such as spreadsheets. 如果你想要与未安装工作台的团队轻松共享结果,此方法会很有用。This method can be useful if you want to easily share results with teams that do not have the workbench installed.
IBM Db2 LUW 清单脚本和项目IBM Db2 LUW inventory scripts and artifacts 此资产包含一个 SQL 查询,该查询可访问 IBM Db2 LUW 版本 11.1 系统表,并按架构和对象类型提供对象计数、每个架构中“原始数据”的粗略估计、每个架构中表的大小,以及 CSV 格式的存储结果。This asset includes a SQL query that hits IBM Db2 LUW version 11.1 system tables and provides a count of objects by schema and object type, a rough estimate of "raw data" in each schema, and the sizing of tables in each schema, with results stored in a CSV format.
Azure 上的 Db2 LUW 纯扩展 - 设置指南Db2 LUW pure scale on Azure - setup guide 本指南用作 Db2 实现计划的起点。This guide serves as a starting point for a Db2 implementation plan. 尽管业务要求有所不同,但均适用相同的基本模式。Although business requirements will differ, the same basic pattern applies. 此体系结构模式还可用于 Azure 上的 OLAP 应用程序。This architectural pattern can also be used for OLAP applications on Azure.

数据 SQL 工程团队开发了这些资源。The Data SQL Engineering team developed these resources. 此团队的核心章程是解锁和加速到 Azure 数据平台的数据平台迁移项目的复杂现代化进程。This team's core charter is to unblock and accelerate complex modernization for data platform migration projects to Azure data platform.

后续步骤Next steps