wiredTiger cacheSize setting not persistent across restart

Hello ,

I am trying to set the mongo cache size via mongoshell but the setting is not persisting across restart.
root@10.60.51.101#mongo -u admin -p xxx
MongoDB shell version v4.4.13
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
MongoDB server version: 4.4.13

db.serverStatus().wiredTiger.cache[“maximum bytes configured”]/1024/1024/1024
7.2060546875
db.adminCommand( { “setParameter”: 1, “wiredTigerEngineRuntimeConfig”: “cache_size=512M”})
{ “was” : “”, “ok” : 1 }
db.serverStatus().wiredTiger.cache[“maximum bytes configured”]/1024/1024/1024
0.5
exit
bye
root@10.60.51.101#systemctl restart mongod
root@10.60.51.101#mongo -u admin -p xxx

> db.serverStatus().wiredTiger.cache["maximum bytes configured"]/1024/1024/1024
7.2060546875

BTW, I tried this setting via /etc/mongod.conf but restart is not working due to some error? I also need help with this syntax
I have this snippet:

storage:
  dbPath: /var/lib/mongodb
  journal:
    enabled: true
 wiredTiger:
       engineConfig:
           configString: cache_size=600M

I also tried several other variants (above) but no luck
thanks

1 Like

What error are you getting with the config file?
Indentation should be correct for YAML
Use space bar not tab after colon(":") while inserting values

Hi Ram,
thanks for your quick reply. There is no TAB anywhere in the config file
systemctl restart mongod
Job for mongod.service failed because the control process exited with error code. See “systemctl status mongod.service” and “journalctl -xe” for details.

This is journalctl -xe output


– The result is dependency.
Dec 30 21:24:01 xxxx.lan systemd[1]: Job idpslogs@test1.service/start failed with result ‘dependency’.
Dec 30 21:24:01 xxxx.lan systemd[1]: Unit mongod.service entered failed state.
Dec 30 21:24:01 xxxx.lan systemd[1]: mongod.service failed.
Dec 30 21:24:01 xxxx.lan polkitd[12362]: Unregistered Authentication Agent for unix-process:12331:173162 (system bus name :1.154, object path /org/fr

Do you need any thing else to help me figure out the issue?
thanks
Sriram

1 Like

The correct configuration would be:

storage:
  wiredTiger:
    engineConfig:         
      cacheSizeGB: 0.6
2 Likes

Thanks, Chris! I tried this as well (earlier) but mongo wouldnt start unless I comment out these lines
Does indenting play a role? Are there any other ways (aparf from config file) ? I tried setting in mongoshell (see below)

db.adminCommand( { “setParameter”: 1, “wiredTigerEngineRuntimeConfig”: “cache_size=512M”})
{ “was” : “”, “ok” : 1 }

but its not persistent when service restarts

Yes indenting is important, the configuration file is yaml. Also be aware that the parameter is cacheSizeGB not MB. Its possible in your config some of these sections exist, in that case nest the required options appropriately.

It can be configured on the command line, but you’d have to update the systemd unit file. Really this works in the configuration file.

Looking into the error returned and correcting that will be a better path to resolution.

1 Like