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
Telen Stanley
  • 155
  • 1
  • 2
  • 7
  • 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 05: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](http://unix.stackexchange.com/a/225407) to see what the output was. – Adam Mar 25 '17 at 22:30
  • @Adam the above showed error log is output of `journalctl -u mongod.service` – Telen Stanley Mar 27 '17 at 04:46

1 Answers1

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.

Tollef Fog Heen
  • 712
  • 3
  • 10
  • 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 06:49