修复数据库需要多少额外空间 [英] How much additional space would repair database require

查看:113
本文介绍了修复数据库需要多少额外空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经问过此问题在mongodb谷歌论坛中,没有任何回复将其张贴在这里.

I've aksed this question in mongodb google group, in absence of any reply posting it here.

我们有一个单节点mongo(版本2.0.1)实例.即使在每天存档之后,我们的磁盘空间也用光了,因为mongo不会将空间返回给操作系统,而是尝试自己使用它.目前,我们的设置非常稀疏,大约有50%的空间处于空闲状态.您可以看到数据+索引大小约为1170 GB,而存储大小约为2158 GB,文件大小约为2368 GB.

We have a single node mongo (version 2.0.1) instance. We are running out of disk space even after daily archiving as mongo doesn't return the space back to the OS and tries to use it itself. Currently our setup has become very sparse with around 50% space lying idle. You can see that data + index size is around 1170 GB while storage size is around 2158 GB and file size is around 2368 GB.

db.stats()    
{  
    "db" : "default",            
    "collections" : 106,  
    "objects" : 553988389,  
    "avgObjSize" : 2094.1392962010254,  
    "dataSize" : NumberLong("1160128855044"),  
    "storageSize" : NumberLong("2315777236208"),  
    "numExtents" : 1487,  
    "indexes" : 107,  
    "indexSize" : 97914435136,  
    "fileSize" : NumberLong("2543459500032"),  
    "nsSizeMB" : 16,  
    "ok" : 1  
}

我们想回收空间,因为这不是关键任务系统(它像原木堆放场一样)可以维持停机时间.我们也不想花钱来创建副本集,因为我们位于物理数据中心,因此宁愿不要仅为了修复数据库而附加其他磁盘.
我想了解:-
-修复数据库需要多少可用磁盘空间
-修复数据库后,我们希望可以恢复多少空间
-大约需要多少时间来修复数据库.
-如果修复数据库仍然持续运行,则可以安全地将其杀死并重新启动数据库.

We want to reclaim the space and as this is not a mission critical system (its like a dumping yard for logs) can sustain a downtime. We don't want to spend on creating a replica set also we are in a physical datacenter hence will prefer not to attach additional disk only for repairing database.
I want to understand :-
-How much free disk space is required for repair database
-How much space can we hope to recover after repair database
-Around how much time should it take to repair database.
-If at all repair database keeps going on, is it safe to just kill it and restart the database.

我们的大部分数据都在一个集合中,因此紧凑集合是否比修复数据库更好.

Bulk of our data lie in a single collection so whether compact collection would be better than repair database.

推荐答案

首先,我建议您从2.0.1升级.如果不是2.2.2,则至少为2.0.7. 修复需要2倍的文件大小. 最后,文件大小应略大于数据大小. 需要多长时间取决于系统资源和系统的繁忙程度. Compact不会释放磁盘上的空间-只是在数据文件中进行碎片整理.

First I would recommend you to upgrade from 2.0.1. At least to 2.0.7 if not 2.2.2. Repair takes 2x file size. You should end up with slightly larger than your data size as your file size. How long it takes depends on system resources and how busy your system is. Compact doesn't free space on disk - it just defragments within the data file.

在2.2.x中,您可以使用 collMod

In 2.2.x you can use collMod

命令设置usePowerOf2Sizes以减少文件碎片.例如,插入800字节的文档,将分配1024字节.删除该文档并插入一个900字节的文档,现在可以重用1024个空间.否则,可能只分配了850个字节,而为900个字节的文档分配了新的可用空间.

command to set usePowerOf2Sizes to reduce file fragmentation. e.g insert 800 byte document and 1024 bytes will be allocated. Delete that doc and insert a 900 byte doc, now the 1024 space can be reused. Without this maybe only 850 bytes would have been allocated and new free space would have been allocated for the 900 byte document.

killing repairDatabase应该没问题-将文件复制到新位置,进行碎片整理,然后在完成复制后再复制回去,但是您必须对其进行测试以确保:)

killing repairDatabase should be ok - files are copied to new location, defragg'd then copied back in on completion but you would have to test it to be sure :)

这篇关于修复数据库需要多少额外空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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