MongoDb:避免过多的磁盘空间 [英] MongoDb : Avoid excessive disk space

查看:251
本文介绍了MongoDb:避免过多的磁盘空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个已分配了85GB空间的数据库.我使用show dbs命令得到了这个大小. 但是当我使用db.stats()时,我得到的存储大小为63GB.浏览完文档后,我发现dat mongo db会为创建的db分配一个大小,然后填充实际数据.

I am having a database which has been allocated a space of 85GB. I got this size using the show dbs command. But when I use the db.stats(), i get the storage size as 63GB. After going through the docs I found dat mongo db allocates a size to the db that is created and then the actual data is filled.

为什么mongo会进行此预分配,有什么办法可以避免这种预分配?

Why does mongo does this preallocation and is there a way I can avoid this preallocation ?

如果是,那么这样做是个好主意还是会影响性能?

If Yes, will it be a good idea to do it or it is going to affect from performance point of view ?

谢谢!

推荐答案

详细信息可在此处找到: http://www.mongodb.org/display/DOCS/Excessive+Disk+Space

Details can be found here: http://www.mongodb.org/display/DOCS/Excessive+Disk+Space

现在就您的情况.我认为您的数据文件的当前大小不能仅由预分配引起.分配的数据文件的最大大小为2G.也许您曾经存储的数据比今天多得多?上面的链接还显示了如果您确定无论如何都不会很快需要它的话,如何取回这些数据.在此过程中,这将需要大量磁盘空间,因此您必须进行一些计划.

Now to your case. I think that the current size of your datafiles cannot be caused by preallocation alone. The maximum size of allocated data files is 2G. Maybe you once stored much more data than today? The link above also shows how to reclaim this data if you're sure you will not need it soon anyway. This will require a lot of disk space during the process, so you must give this some planning.

禁用预分配确实会对性能产生影响.当您进行多次插入操作时,该过程通常需要等待创建新文件.

Disabling preallocation will indeed have perfomance impact. When you do many inserts, the process would regularly have to wait to create a new file.

这篇关于MongoDb:避免过多的磁盘空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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