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
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:
There are a few concerns:
- Does Shard 1's Primary only hold 33% of datas?
- Does Shard 1's Secondary (Replica) hold the data from Shard 2's Primary and Shard 3's Primary?
- I can see "mongos" knows the Shard 1, Shard 2 and Shard 3 location, then what is the use of mongod config?
- Is the logic of server placement as below?:
CodePudding user response:
- Does Shard 1's Primary only hold 33% of datas?
Yes, it does - provided your database and collection have "sharding enabled".
- 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.
- 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.