mongo shell connected to mongos with single replica set shard
> db.foo.find().itcount()
1000
> db.getMongo().setSlaveOk()
> db.foo.find().itcount()
Fri Feb 4 16:21:22 uncaught exception: error:
> db.getMongo().slaveOk = false
false
> db.foo.find().itcount()
1000
connecting directly to replSet:
rs.status()
{
"set" : "slave_ok_no_master",
"date" : ISODate("2011-02-04T21:21:07Z"),
"myState" : 1,
"members" : [
{
"_id" : 0,
"name" : "redbeard:31000",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"optime" :
,
"optimeDate" : ISODate("2011-02-04T21:16:38Z"),
"self" : true
},
{
"_id" : 1,
"name" : "redbeard:31001",
"health" : 1,
"state" : 3,
"stateStr" : "RECOVERING",
"uptime" : 372,
"optime" :
,
"optimeDate" : ISODate("2011-02-04T21:16:37Z"),
"lastHeartbeat" : ISODate("2011-02-04T21:21:05Z"),
"errmsg" : "error RS102 too stale to catch up"
},
{
"_id" : 2,
"name" : "redbeard:31002",
"health" : 1,
"state" : 3,
"stateStr" : "RECOVERING",
"uptime" : 372,
"optime" :
,
"optimeDate" : ISODate("2011-02-04T21:16:37Z"),
"lastHeartbeat" : ISODate("2011-02-04T21:21:05Z"),
"errmsg" : "error RS102 too stale to catch up"
},
{
"_id" : 3,
"name" : "redbeard:31003",
"health" : 1,
"state" : 3,
"stateStr" : "RECOVERING",
"uptime" : 382,
"optime" :
,
"optimeDate" : ISODate("2011-02-04T21:16:37Z"),
"lastHeartbeat" : ISODate("2011-02-04T21:21:05Z"),
"errmsg" : "error RS102 too stale to catch up"
},
{
"_id" : 4,
"name" : "redbeard:31004",
"health" : 1,
"state" : 3,
"stateStr" : "RECOVERING",
"uptime" : 372,
"optime" :
,
"optimeDate" : ISODate("2011-02-04T21:16:37Z"),
"lastHeartbeat" : ISODate("2011-02-04T21:21:05Z"),
"errmsg" : "error RS102 too stale to catch up"
},
{
"_id" : 5,
"name" : "redbeard:31005",
"health" : 1,
"state" : 3,
"stateStr" : "RECOVERING",
"uptime" : 372,
"optime" :
,
"optimeDate" : ISODate("2011-02-04T21:16:37Z"),
"lastHeartbeat" : ISODate("2011-02-04T21:21:05Z"),
"errmsg" : "error RS102 too stale to catch up"
},
{
"_id" : 6,
"name" : "redbeard:31006",
"health" : 1,
"state" : 3,
"stateStr" : "RECOVERING",
"uptime" : 382,
"optime" :
,
"optimeDate" : ISODate("2011-02-04T21:16:37Z"),
"lastHeartbeat" : ISODate("2011-02-04T21:21:05Z"),
"errmsg" : "error RS102 too stale to catch up"
}
],
"ok" : 1
}
> db.setSlaveOk()
> db.foo.find().itcount()
1000