| 开启分片 | sh.enableSharding("app") |
|---|---|
| 分片集合 | sh.shardCollection("app.orders", { customerId: "hashed" }) |
| 查看 | sh.status() |
| 成员 | mongos / config server / shard |
示例
示例
sh.enableSharding("app")
sh.shardCollection("app.orders", { customerId: "hashed" })
sh.status()分片键基数低或单调递增(如时间戳)会产生热点,优先高基数、写入分散的字段。