Open-Source Wikis

/

MongoDB

/

Reference

/

Configuration

mongodb/mongo

Configuration

mongod/mongos are configured through three layers: command-line options, server parameters, and cluster parameters. Behavior also depends on the cluster's Feature Compatibility Version (FCV) which gates feature flags.

Command-line options

The full list is in mongod --help and mongos --help. The options come from IDL files (*_option.idl) processed by the IDL compiler and registered with the option parser at startup. Commonly used:

Option Purpose
--port Listen port.
--bind_ip Bind address.
--dbpath Data directory (mongod only).
--replSet Replica set name.
--shardsvr / --configsvr Cluster role.
--tlsMode, --tlsCertificateKeyFile, --tlsCAFile TLS configuration.
--keyFile / --clusterAuthMode Internal cluster auth.
--config <yaml> Read options from a YAML config file.
--enableTestCommands Enable test-only commands (development/CI only).

YAML configuration is the production-recommended form; the YAML structure mirrors the CLI options.

Server parameters

A server parameter is a runtime tunable declared in IDL (*_server_parameter.idl files). Server parameters can be:

  • Startup-only — read once at startup; cannot change at runtime.
  • Runtime — changeable via setParameter while the process is running.
  • Cluster-wide — see "Cluster parameters" below.

Read with:

db.adminCommand({ getParameter: 1, slowOpThresholdMs: 1 });

Set with:

db.adminCommand({ setParameter: 1, slowOpThresholdMs: 200 });

The full design is in docs/server_parameters.md. Notable categories of parameters:

  • Logging: logComponentVerbosity, quiet, slowOpThresholdMs.
  • Replication: replWriterThreadCount, oplogFetcherUsesExhaust.
  • Sharding: shardingTaskExecutorPoolMaxSize, migrateCloneInsertionBatchDelayMS.
  • Storage: storageEngineConcurrencyAdjustmentAlgorithm, wiredTigerCursorCacheSize.
  • Diagnostics: diagnosticDataCollectionEnabled, traceExceptions, enableDebuggerOnShutdown.

A getParameter: 1 with featureCompatibilityVersion: 1 reports the current FCV.

Cluster parameters

A cluster parameter is a parameter that's persisted in the cluster's config (config.clusterParameters on the CSRS) and propagated to every member. Used for cluster-wide knobs that should be consistent across all mongod/mongos instances.

Read/written via the getClusterParameter/setClusterParameter admin commands. Implementation: src/mongo/db/cluster_parameters.cpp plus IDL declarations in **/*_cluster_parameter.idl.

Examples: defaultMaxTimeMS, changeStreamOptions, reportDataChunkPlacement.

Feature flags

A feature flag is an IDL-declared boolean tied to a specific binary version. Use gFeatureFlagXxx.isEnabled() (or the equivalent server parameter featureFlagXxx) to gate code:

if (gFeatureFlagFoo.isEnabled(serverGlobalParams.featureCompatibility)) {
    // use the new path
}

Feature flags become available only when the cluster's FCV is at least the flag's version. This lets the team land features on master without exposing them in releases.

Feature flags themselves are server parameters (read via getParameter: 1, featureFlagFoo: 1), so operators can confirm whether a feature is enabled in their deployment.

Where to find things

Configuration Where defined
Command-line options *_options.idl files plus src/mongo/db/mongod_options.cpp etc.
Server parameters Files matching **/*_server_parameter.idl and **/*_parameters.idl.
Cluster parameters **/*_cluster_parameter.idl.
Feature flags **/*_feature_flag*.idl.
Built-in roles src/mongo/db/auth/builtin_roles.cpp.
Default read/write concerns src/mongo/db/read_write_concern_defaults.cpp.

Logging configuration

Configured at startup via:

  • --logpath, --logappend, --syslog — destinations.
  • --logRotate — rotation policy.
  • --quiet — minimize startup logging.
  • logComponentVerbosity server parameter — per-component verbosity.

The structured-log format is described in logv2 and docs/logging.md.

Diagnostic data (FTDC)

The Full-Time Diagnostic Data Collector is on by default. It writes compressed snapshots to <dbpath>/diagnostic.data/ (controlled via diagnosticDataCollectionDirectorySizeMB, diagnosticDataCollectionFileSizeMB, etc.). See src/mongo/db/ftdc/.

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

Configuration – MongoDB wiki | Factory