In order to connect to
Sample usages:
Read full details here:
- http://api.mongodb.com/python/current/examples/high_availability.html#connecting-to-a-replica-set
#database #mongodb #mongo #replica_set #replication #pymongo #arbiter #master #primary #slave
MongoDB replica set
in Python
you can give all server node addersses to MongoClient
. Addresses passed to MongoClient()
are called the seeds. As long as at least one of the seeds is online, MongoClient
discovers all the members in the replica set, and determines which is the current primary and which are secondaries or arbiters.Sample usages:
>>> MongoClient('localhost', replicaset='foo')
MongoClient(host=['localhost:27017'], replicaset='foo', ...)
>>> MongoClient('localhost:27018', replicaset='foo')
MongoClient(['localhost:27018'], replicaset='foo', ...)
>>> MongoClient('localhost', 27019, replicaset='foo')
MongoClient(['localhost:27019'], replicaset='foo', ...)
>>> MongoClient('mongodb://localhost:27017,localhost:27018/?replicaSet=foo')
MongoClient(['localhost:27017', 'localhost:27018'], replicaset='foo', ...)
Read full details here:
- http://api.mongodb.com/python/current/examples/high_availability.html#connecting-to-a-replica-set
#database #mongodb #mongo #replica_set #replication #pymongo #arbiter #master #primary #slave