2

I installed MongoDB using sudo apt install mongo-org and followed the instruction to start and everything worked but then when I reboot the system, the MongoDB server failed

● mongodb.service - High-performance, schema-free document-oriented >database 
     Loaded: loaded (/etc/systemd/system/mongodb.service; enabled; vendor prese> 
     Active: failed (Result: exit-code) since Mon 2021-02-15 09:14:37 IST; 2min> 
    Process: 836 ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf (c> 
   Main PID: 836 (code=exited, status=48)
Feb 15 09:14:05 ubuntu systemd[1]: Started High-performance, schema-free docume>
Feb 15 09:14:37 ubuntu systemd[1]: mongodb.service: Main process exited, code=e>
Feb 15 09:14:37 ubuntu systemd[1]: mongodb.service: Failed with result 'exit-co>

I tried changing the permissions of lib/MongoDB and log/mongodb, setting the ulimit of open files to 64000, but nothing worked for me.

What I do till now to do my work is to reinstall MongoDB every time on reboot.

2
  • Hi and welcome to ask Ubuntu... there is no package called mongo-org in the standard Ubuntu repositories. What did you install there?. Also, the error messages are missing: post the output for journalctl -e | tee Feb 17, 2021 at 23:12
  • Assuming that the exit code will be the same as the status (48), then that indicates that MongoDB couldn't start because something else was using its port. Run lsof -i | grep 27017 and see if there is something else — perhaps another instance of MongoDB — appears. If so, that's the problem.
    – user1091774
    Feb 18, 2021 at 2:00

1 Answer 1

1

Okay my problem get resolved by the following steps

  1. sudo apt --purge autoremove mongo-org*
  2. sudo apt install mongodb
  3. sudo service mongodb start
  4. sudo service mongodb status

At this point it gives an error "couldn't open /etc/mongod.conf, No such file in directory"

On checking /etc I saw that it contains mongodb.conf not mongod.conf, So I edited /etc/systemd/system/mongodb.service and changed mongod.conf to mongodb.conf

After that, I did steps 3 and 4 and everything was working.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .