Unable to find mongod.conf file,after installation via source code or bin

Hello,

I have installed MongoDB server on centos 7 via bin, but not able to find mongod.conf file.
While I am starting mongod, it will take default db path i.e. /data/db/.
Even I am adding mongod.conf file in /etc/mongod.conf, it won’t start with this conf file, I have tried with --config options too but bad luck.
While I am executing the command to find the argument, it is throwing an error:

db.adminCommand( { getCmdLineOpts: 1 } )
{ “argv” : [ “mongod” ], “parsed” : { }, “ok” : 1 }

Please find log below:
[root@krishna ~]# ps -eaf|grep -i mongod
root 17615 17565 0 01:44 pts/0 00:00:00 grep --color=auto -i mongod
[root@krishna ~]#
[root@krishna ~]# sudo service mongod status
Redirecting to /bin/systemctl status mongod.service
● mongod.service - MongoDB Database Server
Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Wed 2019-08-28 01:30:12 IST; 14min ago
Docs: https://docs.mongodb.org/manual
Process: 1212 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=2)
Process: 1207 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS)
Process: 1194 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS)
Process: 1179 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS)

Aug 28 01:29:48 krishna systemd[1]: Starting MongoDB Database Server…
Aug 28 01:30:12 krishna mongod[1212]: Unrecognized option: authorization
Aug 28 01:30:12 krishna mongod[1212]: try ‘/usr/bin/mongod --help’ for more information
Aug 28 01:30:12 krishna systemd[1]: mongod.service: control process exited, code=exited status=2
Aug 28 01:30:12 krishna systemd[1]: Failed to start MongoDB Database Server.
Aug 28 01:30:12 krishna systemd[1]: Unit mongod.service entered failed state.
Aug 28 01:30:12 krishna systemd[1]: mongod.service failed.
[root@krishna ~]# sudo service mongod start
Redirecting to /bin/systemctl start mongod.service
Job for mongod.service failed because the control process exited with error code. See “systemctl status mongod.service” and “journalctl - xe” for details.

