From charlesreid1

MongoDB Configuration

MongoDB documentation on configuration: https://docs.mongodb.com/manual/reference/configuration-options/

By default, MongoDB will not require a config file, and if you don't specify one, it makes some weird decisions.

To start mongodb with a specified config file, use the --config or -f options:

mongod --config /etc/mongod.conf
mongod -f /etc/mongod.conf

Core mongodb config sections:

  • systemLog
  • net

systemLog

# default:

systemLog:
  destination: file
  path: /var/log/mongodb/mongod.log
  logAppend: true

can also set verbosity (0-5):

systemLog:
    destination: file
    path: /var/log/mongodb/mongod.log
    verbosity: 2
    logRotate: rename

If using logrotate util, set logRotate: reopen

Can further customize log behavior for specific components (access, commands, etc.)

net

net:
    port: 27017
    bindIp: 10.0.0.1
    ipv6: True

There are also several options for SSL. Those go into an ssl subsection of the net section of the config file.