First of all this is normal, because secondary is not allowed to read and write,
in the application of writing more than read, using the replica sets to achieve read and write separation. By specifying Slaveok at the time of connection, or by specifying the secondary in the main library, the pressure of reading is shared by the primary and only the write operation is assumed.
The secondary node in the replica set is not readable by default,
[email protected] bin]$ MONGO 127.0.0.1:33333MongoDB Shell version:2.0.1Connecting to:127.0.0.1:33333/testsecondary> db.user.find ()error: {"$err": "Not Master and Slaveok=false", "Code": 13435}secondary> Db.getmongo ()connection to 127.0.0.1:33333secondary> Db.getmongo (). Setslaveok ();Not Master and Slaveok=false set up on the main librarySlaveok=ok[email protected] bin]$ MONGO 127.0.0.1:33333MongoDB Shell version:2.0.1Connecting to:127.0.0.1:33333/testprimary>
Db.getmongo (). Setslaveok (); primary>testing from a librarysecondary> db.user.find (){"_id": ObjectId ("4eb68b1540643e10a0000000"), "id": 1, "name": "Zhangsan"}{"_id": ObjectId ("4eb68b1540643e10a0000001"), "id": 2, "name": "; Lisi"}
also refer to the following solution:
Http://stackoverflow.com/questions/8990158/mongdodb-replicates-and-error-err-not-master-and-slaveok-false-code