Home > Software design >  Does Replica Set in Shard Cluster only stores a "Sharded Copy" or "All Sharded"
Does Replica Set in Shard Cluster only stores a "Sharded Copy" or "All Sharded"

Time:04-29

I understand the idea of Replica Set and am able to pull Replica Set Setup by using 3 server, the logic is as below, the reference are from this link enter image description here

So I came to have confusion when I am trying to understand how does Sharded Cluster works in Replica Logic, the reference I was able to find is as below:

enter image description here

There are a few concerns:

  1. Does Shard 1's Primary only hold 33% of datas?
  2. Does Shard 1's Secondary (Replica) hold the data from Shard 2's Primary and Shard 3's Primary?
  3. I can see "mongos" knows the Shard 1, Shard 2 and Shard 3 location, then what is the use of mongod config?
  4. Is the logic of server placement as below?:

enter image description here

CodePudding user response:

  1. Does Shard 1's Primary only hold 33% of datas?

Yes, it does - provided your database and collection have "sharding enabled".

  1. Does Shard 1's Secondary (Replica) hold the data from Shard 2's Primary and Shard 3's Primary?

No, they don't. Shard 1's Secondaries hold a copy of Shard 1's Primary data.

  1. I can see "mongos" knows the Shard 1, Shard 2 and Shard 3 location, then what is the use of mongod config?

The config replica set stores all kind of meta data, e.g. user accounts and privileges and - very important - it stores which ranges of data are stored in which shard. Otherwise, when you insert or read any data, you would not know to which shard they belong to.

  • Related