1. You can change the partition mode for the existing data storage mode of a single instance.
1.1 start and configure the service instance and route service instance respectively.
1.2 add an existing single instance to the partition mode.
1.3 Finally, decide which set in the database adopts the sharding mode and specify the shard key.
2. Add a new data storage node for the partition mode.
Use admin; db. runCommand ({addshard: "IP. Port "});
After the new node is added successfully, the Set Data Specified to adopt the sharding mode is automatically allocated to the new node.
3. In the fragment mode, change the fragment mode for a set that already exists and does not adopt the fragment mode.
3.1 If the library where the set is located already adopts the sharding mode, but it does not, you only need to run the command to specify the sharding mode of the set.
Use admin; db. runCommand ({shardcollection: "database name. Set"}, key: {xx: 1 });
3.2 If the database where the set is located does not adopt the sharding mode, you must change the database to sharable before specifying the sharding mode of the set.
Use admin; db. runCommand ({enablesharding: "Database Name"}); db. runCommand ({shardcollection: "database name. Set"}, key: {xx: 1 });