Reputation: 3260
I switched my mongodb environment from replication-sets to sharding with replication-sets through mongos.
I had 3 rep-sets (A,B,C) which I switched to S1(A,B); S2(C,D) with mongoS running on A,B,C,D.
When I was connecting to my old system, I connected as followed
new Mongo("mongodb://A,B,C", array("replicaSet" => "repset-name"));
Now I tried to to the same with mongoS wich throws an interal server error
new Mongo("mongodb://A,B,C,D", array("replicaSet" => "repset-name"));
If I get rid of the "replicaSet" option, it works again.
new Mongo("mongodb://A,B,C,D")
I was wondering if mongoS now balances the reads between the rep-sets in the shard (e.g. S1 balance between A and B) without the "replicaSet" option set?
By the way, pymongo reacts the same way with a pymongo.errors.AutoReconnect "No address associated with hostname".
Thx
Upvotes: 0
Views: 566
Reputation: 24009
Correct, once you've sharded, you should connect your driver to the mongos as if it were a single server. Mongos is now responsible for distributing reads and writes among the primaries and secondaries around your cluster. Set slaveOk to True for reads if you want mongos to distribute reads to secondaries.
Upvotes: 2