After running db.getMongo().setSlaveOk()
; still below error is coming while I am accessing collections from secondery node. As per my understanding I should able see its data from secondary node.
uncaught exception: error: { "$err" : "not master and slaveOk=false", "code" : 13435 }
I have used below command to create replica set
mkdir D:\data\repdb\One mkdir D:\data\repdb\The mkdir D:\data\repdb\Two mongod --port 27017 --dbpath D:\data\repdb\One --replSet rs0 --smallfiles --oplogSize 128 mongod --port 27018 --dbpath D:\data\repdb\The --replSet rs0 --smallfiles --oplogSize 128 mongod --port 27019 --dbpath D:\data\repdb\Two --replSet rs0 --smallfiles --oplogSize 128 mongo --port 27017 rsconf = { "_id" : "rs0", "version" : 1, "members" : [ { "_id" : 1, "host" : "localhost:27017" } ] }
rs.initiate( rsconf )
rs.conf()
rs.add("localhost:27018") rs.add("localhost:27019")