0
votes

I have 3 computers (A,B,C).

On all computers there will be a replica set of the primary shard (to have a redundancy of the unsharded collections).

On comuter B and C there will be a single member shard replica set.

How to i tell mongodb to not hold any sharded collection on the primary shard replica set cluster?

1
I don't think that's possible. MongoDB distributes sharded data evenly across all shards. You cannot even influence the balancing, see Make sharding balancer smarter when asymmetric hardware - Wernfried Domscheit

1 Answers

0
votes

Sharding is used to horizontally scale (aka scale out). If you shard but then put multiple shards on the same computer, this defeats the purpose of sharding in the first place. Simply use a 3 node replica set with your 3 computers.

With that said, see https://docs.mongodb.com/manual/tutorial/sharding-segmenting-data-by-location/ for how to route your data to specific nodes in a sharded cluster.