Databases 12 min read

MongoDB Config Guide: System Log, Network, Security, and Storage Settings

This article provides a comprehensive walkthrough of MongoDB's configuration file, detailing system log options, process management, network parameters, security settings, storage engine configurations, slow query profiling, replication, sharding, and mongos parameters, along with explanations of each option and recommended defaults.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
MongoDB Config Guide: System Log, Network, Security, and Storage Settings

MongoDB Configuration File Explained

System Log Configuration

systemLog:
  verbosity: <int>
  quiet: <boolean>
  traceAllExceptions: <boolean>
  syslogFacility: <string>
  path: <string>
  logAppend: <boolean>
  logRotate: <string>
  destination: <string>
  timeStampFormat: <string>
  component:
    accessControl:
      verbosity: <int>
    command:
      verbosity: <int>

verbosity: Log level, default 0, range 1‑5.

quiet: Suppresses log output; not recommended for production because it can hide troubleshooting information.

traceAllExceptions: Prints detailed information for debugging.

syslogFacility: Syslog facility (default "user"); requires the --syslog option.

path: File system path where logs are stored.

logAppend: When true, logs are appended to the existing file after a restart; default false creates a new file each start.

logRotate: Log rotation method, default "rename". Can be set to "reopen" which follows Linux log rotation; "reopen" must be used with logAppend=true.

destination: Where logs are sent – either a file or syslog.

timeStampFormat: Timestamp format, default "iso8601-local". Options: "iso8601-utc", "ctime".

Process Management

processManagement:
  fork: <boolean>
  pidFilePath: <string>

fork: Run MongoDB as a daemon.

pidFilePath: Location of the PID file.

Network Options

net:
  port: <int>
  bindIp: <string>
  maxIncomingConnections: <int>
  wireObjectCheck: <boolean>
  ipv6: <boolean>
  unixDomainSocket:
    enabled: <boolean>
    pathPrefix: <string>
    filePermissions: <int>
  http:
    enabled: <boolean>
    JSONPEnabled: <boolean>
    RESTInterfaceEnabled: <boolean>
  ssl:
    sslOnNormalPorts: <boolean>
    mode: <string>
    PEMKeyFile: <string>
    PEMKeyPassword: <string>
    clusterFile: <string>
    clusterPassword: <string>
    CAFile: <string>
    CRLFile: <string>
    allowConnectionsWithoutCertificates: <boolean>
    allowInvalidCertificates: <boolean>
    allowInvalidHostnames: <boolean>
    disabledProtocols: <string>
    FIPSMode: <boolean>
  compression:
    compressors: <string>

net.port: Listening port.

net.bindIp: IP address to bind.

net.maxIncomingConnections: Maximum number of simultaneous connections (default 65535).

net.wireObjectCheck: Validates incoming BSON data; default true.

net.ipv6: Enables IPv6; default false.

net.unixDomainSocket.enabled: Enables Unix domain socket; default true.

net.unixDomainSocket.pathPrefix: Directory for socket files (default /tmp).

net.unixDomainSocket.filePermissions: Permissions for socket files (default 0700).

net.http.enabled: HTTP interface; default false and deprecated since version 3.2.

net.http.JSONPEnabled / net.http.RESTInterfaceEnabled: Control JSONP and simple REST API; both deprecated.

net.ssl: SSL/TLS configuration options.

net.compression.compressors: Enables network compression.

Security Settings

security:
  keyFile: <string>
  clusterAuthMode: <string>
  authorization: <string>
  transitionToAuth: <boolean>
  javascriptEnabled: <boolean>
  redactClientLogData: <boolean>
  sasl:
    hostName: <string>
    serviceName: <string>
    saslauthdSocketPath: <string>
  enableEncryption: <boolean>
  encryptionCipherMode: <string>
  encryptionKeyFile: <string>
  kmip:
    keyIdentifier: <string>
    rotateMasterKey: <boolean>
    serverName: <string>
    port: <string>
    clientCertificateFile: <string>
    clientCertificatePassword: <string>
    serverCAFile: <string>
  ldap:
    servers: <string>
    bind:
      method: <string>
      saslMechanism: <string>
      queryUser: <string>
      queryPassword: <string>
      useOSDefaults: <boolean>
    transportSecurity: <string>
    timeoutMS: <int>
    userToDNMapping: <string>
    authz:
      queryTemplate: <string>

security.authorization: Default "disabled"; enables role‑based access control when set to "enabled".

