15

Ever since I changed the dbpath in /etc/mongodb.conf, MongoDB has not been starting automatically, nor using the new dbpath. Prior to the change, MongoDB would be running when the computer started and I was able to simply run the command mongo to get into the console or start my Ruby on Rails server with no issues.

After I made the modification (in order to switch to a new drive with more space), the only way I can get everything to work is by manually running the command mongod --config /etc/mongodb.conf. If I don't run that, it doesn't seem like the service is running and running without the --config option give me the following error: ERROR: dbpath (/data/db/) does not exist. even though the config file says nothing about data/db.

Some other notes:

  • In addition to changing /etc/mongodb.conf, I moved all files out of /var/lib/mongodb and into /home/nick/appdev/mongodb.
  • I changed the owner and group from root to nick. Tried changing it back, but it didn't seem to fix anything.
  • I'm running Ubuntu 12.10 Beta 1 and Mongo 2.2.0 with Ruby on Rails 3.2.8
Nick
  • 9,493
  • 8
  • 43
  • 66

4 Answers4

24

A late follow up on the above question...

I had a similar issue after moving the db to an ebs on ec2.

It turns out that just running mongod still directs the dbpath to /data/db/ (which exists).

The /etc/mongodb.conf is completely ignored unless specifically directed to.

I manage to work around this by using the directive --config or just the --dbpath(both work) But was left wondering where does mongod takes it defaults from...?!

I was unable to locate and override these defaults anywhere. Anyone ?

Note: I am really annoyed by this behaviour of mongod...This is just bad design,and bad documentation.

kman
  • 249
  • 2
  • 6
  • 4
    Since this isn't a solution to the question, it's better left as a comment to the original question rather than an answer. – Nick Nov 11 '13 at 15:26
  • 7
    I'd be happy to leave this as a comment but to comment on other users' posts "You must have 50 reputation to comment" – kman Dec 05 '13 at 06:02
  • @PeterFox What is the solution proposed here? The question already suggests that `mongod --config` works, but the goal is to get mongo to auto start on system startup and to use the correct db without additional flags. I appreciate the confirmation of the problem from kman, but this post seems to end on a question with no solution. – Nick Nov 17 '16 at 16:44
  • I am also facing the same problem. There is different setting on my mongod.conf file and when it runs the db path , port number everything is different. – Sandip Subedi Feb 01 '17 at 02:00
10

It turns out that I needed to set the owner and group to mongodb. When I transferred the files to the new directory, I had set the owner and group to my user account nick and also tried root, neither of which worked.

To do so, here are the following commands:

sudo chown mongodb /home/nick/appdev/mongodb -R
sudo chgrp mongodb /home/nick/appdev/mongodb -R

To confirm that it worked, you can check the file permissions with:

ls -l /home/nick/appdev/mongodb
Nick
  • 9,493
  • 8
  • 43
  • 66
  • 2
    Nick...thanks for your update. Sorry when I read the issue a few days ago, I missed that bit in your original description where you changed the ownership. This is because `mongod` is running under the `mongodb` user, which is configured through the .deb package on install. You could also have left the directory as owned by Nick and given mongodb write permissions through the "group" or "all" using `chmod`. – Mark Hillick Sep 26 '12 at 14:57
1

After checking all permission in the data, journal and log folders as suggested, my problem was solved by giving permission to a lock file in the /tmp folder

sudo chown mongod:mongod mongodb-27017.sock 

I was running it as a AWS Amazon Linux instance. I figured that out by executing as the mongod user as below, and then, researching the error code. It might be useful for other troubleshooting.

sudo -S -u mongod mongod -f /etc/mongod.conf
Pedro Israel
  • 119
  • 5
0

MongoDB 1.6 is very old and the latest production version is 2.2, which contains a large amount of bug fixes and enhancements since 1.6.

Am I correct that you haven't installed 1.6 via a package manager such as yum or aptitude? I don't believe there are packages for 1.6 at present afaik. Therefore, mongod is behaving correctly as you have not started MongoDB with a control script.

Please see this link on configuration file options.

Mark Hillick
  • 6,853
  • 1
  • 19
  • 23
  • Sorry, I made a mistake. I have 2.2.0 installed, but I had checked my Ruby gem on my app for the version which is 1.6. The question has been updated. I did install via aptitude. – Nick Sep 24 '12 at 17:03
  • Can you put a copy of your config file on gist/pastie/pastebin and a larger snippet of the mongodb log file? – Mark Hillick Sep 24 '12 at 18:57