Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Move MongoDB data from Staging server to Production

Tags:

mongodb

nosql

I have 500,000 documents inside a collection on a staging server, I need to move these documents to the production server.

What is the best way to move this data, can I let mongodb replicate it from staging to production, do I move the data files or do I do an export and re-import?

like image 370
Tom Avatar asked Jan 13 '11 12:01

Tom


People also ask

How do I export an entire MongoDB database?

So, to export data from the MongoDB database, MongoDB provides a command-line tool known as mongoexport. Using this tool you can exports data of a collection in JSON or CSV(comma-separated value) format. Moreover, we can also use features like limit and sort on a collection while exporting the data.

What is the preferred bit to deploy the MongoDB in production?

Use a 64-bit System to Run MongoDB If you have to keep using a 32-bit system, your coding must be very simple to reduce the number of bugs and latency for throughput operations. However for code complexities such as aggregation pipeline and geodata, it is advisable to use the 64-bit system.

What are the two different ways of Modelling relationships within MongoDB?

MongoDB Relationships are the representation of how the multiple documents are logically connected to each other in MongoDB. The Embedded and Referenced methods are two ways to create such relationships.


1 Answers

  • To dump a collection do

    mongodump -d dbname -c collectionname

    On a Windows machine this will create a dump folder under the Mongo 'data' folder with bson files

  • To restore on a remote host

    mongorestore -h hostname -d dbname -c collectionname dump\dbname\collectionname.bson

like image 115
sumit Avatar answered Oct 27 '22 09:10

sumit