2

Related question, didn't fix the issue: MongoDB not using /etc/mongodb.conf after I changed dbpath

On Ubuntu 12.04. $ mongod --version = db version v2.4.9

I'd like the mongo service to use /etc/mongodb.conf (I thought it was set to do that out of the box but apparently not).

$ cat /etc/mongodb.conf | grep dbpath
dbpath=/home/xyz/mongodb

$ cat /etc/mongodb.conf | grep logpath
logpath=/home/xyz/mongodb-logs

$ ll /home/xyz| grep mongo
drwxrwxr-x  2 mongodb mongodb  4096 Feb 19 11:58 mongodb/
drwxrwxr-x  2 mongodb mongodb  4096 Feb 19 11:58 mongodb-logs/

(the instructions say it should be mongod user but that doesn't exist, while mongodb does, instructions incorrect?)

But whenever I start mongod it tries to use /data/db:

ERROR: dbpath (/data/db/) does not exist.

I've looked in the init.d script and don't see any options for config path:

$ cat  /etc/init.d/mongodb | grep config
# release without the 'show-config' command (introduced in
    initctl show-config -e "$JOB"|grep -q '^  start on' || DISABLED=1

When I restart the service it appears to immediately stop:

$ sudo service mongodb restart
stop: Unknown instance: 
mongodb start/running, process 2495
$ sudo service mongodb status
mongodb stop/waiting

Is this a bug? It appears to be ignoring the config file. I know I can start it using --dbpath or --config, but shouldn't it be reading the config file if it isn't provided a dbpath? Since the service is failing to start (apparently) where can I find the error that caused it to fail?

20
  • @PeteGarafano "but shouldn't it be reading the config file if it isn't provided a dbpath?" like I said -- why is it not reading the config file? It seems weird that any tool would ignore it's one and only config file when not provided with an alternate.
    – jcollum
    Feb 19, 2014 at 21:31
  • Also, you missed this part: " If you installed from a package [I did, the PPA] and have started MongoDB using your system’s control script [I think this is the same as using the service], you’re already using a configuration file." -- except it's not using the config file.
    – jcollum
    Feb 19, 2014 at 21:32
  • 1
    Have you tried specifying the config file with --config? Feb 19, 2014 at 21:39
  • trying running mkdir -p /data/db; chown mongodb:mongodb -R /data/db and then running service mongodb start Feb 19, 2014 at 21:42
  • 1
    @Jcollum, if you want to be sure that mongodb is reading from the config file even when you start it with service mongodb start, then change the service file so that mongodb is started with --config <CONFIG> Feb 19, 2014 at 21:44

1 Answer 1

2

I had a similar problem (on v3.2) which turned out to be due to an error in my /etc/mongod.conf. I had the following:

replication:
  replSet: rs0

which should have been:

replication:
  replSetName: rs0

Starting mongod via sudo service mongod start failed silently with nothing in the logs. Fixing the config allowed mongod to start.

This was actually on RHEL, and I verified that the init script was passing --config /etc/mongod.conf. I assume it's the same on Ubuntu.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.