mongodb Mongo“prealloc”文件占用空间
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9473850/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Mongo "prealloc" files taking up room
提问by jbnunn
I'm trying to free up some space on an Ubuntu server running Mongo. I've attached a new, empty 8GB volume, and have the room to move stuff around.
我正在尝试在运行 Mongo 的 Ubuntu 服务器上释放一些空间。我已经附加了一个新的、空的 8GB 卷,并且有足够的空间来移动东西。
I have several large (1GB) files in /var/lib/mongodb/journal/prealloc, is it safe to delete these or move them? If I can move them--can anyone give me a pointer on how to do this for Mongo?
我在 /var/lib/mongodb/journal/prealloc 中有几个大(1GB)文件,删除或移动它们是否安全?如果我可以移动它们——谁能给我一个关于如何为 Mongo 做到这一点的指针?
回答by Gates VP
So in theory, the prealloc
files are preallocated journal files. This is opposed to in usejournal files which have the format j._X
, where X
is a digit.
所以理论上,这些prealloc
文件是预先分配的日志文件。这与正在使用的日志文件格式相反j._X
,其中X
是一个数字。
The goal here is to have "the next" file already allocated when the last file runs out of space. Pre-allocation is often much faster than on-demand allocation.
这里的目标是在最后一个文件空间不足时已经分配了“下一个”文件。预分配通常比按需分配快得多。
is it safe to delete these or move them?
删除或移动它们是否安全?
The answer you seek is in the documentation here. The docs there seem to provide the key answer to your question:
您寻求的答案在此处的文档中。那里的文档似乎为您的问题提供了关键答案:
prealloc files do not contain data, but are rather simply preallocated files that are ready to use that are truly preallocated by the file system (i.e. they are not "sparse"). It is thus safe to remove them, but if you restart mongod with journaling, it will create them again if they are missing.*
prealloc 文件不包含数据,而只是准备使用的预分配文件,这些文件真正由文件系统预分配(即它们不是“稀疏”的)。因此删除它们是安全的,但是如果您使用日志重新启动 mongod,如果它们丢失,它将再次创建它们。*
回答by Erik Ropez
Add "smallfiles=true" in the MongoDB configuration file.
在 MongoDB 配置文件中添加“smallfiles=true”。