Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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!

share|improve this question

2 Answers 2

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
up vote -3 down vote accepted

The answer was indeed to enable the slaveOk option in my driver, even in a sharded environment.

share|improve this answer
1  
Then why did you add an answer and mark yours the accepted one? That's not how ServerFault (and StackExchange as a whole) works. I certainly don't need the points, but either you're garnering points or ignorant of how to use the site. (Ignorance isn't bad; it can be cured...) –  gWaldo Aug 23 '11 at 13:50

Your Answer

 
discard

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.