Custom Parameters

setParameter:
  <parameter1>: <value1>
  <parameter2>: <value2>

setParameter: Allows setting arbitrary MongoDB parameters.

Storage Engine Configuration

storage:
  dbPath: <string>
  indexBuildRetry: <boolean>
  repairPath: <string>
  journal:
    enabled: <boolean>
    commitIntervalMs: <num>
  directoryPerDB: <boolean>
  syncPeriodSecs: <int>
  engine: <string>
  mmapv1:
    preallocDataFiles: <boolean>
    nsSize: <int>
    quota:
      enforced: <boolean>
      maxFilesPerDB: <int>
    smallFiles: <boolean>
    journal:
      debugFlags: <int>
      commitIntervalMs: <num>
  wiredTiger:
    engineConfig:
      cacheSizeGB: <number>
      journalCompressor: <string>
      directoryForIndexes: <boolean>
    collectionConfig:
      blockCompressor: <string>
    indexConfig:
      prefixCompression: <boolean>
  inMemory:
    engineConfig:
      inMemorySizeGB: <number>

storage.dbPath: Directory for data files.

storage.indexBuildRetry: If true (default), MongoDB attempts to rebuild incomplete indexes on startup.

storage.repairPath: Temporary directory for --repair files; removed after use.

storage.journal.enabled: Enables journaling; default true on 64‑bit systems.

storage.journal.commitIntervalMs: Maximum time between journal commits (default 100 ms, older default 30 ms).

storage.directoryPerDB: When true, each database gets its own subdirectory under dbPath.

storage.syncPeriodSecs: Interval for syncing data to disk (default 60 s; 0 disables syncing).

storage.engine: Storage engine, default "wiredTiger".

storage.mmapv1.preallocDataFiles: Pre‑allocates data files; default true.

storage.mmapv1.nsSize: Default 16 MB per namespace file.

storage.mmapv1.quota.enforced: Enforces a limit on the number of data files per database.

storage.mmapv1.quota.maxFilesPerDB: Maximum data files per database (default 8).

storage.mmapv1.smallFiles: Uses smaller default file sizes; default false.

storage.mmapv1.journal.debugFlags: Debug feature, not recommended for production.

storage.wiredTiger.engineConfig.cacheSizeGB: Maximum internal cache size (up to half of RAM minus 1 GB, max 256 GB).

storage.wiredTiger.engineConfig.journalCompressor: Compression for journal data (none, snappy, zlib).

storage.wiredTiger.engineConfig.directoryForIndexes: When true, creates an "index" subdirectory for indexes.

storage.wiredTiger.collectionConfig.blockCompressor: Data compression format (none, snappy, zlib).

storage.wiredTiger.indexConfig.prefixCompression: Enables prefix compression for index data; default true.

storage.inMemory.engineConfig.inMemorySizeGB: Maximum memory allocated for the in‑memory engine (default half of RAM minus 1 GB).

Slow Query Profiling

operationProfiling:
  slowOpThresholdMs: <int>
  mode: <string>

operationProfiling.slowOpThresholdMs: Threshold in milliseconds for logging slow operations (default 100 ms).

operationProfiling.mode: Profiling level – "off" (disabled), "slowOp" (only slow ops), or "all" (all operations).

Replication Options

replication:
  oplogSizeMB: <int>
  replSetName: <string>
  secondaryIndexPrefetch: <string>
  enableMajorityReadConcern: <boolean>

replication.oplogSizeMB: Maximum size of the oplog; typically 5 % of disk space.

replication.replSetName: Name of the replica set.

replication.secondaryIndexPrefetch: For mmapv1 engine; default "all". Loads all indexes into memory before applying oplog entries.

replication.enableMajorityReadConcern: Enables majority read concern; default false.

Sharding Configuration

sharding:
  clusterRole: <string>
  archiveMovedChunks: <boolean>

sharding.clusterRole: Defines the node role – "configsvr" for config servers or "shardsvr" for shard servers.

sharding.archiveMovedChunks: When false (default), documents moved out of a shard are not archived.

Mongos Parameters

replication:
  localPingThresholdMs: <int>

sharding:
  configDB: <string>

replication.localPingThresholdMs: Default 15 ms; mongos uses this to forward client requests to the secondary with the lowest latency.

sharding.configDB: List of config server addresses.

MongoDB supports three storage engines: mmapv1, WiredTiger, and inMemory.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

databaseConfigurationReplicationSecurityMongoDB
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.