MongoDB 数据删除 - 回收磁盘空间
可能的重复:
自动压缩mongodb中已删除的空间?
我的理解是在删除时操作 MongoDB 不会释放磁盘空间,但会根据需要重用它。
- 这是正确的吗?
- 如果没有,我会运行修复命令吗?
- 修复可以在实时 mongo 实例上运行吗?
Possible Duplicate:
Auto compact the deleted space in mongodb?
My understanding is that on delete operations MongoDB won't free up the disk space but would reuse it as needed.
- Is that correct?
- If not, would I have run a repair command?
- Could the repair be run on a live mongo instance?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
db.repairDatabase()
from mongodb shell to shrink database size.这有点重复这个 MongoDB 问题...
自动压缩 mongodb 中已删除的空间?
有关如何...
运行重复性作业以返回
空间(包括您可以运行的脚本...)
进入上限集合以供某些用途
案例!
您还可以看到此相关博客文章: http://learnmongo.com/posts/压缩-mongodb-数据文件/
This is somewhat of a duplicate of this MongoDB question ...
Auto compact the deleted space in mongodb?
See that answer for details on how to ...
to run a recurring job to get back
space (including a script you can run ...)
into Capped Collections for some use
cases!
Also you can see this related blog posting: http://learnmongo.com/posts/compacting-mongodb-data-files/
如果您无法承担系统被锁定的费用,或者没有双倍的存储空间,我有另一个解决方案可能比 db.repairDatabase() 更好。
您必须使用副本集。
我的想法是,一旦您删除了占用磁盘的所有多余数据,请停止辅助副本,擦除其数据目录,启动它并让它与主副本重新同步。对其他次要重复此操作,一次一个。
在主服务器上,执行 rs.stepDown() 将 MASTER 移交给已同步的辅助服务器之一,现在停止此服务器,擦除它,然后让它重新同步。
该过程非常耗时,但当您执行 rs.stepDown() 时,应该只需要几秒钟的停机时间。
I have another solution that might work better than doing db.repairDatabase() if you can't afford for the system to be locked, or don't have double the storage.
You must be using a replica set.
My thought is once you've removed all of the excess data that's gobbling your disk, stop a secondary replica, wipe its data directory, start it up and let it resynchronize with the master. Repeat with the other secondaries, one at a time.
On the master, do an rs.stepDown() to hand over MASTER to one of the synched secondaries, now stop this one, wipe it, and let it resync.
The process is time consuming, but it should only cost a few seconds of down time, when you do the rs.stepDown().