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
- Your data is currently in a MongoDB database.
This guide focuses on migrating to MongoDB Atlas on AWS from an existing self-managed MongoDB deployment on AWS. If you have data in other database systems, such as MySQL, PostgreSQL, or DynamoDB, please contact usfor help with your migration. - Update your MongoDB driversand make any necessary code changes at the application level to ensure compatibility.
- Your current deployment is a MongoDB replica set or sharded cluster.
If your deployment is currently a standalone instance, you must firstconvert it to a replica set. - If you're migrating a replica set, it is running MongoDB 2.6 or higher.
The Atlas Live Migration Service can move your data directly into a newer database version. For more information about the supported upgrade paths, see the Atlas documentation.
If you're running a version older than 2.6, seeUpgrade MongoDB to 2.6for upgrade instructions. - If you're migrating a sharded cluster, it is running MongoDB 4.0 or higher.
The Atlas Live Migration Service can move your data directly the same database version. For more information about the supported upgrade paths, see the Atlas documentation.
If you're running a version older than 4.0, seeUpgrade MongoDB to 4.0for upgrade instructions. - (Optional) Enabled authentication on your source deployment.
The migration process requires that authentication is enabled on your source cluster in AWS. See Enable Authfor instructions on enabling authentication. You can verify that authentication is enabled on your source cluster using the mongosh command:
mongosh <mongodb-connection-string> -u <mongodb-username> -p --authenticationDatabase admin
- The database user from your source cluster on AWS that you will use to perform the migration has the required MongoDB roles.
The user must have theclusterMonitor
andbackup
roles. To verify that the database user that you intend to use for migration has the appropriate roles, run the db.getUser() command against the admin database.
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.
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.
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.
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:
- Stop your application. This ensures that no additional writes are generated to the source cluster.
- Wait for the optime gap to reach zero. When the counter reaches zero, the source and destination clusters are in sync.
- 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:
- Mark the migration plan as complete.
- Remove the Application Server subnets from the destination cluster IP access list.
- Remove the MongoDB user that Live Migrate used to import data to the destination cluster.
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.