Mongodb doesn't start using systemctl

16,915

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.

Share:
16,915

Related videos on Youtube

Telen Stanley
Author by

Telen Stanley

satisfaction is exploring something new in codeworld and makes it works!!! cheers:)

Updated on September 18, 2022

Comments

  • Telen Stanley
    Telen Stanley almost 2 years

    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
    
    • Admin
      Admin over 7 years
      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
    • Admin
      Admin over 7 years
      sorry its just happend when posted here..no mistake in actual code
    • Admin
      Admin over 7 years
      have you tried removing --quiet and checking logs? Also, whats in your /etc/locale.conf?
    • Admin
      Admin over 7 years
      @Deeh : tried without --quiet , same error!! locale.conf contains LANG="en_US.UTF-8"
    • Admin
      Admin over 7 years
      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.
    • Admin
      Admin over 7 years
      @Adam the above showed error log is output of journalctl -u mongod.service
  • Telen Stanley
    Telen Stanley about 7 years
    changed the mongod1.conf code. showing the error F CONTROL Failed global initialization: FileNotOpen Failed probe for "var/log/mongod1.log": Permission denied