Version Matrix
Port Planning
- Config Server (cfg): 17017 / 17018 / 17019
- Shard1: 37017-37019
- Shard2: 47017-47019
- Mongos: 27017
Sharded Cluster Core Components
- Shards: Nodes that actually store data
- Config Servers: Stores cluster metadata
- Mongos: Application access entry point
Config Server Setup
dbpath=config/config1
port=17017
configsvr=true
replSet=configsvr
Initialize
var cfg = {
"_id":"configsvr",
"members":[
{"_id":1,"host":"192.0.2.38:17017"},
{"_id":2,"host":"192.0.2.38:17018"},
{"_id":3,"host":"192.0.2.38:17019"}
]
};
rs.initiate(cfg);
Mongos Router Node
port=27017
configdb=configsvr/192.0.2.38:17017,192.0.2.38:17018,192.0.2.38:17019
Add Shards
sh.addShard("shard1/192.0.2.38:37017,192.0.2.38:37018,192.0.2.38:37019");
sh.addShard("shard2/192.0.2.38:47017,192.0.2.38:47018,192.0.2.38:47019");
Enable Sharding
sh.enableSharding("wzk_test")
sh.shardCollection("wzk_test.wzk_test_data",{"name": "hashed"})
Error Quick Reference