为什么一个空的MongoDB数据库这么大? [英] Why is an empty MongoDB database so big?

查看:462
本文介绍了为什么一个空的MongoDB数据库这么大?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用命令创建新的mongoDB数据库实例时

When I create a new mongoDB database instance with the command

mongod --dbpath db

其中db是我在调用命令的目录中创建的文件夹.运行此命令并检查目录的大小后,我发现它的大小超过了 300MB -当其中没有数据时.

where db is a folder I have made in the directory from which I call the command. After running this and checking the size of the directory, I see that is is over 300MB in size - when there's no data in there.

这是怎么回事?

感谢您的帮助!

编辑

感谢人们谈论journal的预分配大小.

Thanks to the people talking about the pre-allocated size for journal.

这是数据库目录中文件/文件夹的列表,按顺序排序(目前数据库中有少量数据,但此处大小可忽略):

Here is a listing of files/folders in the database directory, sorted by order (there is a little bit of data in the database by now, but its size is neglible here):

$du -ha | sort -n
4.0K    ./WiredTiger
4.0K    ./WiredTiger.lock
4.0K    ./WiredTiger.turtle
4.0K    ./WiredTigerLAS.wt
4.0K    ./mongod.lock
4.0K    ./storage.bson
8.0K    ./.DS_Store
8.0K    ./diagnostic.data/metrics.2016-06-10T11-07-50Z-00000
8.0K    ./diagnostic.data/metrics.interim
 16K    ./_mdb_catalog.wt
 16K    ./index-3-3697658674625742251.wt
 36K    ./collection-0-3697658674625742251.wt
 36K    ./index-1-3697658674625742251.wt
 36K    ./sizeStorer.wt
 44K    ./WiredTiger.wt
 60K    ./collection-2-3697658674625742251.wt
 72K    ./diagnostic.data/metrics.2016-06-10T10-19-31Z-00000
100M    ./journal/WiredTigerLog.0000000003
100M    ./journal/WiredTigerPreplog.0000000001
100M    ./journal/WiredTigerPreplog.0000000002
168K    ./diagnostic.data/metrics.2016-06-10T11-17-58Z-00000
256K    ./diagnostic.data
300M    ./journal
301M    .

如您所见,日志目录几乎占据了所有空间.

As you can see, the journal directory is taking up almost all of the space.

推荐答案

具体取决于您的MongoDB版本和配置的存储引擎,启动时将预先分配一些数据和元数据文件.这是预期的行为:空"部署仍然会产生内务处理和诊断数据.

Depending on your version of MongoDB and configured storage engine, several data and metadata files will be preallocated on startup. This is the expected behaviour: an "empty" deployment still results in housekeeping and diagnostic data.

根据您的目录列表,您正在运行MongoDB 3.2,默认情况下使用MonthDB存储引擎. WiredTiger每个日志文件最多分配100MB,因此您的新部署具有约300MB的预分配 journal文件:

Based on your directory listing, you are running MongoDB 3.2 which defaults to using the WiredTiger storage engine. WiredTiger allocates up to 100MB per journal file, so your new deployment has ~300MB of preallocated journal files:

     100M    ./journal/WiredTigerLog.0000000003
     100M    ./journal/WiredTigerPreplog.0000000001
     100M    ./journal/WiredTigerPreplog.0000000002

除了日志文件,其他将在dbpath中创建的元数据(尚未显式创建数据库)将包括:

Aside from journal files, other metadata that will be created in your dbpath (without you having explicitly created databases yet) will include:

  • 一个local数据库,该数据库具有一个名为 startup_log ,其中包含有关此mongod实例的每次启动调用的一些诊断信息. local.startup_log将有一个关联的集合和索引文件;文件名是不透明的,但是作为您创建的第一个文件,我想在您的示例中可能是:

  • A local database with a capped collection called startup_log with some diagnostic information about each startup invocation of this instance of mongod. There will be an associated collection and index file for local.startup_log; the filenames are opaque but as the first files created I'm guessing in your example these might be:

 36K    ./collection-0-3697658674625742251.wt
 36K    ./index-1-3697658674625742251.wt

  • 多个WiredTiger元数据文件.由于默认情况下为startup_log创建了local数据库,因此部署中将始终至少有一个数据库:

  • Multiple WiredTiger metadata files. There will always be at least one database in a deployment since the local database is created by default for the startup_log:

    4.0K    ./WiredTiger
    4.0K    ./WiredTiger.lock
    4.0K    ./WiredTiger.turtle
    4.0K    ./WiredTigerLAS.wt
     16K    ./_mdb_catalog.wt
     36K    ./sizeStorer.wt
     44K    ./WiredTiger.wt
    

  • 一个diagnostic.data目录;这是用于服务器状态指标的定期采样:

  • A diagnostic.data directory; this is for periodic sampling of server status metrics:

    168K    ./diagnostic.data/metrics.2016-06-10T11-17-58Z-00000
    72K    ./diagnostic.data/metrics.2016-06-10T10-19-31Z-00000
    

  • 这篇关于为什么一个空的MongoDB数据库这么大?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