设置smallfiles选项以控制日记功能不会控制大小

时间:2013-10-21 13:15:37

标签: mongodb

我正在使用mongodb 2.0进行我的开发environemnt。 我通过配置文件使用以下配置启动mongodb。

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

我的问题是,即使我在配置文件中通过设置(smallfiles = true)设置为日记生成小文件的选项。

我只访问了应用程序5分钟,(5-10分钟),日记文件夹中的文件已经变得很大了

[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

请让我知道为什么文件已经变大了?

2 个答案:

答案 0 :(得分:2)

启用smallfiles后重启mongodb服务器后,它将仅应用于新数据库。此配置不会影响任何现有数据库。

通过创建新数据库来测试此配置。

此外,文档中提到启用此配置会影响性能。

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

所以要谨慎使用

答案 1 :(得分:1)

  

我只访问了应用程序5分钟,(5-10分钟),日记文件夹中的文件已经变得很大了

嗯,文件不是那么大(不管是mongodb的意思)。启用smallfiles后,日志文件大小设置为128MB(正好为134217728字节),而不是1GB,这是默认值。

所以它不是因为它已经变得如此巨大。这是使用smallfiles选项时的默认(预分配)日志文件。

相关问题