简体   繁体   English

MongoDB和磁盘空间

[英]MongoDB and disk space

We have a MongoDB cluster with 4 shards. 我们有一个带有4个分片的MongoDB集群。 Our primary shard disk space has 700GB, and according to db.stats() that shard is using ~530GB. 我们的主分片磁盘空间为700GB,根据db.stats(),分片正在使用〜530GB。 When checking df -h, the disk usage is on 99% (9.5 GB free), i'm guessing this means that all the rest is data files pre-allocated by Mongo. 当检查df -h时,磁盘使用率为99%(9.5 GB可用空间),我猜这意味着其余所有都是由Mongo预分配的数据文件。 I've ran compact on couple of collections, and the disk space was reduced to 3.5GB(?) 我在几个集合上进行了压缩,磁盘空间减少到3.5GB(?)

We're going to run a process that will generate ~140GB of extra data (35GB per shard). 我们将运行一个过程,该过程将产生约140GB的额外数据(每个分片35GB)。 Should we have any concerned on running out of disk space? 我们是否应该担心磁盘空间不足?

Thanks in advance. 提前致谢。

compact doesn't decrease disk usage at all, actually it could even lead to additional file perallocation. compact根本不会减少磁盘使用,实际上甚至可能导致额外的文件分配。 To reduce disk usage you could use repairDatabase command or start mongo with repair option. 为了减少磁盘使用,您可以使用repairDatabase命令或使用修复选项启动mongo。 However, it would require additional free space on disk. 但是,这将需要额外的磁盘可用空间。

Described situation could be the case if you did a lot of document deletions or some operations that forced documents to move. 如果您进行了很多文档删除或某些迫使文档移动的操作,则可能是上述情况。 In this case your database would be highly defragmented. 在这种情况下,您的数据库将进行高度碎片整理。 compact command helps you to reduce defragmentation and you will have more space for new records, but again, it doesn't reclaim any space back to OS. compact命令可以帮助您减少碎片整理,您将有更多空间用于存储新记录,但是同样,它也不会将任何空间回收回OS。

Best option for you is to try to get why you have such level of defragmentation. 对您来说最好的选择是尝试弄清为什么会有这样的碎片整理水平。

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

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