1

I am running mongo daemon using systemctl start mongod. While it works for a couple of hours, the daemon will change to active(exited). No errors thrown, I can't find out the reason either. Anyone had any idea what went wrong?

Output when I ran systemctl status mongod:

mongod.service - SYSV: Mongo is a scalable, document-oriented database.
Loaded: loaded (/etc/rc.d/init.d/mongod; bad; vendor preset: disabled)
Active: active (exited) since Wed 2017-08-30 19:28:20 +08; 3h 58min ago
Docs: man:systemd-sysv-generator(8)
Process: 11812 ExecStop=/etc/rc.d/init.d/mongod stop (code=exited, 
status=0/SUCCESS)
Process: 11837 ExecStart=/etc/rc.d/init.d/mongod start (code=exited, status=0/SUCCESS)

Aug 30 19:28:14 example.com systemd[1]: Starting SYSV: Mongo is a scalable, document-oriented database....
Aug 30 19:28:14 example.com runuser[11844]: pam_unix(runuser:session): session opened for user mongod by (uid=0)
Aug 30 19:28:20 example.com runuser[11844]: pam_unix(runuser:session): session closed for user mongod
Aug 30 19:28:20 example.com mongod[11837]: Starting mongod: [  OK  ]
Aug 30 19:28:20 example.com systemd[1]: Started SYSV: Mongo is a 
scalable, document-oriented database..

Output when I ran journalctl -u mongod:

-- Logs begin at Wed 2017-08-30 13:39:42 +08, end at Wed 2017-08-30 23:51:34 +08. --
Aug 30 13:40:08 example.com systemd[1]: Starting SYSV: Mongo is a scalable, document-oriented database....
Aug 30 13:40:08 example.com runuser[2861]: pam_unix(runuser:session): session opened for user mongod by (uid=0)
Aug 30 13:40:11 example.com mongod[2846]: Starting mongod: [  OK  ]
Aug 30 13:40:11 example.com systemd[1]: Started SYSV: Mongo is a scalable, document-oriented database..
Aug 30 19:28:13 example.com systemd[1]: Stopping SYSV: Mongo is a scalable, document-oriented database....
Aug 30 19:28:14 example.com mongod[11812]: Stopping mongod: [  OK  ]
Aug 30 19:28:14 example.com systemd[1]: Starting SYSV: Mongo is a scalable, document-oriented database....
Aug 30 19:28:14 example.com runuser[11844]: pam_unix(runuser:session): session opened for user mongod by (uid=0)
Aug 30 19:28:20 example.com runuser[11844]: pam_unix(runuser:session): session closed for user mongod
Aug 30 19:28:20 example.com mongod[11837]: Starting mongod: [  OK  ]
Aug 30 19:28:20 example.com systemd[1]: Started SYSV: Mongo is a scalable, document-oriented database..
  • 1
    the existing logs don't show mongo stopping, so ... I think anyone that might know the answer couldn't be sure without seeing more evidence. – Jeff Schaller Aug 30 '17 at 14:42
  • 1
    Use "journalctl -u mongodb" to check for any messages related to the mongodb service – Raman Sailopal Aug 30 '17 at 14:43
  • I added the outputs, doesn't seem to throw out any errors as well – jomaint Aug 30 '17 at 14:47
  • 1
    Are you using SELinux? If you are then execute sudo ausearch -m avc -ts today | audit2allow to see if its permission related. – verisimilitude Aug 30 '17 at 14:55
  • @verisimilitude Im using redhat, did this command sudo ausearch -m avc -c mongod but no matches – jomaint Aug 31 '17 at 17:09
0

One potential source of problem is that you are using system to start the service, but instead of using a systemd unit file, you are using an old SysVinit script.

This could indicate you are using an old version of MongoDB or that your newer version of MongoDB is misconfigured.

Confirm what version of MongoDB you are using and check to see if /lib/systemd/system/mongod.service is installed on your system.

Switching to using a systemd unit file to manage the service may not solve your crash, but it will definitely simplify your configuration and perhaps make the remaining troubleshooting easier.

  • sudo stat /proc/1/exe yields: File: ‘/proc/1/exe’ -> ‘/usr/lib/systemd/systemd’ Size: 0 Blocks: 0 IO Block: 1024 symbolic link – jomaint Sep 1 '17 at 4:44
  • I'm not sure how this is a reply to my answer. The output provided already confirmed the system is running systemd. That's not in question. The question whether you are using MongoDB package that provides a systemd unit file. – Mark Stosberg Sep 1 '17 at 9:02
  • I am not too sure if mongod.service was provided by the package. But i found the mongod.service – jomaint Sep 6 '17 at 14:34
  • Your package manager should have a command to show you all the files provided by a given package, allowing you to confirm if the .service file came from the MongoDB package. – Mark Stosberg Sep 6 '17 at 18:07
  • Yes a service file is installed together with the package in this location. /usr/lib/systemd/system/mongod.service – jomaint Sep 7 '17 at 9:08

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.