Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mongodb - View collections in the secondary replica member

Is it possible to view the synced data in the secondary replica set of mongodb ?

rs0:SECONDARY> use testdb
switched to db testdb
rs0:SECONDARY> db.auth("tester","123123")
1
rs0:SECONDARY> db.zips.find().pretty();
    error: { "$err" : "not master and slaveOk=false", "code" : 13435 }

I'm getting this error when I tried to view the synced data or what is the command to view the synced data in the secondary mongodb? Did I miss any steps?

like image 536
Sathish Avatar asked Feb 05 '15 13:02

Sathish


1 Answers

You have to run

rs.slaveOk()

http://docs.mongodb.org/manual/reference/method/rs.slaveOk/

To say to db that you know you are reading from secondary

like image 61
marcinn Avatar answered Nov 15 '22 15:11

marcinn