删除Mongo集合不会清除磁盘空间 [英] Dropping Mongo collection not clearing disk space

查看:90
本文介绍了删除Mongo集合不会清除磁盘空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含750,000个文档的集合,它在磁盘上大约占用7Gb.

I have a collection with 750,000 documents, it's taking around 7Gb on the disk.

我删除了集合,但是文件(test.0 ... test.11)仍在磁盘上.

I've dropped the collection, but the files (test.0...test.11) are still on the disk.

  • 如果删除它们,那么我会丢失所有集合,而不仅仅是丢失的集合
  • Mongo不能删除它们吗?

仅注意到数据库统计信息有误.

Just noticed that the database stats have an error.

{
    "ok" : 0,
    "errmsg" : "Collection [test.loadTest-2016-02-06 15:05:34Z] not found."
}

推荐答案

您删除了一个集合,但没有删除包含该集合的数据库.删除集合不会压缩数据文件,也不会删除文档.如果您确实要压缩数据库,请完全删除它并重新导入它,或者使用repairDatabase对其进行压缩(请参阅

You have dropped a collection, but not the database containing it. Dropping the collection does not compact the data files, nor does deleting a document. If you really want to compact the database, either drop it entirely and reimport it, or compact it using repairDatabase (see the docs). Beware though, you cannot compact the database online I think if you just have one node.

如果有副本集,则添加新节点并删除旧节点是在线压缩数据库的最安全方法.我不时这样做,这很容易.

If you have a replica set, adding new nodes and removing the old ones is the safest way of compacting the database online. I do that from time to time and it's easy.

这篇关于删除Mongo集合不会清除磁盘空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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