Leo
Leo

Reputation: 639

How to specify which node is being queried in Mongo ReplicaSet?

connection:

client = MongoClient(
    'localhost:27017',
    replicaSet='foo',
    readPreference='secondaryPreferred')

so, how to specify whether slave or master is used ? thanks~

Upvotes: 0

Views: 50

Answers (1)

zero323
zero323

Reputation: 330083

You can set readPreference to either primary or secondary if you want to limit to the specific category. If need more granular control you can use tagSet to limit the options.

To use the tag sets you have to:

Upvotes: 1

Related Questions