Whereas just typing mongod it will successfully launch:
[root@krishna ~]# mongod
2019-08-28T01:45:24.248+0530 I STORAGE [main] Max cache overflow file size custom option: 0
2019-08-28T01:45:24.392+0530 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols ‘n one’
2019-08-28T01:45:24.568+0530 I CONTROL [initandlisten] MongoDB starting : pid=17672 port=27017 dbpath=/data/db 64-bit host=krishna
2019-08-28T01:45:24.568+0530 I CONTROL [initandlisten] db version v4.0.12
2019-08-28T01:45:24.568+0530 I CONTROL [initandlisten] git version: 5776e3cbf9e7afe86e6b29e22520ffb6766e95d4
2019-08-28T01:45:24.568+0530 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
2019-08-28T01:45:24.568+0530 I CONTROL [initandlisten] allocator: tcmalloc
2019-08-28T01:45:24.568+0530 I CONTROL [initandlisten] modules: none
2019-08-28T01:45:24.568+0530 I CONTROL [initandlisten] build environment:
2019-08-28T01:45:24.569+0530 I CONTROL [initandlisten] distmod: rhel70
2019-08-28T01:45:24.569+0530 I CONTROL [initandlisten] distarch: x86_64
2019-08-28T01:45:24.569+0530 I CONTROL [initandlisten] target_arch: x86_64
2019-08-28T01:45:24.569+0530 I CONTROL [initandlisten] options: {}
2019-08-28T01:45:24.688+0530 I STORAGE [initandlisten] Detected data files in /data/db created by the ‘wiredTiger’ storage engine, so se tting the active storage engine to ‘wiredTiger’.
2019-08-28T01:45:24.689+0530 I STORAGE [initandlisten]
2019-08-28T01:45:24.689+0530 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2019-08-28T01:45:24.689+0530 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
2019-08-28T01:45:24.753+0530 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1062M,cache_overflow=(file_max=0M),sess ion_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,comp ressor=snappy),file_manager=(close_idle_time=100000),statistics_log=(wait=0),verbose=(recovery_progress),
2019-08-28T01:45:34.232+0530 I STORAGE [initandlisten] WiredTiger message [1566936934:232359][17672:0x7fbc5a6e6b80], txn-recover: Main r ecovery loop: starting at 16/27648 to 17/256
2019-08-28T01:45:34.953+0530 I STORAGE [initandlisten] WiredTiger message [1566936934:953372][17672:0x7fbc5a6e6b80], txn-recover: Recove ring log 16 through 17
2019-08-28T01:45:35.551+0530 I STORAGE [initandlisten] WiredTiger message [1566936935:551942][17672:0x7fbc5a6e6b80], txn-recover: Recove ring log 17 through 17
2019-08-28T01:45:35.916+0530 I STORAGE [initandlisten] WiredTiger message [1566936935:916061][17672:0x7fbc5a6e6b80], txn-recover: Set gl obal recovery timestamp: 0
2019-08-28T01:45:36.073+0530 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2019-08-28T01:45:36.599+0530 I CONTROL [initandlisten]
2019-08-28T01:45:36.599+0530 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2019-08-28T01:45:36.599+0530 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2019-08-28T01:45:36.600+0530 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommend ed.
2019-08-28T01:45:36.600+0530 I CONTROL [initandlisten]
2019-08-28T01:45:36.600+0530 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost.
2019-08-28T01:45:36.600+0530 I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server.
2019-08-28T01:45:36.600+0530 I CONTROL [initandlisten] ** Start the server with --bind_ip to specify which IP
2019-08-28T01:45:36.600+0530 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to
2019-08-28T01:45:36.601+0530 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the
2019-08-28T01:45:36.601+0530 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning.
2019-08-28T01:45:36.601+0530 I CONTROL [initandlisten]
2019-08-28T01:45:36.610+0530 I CONTROL [initandlisten]
2019-08-28T01:45:36.610+0530 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is ‘always’.
2019-08-28T01:45:36.610+0530 I CONTROL [initandlisten] ** We suggest setting it to ‘never’
2019-08-28T01:45:36.611+0530 I CONTROL [initandlisten]
2019-08-28T01:45:36.611+0530 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is ‘always’.
2019-08-28T01:45:36.611+0530 I CONTROL [initandlisten] ** We suggest setting it to ‘never’
2019-08-28T01:45:36.611+0530 I CONTROL [initandlisten]
2019-08-28T01:45:37.565+0530 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory ‘/data/db/diagnosti c.data’
2019-08-28T01:45:37.590+0530 I NETWORK [initandlisten] waiting for connections on port 27017
2019-08-28T01:45:56.431+0530 I NETWORK [listener] connection accepted from 127.0.0.1:53462 #1 (1 connection now open)
2019-08-28T01:45:56.440+0530 I NETWORK [conn1] received client metadata from 127.0.0.1:53462 conn1: { application: { name: “MongoDB Shell” }, driver: { name: “MongoDB Internal Client”, version: “4.0.12” }, os: { type: “Linux”, name: "CentOS Linux release 7.6.1810 (Core) ", architecture: “x86_64”, version: “Kernel 3.10.0-957.27.2.el7.x86_64” } }

Please help me to understand.

Thanks
Krishna

Hi @kmk050193,

By default, mongod does not load any particular configuration file (and simply uses the built-in defaults for all options).

db.adminCommand( { getCmdLineOpts: 1 } )

The output that you have shared after running this command is not an errror. The argv field contains an array with each item from the command string used to invoke the mongod. In your case you are running with all the default options by invoking the mongod process in your command line. The parsed field is empty because you are not running your mongod instance with any extra runtime instance.

For instance if I run a mongod instance on the port 27015.

mongod --port 27015

And then if I run this command from the mongo shell then the output will look like this.

