Navigation

enableSharding

enableSharding

The enableSharding command enables sharding on a per-database level. The enableSharding command has the following syntax:

{ enableSharding: "<database name>" }

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

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

Returns:A document that contains status of the operation.

Once you enabled sharding in a database, you can use the shardCollection command to begin the process of distributing data among the shards.