In a replica set, you are connected to one of the secondary nodes with mongo shell. If you run command like show dbs there will be an error: "errmsg" : "not master and slaveOk=false". You can run read commands only after telling MongoDB so. The command to enable read operations on replica set’s secondary node is:
rs.slaveOk()
Alternatively, you can use the command:
db.getMongo().setSlaveOk()
Both the commands are the same (you can type rs.slaveOk when connected to a secondary node and see):
The functionality of this command is limited to data within a database only, I see. For example:
replset:SECONDARY> show dbs
"errmsg" : "not master and slaveOk=false"
replset:SECONDARY> use testdb // this is an existing database with a collection testColl
replset:SECONDARY> show collections
testColl
replset:SECONDARY> db.testColl.find()
{ "_id" : ObjectId("5f630147076a85deff34973a") }