

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 在 上將資料從 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*

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

此模式說明將資料從 IBM Db2 和其他資料庫遷移至 上的 MongoDB Atlas 的步驟，例如大型主機資料庫和 Sybase AWS 雲端。它使用 [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)

模式 適用於 [AWS Managed 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 版或更新版本。

## Architecture
<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。與 MongoDB Atlas AWS Glue 編目程式 整合，以促進資料控管。資料可以使用 Amazon Kinesis Data Streams 批次移植或串流至 MongoDB Atlas。

**批次資料載入**

![\[以批次模式將資料遷移至 MongoDB Atlas。\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/images/pattern-img/805a376f-35f4-44cc-b4b0-8bf4d95c1e5d/images/68d87202-95ba-4e2a-9b3b-27dd6db6165e.png)


如需批次資料遷移的詳細資訊，請參閱 AWS 部落格文章[使用 編寫 MongoDB Atlas 的 ETL 任務 AWS Glue](https://aws.amazon.com/blogs/big-data/compose-your-etl-jobs-for-mongodb-atlas-with-aws-glue/)。

**資料串流**

![\[在資料串流模式下將資料遷移至 MongoDB Atlas。\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/images/pattern-img/805a376f-35f4-44cc-b4b0-8bf4d95c1e5d/images/b007a116-f463-418f-9721-647d80177e3b.png)


如需支援不同使用案例的 MongoDB Atlas 參考架構，請參閱 AWS Prescriptive Guidance 網站上的[遷移至 上的 MongoDB Atlas AWS](https://docs.aws.amazon.com/prescriptive-guidance/latest/migration-mongodb-atlas/architecture.html)。

## 工具
<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 GitHub 儲存庫中的 MongoDB 最佳實務指南](https://github.com/mongodb-partners/mongodb_atlas_as_aws_bedrock_knowledge_base/blob/main/data/MongoDB_Best_Practices_Guide.pdf)。 MongoDB GitHub 

## 史詩
<a name="stream-data-from-ibm-db2-to-mongodb-atlas-epics"></a>

### 探索和評估
<a name="discovery-and-assessment"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 決定叢集大小。 | 使用來自 的資訊估計工作集大小`db.stats()`，以取得總索引空間。假設經常存取您資料空間的百分比。或者，您可以根據您的假設預估記憶體需求。此任務大約需要一週的時間。如需此範例和其他案例的詳細資訊和範例，請參閱[相關資源](#stream-data-from-ibm-db2-to-mongodb-atlas-resources)區段中的連結。 | MongoDB DBA，應用程式架構師 | 
| 估計網路頻寬需求。 | 若要估算您的網路頻寬需求，請將平均文件大小乘以每秒提供的文件數量。請考慮叢集上任何節點所承擔的最大流量。若要計算從叢集到用戶端應用程式的下游資料傳輸率，請使用一段時間內傳回文件總數的總和。如果您的應用程式從次要節點讀取，請將總文件數除以可提供讀取操作的節點數。若要尋找資料庫的平均文件大小，請使用 `db.stats().avgObjSize`命令。此任務通常需要一天的時間。 | MongoDB DBA | 
| 選取 Atlas 層。 | 遵循 [MongoDB 文件](https://www.mongodb.com/docs/atlas/manage-clusters/)中的指示，選取正確的 Atlas 叢集層。  | MongoDB DBA | 
| 規劃切換。 | 規劃應用程式切換。 | MongoDB DBA，應用程式架構師 | 

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


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 在 上建立新的 MongoDB Atlas 叢集 AWS。 | 在 MongoDB Atlas 中，選擇**建置叢集**，然後選取 AWS 做為雲端供應商。 | MongoDB DBA | 
| 選取 AWS 區域 和 全域叢集組態。 | 從 AWS 區域 Atlas 叢集可用的 清單中選取 。視需要設定全域叢集。 | MongoDB DBA | 
| 選取叢集層。 | 選取您偏好的叢集層。您的方案選擇會決定記憶體、儲存體和 IOPS 規格等因素。 | MongoDB DBA | 
| 設定其他叢集設定。 | 設定其他叢集設定，例如 MongoDB 版本、備份和加密選項。如需這些選項的詳細資訊，請參閱[相關資源](#stream-data-from-ibm-db2-to-mongodb-atlas-resources)一節。 | MongoDB DBA | 

### 設定安全與合規
<a name="configure-security-and-compliance"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 設定存取清單。 | 若要連線至 Atlas 叢集，您必須將項目新增至[專案的存取清單](https://www.mongodb.com/docs/atlas/setup-cluster-security/#configure-security-features-for-clusters)。Atlas 使用 Transport Layer Security (TLS) / Secure Sockets Layer (SSL) 來加密資料庫虛擬私有雲端 (VPC) 的連線。若要設定專案的存取清單，以及有關此史詩中案例的詳細資訊，請參閱[相關資源](#stream-data-from-ibm-db2-to-mongodb-atlas-resources)區段中的連結。  | MongoDB DBA | 
| 驗證和授權使用者。 | 您必須建立和驗證將存取 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 DBA | 
| 建立自訂角色。 | （選用） 如果內建的 Atlas 資料庫使用者權限未涵蓋您所需的權限集，則 Atlas 支援建立[自訂角色](https://www.mongodb.com/docs/atlas/reference/custom-role-actions/)。 | MongoDB DBA | 
| 設定 VPC 對等互連。 | （選用） Atlas 支援 [VPC 與其他 AWS VPC 對等互連](https://www.mongodb.com/docs/atlas/security-vpc-peering/#set-up-a-network-peering-connection)。 VPCs | MongoDB DBA | 
| 設定 AWS PrivateLink 端點。 | （選用） 您可以使用 AWS 在 上設定私有端點[AWS PrivateLink](https://www.mongodb.com/docs/atlas/security-private-endpoint/)。 | MongoDB DBA | 
| 啟用雙重驗證。 | （選用） Atlas 支援雙重驗證 (2FA)，以協助使用者控制對其 Atlas 帳戶的存取。 | MongoDB DBA | 
| 使用 LDAP 設定使用者身分驗證和授權。 | （選用） Atlas 支援使用輕量型目錄存取通訊協定 (LDAP) 執行使用者身分驗證和授權。 | MongoDB DBA | 
| 設定統一 AWS 存取。 | （選用） 某些 Atlas 功能，包括使用客戶金鑰管理的 Atlas Data Lake 和靜態加密，請使用 IAM 角色進行身分驗證。 | MongoDB DBA | 
| 使用 設定靜態加密 AWS KMS。 | （選用） Atlas 支援使用 AWS Key Management Service (AWS KMS) 加密儲存引擎和雲端供應商備份。 | MongoDB DBA | 
| 設定 CSFLE。 | （選用） Atlas [支援用戶端欄位層級加密 (CSFLE)](https://www.mongodb.com/docs/upcoming/core/csfle/#client-side-field-level-encryption)，包括欄位的自動加密。  | MongoDB DBA | 

### 遷移資料
<a name="migrate-data"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 在 MongoDB Atlas 中啟動您的目標複本集。 | 在 MongoDB Atlas 中啟動您的目標複本集。在 Atlas Live Migration Service 中，選擇**我已準備好遷移**。 | MongoDB DBA | 
| 建立 AWS Glue 與 MongoDB Atlas 的連線。 | 使用 AWS Glue 編目程式 與 MongoDB Atlas （目標資料庫） AWS Glue 連線。此步驟有助於準備目標環境以進行遷移。如需詳細資訊，請參閱 [AWS Glue 文件](https://docs.aws.amazon.com/glue/latest/dg/console-connections.html)。 | MongoDB DBA | 
| 建立 AWS Glue 與來源資料庫或來源串流的連線。 | 這有助於準備目標環境以進行遷移。 | MongoDB DBA | 
| 設定資料轉換。 | 設定轉換邏輯，將資料從舊版結構化結構描述遷移至 MongoDB 的彈性結構描述。 | MongoDB DBA | 
| 遷移資料。 | 排程 中的遷移 AWS Glue Studio。 | MongoDB DBA | 

### 設定操作整合
<a name="configure-operational-integration"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 連線至叢集。 | 連線至 MongoDB Atlas 叢集。 | 應用程式開發人員 | 
| 與資料互動。 | 與叢集資料互動。 | 應用程式開發人員 | 
| 監控叢集。 | 監控您的 MongoDB Atlas 叢集。 | MongoDB DBA | 
| 備份和還原資料。 | 備份和還原叢集資料。 | MongoDB DBA | 

## 疑難排解
<a name="stream-data-from-ibm-db2-to-mongodb-atlas-troubleshooting"></a>


| 問題 | 解決方案 | 
| --- | --- | 
| 如果您遇到問題 | 請參閱 MongoDB Atlas CloudFormation 資源儲存庫中的[故障診斷](https://github.com/mongodb/mongodbatlas-cloudformation-resources/tree/master#troubleshooting)。 | 

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

除非另有說明，否則下列所有連結都會移至 MongoDB 文件中的網頁。

**遷移指南**
+ [在 上遷移至 MongoDB Atlas AWS](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 Data Lake](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/)

**在 上設定新的 MongoDB Atlas 環境 ****AWS**
+ [雲端供應商和區域](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 儲存庫**
+ [使用 將資料串流至 MongoDB Atlas AWS Glue](https://github.com/mongodb-partners/Stream_Data_into_MongoDB_AWS_Glue?tab=readme-ov-file#troubleshooting)