Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?


share|improve this question
up vote 3 down vote accepted

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.

share|improve this answer
The answer was indeed to enable the slaveOk option in my driver, even in a sharded environment. – Pierre Jan 9 '15 at 2:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.