I have installed MongoDB on a Ubuntu server like is indicated in the docs http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/. Then, I have modified the configuration file /etc/mongod.conf
for, later, run a mongod service.
MongoDB runs correctly if I execute:
sudo mongod -f /etc/mongod.conf
But MongoDB stops if I execute:
sudo service mongod start
In the config file /etc/mongod.conf
I changed only this:
dbpath=/data/db
logpath=/root/logs/mongod.log
port=20000
With this configuration, the log file is not created too.
If I don't modify the previous values indicated, the service starts correctly. The default values are:
dbpath=/var/lib/mongodb
logpath=/var/log/mongodb/mongod.log
port = 27017
Because the log file is not created with the custom configuration, I have only changed the dbpath for see the error:
[initandlisten] exception in initAndListen: 10309 Unable to create/open lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?
I tried to run the following commands but without success:
sudo chown -R `id -u` /data/db
sudo rm /var/lib/mongodb/mongod.lock
mongod --repair
Stack:
- Ubuntu 14.10
- MongoDB 2.6.5
We must make all the directories/files owned by mongod user. For this: