i am using a simple mongodb replica set configuration. i have one primary and two secondaries. every thing was fine until i planned to add access control to the mongodb instances.(i know how to add it)
i close down all mongod instances and when i restarted them , all the nodes went into
RECOVERING state. i noticed when any (only one at a time) instance is running the state changes to
SECONDARY. now to add access controll (use access) i have to be in
PRIMARY node which cant come up because as soon as i start all the instances all go into
why is this happening? EDIT1: size of database is 700 Mb
EDIT2: i managed to bring back them to a consistent state , it was because i think before i had different settings in mongod.conf file.
now i have two
secondaries and one
primary. now i want to add use access control how should i go about it so that nodes don't go into inconsistent state again.
The solution for me was to use keyFile authentication. So instead of:
security: authorization: enabled
security: keyFile: <path-to-keyfile>
Basically I followed the instructions at:
This guarantees a few things:
With keyfile authentication, each mongod instances in the replica set uses the contents of the keyfile as the shared password for authenticating other members in the deployment. Only mongod instances with the correct keyfile can join the replica set.