Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

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 case mongod). 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.

share|improve this answer
    
I'll mark it as answer, thank you. I guess this is by design? Same thing will happen when one of my secondaries loses power source? Is manual intervention needed anyway? Huh, lotta questions :) Thank you Adam. –  ivica Dec 31 '13 at 20:21
1  
Manually starting the mongod as root (or another alternate user) and incorrectly setting permissions is not by design, it's not something you are supposed to do. Generally the mongod process should be started with the service command or from the init script (depending on your distro) so that it starts as the correct user. If you know what you are doing you can start it as the correct user manually (using su etc.) but this is basically true of most Linux services, not something unique to MongoDB. –  Adam C Jan 1 at 2:14
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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