Problem Statement
What do config servers store in a MongoDB sharded cluster?
Explanation
Config servers store metadata and configuration settings for the sharded cluster. This includes information about which chunks of data are on which shards, shard key ranges, and cluster topology.
Mongos routers query config servers to determine where to route operations. Config servers must be deployed as a replica set for high availability. Without functioning config servers, the cluster cannot route queries or perform chunk migrations, though existing connections to shards continue to work.
Code Solution
SolutionRead Only
// Config server replica set stores:
// - Shard information and locations
// - Chunk ranges for each shard
// - Database and collection metadata
// View chunk distribution
use config
db.chunks.find({ ns: "mydb.users" }).pretty()
// Example chunk metadata
{
_id: "mydb.users-userId_1000",
ns: "mydb.users",
min: { userId: 1000 },
max: { userId: 2000 },
shard: "shard0001"
}