2

I have a Mongo DB setup of 4 DB (2 shards of 2 replica) and I noticed that the secondary servers of each shard is not being used for read queries. Both secondary servers received all inserts, updates and deletes from their master but when I look at mongostat, the number under 'query' is always zero.

Do I need to setup something such as 'slaveOk' for my mongos client to be able to use the secondary server of each shard for read queries?

Thanks!

Pierre
  • 241
  • 1
  • 2
  • 11

1 Answers1

3

Reading from the slaves is not the default behavior, but it is enabled in the application via the language driver (because they can only be used on read operations.) It is not controllable from the server. An example in pymongo is described in the master_slave_connection page.

gWaldo
  • 11,887
  • 8
  • 41
  • 68
  • The answer was indeed to enable the slaveOk option in my driver, even in a sharded environment. – Pierre Jan 09 '15 at 02:18