• 当删除一个分片时,均衡器需要将被删除的分片上的数据全部迁移到其他分片上,在全部迁移结束且元信息更新完毕之后,你可以安全地将这个分片移除.


    • How frequently does MMAPv1 write to disk?¶
    • 为什么目录里面的文件比我的数据库还要大?

    默认存储目录 /data/db 中的数据文件可能会比数据库中的数据大,思考一下下面可能的原因:

    Preallocated data files

    The storage.mmapv1.smallFiles option will reduce the size of these files, which may be useful if you have many small databases on disk.

    在类Unix系统中, mongod 预先配置了一个另外的数据文件并将磁盘空间初始化为0。当创建一个新的数据库时,预配置文件对于避免延迟有非常大的作用。

    你可以通过 preallocDataFiles 设置将预配置设为 false。但是千万不要设置 preallocDataFiles ,只需使用 preallocDataFiles 调试你经常删除的小数据库。

    The default allocation is approximately 5% of disk space on 64-bit installations. In most cases, you should not need to resize the oplog. See Oplog Sizing for more information.

    • Empty records

    To allow MongoDB to more effectively reuse the space, you can de-fragment your data. To de-fragment, use the compact command. The compact requires up to 2 gigabytes of extra disk space to run. Do not use compact if you are critically low on disk space. For more information on its behavior and other considerations, see compact.

    当删除文档和集合时,MongoDB将会继续列出数据文件中的空记录。MongoDB可以重复使用这部分空间,但是不会释放这部分空间给操作系统。

    • repairDatabase

    Do not use repairDatabase if you are critically low on disk space.