Reputation: 46579
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?
Upvotes: 2
Views: 8401
Reputation: 1503
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.
Upvotes: 2