How to check the current configuration of MongoDB?

To check the current configuration of MongoDB, you can use administrative commands to retrieve both command line options and runtime parameters. These commands help troubleshoot configuration issues and verify current settings.

Syntax

// Get command line options
db._adminCommand({getCmdLineOpts: 1});

// Get all runtime parameters
db._adminCommand({getParameter: "*"});

Method 1: Check Command Line Options

Use getCmdLineOpts to see the options MongoDB was started with ?

db._adminCommand({getCmdLineOpts: 1});
{
    "argv": ["mongod"],
    "parsed": {},
    "ok": 1
}

Method 2: Check Runtime Parameters

Use getParameter with "*" to retrieve all current runtime settings ?

db._adminCommand({getParameter: "*"});
{
    "AsyncRequestsSenderUseBaton": true,
    "KeysRotationIntervalSec": 7776000,
    "ShardingTaskExecutorPoolMaxSize": -1,
    "authenticationMechanisms": [
        "MONGODB-X509",
        "SCRAM-SHA-1",
        "SCRAM-SHA-256"
    ],
    "featureCompatibilityVersion": {
        "version": "4.0"
    },
    "logLevel": 0,
    "maxSessions": 1000000,
    "sslMode": "disabled",
    "ok": 1
}

Key Points

  • getCmdLineOpts shows startup arguments and configuration file settings
  • getParameter: "*" displays all current runtime parameters and their values
  • Both commands require administrative privileges to execute
  • Use specific parameter names instead of "*" to query individual settings

Conclusion

MongoDB provides getCmdLineOpts and getParameter commands to inspect current configuration. These administrative commands are essential for monitoring and troubleshooting MongoDB instances.

Updated on: 2026-03-15T00:21:49+05:30

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements