Watch keynotes and sessions from MongoDB.live, our virtual developer conference.

Already inserted data, how to distribute shard?

Can I distribute shard already inserted data?

I tried to do it alone, but it didn’t work.

Step)

  1. insert document
  2. sh.enableSharding
  3. db.createIndex
  4. sh.shardCollection

It’s awkward because it’s a translator, sorry.
Ask me if you don’t understand anything.

If the collection (with the inserted data) is sharded, the collection’s data is distributed among the shards - based upon the Shard Key.

Also see:

Review your steps once again for deploying a sharded cluster: Deploy a Sharded Cluster. If you had followed the procedures then there should not be any problem.