Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mongo "prealloc" files taking up room

Tags:

mongodb

ubuntu

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.

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?

like image 239
jbnunn Avatar asked Feb 27 '12 23:02

jbnunn


2 Answers

So in theory, the prealloc files are preallocated journal files. This is opposed to in use journal files which have the format j._X, where X is a digit.

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.*

like image 84
Gates VP Avatar answered Nov 05 '22 12:11

Gates VP


Add "smallfiles=true" in the MongoDB configuration file.

like image 40
Erik Ropez Avatar answered Nov 05 '22 11:11

Erik Ropez