M BUZZ CRAZE NEWS
// general

MongoDB loads but breaks, returning status=14

By Emma Johnson

So im trying to setup Mongodb on Ubuntu 16.04 but im running into trouble.

when running :

sudo systemctl status mongodb

I get the following:

 mongodb.service - High-performance, schema-free document-oriented database Loaded: loaded (/etc/systemd/system/mongodb.service; disabled; vendor preset: enabled) Active: failed (Result: exit-code) since Sat 2016-09-10 14:02:22 CEST; 14s ago Docs: Process: 8724 ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf (code=exited, status=14) Main PID: 8724 (code=exited, status=14)

According to the mongo-docs, status=14 is:

"Returned by MongoDB applications which encounter an unrecoverable error, an uncaught exception or uncaught signal. The system exits without performing a clean shut down."

I doesnt really point me in any particular direction.

My /etc/systemd/system/mongodb.service looks like this:

[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target
[Service]
User=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf
[Install]
WantedBy=multi-user.target

Any thought on what may be the cause of this?

Thank you

2

10 Answers

After googling around for a while. I found that that is because the permission settings on/var/lib/mongodb and /tmp/mongodb-27017.lock are wrong. You will have to change the owner to monogdb user

sudo chown -R mongodb:mongodb /var/lib/mongodb
sudo chown mongodb:mongodb /tmp/mongodb-27017.sock

then

sudo service mongod restart
11

By using this my error was gone:

  1. Go to the TMP directory: cd /tmp
  2. Check if you have the mongodb sock file: ls *.sock
  3. Change the user:group permission: chown mongodb:mongodb <YOUR_SOCK>
  4. Start MongoDB: sudo service mongod start
  5. Check the MongoDB status: sudo service mongod status
2

deleting the mongod sock file solved the issue for me sudo rm -rf /tmp/mongodb-27017.sockthen start again sudo systemctl start mongod

  1. Check for both mentioned directories If they don't exist, use the following commands:
sudo mkdir /var/lib/mongodb
sudo mkdir /var/log/mongodb
sudo chown -R mongodb:mongodb /var/lib/mongodb
sudo chown -R mongodb:mongodb /var/log/mongodb
  1. Clear the socket with the following command:
chown mongodb:mongodb /tmp/mongodb-27017.sock
  1. Restart and check the status of the service:
sudo service mongod restart
1

i tried this and it worked :

sudo nano /etc/mongod.conf

comment the "bind ip" line.

sudo mongod --auth --port 27017 --dbpath /data/db

then i ran

sudo service mongod restart

for beginners only if you are trying the following and getting errors :

 sudo chown -R mongodb:mongodb /var/lib/mongodb sudo chown mongodb:mongodb /tmp/mongodb-27017.sock sudo service mongod restart

then try checking the status

 sudo systemctl status mongod

it will show active ..

I also got status 14 at some point, but it was not because of my .lock files.

Looks like everything in your dbPath (in my case /data/mongodb) should belong to mongodb. In my case, two files and files in the journal folder were owned by root, possibly because I have run the mongod command with sudo instead of the mongodb user (as configured in mongod.service).

sudo chown mongodb:mongodb /data/mongodb/ -R

In order to find my problem, it helped to set the verbosity to 5 in /etc/mongod.conf:

systemLog: verbosity: 5

and run tail /var/log/mongodb/mongodb.log -n 100 after sudo systemctl start mongod

For this to work, mongod.conf needs to be loaded by mongod. mongod.service does that with the --config parameter.

Make sure to remove the high verbosity when your mongodb works again, because that logfile can grow very large.

My /var/lib/mongodb was corrupt, rming it and reinstalling mongo worked.

This error occurred for me just because the disk space was full. And solved after deleting some unused files.

In my case, it was because of an incomplete repair operation, in which case I had to run mongod --repair --dbpath /var/lib/mongodb.