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
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>
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
, andDB_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
Database Migration:
Execute the database migration as needed. Ensure that all data has been successfully transferred to the new environment.Connect to the Destination Database:
See our compass guide on how to connect to MongoDB:Select the Database:
Select the database that was migrated. For example, if the database is named "simpletask":use simpletask
Create the New User:
Create a new user specific to this database. For example, to create a user named "newuser" with a secure password:db.createUser({ user: "newuser", pwd: "<new-secure-password>", roles: ["readWrite"] })
Replace
<new-secure-password>
with the password you want to assign to the new user.Verify the New User:
Verify that the new user has been successfully created:db.getUsers()
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:
Connect to your database. See our compass guide on how to connect to MongoDB;
Open your console;
Run the following command to create the oplog user
db.createUser({user: "oplogger", pwd: "PasswordForOplogger", roles: [{role: "read", db: "local"}]})
The Oplog user must be created inside the admin database, but it’s role contains read permission to the local database.
Now, your new MongoDB connection string will be like this:
mongodb://oplogger:PasswordForOplogger@mongo-1.example.com,mongo-2.example.com,mongo-3.example.com/local?authSource=admin&replicaSet=replicaSetName
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.