

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 将数据从 IBM Db2、SAP、Sybase 和其他数据库流式传输到 MongoDB Atlas AWS
<a name="stream-data-from-ibm-db2-to-mongodb-atlas"></a>

*Battulga Purevragchaa 和 Igor Alekseev，Amazon Web Services*

*Babu Srinivasan，MongoDB*

## Summary
<a name="stream-data-from-ibm-db2-to-mongodb-atlas-summary"></a>

此模式介绍了将数据从 IBM Db2 及其他数据库（例如大型机数据库、Sybase）迁移至 AWS Cloud上的 MongoDB Atlas 的具体步骤。它使用 [AWS Glue](https://aws.amazon.com/glue/) 来帮助加速向 MongoDB Atlas 的数据迁移进程。

该模式与规范性指导网站上的《[迁移到 MongoDB Atlas AWS](https://docs.aws.amazon.com/prescriptive-guidance/latest/migration-mongodb-atlas/)》 AWS 指南一起出现。其中提供了适用于该指南中讨论的其中一个迁移场景的实施步骤。有关其他迁移方案，请参阅 AWS 规范性指导网站上的以下模式：
+ [将自托管 MongoDB 环境迁移到 MongoDB Atlas AWS](https://docs.aws.amazon.com/prescriptive-guidance/latest/patterns/migrate-a-self-hosted-mongodb-environment-to-mongodb-atlas-on-the-aws-cloud.html)
+ [将关系数据库迁移到 MongoDB Atlas AWS](https://docs.aws.amazon.com/prescriptive-guidance/latest/patterns/migrate-relational-database-to-mongodb-atlas.html)

该模式适用于 Manage [AWS d Services 合作伙伴](https://aws.amazon.com/managed-services/partners/)和 AWS 用户。

## 先决条件和限制
<a name="stream-data-from-ibm-db2-to-mongodb-atlas-prereqs"></a>

**先决条件**
+ 要迁移至 MongoDB Atlas 的源数据库，例如 SAP、Sybase、IBM Db2 等。
+ 熟悉 SAP、Sybase、IBM Db2、MongoDB Atlas 等数据库。 AWS 服务

**产品版本**
+ MongoDB 版本 5.0 或更高版本。

## 架构
<a name="stream-data-from-ibm-db2-to-mongodb-atlas-architecture"></a>

下图说明了使用 AWS Glue Studio Amazon Kinesis Data Streams 和 MongoDB Atlas 进行批量数据加载和数据流式传输。

此参考架构用于创建 AWS Glue Studio 提取、转换和加载 (ETL) 管道，以将数据迁移到 MongoDB Atlas。 AWS Glue 爬网程序 与 MongoDB Atlas 集成，以促进数据治理。数据可以批量迁移，也可以使用 Amazon Kinesis Data Streams 流式传输到 MongoDB Atlas。

**批量数据加载**

![在批处理模式下将数据迁移到 MongoDB Atlas。](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/images/pattern-img/805a376f-35f4-44cc-b4b0-8bf4d95c1e5d/images/68d87202-95ba-4e2a-9b3b-27dd6db6165e.png)


有关批量数据迁移的更多信息，请参阅 AWS 博客文章使用 M [ongoDB Atlas 编写 ETL 作业](https://aws.amazon.com/blogs/big-data/compose-your-etl-jobs-for-mongodb-atlas-with-aws-glue/)。 AWS Glue

**数据流**

![在数据流式传输模式下将数据迁移到 MongoDB Atlas。](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/images/pattern-img/805a376f-35f4-44cc-b4b0-8bf4d95c1e5d/images/b007a116-f463-418f-9721-647d80177e3b.png)


有关支持不同使用场景的 MongoDB Atlas 参考架构，请参阅规范性指南网站上的[迁移到 MongoDB](https://docs.aws.amazon.com/prescriptive-guidance/latest/migration-mongodb-atlas/architecture.html) Atlas。 AWS AWS 

## 工具
<a name="stream-data-from-ibm-db2-to-mongodb-atlas-tools"></a>

●      [AWS Glue](https://docs.aws.amazon.com/glue/latest/dg/what-is-glue.html) 是一项完全托管的 ETL 服务。它可以帮助您在数据存储和数据流之间对数据进行可靠地分类、清理、扩充和移动。

●      [Amazon Kinesis Data Streams](https://aws.amazon.com/kinesis/data-streams/) 可帮助您实时收集和处理大型数据记录流。

●      [MongoDB Atlas](https://www.mongodb.com/atlas) 是一种完全托管式数据库即服务（DbaaS），用于在云中部署和管理 MongoDB 数据库。

## 最佳实践
<a name="stream-data-from-ibm-db2-to-mongodb-atlas-best-practices"></a>

有关指南，请参阅 MongoDB 存储[库中的 MongoDB 最佳实践指南](https://github.com/mongodb-partners/mongodb_atlas_as_aws_bedrock_knowledge_base/blob/main/data/MongoDB_Best_Practices_Guide.pdf)。 GitHub 

## 操作说明
<a name="stream-data-from-ibm-db2-to-mongodb-atlas-epics"></a>

### 发现与评测
<a name="discovery-and-assessment"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 确定集群大小。 | 使用 `db.stats()` 中关于总索引空间的信息来估计工作集大小。假设您的数据空间中有一定比例会被频繁访问。或者，您可以根据自己的假设来估计内存需求。此任务大约需要一周时间。有关此故事以及此操作说明中其他故事的详细信息和示例，请参阅[相关资源](#stream-data-from-ibm-db2-to-mongodb-atlas-resources)部分中的链接。 | MongoDB 数据库管理员，应用程序架构师 | 
| 估计网络带宽要求。 | 要估计网络带宽要求，请将平均文档大小乘以每秒提供的文档数量。考虑集群中任何节点将承受的最大流量作为基础。要计算从集群到客户端应用程序的下游数据传输速率，请使用一段时间内返回的文档总数的总和。如果您的应用程序从辅助节点读取数据，请将文档总数除以可以提供读取操作的节点数。要查找数据库的平均文档大小，请使用 `db.stats().avgObjSize` 命令。此任务通常需要一天的时间。 | MongoDB 数据库管理员 | 
| 选择 Atlas 层。 | 按照 [MongoDB 文档](https://www.mongodb.com/docs/atlas/manage-clusters/)中的说明选择正确的 Atlas 集群层。  | MongoDB 数据库管理员 | 
| 制定割接计划。 | 制定应用程序割接计划。 | MongoDB 数据库管理员，应用程序架构师 | 

### 在 AWS 上设置新的 MongoDB Atlas 环境
<a name="set-up-a-new-mongodb-atlas-environment-on-aws"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 在上创建新的 MongoDB Atlas 集群。 AWS | 在 MongoDB Atlas 中，**选择构建**集群，然后 AWS 选择作为云提供商。 | MongoDB 数据库管理员 | 
| 选择 AWS 区域 和全局群集配置。 | 从适用于您的 Atlas 集群 AWS 区域 的列表中进行选择。如果需要，请配置全局集群。 | MongoDB 数据库管理员 | 
| 选择集群层。 | 选择您的首选集群层。您的层选择决定了内存、存储和 IOPS 规格等因素。 | MongoDB 数据库管理员 | 
| 配置其他集群设置。 | 配置其他集群设置，例如 MongoDB 版本、备份和加密选项。有关这些选项的更多信息，请参阅[相关资源](#stream-data-from-ibm-db2-to-mongodb-atlas-resources)部分。 | MongoDB 数据库管理员 | 

### 配置安全性和合规性
<a name="configure-security-and-compliance"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 配置访问列表。 | 要连接到 Atlas 集群，您必须在[项目的访问列表](https://www.mongodb.com/docs/atlas/setup-cluster-security/#configure-security-features-for-clusters)中添加一个条目。Atlas 使用传输层安全性协议（TLS）/安全套接字层 (SSL) 来加密数据库与虚拟私有云（VPC）的连接。若要设置项目的访问列表以及有关此操作说明中的故事的详细信息，请参阅[相关资源](#stream-data-from-ibm-db2-to-mongodb-atlas-resources)部分中的链接。  | MongoDB 数据库管理员 | 
| 对用户进行身份验证和授权。 | 您必须创建并验证将访问 MongoDB Atlas 集群的数据库用户。要访问项目中的集群，用户必须属于该项目，并且他们可以属于多个项目。 您也可以使用 AWS Identity and Access Management (IAM) 启用授权。有关更多信息，请参阅 MongoDB 文档中的[使用 IAM 设置身份验证](https://www.mongodb.com/docs/atlas/security/aws-iam-authentication/#set-up-authentication-with-aws-iam)。 | MongoDB 数据库管理员 | 
| 创建自定义角色。 | （可选）Atlas 支持在内置的 Atlas 数据库用户权限未涵盖所需权限集的情况下创建[自定义角色](https://www.mongodb.com/docs/atlas/reference/custom-role-actions/)。 | MongoDB 数据库管理员 | 
| 设置 VPC 对等连接。 | （可选）Atlas 支持与其他 AWS 的 [ VPCsVPC 对](https://www.mongodb.com/docs/atlas/security-vpc-peering/#set-up-a-network-peering-connection)等。 | MongoDB 数据库管理员 | 
| 设置 AWS PrivateLink 终端节点。 | （可选）您可以使用在上 AWS 设置私有终端节点[AWS PrivateLink](https://www.mongodb.com/docs/atlas/security-private-endpoint/)。 | MongoDB 数据库管理员 | 
| 启用双因素身份验证。 | （可选）Atlas 支持双因素身份验证 (2FA)，以帮助用户控制对其 Atlas 账户的访问。 | MongoDB 数据库管理员 | 
| 使用 LDAP 设置用户身份验证和授权。 | （可选）Atlas支持使用轻量级目录访问协议 (LDAP) 执行用户身份验证和授权。 | MongoDB 数据库管理员 | 
| 设置统一 AWS 接入。 | （可选）某些 Atlas 功能（包括 Atlas 数据湖和使用客户密钥管理的静态加密）使用 IAM 角色进行身份验证。 | MongoDB 数据库管理员 | 
| 使用设置静态加密 AWS KMS。 | （可选）Atlas 支持使用 AWS Key Management Service (AWS KMS) 加密存储引擎和云提供商备份。 | MongoDB 数据库管理员 | 
| 设置 CSFLE。 | （可选）Atlas 支持[客户端字段级加密（CSFLE）](https://www.mongodb.com/docs/upcoming/core/csfle/#client-side-field-level-encryption)，包括字段的自动加密。  | MongoDB 数据库管理员 | 

### 迁移数据
<a name="migrate-data"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 在 MongoDB Atlas 中启动目标副本集。 | 在 MongoDB Atlas 中启动目标副本集。在 Atlas Live Migration Service 中，选择**我已准备好迁移**。 | MongoDB 数据库管理员 | 
|  AWS Glue 与 MongoDB Atlas 建立连接。 | 使用连接 AWS Glue MongoDB Atlas（目标数据库）。 AWS Glue 爬网程序 此步骤有助于为迁移准备目标环境。有关详情，请参阅 [AWS Glue 文档](https://docs.aws.amazon.com/glue/latest/dg/console-connections.html)。 | MongoDB 数据库管理员 | 
|  AWS Glue 与源数据库或源流建立连接。 | 此步骤有助于为迁移准备目标环境。 | MongoDB 数据库管理员 | 
| 设置数据转换。 | 配置转换逻辑，将数据从传统的结构化架构迁移到 MongoDB 的灵活架构。 | MongoDB 数据库管理员 | 
| 迁移数据。 | 计划 AWS Glue Studio中的迁移。 | MongoDB 数据库管理员 | 

### 配置操作集成
<a name="configure-operational-integration"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 连接到集群。 | 连接到 MongoDB Atlas 集群。 | 应用程序开发人员 | 
| 与数据交互。 | 与集群数据交互。 | 应用程序开发人员 | 
| 监控集群。 | 监控您的 MongoDB Atlas 集群。 | MongoDB 数据库管理员 | 
| 备份和还原数据。 | 备份和恢复集群数据。 | MongoDB 数据库管理员 | 

## 问题排查
<a name="stream-data-from-ibm-db2-to-mongodb-atlas-troubleshooting"></a>


| 问题 | 解决方案 | 
| --- | --- | 
| 如果您遇到问题 | 参见 Mongo CloudFormation DB Atlas 资源库中的[疑难解答](https://github.com/mongodb/mongodbatlas-cloudformation-resources/tree/master#troubleshooting)。 | 

## 相关资源
<a name="stream-data-from-ibm-db2-to-mongodb-atlas-resources"></a>

除非另有说明，否则以下所有链接均指向 MongoDB 文档中的网页。

**迁移指南**
+ [在（规范性指南）上迁移到 MongoDB Atla AWS s](https://docs.aws.amazon.com/prescriptive-guidance/latest/migration-mongodb-atlas/)AWS 

**发现与评测**
+ [内存](https://docs.atlas.mongodb.com/sizing-tier-selection/#memory)
+ [使用 Atlas 示例数据集进行大小调整示例](https://www.mongodb.com/docs/atlas/sizing-tier-selection/#example--the-service-sample-data-sets)
+ [移动应用程序的大小调整示例](https://www.mongodb.com/docs/atlas/sizing-tier-selection/#example--mobile-app)
+ [网络流量](https://docs.atlas.mongodb.com/sizing-tier-selection/#network-traffic)
+ [集群自动扩缩](https://www.mongodb.com/docs/atlas/sizing-tier-selection/#cluster-auto-scaling)
+ [Atlas 大小调整模板](https://view.highspot.com/viewer/5f438f47a4dfa042e97130c5)

**配置安全性和合规性**
+ [配置 IP 访问列表条目](https://docs.atlas.mongodb.com/security/ip-access-list/)
+ [配置数据库用户](https://docs.atlas.mongodb.com/security-add-mongodb-users/)
+ [配置对 Atlas UI 的访问权限](https://docs.atlas.mongodb.com/organizations-projects/)
+ [配置自定义数据库角色](https://docs.atlas.mongodb.com/security-add-mongodb-roles)
+ [配置数据库用户](https://docs.atlas.mongodb.com/security-add-mongodb-users/#atlas-user-privileges)
+ [设置网络对等连接](https://docs.atlas.mongodb.com/security-vpc-peering/)
+ [了解 Atlas 中的私有端点](https://docs.atlas.mongodb.com/security-private-endpoint/)
+ [管理多重身份验证选项](https://docs.atlas.mongodb.com/security-two-factor-authentication/)
+ [使用 LDAP 设置用户身份验证和授权](https://docs.atlas.mongodb.com/security-ldaps/)
+ [Atlas 数据湖](https://docs.mongodb.com/datalake/)
+ [使用客户密钥管理进行静态加密](https://docs.atlas.mongodb.com/security-kms-encryption/)
+ [承担角色的方法](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use.html)（IAM 文档）
+ [客户端字段级加密](https://docs.mongodb.com/manual/core/security-client-side-encryption)
+ [自动加密](https://docs.mongodb.com/manual/core/security-automatic-client-side-encryption) 
+ [MongoDB Atlas 安全控制](https://webassets.mongodb.com/_com_assets/cms/MongoDB_Atlas_Security_Controls-v7k3rbhi3p.pdf)
+ [MongoDB 信任中心](https://www.mongodb.com/cloud/trust)
+ [为集群配置安全功能](https://docs.atlas.mongodb.com/setup-cluster-security/)

**在 **AWS** 上设置新的 MongoDB Atlas 环境**
+ [云提供商和地区](https://docs.atlas.mongodb.com/cloud-providers-regions/)
+ [管理全局集群](https://docs.atlas.mongodb.com/global-clusters/)
+ [选择集群层级](https://www.mongodb.com/docs/atlas/manage-clusters/#select-cluster-tier)
+ [配置其他设置](https://docs.atlas.mongodb.com/cluster-additional-settings/)
+ [开始使用 Atlas](https://docs.atlas.mongodb.com/getting-started/)
+ [配置对 Atlas UI 的访问权限](https://docs.atlas.mongodb.com/organizations-projects/)

**迁移数据**
+ [迁移或导入数据](https://www.mongodb.com/docs/atlas/import/)

**监控集群**
+ [监控您的集群](https://docs.atlas.mongodb.com/monitoring-alerts/)

**集成操作**
+ [连接到集群](https://docs.atlas.mongodb.com/connect-to-cluster/)
+ [与您的数据交互](https://docs.atlas.mongodb.com/data-explorer/)
+ [监控您的集群](https://docs.atlas.mongodb.com/monitoring-alerts/)
+ [备份、恢复和存档数据](https://docs.atlas.mongodb.com/backup-restore-cluster/)

**GitHub repository**
+ [使用以下命令将数据流式传输到 MongoDB Atlas AWS Glue](https://github.com/mongodb-partners/Stream_Data_into_MongoDB_AWS_Glue?tab=readme-ov-file#troubleshooting)