Migrate from MongoDB® to SingleStore
On this page
To migrate your collection from MongoDB® to SingleStore, you can perform the following tasks:
-
Replicate your MongoDB® collections using Change Data Capture (CDC).
-
Back up your collections using
mongodump
, and then restore the backup into your SingleStore Helios workspace usingmongorestore
. -
Export your collection using
mongoexport
, and then import the exported data into your SingleStore Helios workspace usingmongoimport
.
Replicate MongoDB® Collections to SingleStore
SingleStore allows you to perform a one-time data replication or ongoing CDC (Change Data Capture) from MongoDB® collections into SingleStore.
Use mongodump
and mongorestore
Back Up Data using mongodump
You can back up your collections in the BSON format using the mongodump
command-line tool.mongodump
command from the system command-line.
Here's a sample command to create a backup:
mongodump --uri="mongodb://<username>:<password>@<MongoDB_endpoint>:27017" \--db=<database_name> --collection=<collection_name> \--out=<path_to_output_directory>
For MongoDB® Atlas instances, use the mongodb+srv://
scheme.
mongodump --uri="mongodb+srv://<username>:<password>@<MongoDB_Atlas_endpoint>" \--db=<database_name> --collection=<collection_name> \--out=<path_to_output_directory>
Restore the Backup using mongorestore
To restore the backup of your MongoDB® collections created using mongodump
into your SingleStore Helios workspace, use the mongorestore
command-line tool.mongorestore
command from the system command-line.
Note
Do not restore and build the indexes specified in the backup.--noIndexRestore
option to ignore the indexes in the backup.
Here's a sample command to restore your MongoDB® backup into SingleStore:
mongorestore \--uri 'mongodb://<user>:<password>@<SingleStore_Kai_endpoint>:27017/<target_database>?authMechanism=PLAIN&tls=true&loadBalanced=true' \--noIndexRestore --ssl <path_to_backup>
Use mongoexport
and mongoimport
Export Data using mongoexport
You can export your collection in either JSON or CSV format using the mongoexport
command-line tool.mongoexport
command from the system command-line.
Run the following command to export collections from a MongoDB® endpoint:
mongoexport --uri='mongodb://<user>:<password>@<MongoDB_endpoint>:27017' \--db=<database_name> --collection=<collection_name> \--out=<path_to_output/filename.[json|csv]>
Run the following command to export collections from a MongoDB® Atlas endpoint:
mongoexport --uri mongodb+srv://<username>@<atlas_endpoint>/<database_name> \--collection=<collection_name> --out=<path_to_output/filename.[json|csv]>
Import Data using mongoimport
To import the data exported using mongoexport
into your SingleStore Helios workspace, use the mongoimport
command-line tool.mongoimport
supports Extended JSON, CSV, and TSV formats that have been exported via mongoexport
.mongoimport
command from the system command-line.
mongoimport \--uri 'mongodb://<user>:<password>@<SingleStore_Kai_endpoint>:27017/?authMechanism=PLAIN&tls=true&loadBalanced=true' \--db <database_name> --collection <collection_name> \--file <path_to_import_file/filename.[json|csv]>
If your file contains arrays, add --jsonArray
after the database name.
Last modified: March 13, 2024