In order to enable sharding for a collection of data, we should enable sharding for a database first.
We should use the same
mongo command-line environment to enable, deactivate, or modify database sharding. To enable sharding for a database, you can use following command:
We enable sharding for the database
newdb. This is shown in the following screenshot:
If the enabling process is successful, you get the preceding message from the shell. Otherwise, you will get an error. Now that we enabled sharding for the database, the next step is to enable sharding for database collections.
The following screenshot ...