db.adminCommand( { getCmdLineOpts: 1  } )

24%20PM

When you run the mongod command in your shell, it starts with the compiled in defaults such as port 27017 and database path of /data/db. In this case the wiredTiger storage engine creates the directories for you.

Can you please share these information :

  • Command that you are using to run the configuration file
  • Content of the configuration file
  • Screenshots of the output

Thanks,
Shubham Ranjan
Curriculum Support Engineer

1 Like

Hello,

Thank you for the response.Please find details below as requested:

  1. mongod --config /etc/mongod.conf

  2. [root@krishna etc]# cat mongod.conf
    # mongod.conf

for documentation of all options, see:

http://docs.mongodb.org/manual/reference/configuration-options/

where to write logging data.

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

Where and how to store data.

storage:
dbPath: /var/lib/mongo
journal:
enabled: true

engine:

mmapv1:

wiredTiger:

how the process runs

processManagement:
fork: true # fork and run in background
pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile
timeZoneInfo: /usr/share/zoneinfo

network interfaces

net:
port: 27017
bindIp: 0.0.0.0 # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.

#security:
authorization: enabled

#operationProfiling:

#replication:

#sharding:

Enterprise-Only Options

#auditLog:

#snmp:
[root@krishna etc]#
[root@krishna etc]# service mongod status
Redirecting to /bin/systemctl status mongod.service
● mongod.service - MongoDB Database Server
Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Wed 2019-08-28 21:48:44 IST; 8min ago
Docs: https://docs.mongodb.org/manual
Process: 9958 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=2)
Process: 9956 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS)
Process: 9953 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS)
Process: 9949 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS)

Aug 28 21:48:44 krishna systemd[1]: Starting MongoDB Database Server…
Aug 28 21:48:44 krishna mongod[9958]: Unrecognized option: authorization
Aug 28 21:48:44 krishna systemd[1]: mongod.service: control process exited, code=exited status=2
Aug 28 21:48:44 krishna systemd[1]: Failed to start MongoDB Database Server.
Aug 28 21:48:44 krishna systemd[1]: Unit mongod.service entered failed state.
Aug 28 21:48:44 krishna systemd[1]: mongod.service failed.
[root@krishna etc]#
[root@krishna etc]# service mongod start
Redirecting to /bin/systemctl start mongod.service
Job for mongod.service failed because the control process exited with error code. See “systemctl status mongod.service” and “journalctl -xe” for details.
[root@krishna etc]#
[root@krishna etc]# systemctl status mongod.service
● mongod.service - MongoDB Database Server
Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Wed 2019-08-28 21:57:50 IST; 11s ago
Docs: https://docs.mongodb.org/manual
Process: 10588 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=2)
Process: 10585 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS)
Process: 10581 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS)
Process: 10579 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS)

Aug 28 21:57:49 krishna systemd[1]: Starting MongoDB Database Server…
Aug 28 21:57:50 krishna mongod[10588]: Unrecognized option: authorization
Aug 28 21:57:50 krishna systemd[1]: mongod.service: control process exited, code=exited status=2
Aug 28 21:57:50 krishna systemd[1]: Failed to start MongoDB Database Server.
Aug 28 21:57:50 krishna systemd[1]: Unit mongod.service entered failed state.
Aug 28 21:57:50 krishna systemd[1]: mongod.service failed.
[root@krishna etc]# service mongod restart
Redirecting to /bin/systemctl restart mongod.service
Job for mongod.service failed because the control process exited with error code. See “systemctl status mongod.service” and “journalctl -xe” for details.
[root@krishna etc]#

Thanks
Krishna

Hi @kmk050193,

Given the information that you have provided, I do not have the debugging information to address your issue. There are a number of things that could be causing your issues, including directory issues, permission issues, or syntax errors in the configuration file. I’m sorry we’re unable to help you in addressing your current issue.

For more information on configuration file options please refer our documentation.

Thanks,
Shubham Ranjan
Curriculum Support Engineer