Reshard a MongoDB sharded collection with reshardCollection

domain: mongodb · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Verify you are running MongoDB 5.0 or later (reshardCollection was introduced in 5.0); connect to mongos with mongosh
  2. Stop or pause the balancer before resharding: sh.stopBalancer(); confirm with sh.getBalancerState()
  3. Issue the reshard command with the new shard key: db.adminCommand({ reshardCollection: 'mydb.orders', key: { customerId: 1 } }); MongoDB sets a default max-write-block duration of 2 seconds during cut-over
  4. Monitor resharding progress: db.adminCommand({ currentOp: true, type: 'op', desc: /reshard/ }) and watch for the oplogSize and remainingOperationTimeEstimated fields
  5. The operation runs in the background and completes with a brief write block for the final cut-over; the minimum total duration is 5 minutes regardless of data size
  6. After completion, re-enable the balancer: sh.startBalancer(); verify chunk distribution with sh.status()

Known gotchas

Related routes

Shard a previously unsharded MongoDB collection and choose an appropriate shard key with sh.shardCollection()
mongodb.com · 5 steps · unrated
Reshard a Redis Cluster by moving hash slots between nodes
redis · 6 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans