[MognoDB]: How to know the configured parameters without looking at mongod.conf/startup command.

 

serverCmdLineOpts is the command line option to check the mongod server configured values without looking at mongod.conf or startup script.
This is something like standard RDBMS ‘s “SHOW GLOBAL VARIABLES;”

It returns a document that reports on the arguments and configuration options used to start the mongod or mongos instance.

This command returns a document with two fields, argv and parsed. The argv field contains an array with each item from the command string used to invoke mongod or mongos. The document in the parsed field includes all runtime options, including those parsed from the command line and those specified in the configuration file, if specified.

 

[root@ dbversity.com]# ./mongod –dbpath /data/db/ –logpath ./mongod.log –port 27017 –fork
about to fork child process, waiting until server is ready for connections.
forked process: 1298
child process started successfully, parent exiting
[root@ dbversity.com]#
[root@ dbversity.com]# ./mongo
MongoDB shell version v4.0.2
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 4.0.2
Server has startup warnings:
>
> db.serverCmdLineOpts()
{
“argv” : [
“./mongod”,
“–dbpath”,
“/data/db/”,
“–logpath”,
“./mongod.log”,
“–port”,
“27017”,
“–fork”
],
“parsed” : {
“net” : {
“port” : 27017
},
“processManagement” : {
“fork” : true
},
“storage” : {
“dbPath” : “/data/db/”
},
“systemLog” : {
“destination” : “file”,
“path” : “./mongod.log”
}
},
“ok” : 1
}
>

OR

getCmdLineOpts which is a wrapper for above command.

> db.adminCommand( { getCmdLineOpts: 1 } )
{
“argv” : [
“./mongod”,
“–dbpath”,
“/data/db/”,
“–logpath”,
“./mongod.log”,
“–port”,
“27017”,
“–fork”
],
“parsed” : {
“net” : {
“port” : 27017
},
“processManagement” : {
“fork” : true
},
“storage” : {
“dbPath” : “/data/db/”
},
“systemLog” : {
“destination” : “file”,
“path” : “./mongod.log”
}
},
“ok” : 1
}
>
>

 

  • Ask Question