迁移指南:从 IBM Db2 到 Azure VM 上的 SQL ServerMigration guide: IBM Db2 to SQL Server on Azure VM

适用于: Azure VM 上的 SQL Server

本指南介绍了如何使用 Db2 的 SQL Server 迁移助手将用户数据库从 IBM Db2 迁移到 Azure VM 上的 SQL Server。This guide teaches you to migrate your user databases from IBM Db2 to SQL Server on Azure VM, by using the SQL Server Migration Assistant for Db2.

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


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


满足先决条件后即可查看环境中的拓扑并评估迁移的可行性。After you have met the prerequisites, you're ready to discover the topology of your environment and assess the feasibility of your migration.


使用 DB2 的 SSMA 查看数据库对象和数据并评估数据库是否适合迁移。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. 然后从下拉列表中选择一个 SQL Server 迁移目标,再选择“确定”。Then select a SQL Server 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. 选择“连接到 SQL Server”。Select Connect to SQL Server.

    1. 输入连接详细信息,以连接到 Azure VM 上的 SQL Server 实例。Enter connection details to connect to your instance of SQL Server on your Azure VM.
    2. 选择连接到目标服务器上的现有数据库,或提供新名称以在目标服务器上创建新数据库。Choose to connect to an existing database on the target server, or provide a new name to create a new database on the target server.
    3. 提供身份验证详细信息。Provide authentication details.
    4. 选择“连接” 。Select Connect.

    该屏幕截图显示在 Azure VM 上连接至 SQL Server 所需的详细信息。

  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 finishes, 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. 这样即有机会在将架构发布到 Azure VM 上的 SQL Server 之前,先对源和目标架构进行脱机评估并修正。This gives you an opportunity to evaluate the source and target schemas offline, and perform remediation before you can publish the schema to SQL Server on Azure VM.


完成对数据库的评估并解决任何分歧后,下一步就是执行迁移过程。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. 在 SQL Server 元数据资源管理器的数据库节点中,右键单击数据库。 In SQL Server 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 和 SQL Server 实例的连接详细信息。Provide connection details for both the Db2 and SQL Server instances.

  4. 迁移完成后,查看“数据迁移报表”:After migration finishes, view the Data Migration Report:


  5. 使用 SQL Server Management Studio 连接到 Azure VM 上 SQL Server 的实例。Connect to your instance of SQL Server on Azure VM by using SQL Server Management Studio. 通过查看数据和架构来验证迁移。Validate the migration by reviewing the data and schema.

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


成功完成迁移后还需要执行一系列的迁移后任务,以确保所有操作尽可能顺利高效。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.

迁移资产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

迁移后,请查看迁移后验证和优化指南After migration, review the Post-migration validation and optimization guide.

如需 Azure 与第三方服务和工具以了解各种数据库和数据迁移方案,请参阅数据迁移服务和工具For Azure and third-party services and tools that are available to assist you with various database and data migration scenarios, see Data migration services and tools.