pymongo 副本及链接 说明

ReplicaSetConnection('%s:27018,%s:27018,%s:27018' % ('ip0','ip2','ip1'), replicaSet = 'rs0', read_preference=0)['beehoo']


read_preference 解释:

|
|  NEAREST = 4
|
|  PRIMARY = 0
|
|  PRIMARY_PREFERRED = 1
|
|  SECONDARY = 2
|
|  SECONDARY_ONLY = 2
|
|  SECONDARY_PREFERRED = 3



MongoReplicaSetClient:

PRIMARY: Queries are sent to the primary of the replica set.
PRIMARY_PREFERRED: Queries are sent to the primary if available, otherwise a secondary.
SECONDARY: Queries are distributed among secondaries. An error is raised if no secondaries are available.
SECONDARY_PREFERRED: Queries are distributed among secondaries, or the primary if no secondary is available.
NEAREST: Queries are distributed among all members.

猜你喜欢

转载自cooler1217.iteye.com/blog/2156732