Replica set authentication works a little differently from single-server authentication, so that each member can automatically authenticate itself to the other members of the set. See the main docs on authentication for details. ExampleIf we had a two-member replica set with members a and b, we could start them up with authentication enabled by running: a$ echo "this is my super secret key" > mykey a$ chmod 600 mykey a$ mongod --keyFile mykey # other options... b$ echo "this is my super secret key" > mykey b$ chmod 600 mykey b$ mongod --keyFile mykey # other options... Then run rs.initiate() and so on. Using the Database with Replica Set Authentication OnFrom the client's perspective, authentication works the same way with replica sets as it does with single servers. For example, suppose you create a new replica set and start the members with --keyFile. Connect to the master locally to add users: master$ mongo MongoDB shell version: x.y.z connecting to: test > db.addUser("foo", "bar") Clients should authenticate as usual when they make connections. any-member$ mongo -u foo -p MongoDB shell version: x.y.z Enter password: <bar> |

PLEASE POST QUESTIONS IN THE USER GROUPS FORUM. Post non-question comments and helpful hints here.
blog comments powered by Disqus