Mongodb – Set mongodb’s `maxIndexBuildMemoryUsageMegabytes` setting in conf file

mongodb

In the mongodb documentation for the configuration options it says that I can specify how much RAM index building will consume:

maxIndexBuildMemoryUsageMegabytes: Limits the amount of memory
that simultaneous foreground index builds on one collection may
consume for the duration of the builds.

This setting is set after starting the server by executing an administrative command called setParameter.
This is done like this:

mongo --eval "db.adminCommand({setParameter: 1, maxIndexBuildMemoryUsageMegabytes: 700})"

I would like to specify this amount when the server starts up by putting it in the Configuration File Options. The documentation does not seem to include this option.

How can I specify this setting from the mongod.conf file?

Best Answer

The different approaches for configuring setParameter options (via runtime admin command, config file setting, or command-line option) are listed in the Synopsis section at the top of the MongoDB Server Parameters page you referenced.

You can use setParameter key/value pairs in the YAML configuration file.

For example:

setParameter:
    maxIndexBuildMemoryUsageMegabytes: 700

To confirm this setting has taken effect via the mongo shell, use either of:

// Check the parameter values parsed from config file or command-line options
db.serverCmdLineOpts().parsed.setParameter

// Check the current setting of the maxIndexBuildMemoryUsageMegabytes parameter 
db.adminCommand({getParameter: 1, maxIndexBuildMemoryUsageMegabytes: 1})