I'm trying to set up my mongodb upstart script to work as an arbiter, but I'm having permission problems when trying to create the lock file in the data directory:
Tue Apr 1 17:11:01 [initandlisten] options: { config: "/etc/mongodb.conf", dbpath: "/tmp/arb", journal: "true", logappe
nd: "true", logpath: "/var/log/mongodb/mongodb-arbiter.log", port: 27017, replSet: "rs1" }
Tue Apr 1 17:11:01 [initandlisten] exception in initAndListen: 10309 Unable to create/open lock file: /tmp/arb/mongod.l
ock errno:13 Permission denied Is a mongod instance already running?, terminating
There definitely is no lock file present and there definitely is no other mongod
process running (ps -A | grep mongod
will return nothing).
Also when I try to start the mongod
process
mongod --fork --port 27017 --dbpath /data/arb --replSet rs1 --logpath /var/log/mongodb.log
this will also throw the same error when not sudo
ed.
How can I setup the right permissions for the upstart script to write data in /data/arb
?
Best Answer
You need to have the permissions on that folder (and everything under it) such that the
mongodb
user can write to it. The reason it is working withsudo
is because theroot
user has those permissions regardless of the owner/group. In fact, that may be the root cause here - when you run themongod
process with sudo it will create the files withroot:root
ownership which the normal mongodb user cannot access.The
user:group
for MongoDB on Ubuntu is usuallymongodb:mongodb
, hence just do the following:Since you are running an arbiter here I would also recommend the following options in your config file (note: not for use on a regular data bearing node - arbiter only):
These settings will minimize the footprint of the arbiter on the host.