I'm having some trouble with intentionally removing a secondary from a replica set. I'm trying to simulate unexpected shutdown.
My replica set consists of one primary and 2 secondaries. When I shut down the mongo instance on one of the secondaries and try to restart the service it fails with the message from the log which states:
Tue Dec 24 12:20:08.882 [initandlisten] couldn't open /var/lib/mongo/maars.ns errno:13 Permission denied
Simple chown -R mongod /var/lib/mongo
solves the problem, but this shouldn't happend. Am I doing something wrong?
Ask for more info if you need something.
Best Answer
Usually the cause for this is that you are restart the
mongod
process as the root user (using sudo, or perhaps invoking directly as root) or some other user besides the appropriate MongoDB user (in your casemongod
). That is then screwing up the permissions in your data folder and giving you the error you are seeing.If you examine how you are starting/stopping the process and correct it to only start with the correct user (or use the service commands instead) then this problem should stop happening.