

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

# 從 MongoDB 遷移至 Amazon DocumentDB：離線
<a name="migration-mongodb-documentdb-offline"></a>

發佈日期：**2022 年 3 月 25 日 ([圖表歷史記錄](#diagram-history))**

此架構示範如何使用 MongoDB公用程式的離線方法，從 遷移MongoDB至 [Amazon DocumentDB](https://docs.aws.amazon.com/documentdb/latest/developerguide/what-is.html)。這是最簡單的方法，但在遷移期間可能會導致更多停機時間。

## 從 MongoDB 遷移至 Amazon DocumentDB：離線方法
<a name="diagram1"></a>

![架構圖顯示使用 MongoDB 公用程式從 MongoDB 離線遷移到 Amazon DocumentDB。 MongoDB](https://docs.aws.amazon.com/zh_tw/reference-architecture-diagrams/latest/migration-mongodb-documentdb/images/migration-mongodb-documentdb-1.png)


下列步驟說明 架構：

1. 遷移至 Amazon DocumentDB 叢集之前，請確定MongoDB來源和應用程式驅動程式使用 3.6 版或更新版本。停止應用程式寫入來源MongoDB以確保資料一致性。

1. 建立從 Amazon EC2 執行個體到MongoDB來源的連線，然後使用 mongodump 工具將資料和索引匯出至 Amazon EC2 遷移執行個體。若要降低對來源部署的影響，請使用MongoDB讀取偏好設定選項強制傾印連線至次要複本集成員。

1. 使用 Amazon DocumentDB 索引工具來檢查傾印索引的相容性，以及在目標 Amazon DocumentDB 叢集上預先建立索引。這可改善整體還原時間。

1. 使用 mongorestore 工具將匯出的資料還原至目標 Amazon DocumentDB 叢集。若要平行化匯入，請使用 mongorestore `numInsertionWorkersPerCollection`選項。

1. 資料還原完成後，請切換應用程式的資料庫連線字串，以使用新的目標 Amazon DocumentDB 叢集。

## 深入閱讀
<a name="further-reading"></a>

如需詳細資訊，請參閱下列資源：
+ [AWS 架構圖示](https://aws.amazon.com/architecture/icons)
+ [AWS 架構中心](https://aws.amazon.com/architecture)
+ [AWS Well-Architected](https://aws.amazon.com/architecture/well-architected)

## 圖表歷史記錄
<a name="diagram-history"></a>

若要收到此參考架構圖的更新通知，請訂閱 RSS 摘要。

| 變更 | 描述 | 日期 | 
| --- |--- |--- |
| [初次出版](#diagram-history) | 首先發佈參考架構圖。 | 2022 年 3 月 25 日 | 

**注意**  
若要訂閱 RSS 更新，您必須為正在使用的瀏覽器啟用 RSS 外掛程式。