简体   繁体   中英

Mongos replicaset

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 (eg 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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM