简体   繁体   English

MongoDB 数据库中的数据如何存储在磁盘上?

[英]How is the data in a MongoDB database stored on disk?

I know that MongoDB accepts and retrieves records as JSON/BSON objects, but how does it actually store these files on disk?我知道MongoDB接受和检索记录作为 JSON/BSON 对象,但它实际上如何将这些文件存储在磁盘上? Are they stored as a collection of individual *.json files or as one large file?它们是存储为一组单独的*.json文件还是一个大文件? I have a hunch as to the latter, since the MongoDB docs state that it works best on systems with ext4/xfs , which are better at handling large files.我对后者有一种预感,因为MongoDB文档指出它在具有ext4/xfs系统上效果最佳,后者更ext4/xfs处理大文件。 Can anyone confirm?有人可以确认吗?

A given mongo database is broken up into a series of BSON files on disk, with increasing size up to 2GB.一个给定的 mongo 数据库被分解成一系列磁盘上的 BSON 文件,大小增加到 2GB。 BSON is its own format, built specifically for MongoDB. BSON 是它自己的格式,专为 MongoDB 构建。

These slides should answer all of your questions:这些幻灯片应该可以回答您的所有问题:

http://www.slideshare.net/mdirolf/inside-mongodb-the-internals-of-an-opensource-database http://www.slideshare.net/mdirolf/inside-mongodb-the-internals-of-an-opensource-database

MongoDB stores the data on the disk as BSON in your data path directory, which is usually /data/db . MongoDB 将磁盘上的数据作为 BSON 存储在您的数据路径目录中,通常是/data/db There should be two files per collection there, collection.0 , which stores the data (and that integer is then incremented as needs be) and collection.ns which stores the namespacing metadata for the collection.每个集合应该有两个文件, collection.0存储数据(然后该整数根据需要递增)和collection.ns存储集合的命名空间元数据。

BSON 格式的详细文档可以在这里找到: http : //bsonspec.org/

最高 mongodb 3.0 http://blog.mongolab.com/2014/01/how-big-is-your-mongodb/如果您在 MongoDB 3.0 中打开了wiredtiger 存储引擎,它将使用wiredtiger 存储模型http://docs。 mongodb.org/v3.0/core/storage/#storage-wiredtiger

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

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