enableSharding

  1. { enableSharding: "<database name>" }

To run enableSharding, use the db.runCommand( { <command> } ) method.

To run enableSharding, connect to a mongosinstance and run the command in the admin database.

mongos uses"majority" for theenableSharding command and its helpersh.enableSharding().

Returns:A document that contains status of the operation.

Once you enabled sharding in a database, you can use theshardCollection command to begin the process ofdistributing data among the shards.