Skip to content

Migrating a MongoDB Capped collection to DocumentDB

0

Hello, We are planning to migrate from MongoDB to DocumentDB. Some collections are capped and since capped collections are not supported in DocumentDB, I would like to know if it is possible to migrate them as uncapped in DocDB without changing MongoDB. The goal is to have zero downtime in PRODUCTION.

Will DMS CDC create the target in DocumentDB as uncapped or will it fail? Or if I use the hybrid option and create the target as uncapped will DMS CDC migrate new data from capped source to target?

1 Answer
0

When migrating from MongoDB to Amazon DocumentDB, handling capped collections requires special consideration since DocumentDB does not support capped collections. However, there are ways to migrate these collections as uncapped in DocumentDB without modifying your source MongoDB.

For your goal of zero downtime in production, you can use the hybrid migration approach, which combines offline and online migration methods. This approach is particularly useful for large datasets and when you need to minimize downtime.

Here's how you can handle the capped collections:

  1. In the first phase of the hybrid approach, you would use the mongodump tool to export data from your MongoDB source, including the capped collections. When restoring this data to Amazon DocumentDB using mongorestore, the collections will be created as uncapped by default since DocumentDB doesn't support capped collections.

  2. For the second phase, you can use AWS Database Migration Service (DMS) in Change Data Capture (CDC) mode to replicate ongoing changes from your MongoDB source to Amazon DocumentDB. DMS will continue to replicate data from the source capped collections to the uncapped collections in DocumentDB without issues.

To answer your specific questions:

  1. DMS CDC will not fail when encountering capped collections in the source. It will create the target collections in DocumentDB as uncapped.

  2. If you use the hybrid option and create the target as uncapped (which is the default behavior in DocumentDB), DMS CDC will indeed migrate new data from the capped source to the uncapped target in DocumentDB.

This approach allows you to maintain zero downtime in production while effectively migrating your capped collections to uncapped collections in DocumentDB. After the migration is complete and the databases are in sync, you can switch your applications to point to Amazon DocumentDB with minimal disruption to your production environment.

Remember to thoroughly test this migration process in a non-production environment before applying it to your production system to ensure all your application functionalities work correctly with the uncapped collections in DocumentDB.

Sources
Migrating to Amazon DocumentDB - Getting Started with Amazon DocumentDB (with MongoDB Compatibility)
Migrating Self-Managed MongoDB Databases to AWS with Amazon DocumentDB
Migration playbook: MongoDB to Amazon DocumentDB - Amazon DocumentDB

answered 2 years ago

AWS
SUPPORT ENGINEER

reviewed 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.