MongoDB Behaves Differently With Service File(?)


When I try to run the mongod.service via service mongod start MongoDB tells me that it can’t find database files on /data/db weird thing is in my configuration file dbPath is specifically specified as /var/lib/mongodb. mongod service configuration under /lib/systemd/system/mongod.service uses /etc/mongod.conf and that config file specifies /var/lib/mongodb/ like I described above.

Here comes the even weirder part;

When I try to run the mongodb via service it fails but when I try to run it via shell like mongod --config /etc/mongod.conf it runs without a problem.

Any idea?

You might be confusing your init daemons. Systemd uses /lib/systemd/system/mongod.service. But service mongod start is the command for SYS V init. The docs detail both approaches.