|
| 1 | +:orphan: |
| 2 | +:template: guide |
| 3 | + |
| 4 | +============================================================== |
| 5 | +Migrate a MongoDB Replica Set from AWS to MongoDB Atlas on AWS |
| 6 | +============================================================== |
| 7 | + |
| 8 | +.. default-domain:: mongodb |
| 9 | + |
| 10 | +.. contents:: On this page |
| 11 | + :local: |
| 12 | + :backlinks: none |
| 13 | + :depth: 1 |
| 14 | + :class: singlecol |
| 15 | + |
| 16 | +The MongoDB Atlas Live Migration Service helps you migrate MongoDB databases to |
| 17 | +our fully managed cloud database, MongoDB Atlas, running on AWS quickly and |
| 18 | +securely. It works by connecting to your existing MongoDB database and synchronizing |
| 19 | +it with a cluster running in Atlas all while your application continues to function |
| 20 | +normally. Once the data between the two clusters has been synchronized, you can |
| 21 | +simply update the database connection string in your application to cut over to |
| 22 | +your cluster in Atlas. |
| 23 | + |
| 24 | +.. time:: 20 |
| 25 | + |
| 26 | +What You'll Need |
| 27 | +---------------- |
| 28 | + |
| 29 | +* Your data is currently in a MongoDB database. |
| 30 | + |
| 31 | + This guide focuses on migrating to MongoDB Atlas on AWS from an existing self-managed MongoDB |
| 32 | + deployment on AWS. If you have data in other database systems, such as MySQL, PostgreSQL, or |
| 33 | + DynamoDB, please `contact us <https://mongodb.com/contact>`_ |
| 34 | + for help with your migration. |
| 35 | + |
| 36 | +* Update your `MongoDB drivers <https://mongodb.com/docs/drivers/>`_ |
| 37 | + and make any necessary code changes at the application level to ensure |
| 38 | + compatibility. |
| 39 | + |
| 40 | +* Your current deployment is a MongoDB replica set or sharded cluster. |
| 41 | + |
| 42 | + If your deployment is currently a standalone instance, you must first |
| 43 | + :manual:`convert it to a replica set </tutorial/convert-standalone-to-replica-set/>`. |
| 44 | + |
| 45 | +* If you're migrating a replica set, it is running MongoDB 2.6 or |
| 46 | + higher. |
| 47 | + |
| 48 | + The Atlas Live Migration Service can move your data directly into a |
| 49 | + newer database version. For more information about the supported |
| 50 | + upgrade paths, see the :atlas:`Atlas documentation |
| 51 | + </import/live-import/#upgrade-path>`. |
| 52 | + |
| 53 | + If you're running a version older than 2.6, see |
| 54 | + `Upgrade MongoDB to 2.6 |
| 55 | + <https://mongodb.com/docs/v2.6/release-notes/2.6-upgrade/index.html>`_ |
| 56 | + for upgrade instructions. |
| 57 | + |
| 58 | +* If you're migrating a sharded cluster, it is running MongoDB 4.0 or |
| 59 | + higher. |
| 60 | + |
| 61 | + The Atlas Live Migration Service can move your data directly the same database version. For more information about the supported |
| 62 | + upgrade paths, see the :atlas:`Atlas documentation |
| 63 | + </import/live-import-sharded/#migration-path>`. |
| 64 | + |
| 65 | + If you're running a version older than 4.0, see |
| 66 | + `Upgrade MongoDB to 4.0 |
| 67 | + <https://mongodb.com/docs/v4.0/release-notes/4.0-upgrade-sharded-cluster/>`_ |
| 68 | + for upgrade instructions. |
| 69 | + |
| 70 | +* (Optional) Enabled authentication on your source deployment. |
| 71 | + |
| 72 | + The migration process requires that authentication is enabled on your |
| 73 | + source cluster in AWS. See :manual:`Enable Auth </tutorial/enable-authentication/>` |
| 74 | + for instructions on enabling authentication. |
| 75 | + You can verify that authentication is enabled on your source cluster |
| 76 | + using the :binary:`~bin.mongosh` command: |
| 77 | + |
| 78 | + .. code-block:: sh |
| 79 | + |
| 80 | + mongosh <mongodb-connection-string> -u <mongodb-username> -p --authenticationDatabase admin |
| 81 | + |
| 82 | +* The database user from your source cluster on AWS that you will use to perform the migration has the required MongoDB roles. |
| 83 | + |
| 84 | + The user must have the ``clusterMonitor`` and ``backup`` roles. To verify |
| 85 | + that the database user that you intend to use for migration has the appropriate |
| 86 | + roles, run the :manual:`db.getUser() </reference/method/db.getUser/>` command against the admin database. |
| 87 | + |
| 88 | + .. code-block:: javascript |
| 89 | + |
| 90 | + use admin |
| 91 | + db.getUser("admin") |
| 92 | + { |
| 93 | + "_id" : "admin.admin", |
| 94 | + "user" : "admin", |
| 95 | + "db" : "admin", |
| 96 | + "roles" : [ |
| 97 | + { |
| 98 | + "role" : "backup", |
| 99 | + "db" : "admin" |
| 100 | + }, |
| 101 | + { |
| 102 | + "role" : "clusterMonitor", |
| 103 | + "db" : "admin" |
| 104 | + } |
| 105 | + ] |
| 106 | + } ... |
| 107 | + |
| 108 | +Procedure |
| 109 | +--------- |
| 110 | + |
| 111 | +.. procedure:: |
| 112 | + :style: normal |
| 113 | + |
| 114 | + .. step:: Launch your target replica set in MongoDB Atlas running on AWS. |
| 115 | + |
| 116 | + See :doc:`Create a MongoDB Account </atlas/account>` and |
| 117 | + `Create a New Cluster |
| 118 | + <https://docs.atlas.mongodb.com/tutorial/create-new-cluster/>`__ |
| 119 | + for instructions. |
| 120 | + |
| 121 | + .. note:: |
| 122 | + Your target cluster must use ``M10`` or larger instance nodes. |
| 123 | + For development or staging environments, deploy a cluster |
| 124 | + with ``M10`` or ``M20`` instance nodes. For production workloads, |
| 125 | + select ``M30`` or larger instance nodes. |
| 126 | + |
| 127 | + .. step:: Open Atlas Live Migration Service. |
| 128 | + |
| 129 | + .. procedure:: |
| 130 | + :style: connected |
| 131 | + |
| 132 | + .. step:: Navigate to your Atlas cluster. Click the ellipsis (:guilabel:`...`) button and select |
| 133 | + :guilabel:`Migrate Data to this Cluster`. |
| 134 | + |
| 135 | + .. figure:: /images/atlas-deployment.png |
| 136 | + :figwidth: 700px |
| 137 | + :alt: This image highlights the Migrate Data to this Cluster |
| 138 | + option on a cluster card in Atlas. |
| 139 | + |
| 140 | + .. step:: Click :guilabel:`General Live Migration`. |
| 141 | + |
| 142 | + .. step:: Click :guilabel:`I'm ready to migrate`. |
| 143 | + |
| 144 | + .. step:: Add the IP address for the Atlas Live Migration Service on your AWS source cluster. |
| 145 | + |
| 146 | + At the top of the :guilabel:`Migrate Data to Cluster` modal, Atlas displays |
| 147 | + the IP address ranges that must be accessible from your source cluster. |
| 148 | + The address ranges displayed depend on the location of your target |
| 149 | + cluster and can change, so verify that you enter the address ranges |
| 150 | + as displayed in the modal. |
| 151 | + |
| 152 | + AWS EC2 servers are protected from unauthorized network access using |
| 153 | + `Security Groups <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/security-group-rules-reference.html>`_. |
| 154 | + To add new IP address ranges to the IP access list, either create a |
| 155 | + new Security Group, or modify your existing Security Group to permit |
| 156 | + inbound network access from the displayed IP address ranges. |
| 157 | + |
| 158 | + Here is an example security group that grants access to Atlas Live Migration Service. |
| 159 | + |
| 160 | + .. figure:: /images/aws-inbound-rules.png |
| 161 | + :figwidth: 760 |
| 162 | + :alt: Image shows editing and adding inbound rules. |
| 163 | + |
| 164 | + If you create a new Security Group, you must associate it with |
| 165 | + the EC2 instances running your source cluster. In the AWS EC2 console, |
| 166 | + click the :guilabel:`Actions` dropdown and select :guilabel:`Change |
| 167 | + Security Group`. |
| 168 | + |
| 169 | + .. figure:: /images/aws-change-security-group.gif |
| 170 | + :figwidth: 760 |
| 171 | + :alt: GIF demonstrating changing a security group. |
| 172 | + |
| 173 | + For additional information on creating or modifying Security Groups, see `Adding Rules to a Security Group |
| 174 | + <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-network-security.html#adding-security-group-rule>`_ |
| 175 | + in the AWS EC2 documentation. |
| 176 | + |
| 177 | + .. step:: Validate your AWS credentials with Atlas Live Migration Service. |
| 178 | + |
| 179 | + .. procedure:: |
| 180 | + :style: connected |
| 181 | + |
| 182 | + .. step:: On the :guilabel:`Migrate Data to Cluster` modal, enter the hostname |
| 183 | + and port number of the primary node in your source AWS source cluster |
| 184 | + that Atlas will use to perform the data migration. |
| 185 | + |
| 186 | + .. note:: |
| 187 | + |
| 188 | + The address must be resolvable over the public internet, so do not use |
| 189 | + the private IP address of the node. |
| 190 | + |
| 191 | + .. step:: Enter the MongoDB username and password from the AWS source cluster |
| 192 | + in :guilabel:`Username/Password`. |
| 193 | + |
| 194 | + .. step:: If TLS/SSL is enabled on the source cluster, toggle the :guilabel:`Is TLS/SSL enabled` |
| 195 | + to :guilabel:`Yes` and upload the CA file that your source AWS cluster |
| 196 | + uses. |
| 197 | + |
| 198 | + .. step:: Click :guilabel:`Validate`. |
| 199 | + |
| 200 | + .. step:: Click :guilabel:`Start Migration`. |
| 201 | + |
| 202 | + A countdown timer in a progress bar indicates how much time remains |
| 203 | + before your target cluster is ready to migrate data from your source |
| 204 | + cluster. Wait until the countdown timer and the :guilabel:`Prepare to Cutover` |
| 205 | + button are green before proceeding to the next step. |
| 206 | + |
| 207 | + .. step:: Click :guilabel:`Prepare to Cutover`. |
| 208 | + |
| 209 | + .. step:: Perform the cutover. |
| 210 | + |
| 211 | + When Atlas detects that the source and destination clusters are nearly |
| 212 | + in sync, it starts an extendable 72 hour timer to begin the cutover |
| 213 | + procedure. If the 72 hour period passes, Atlas stops synchronizing with |
| 214 | + the source cluster. You can extend the time remaining by 24 hours by |
| 215 | + clicking the :guilabel:`Extend time` hyperlink below the :guilabel:`<time> |
| 216 | + left to cut over` timer. |
| 217 | + |
| 218 | + |
| 219 | + .. procedure:: |
| 220 | + :style: connected |
| 221 | + |
| 222 | + .. step:: Once you are prepared to cut your applications over to the |
| 223 | + destination Atlas cluster, click :guilabel:`Prepare to Cutover`. |
| 224 | + |
| 225 | + .. step:: Atlas displays a walk-through screen with instructions |
| 226 | + on how to proceed with the cutover. These steps are also outlined |
| 227 | + below: |
| 228 | + |
| 229 | + 1. Stop your application. This ensures that no additional writes |
| 230 | + are generated to the source cluster. |
| 231 | + |
| 232 | + #. Wait for the optime gap to reach zero. When the counter reaches |
| 233 | + zero, the source and destination clusters are in sync. |
| 234 | + |
| 235 | + #. Restart your application using the new connection string |
| 236 | + provided in step 3 of the Live Migrate cutover UI. |
| 237 | + |
| 238 | + .. step:: Once you are prepared to cut your applications over to the |
| 239 | + destination Atlas cluster, click :guilabel:`Prepare to Cutover`. |
| 240 | + |
| 241 | + .. step:: Once you have completed the cutover procedure and confirmed |
| 242 | + your applications are working normally with the Atlas cluster, |
| 243 | + click :guilabel:`Cut Over` to complete the migration procedure. |
| 244 | + This allows Atlas to: |
| 245 | + |
| 246 | + - Mark the migration plan as complete. |
| 247 | + - Remove the Application Server subnets from the destination |
| 248 | + cluster IP access list. |
| 249 | + - Remove the MongoDB user that Live Migrate used to import data |
| 250 | + to the destination cluster. |
| 251 | + |
| 252 | +Migration Support |
| 253 | +----------------- |
| 254 | + |
| 255 | +If you have any questions regarding migration beyond what is covered |
| 256 | +in this documentation, or if you encounter an error during migration, please |
| 257 | +see the Atlas documentation on |
| 258 | +`requesting support <https://docs.atlas.mongodb.com/support/#request-support>`__. |
| 259 | + |
| 260 | +Summary |
| 261 | +------- |
| 262 | + |
| 263 | +You created an Atlas cluster, migrated data from your previous AWS |
| 264 | +MongoDB cluster, and updated your applications to use the new |
| 265 | +MongoDB Atlas cluster running on AWS. For more information on the |
| 266 | +data migration process, see `Live Migrate Your Replica Set to Atlas |
| 267 | +<https://docs.atlas.mongodb.com/import/live-import/>`_ and |
| 268 | +`mongomirror <https://docs.atlas.mongodb.com/reference/mongomirror/index.html>`_. |
0 commit comments