Live Migration for MongoDB

Easily migrate your MongoDB deployments to ScaleGrid with no downtime using our live migration tool.

Ready to upgrade to fully managed hosting for MongoDB®? Easily migrate your MongoDB deployments to ScaleGrid and we'll take those time-consuming database management tasks off your plate so you can get back to working on your product.

Prerequisites

Here are the things you'll need to set up live migration of your MongoDB deployment to ScaleGrid:

  • ScaleGrid MongoDB replica set cluster - Create under our Dedicated or BYOC plans.
  • Remote server name
  • Port
  • SSL config
  • Remote server username and password
  • The source cluster firewall settings should allow connection with the private IP of the target cluster.

Here are the things you need to ensure before you set up live migration of your MongoDB replica set to ScaleGrid:

  • If the source cluster must be a replica set, the destination (ScaleGrid) cluster must be a replica set.
  • The destination cluster must be of size Medium or above.
  • The destination cluster should be the same or greater version than the source cluster.
  • The source cluster must have a minimum of 12 hours replication window.
  • The network communication must be properly configured between source and destination clusters.
    • Ensure that the destination server IP addresses are whitelisted on the source cluster. You can obtain the IP addresses of the destination cluster from the livesync wizard as well by clicking on Lookup ScaleGrid Server IP’s link.
    • If the clusters are within VPC, ensure that security groups are properly configured to allow communication between destination and source cluster.
  • The user on the source cluster must have the following minimal roles: backup, clusterMonitor, and read on local database.

In this tutorial, we're going to show you how to live migrate into an existing, newly created cluster at ScaleGrid. To learn how to import your MongoDB data during the cluster creation process, check out these docs based on your plan:

Live Migration into an Existing MongoDB Cluster

Before starting your live migration into your newly created MongoDB cluster at ScaleGrid, verify that there is no data in this cluster so that any existing data isn't overwritten. If you'd like to override your existing data in the import, first create a backup to ensure your existing data is preserved.

Live Migration Setup

  1. Log into your ScaleGrid account, or start a free 30-day trial.
  2. Go to your MongoDB dashboard, and select the cluster you'd like to migrate to.
  3. Under the Overview tab, click Import Data -> Live sync:
1920
  1. Stay on the Remote Server tab, and enter your server name and port.
  2. Next, enter the username and password for your remote server.
  3. Check the 'Yes' box if the remote server has SSL enabled.
  4. Review the information entered is correct, and click 'Start live sync'.
  5. We will perform the required validations to the remote server once you click start live sync, and upon successful validation, the live sync job will begin.

👍

Your MongoDB live sync has now begun!

Your data will be in sync once the replication lag is 0, and the time will vary based on the size of your data.

Live Migration Workflow

Initial import

The first step of the live migration process is the initial import. This step involves taking a full dump of the source data using mongodump and will be restored on destination cluster using mongorestore. Once the initial import is complete, ScaleGrid system will advance to the next step for performing live sync.

Live Sync Of Data

Once the initial import step is complete, the destination cluster is kept in sync with the source using oplog tailing. The replication lag is displayed in the UI. Once the destination cluster has caught up with the source and the replication lag is within the threshold, ScaleGrid system will advance the workflow to next step.

Ready To Switchover

This is the final step of the live migration and your cluster is ready for switchover. At this point, you can get ready to complete the migration and point your application to the destination cluster.
Here are the steps to be followed

  1. Stop all writes to the source cluster. Wait for at least 30 seconds for all the writes to get replicated.
  2. Ensure the replication sync lag is 0. This indicates that both clusters are in sync.
  3. Change the connection string to point to the ScaleGrid cluster. The credentials and connection string are available under the Overview tab in the cluster details page.
  4. Click the Complete live sync button to complete the live migration process.

Confirm Your Successful MongoDB Data Migration

After the migration is complete, make sure to also confirm the following:

  1. Data size and details match your imported cluster.
  2. Your MongoDB cluster is connected to your application.
  3. Your backup schedule is configured.