Migrate a self-hosted MongoDB environment to MongoDB Atlas on AWS - AWS Prescriptive Guidance

Migrate a self-hosted MongoDB environment to MongoDB Atlas on AWS

Created by Battulga Purevragchaa (AWS), Babu Srinivasan (MongoDB), and Igor Alekseev (AWS)

Environment: Production

Source: On-premises MongoDB environment

Target: MongoDB Atlas on AWS

R Type: Replatform

Workload: All other workloads

Technologies: Migration; Databases

Summary

This pattern describes the steps for migrating from a self-managed MongoDB environment (including MongoDB Community Server, Enterprise Server, Enterprise Advanced, mLab, or any managed MongoDB cluster) to MongoDB Atlas in the AWS Cloud. It uses the Atlas Live Migration Service to help accelerate the data migration from MongoDB to MongoDB Atlas.

The pattern accompanies the guide Migrating to MongoDB Atlas on AWS on the AWS Prescriptive Guidance website. It provides the implementation steps for one of the migration scenarios that are discussed in that guide. For additional migration scenarios, see the following patterns on the AWS Prescriptive Guidance website:

The pattern is intended for AWS Systems Integrator (SI) Partners and AWS users.

Prerequisites and limitations

Prerequisites

  • A source MongoDB Enterprise Advanced, Community Server, or other self-managed MongoDB environment to migrate to MongoDB Atlas.

  • Familiarity with MongoDB, MongoDB Atlas, and AWS services. This pattern explains some of the migration steps at a high level. Additional details will be added in future versions.

Product versions

  • MongoDB version 6.0.13 or later

Architecture

The following diagram shows the Atlas Live Migration Service that is used to migrate data from a MongoDB Enterprise Advanced database and a MongoDB Community database to MongoDB Atlas on AWS. Use this service when you need to migrate large, complex databases to MongoDB Atlas with minimal downtime and continuous data synchronization. This pattern uses Atlas Live Migration Service.

Migrating data with MongoDB Atlas Live Migration Service.

The following diagram shows the MongoDB mirror service (mongomirror) that you can also use to migrate data from a MongoDB Enterprise Advanced database and a MongoDB Community database to MongoDB Atlas on AWS over a secured AWS PrivateLink connection. Use mongomirror for ongoing data replication between on-premises MongoDB and MongoDB Atlas. This tool is ideal for disaster recovery or phased migrations but is outside the scope of this pattern.

Migrating data with mongomirror tool.

For more MongoDB Atlas reference architectures that support different usage scenarios, see Migrating to MongoDB Atlas on AWS on the AWS Prescriptive Guidance website.

Tools

  • MongoDB Atlas is a fully managed database as a service (DbaaS) for deploying and managing MongoDB databases in the cloud.

  • Atlas Live Migration Service is a free MongoDB utility that helps migrate databases to Atlas. This service keeps the source database in sync with the destination database until cutover. When you’re ready to cut over, you stop your application instances, point them to the destination Atlas cluster, and restart them. To access this service, choose Database options from your MongoDB Atlas cluster.

  • mongomirror is a tool for manually migrating data from an existing MongoDB replica set to a MongoDB Atlas replica set. mongomirror doesn’t require you to shut down your existing replica set or applications, doesn’t import user or role data, or copy the configuration database. You can download mongomirror from the MongoDB documentation.

Best practices

For best practices for using MongoDB on AWS, see the posts on the AWS Partner Network Blog.

Epics

TaskDescriptionSkills required

Determine the cluster size.

Estimate the working set size by using the information from db.stats() for the total index space. Assume that a percentage of your data space will be accessed frequently. Or, you can estimate your memory requirements based on your own assumptions. This task should take approximately one week. For more information and examples for this and the other stories in this epic, see the Related resources section.

DBA, App owner

Estimate network bandwidth requirements.

To estimate your network bandwidth requirements, multiply the average document size by the number of documents served per second. Consider the maximum traffic that any node on your cluster will bear as the basis. To calculate downstream data transfer rates from your cluster to client applications, use the sum of the total documents returned over a period of time. If your applications read from secondary nodes, divide this number of total documents by the number of nodes that can serve read operations. To find the average document size for a database, use the db.stats().avgObjSize command. This task will typically take one day.

DBA

Select the Atlas tier.

Follow the instructions in the MongoDB documentation to select the correct Atlas cluster tier.

DBA

Plan for cutover.

Plan for application cutover.

DBA, App owner
TaskDescriptionSkills required

Create a new MongoDB Atlas cluster on AWS.

Log in to Atlas and open the Overview page for your project. Choose the Create button to create a cluster. For more information, see the MongoDB documentation.

DBA

Select AWS Regions and global cluster configuration.

Select from the list of available AWS Regions for your Atlas cluster. Configure global clusters if required. For more information, see the MongoDB documentation.

DBA

Select the cluster tier.

Select your preferred cluster tier. Your tier selection determines factors such as memory, storage, and IOPS specification.

DBA

Configure additional cluster settings.

Configure additional cluster settings such as MongoDB version, backup, and encryption options. For more information about these options, see the Related resources section.

DBA
TaskDescriptionSkills required

Authenticate and authorize users.

You must create and authenticate the database users who will access the MongoDB Atlas clusters. To access clusters in a project, users must belong to that project, and they can belong to multiple projects. Atlas also supports authentication based on AWS Identity and Access Management (IAM). For more information, see the MongoDB documentation.

DBA

Create custom roles.

(Optional) Atlas supports creating custom roles in cases where the built-in Atlas database user permissions don’t cover the set of permissions you want.

DBA

Set up VPC peering.

(Optional) Atlas supports virtual private cloud (VPC) peering with other VPCs on AWS.

AWS administrator

Set up an AWS PrivateLink endpoint.

(Optional) You can set up private endpoints on AWS by using AWS PrivateLink. For more information, see the Amazon VPC documentation.

AWS administrator

Enable two-factor authentication.

(Optional) Atlas supports two-factor authentication (2FA) to help users control access to their Atlas accounts.

AWS administrator

Set up user authentication and authorization with LDAP.

(Optional) Atlas supports performing user authentication and authorization with Lightweight Directory Access Protocol (LDAP).

AWS administrator

Set up unified AWS access.

(Optional) Some Atlas features, including Atlas Data Lake and encryption at rest using customer key management, use IAM roles for authentication.

AWS administrator

Set up encryption at rest using AWS KMS.

(Optional) Atlas supports using AWS Key Management Service (AWS KMS) to encrypt storage engines and cloud provider backups.

AWS administrator

Set up client-side field-level encryption.

(Optional) Atlas supports client-side field level encryption, including automatic encryption of fields.

AWS administrator
TaskDescriptionSkills required

Select your target replica set in MongoDB Atlas.

Navigate to the destination Atlas cluster and choose the ellipsis (...) button. On the cluster list, this button appears below the cluster name. In cluster details, the button appears on the right, next to the Connect and Configuration buttons. For more information, see the MongoDB documentation.

DBA

Add the Atlas Live Migration Service to the access list.

Add the Atlas Live Migration Service to the access list in your AWS source cluster. This helps prepare the source environment to connect to the target Atlas cluster.

DBA

Perform migration with Atlas Live Migration Service.

Choose Start migration. When the Prepare to Cutover button turns green, perform the cutover. Review Atlas cluster performance metrics. Consider updating the database connection in all application layers to point to the new database.

DBA
TaskDescriptionSkills required

Connect to the MongoDB Atlas cluster.

Make sure that MongoDB Atlas cluster connectivity works as expected.

App owner

Interact with cluster data.

Test the cluster data.

DBA

Monitor your clusters.

Verify that your clusters are set up correctly.

DBA

Back up and restore cluster data.

Schedule backups with a regular cadence for cluster data.

DBA

Troubleshooting

IssueSolution

Error: Could not reach specified source

  • Make sure that you added the correct subnet ranges to the IP access list on the source cluster. You can find the four required subnet ranges in the Live Migration modal window.

  • Confirm that the hostname that you specified resolves to a public IP address. At a command prompt, use one of the following commands:

    nslookup <hostname> ping <hostname>
  • Make sure that you are not using a VPC peering connection, which isn’t compatible with pull live migration. If a VPC peering connection is your only option, use mongomirror instead.

Error: Could not resolve hostname

No IP address was found for the given hostname. Confirm that the given hostname is correct and publicly accessible.

Any other error

If you encounter any other errors, see Troubleshoot Live Migration (Pull) in the MongoDB documentation.

Related resources

All of the following links, unless noted otherwise, go to webpages in the MongoDB documentation.

Migration guide

Legacy migration

Discovery and assessment

Configuring security and compliance

Setting up a new MongoDB Atlas environment on AWS

Migrating data

Monitoring clusters

Integrating operations

Training

Additional information

For additional information, see the following topics in the MongoDB documentation: