4

When I try to start the mongo service(systemctl start mongodb) I get this error in journalctl:

Mar 21 15:36:18 redhat7 systemd[1]: Started High-performance, schema-free document-oriented database.
Mar 21 15:36:18 redhat7 systemd[1]: Starting High-performance, schema-free document-oriented database...
Mar 21 15:36:18 redhat7 mongod[14333]: about to fork child process, waiting until server is ready for con
Mar 21 15:36:18 redhat7 mongod[14333]: forked process: 14335
Mar 21 15:36:18 redhat7 systemd[1]: mongod.service: main process exited, code=exited, status=1/FAILURE
Mar 21 15:36:18 redhat7 systemd[1]: Unit mongod.service entered failed state.
Mar 21 15:36:18 redhat7 systemd[1]: mongod.service failed.

But running the following command as root, works!

sudo -u mongod /usr/bin/mongod -f /etc/mongod1.conf

/lib/systemd/system/mongod.service

[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target

[Service]
User=mongod
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod1.conf

[Install]
WantedBy=multi-user.target
6
  • Typo is only here or in your cfg? user in sudo example is mongod but in service unit is mongodb with b at the end
    – Quantim
    Mar 21, 2017 at 11:24
  • sorry its just happend when posted here..no mistake in actual code Mar 21, 2017 at 11:47
  • have you tried removing --quiet and checking logs? Also, whats in your /etc/locale.conf?
    – Deeh
    Mar 21, 2017 at 20:29
  • @Deeh : tried without --quiet , same error!! locale.conf contains LANG="en_US.UTF-8" Mar 22, 2017 at 5:02
  • 1
    If you remove --quiet you won't see anything different in the console. You should check the systemctl logs for the service using journalctl to see what the output was.
    – Adam
    Mar 25, 2017 at 22:30

1 Answer 1

2

The default for systemd is that a service is simple. This means that it runs in foreground and if it exits, the service is considered stopped.

Your mongod configuration file has something like:

processManagement: fork: true

in it, which causes mongod to fork to the background. There are two ways to fix this, the best is to change fork in /etc/mongod1.conf to false. The other is to set Type=forking in the [Service] section of the .service file.

1
  • 1
    changed the mongod1.conf code. showing the error F CONTROL Failed global initialization: FileNotOpen Failed probe for "var/log/mongod1.log": Permission denied May 30, 2017 at 6:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .