3

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
  • 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 '17 at 11:24
  • sorry its just happend when posted here..no mistake in actual code – Telen Stanley Mar 21 '17 at 11:47
  • have you tried removing --quiet and checking logs? Also, whats in your /etc/locale.conf? – Deeh Mar 21 '17 at 20:29
  • @Deeh : tried without --quiet , same error!! locale.conf contains LANG="en_US.UTF-8" – Telen Stanley Mar 22 '17 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 '17 at 22:30
1

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
    changed the mongod1.conf code. showing the error F CONTROL Failed global initialization: FileNotOpen Failed probe for "var/log/mongod1.log": Permission denied – Telen Stanley May 30 '17 at 6:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.