Migrate a MongoDB Replica Set from AWS to MongoDB Atlas on AWS (original) (raw)

The MongoDB Atlas Live Migration Service helps you migrate MongoDB databases to our fully managed cloud database, MongoDB Atlas, running on AWS quickly and securely. It works by connecting to your existing MongoDB database and synchronizing it with a cluster running in Atlas all while your application continues to function normally. Once the data between the two clusters has been synchronized, you can simply update the database connection string in your application to cut over to your cluster in Atlas.

Time required: 20 minutes

mongosh <mongodb-connection-string> -u <mongodb-username> -p --authenticationDatabase admin  
use admin  
db.getUser("admin")  
{  
  "_id" : "admin.admin",  
  "user" : "admin",  
  "db" : "admin",  
  "roles" : [  
    {  
      "role" : "backup",  
      "db" : "admin"  
    },  
    {  
      "role" : "clusterMonitor",  
      "db" : "admin"  
    }  
  ]  
} ...  

See Create a MongoDB Account andCreate a New Clusterfor instructions.

Note

Your target cluster must use M10 or larger instance nodes. For development or staging environments, deploy a cluster with M10 or M20 instance nodes. For production workloads, select M30 or larger instance nodes.

Navigate to your Atlas cluster. Click the ellipsis (...) button and selectMigrate Data to this Cluster.

This image highlights the Migrate Data to this Cluster
option on a cluster card in Atlas.

click to enlarge

At the top of the Migrate Data to Cluster modal, Atlas displays the IP address ranges that must be accessible from your source cluster. The address ranges displayed depend on the location of your target cluster and can change, so verify that you enter the address ranges as displayed in the modal.

AWS EC2 servers are protected from unauthorized network access usingSecurity Groups. To add new IP address ranges to the IP access list, either create a new Security Group, or modify your existing Security Group to permit inbound network access from the displayed IP address ranges.

Here is an example security group that grants access to Atlas Live Migration Service.

Image shows editing and adding inbound rules.

click to enlarge

If you create a new Security Group, you must associate it with the EC2 instances running your source cluster. In the AWS EC2 console, click the Actions dropdown and select Change Security Group.

GIF demonstrating changing a security group.

For additional information on creating or modifying Security Groups, see Adding Rules to a Security Groupin the AWS EC2 documentation.

On the Migrate Data to Cluster modal, enter the hostname and port number of the primary node in your source AWS source cluster that Atlas will use to perform the data migration.

Note

The address must be resolvable over the public internet, so do not use the private IP address of the node.

Enter the MongoDB username and password from the AWS source cluster in Username/Password.

If TLS/SSL is enabled on the source cluster, toggle the Is TLS/SSL enabledto Yes and upload the CA file that your source AWS cluster uses.

A countdown timer in a progress bar indicates how much time remains before your target cluster is ready to migrate data from your source cluster. Wait until the countdown timer and the Prepare to Cutoverbutton are green before proceeding to the next step.

When Atlas detects that the source and destination clusters are nearly in sync, it starts an extendable 72 hour timer to begin the cutover procedure. If the 72 hour period passes, Atlas stops synchronizing with the source cluster. You can extend the time remaining by 24 hours by clicking the Extend time hyperlink below the

Once you are prepared to cut your applications over to the destination Atlas cluster, click Prepare to Cutover.

Atlas displays a walk-through screen with instructions on how to proceed with the cutover. These steps are also outlined below:

  1. Stop your application. This ensures that no additional writes are generated to the source cluster.
  2. Wait for the optime gap to reach zero. When the counter reaches zero, the source and destination clusters are in sync.
  3. Restart your application using the new connection string provided in step 3 of the Live Migrate cutover UI.

Once you have completed the cutover procedure and confirmed your applications are working normally with the Atlas cluster, click Cut Over to complete the migration procedure. This allows Atlas to:

If you have any questions regarding migration beyond what is covered in this documentation, or if you encounter an error during migration, please see the Atlas documentation onrequesting support.

You created an Atlas cluster, migrated data from your previous AWS MongoDB cluster, and updated your applications to use the new MongoDB Atlas cluster running on AWS. For more information on the data migration process, see Live Migrate Your Replica Set to Atlas andmongomirror.