Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure storage.smallFiles on mongodb

Tags:

I have a CentOS machine where I installed mongodb and I want it to always use storage.smallFiles setting, so I went to /etc and I created a new file /etc/mongodb.conf where I added the following text and I saved:

storage:
   smallFiles:
      enabled: true

then I typed:

$ mongod --config /etc/mongodb.conf
Unrecognized option: storage.smallFiles.enabled
try 'mongod --help' for more information

I followed documentation on http://docs.mongodb.org/manual/reference/configuration-options/#storage.smallFiles

like image 870
user3665192 Avatar asked Jun 26 '14 09:06

user3665192


People also ask

What is configuration file in MongoDB?

The MongoDB configuration file contains settings that are equivalent to the command-line options mongod and mongos. Using a MongoDB configuration file simplifies the management of mongod and mongos options, especially in large-scale deployments.

Which is the easy way to find the storage engine currently used in MongoDB?

Easiest way to find the storage engine being used currently in from mongo console. WireTiger Storage engine is being used. to get all the configuration details of wiredTiger.


2 Answers

The configuration for storage option smallFiles is different for different versions of MongoDB. Note that MMAPv1 storage engine is deprecated in MongoDG v4.0 and removed in MongoDB v4.2 - docs.

MongoDB 3.0–4.0 - docs:

storage:
  mmapv1:
    smallFiles: true

MongoDB 2.6 - docs:

storage:
   smallFiles: true

MongoDB 2.4 - docs:

smallfiles = true

You can check that your setting is properly set by calling this command against admin database:

db.runCommand({getCmdLineOpts:1});

You can also specify it directly when starting mongod:

mongod --config /etc/mongodb.conf --smallFiles
like image 109
Christian P Avatar answered Sep 19 '22 03:09

Christian P


If you're a developer, don't have time and is using a VM getting out of space... Just copy, paste and go!

sudo bash -c "echo \"smallfiles=true\" >> /etc/mongodb.conf"
sudo service mongodb restart
like image 31
Italo Borssatto Avatar answered Sep 19 '22 03:09

Italo Borssatto