MongoDB - Simplify migration to Galaxy Database

This Docker image made by the meteor expert team simplifies the migration of MongoDB databases from one server to another. It is particularly useful when migrating from any MongoDB hosting to Galaxy Databases - MongoDB.

Usage

Prerequisites

Before using this Docker image, make sure you have the following:

  • Docker installed on your machine.

  • Source and target MongoDB URIs ready and tested.

  • IP whitelist configured on MongoDB Atlas if applicable.

Step-by-Step Guide

  1. Get the MongoDB URIs

    • Obtain the source MongoDB URI in the format: mongodb+srv://<username>:<password>@<source-cluster>

    • Get the MongoDB target URI in format from the Galaxy Database team: mongodb://<username>:<password>@<destination-host>:<port>

      image-20240522-193427.png

       

This procedure should not be used for MongoDB Sharded clusters.

  1. Run the Docker Container

    Use the following command to run the migration container:

    docker run --rm \ -e SOURCE_URI="" \ -e TARGET_URI="" \ -e DB_NAME="simpletask" \ meteor/galaxy-mongodb-migrate:202409101534

    Replace SOURCE_URI, TARGET_URI, and DB_NAME with your actual values.

Example

docker run --rm \ -e SOURCE_URI="mongodb+srv://username:password@source-cluster.mongodb.net" \ -e TARGET_URI="mongodb://username:password@destination-host-01.mongodb.net:27017,destination-host-02.mongodb.net:27017,destination-host-03.mongodb.net:27017/admin?replicaSet=replicaSetName" \ -e DB_NAME="simpletask" \ meteor/galaxy-mongodb-migrate:202409101534

 


Certainly, here's the documentation recommending the creation of a new user specifically for the database after migration:


Creating User for the Database

We recommend that after successfully migrating the database, you create a new user specifically for that database. This helps to improve security and access control to the data.

Recommended Steps

  1. Database Migration:
    Execute the database migration as needed. Ensure that all data has been successfully transferred to the new environment.

  2. Connect to the Destination Database:
    See our compass guide on how to connect to MongoDB:

  3. Select the Database:
    Select the database that was migrated. For example, if the database is named "simpletask":

    use simpletask
  4. Create the New User:
    Create a new user specific to this database. For example, to create a user named "newuser" with a secure password:

    Replace <new-secure-password> with the password you want to assign to the new user.

  5. Verify the New User:
    Verify that the new user has been successfully created:


Now you can use a URI like this in your Meteor app, just change your host, user, database, and password settings:

mongodb://newuser:pass@destination-host-01.mongodb.net:27017,destination-host-02.mongodb.net:27017,destination-host-03.mongodb.net:27017/simpletask?replicaSet=NameOfYourReplicaSet&readPreference=secondary



Security Considerations

  • Use secure passwords for your users.

  • Assign only the necessary permissions to each user.

  • Regularly review user privileges to ensure that only the right people have access.

By following these steps, you will have set up a new user specific to the migrated database, ensuring better security and access control to your data.


This documentation provides a straightforward guide on how to create a new user for the database after migration. Be sure to adapt the commands according to your specific settings.

 

 

Security Considerations

  • Make sure to protect sensitive data and passwords.

  • Ensure that proper network access controls are in place.

Troubleshooting

  • Check connection details and permissions.

  • Review logs for any errors.

Users

To effectively manage your MongoDB cluster, the Galaxy Database team sets up several MongoDB users within your clusters:

  • admin@admin: This is your initial user with administrative privileges.

  • galaxyadmin@admin: This is a technical user required for automation purposes.

  • galaxybackup@admin: This user is designated for performing backups.

  • galaxymonitor@admin: This user is also used for monitoring.

 

Please do not delete these users.


If you need a migration without downtime, contact our team of experts by emailing sales@meteor.com


Creating a MongoDB user for Oplog

To set up an oplog user, you need to configure a MongoDB replica set. This will create the local database to store all Oplog information.

Here are the steps to create the Oplog user on your MongoDB:

  1. Connect to your database. See our compass guide on how to connect to MongoDB;

  2. Open your console;

  3. Run the following command to create the oplog user

The Oplog user must be created inside the admin database, but it’s role contains read permission to the local database.

  1. Now, your new MongoDB connection string will be like this:

Note that at the end of this string, the parameter authSource=admin must be present. This is because we are accessing the local database but authenticating in the admin database.