简体   繁体   中英

MongoDB databases migrating from one OS to another

I am building a web application in Python for which I need MongoDB. I have MongoDB installed on a Mac OS X. And for my app I want to have a Linux VPS. I wanted to know whether I could migrate MongoDB collections from Mac to Linux. Does endianess of the system causes problems? What else might? I am no expert in databases or operating systems. And if we can migrate, can someone point me towards a guide or procedure? Thanks in advance.

You can just run mongoexport, which will dump your database to a file in either JSON or CSV format.

Then, on your new machine, you can run mongoimport with the input file you got from mongoexport, and everything should be there.

mongoexport: http://www.mongodb.org/display/DOCS/mongoexport

mongoimport: http://www.mongodb.org/display/DOCS/Import+Export+Tools?focusedCommentId=4554852#ImportExportTools-mongoimport

While export and re-importing certainly works, this will recreate all the indices from scratch in the new location. For complex indices this could take days.

I wouldn't be surprised in the binary files are compatible - so I would first try shutting down the original server, copying over the entire data directory to the new location. Make sure you are running the exact same version of the mongo server software (eg 2.0.x, both 64-bit and both official binaries from 10gen, and with the same configuration options).

I'm pretty sure this will start correctly and all data AND indices will be ready to go. This is basically just taking a binary snapshot of your data files.

mongodb has plenty of tools for export and import of databases. Check out: http://www.mongodb.org/display/DOCS/Import+Export+Tools

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM