MongoDB replica sets
Author
Anjani Phuyal
Date
May 26, 2014
Category
MongoDB
Read Time
2 min read
http://engineering.foursquare.com/2011/05/24/fun-with-mongodb-replica-sets/
http://docs.mongodb.org/manual/tutorial/convert-standalone-to-replica-set/
replSet = auxdb
fastsync = true
rest = trueconnecting to: auxdb-0:27017/admin
> rs.initiate() // initialize with a fresh replica set config
{
"info" : "Config now saved locally. Should come online in about a minute.",
"ok" : 1
}
auxdb:PRIMARY> rs.add("auxdb-1:27017") // add another node
{ "ok" : 1 }
auxdb:PRIMARY> rs.addArb("auxdb-arbiter:27017") // add the arbiter node
{ "ok" : 1 }MongoDB replica set preventing queries to secondary: http://stackoverflow.com/questions/17153813/mongodb-replica-set-preventing-queries-to-secondary
error:
{ "$err" : "not master and slaveOk=false", "code" : 13435 }solution:
rs.slaveOk()#MongoDB#Replica Set#Database