Setting smallfiles option for controlling journali

2019-01-29 06:37发布

问题:

I am using mongodb 2.0 for my development environemnt . i am starting mongodb with the following below configuration through a config file .

replSet = ubsc
fork    = true
port    = 27017
dbpath  = /data/mongodb
logpath = /data/mongodb/mongodb.log
rest = true
smallfiles = true

My question is that even though i am setting the option of generating smallfiles for the journaling through setting (smallfiles = true ) in my config file .

I accessed the application only for 5 minutes , (5-10 minutes ) , the file inside the journal folder has grown to a huge size

[mark_user@ubsdvf.oitreo.com journal]$  ls -lrt
total 393632
-rw------- 1 s606970 s606970 134217728 Oct 21 07:41 prealloc.1
-rw------- 1 s606970 s606970 134217728 Oct 21 07:46 prealloc.2
-rw------- 1 s606970 s606970        88 Oct 21 08:42 lsn
-rw------- 1 s606970 s606970 134217728 Oct 21 08:42 j._0

Please let me know why the file has grown to a huge size ??

回答1:

Once you restart mongodb server after enabling smallfiles, it will be applied only for new databases. Any existing database will not be affected by this configuration.

Test this configuration by creating a new database.

Also, it is mentioned in the documentation that enabling this configuration will affect the performance.

The smallfiles setting can lead mongod to create many files, which may affect performance for larger databases.

So use it cautiously



回答2:

I accessed the application only for 5 minutes , (5-10 minutes ) , the file inside the journal folder has grown to a huge size

Well, the file is not that huge (not in the sense of mongodb anyway). Once you enable smallfiles, the journal files size is set to 128MB (exactly 134217728 bytes) instead of 1GB, which is the default.

So it's not as it has grown so huge. This is the default (pre-allocated) journal file, when using smallfiles option.



标签: mongodb