I'm a new in MongoDB cluster. I have a question about config enable shading collection in MongoDB:
I have a cluster :
Shard1: replical01/node1:27017, node2:27017
Shard2: replical02/node3:27017, node4:27017
2 config Server on other virtual machine.
Everything worked normally under manual. But I have a question as follows: how can I just shading a collection for only one shard. For example, I used mongos to create a database Test with 3 collection T1, T2, T3.
Which T1 only located on shard1, T2 only on shard2. T3 is also located on the both shard1 and shard2.
Please help me. Thank you and regards!!
Mongodb – Config enable sharding collection in MongoDB cluster
clusteringdistributed-databasesmongodbnosqlsharding
Best Answer
You can enable sharding on collection base, i.e. collection T3 is sharded.
Unsharded collection are created in the Primary Shard, see Sharded and Non-Sharded Collections
Typically the Primary Shard is the least loaded shard at the time when the database was created. When you are not happy with the selected Primary Shard then you can move it with movePrimary command. But you have to move all collections of one database, you cannot move a single collection.