简体   繁体   English

MongoDB 数据库从一个操作系统迁移到另一个操作系统

[英]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.我正在 Python 中构建一个 web 应用程序,为此我需要 MongoDB。我在 Mac OS X 上安装了 MongoDB。对于我的应用程序,我想要一个 Linux VPS。 I wanted to know whether I could migrate MongoDB collections from Mac to Linux. Does endianess of the system causes problems?我想知道我是否可以将 MongoDB collections 从 Mac 迁移到 Linux。系统的字节顺序是否会导致问题? 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.您可以只运行 mongoexport,它会将您的数据库转储到 JSON 或 CSV 格式的文件中。

Then, on your new machine, you can run mongoimport with the input file you got from mongoexport, and everything should be there.然后,在您的新机器上,您可以使用从 mongoexport 获得的输入文件运行 mongoimport,一切都应该在那里。

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

mongoimport: http://www.mongodb.org/display/DOCS/Import+Export+Tools?focusedCommentId=4554852#ImportExportTools-mongoimport 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).确保您运行的是完全相同版本的 mongo 服务器软件(例如 2.0.x,都是 64 位版本和来自 10gen 的官方二进制文件,并且具有相同的配置选项)。

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.我很确定这将正确启动,所有数据和索引都将准备好到 go。这基本上只是对数据文件进行二进制快照。

mongodb has plenty of tools for export and import of databases. mongodb 有大量的数据库导出和导入工具。 Check out: http://www.mongodb.org/display/DOCS/Import+Export+Tools查看: http://www.mongodb.org/display/DOCS/Import+Export+Tools

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将MySQL服务器从一个盒子迁移到另一个盒子 - Migrating a MySQL server from one box to another 将邮件从一个帐户迁移到另一个帐户:imapsync 还是 offlineimap? - Migrating Mail from One Account to Another: imapsync or offlineimap? 将Web服务器目录从一个操作系统链接到另一个操作系统 - Linking webserver directory from one OS to another OS 将Meteor MongoDB从一个VPS迁移到另一个? - Migrate Meteor MongoDB from one VPS to another? 一次将多个课程从一台服务器迁移到另一台 Moodle 服务器 - Migrating multiple courses from one server to another moodle server all at once 如何在mongodb中将数据库从一台服务器复制到另一台服务器 - How to copy database from one server to another in mongodb 是否允许任何操作系统将内存从一个地址移动到另一个地址而不进 - Does any OS allow moving memory from one address to another without physically copying it? 将 docker 实例迁移到另一台服务器 - Migrating docker instance to another server 从Windows迁移到Linux - Migrating to Linux from Windows OpenMP不会在一台机器上启动线程,但在另一台运行相同操作系统的机器上可以正常工作 - OpenMP not starting threads in one machine but works OK in another one running the same OS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM