Mongodb Service Will Not Start After Initial Setup

MongoDB Service Will Not Start After Initial Setup

What worked for me on Fedora 20: we need to create the temp dir on every boot, and that's handled by systemd-tmpfiles. So, create a file /lib/tmpfiles.d/mongodb.conf and put one line in it:

d /var/run/mongodb 0755 mongod mongod

That seems to handle it on restarts; if you don't want to restart right away, you can execute that with:

sudo systemd-tmpfiles --create mongodb.conf

(See the man pages for systemd-tmpfiles)

Mongodb service won't start

After running the repair I was able to start the mongod proccessor but as root, which meant that service mongod start would not work. To repair this issue, I needed to make sure that all the files inside the database folder were owned and grouped to mongod. I did this by the following:

  1. Check the file permissions inside your database folder

    1. note you need to be in your dbpath folder mine was
      /var/lib/mongo I went to cd /var/lib
    2. I ran ls -l mongo
  2. This showed me that databases were owned by root, which is wrong. I ran the following to fix this: chown -R mongod:mongod mongo. This changed the owner and group of every file in the folder to mongod. (If using the mongodb package, chown -R mongodb:mongodb mongodb)

I hope this helps someone else in the future.

mongodb service is not starting up

Fixed!

The reason was the dbpath variable in /etc/mongodb.conf.
Previously, I was using mongodb 1.8, where the default value for dbpath was /data/db.
The upstart job mongodb(which comes with mongodb-10gen package) invokes the mongod with --config /etc/mongodb.conf option.

As a solution, I only had to change the owner of the /data/db directory recursively.

Can't start mongodb service

Check mongodb logs. In my case mongodb could not find directory from mongod.cfg

Mongodb 4 service will not start after setting auth - Error 1053

I had the same problem, but in my case what solved was replacing the tab for two spaces in the authorization: enabled line, like this:

# Configuration using TAB not working
security:
authorization: enabled

# Configuration using two spaces working
security:
authorization: enabled

MongoDB on Ubuntu won't start as a service, nothing in the log

OK, this all comes down to permissions, but let's take it step by step. When you run sudo mongod it does not load a config file at all, it literally starts with the compiled in defaults - port 27017, database path of /data/db etc. - that is why you got the error about not being able to find that folder. The "Ubuntu default" is only used when you point it at the config file (if you start using the service command, this is done for you behind the scenes).

Next you ran it like this:

sudo mongod -f /etc/mongodb.conf

If there weren't problems before, then there will be now - you have run the process, with your normal config (pointing at your usual dbpath and log) as the root user. That means that there are going to now be a number of files in that normal MongoDB folder with the user:group of root:root.

This will cause errors when you try to start it as a normal service again, because the mongodb user (which the service will attempt to run as) will not have permission to access those root:root files, and most notably, it will probably not be able to write to the log file to give you any information.

Therefore, to run it as a normal service, we need to fix those permissions. First, make sure MongoDB is not currently running as root, then:

cd /var/log/mongodb
sudo chown -R mongodb:mongodb .
cd /var/lib/mongodb
sudo chown -R mongodb:mongodb .

That should fix it up (assuming the user:group is mongodb:mongodb), though it's probably best to verify with an ls -al or similar to be sure. Once this is done you should be able to get the service to start successfully again.



Related Topics



Leave a reply



Submit