Database Administrators Asked by muon.ha on December 26, 2020
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!!
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
Sharded and Non-Sharded Collections
A database can have a mixture of sharded and unsharded collections. Sharded collections are partitioned and distributed across the shards in the cluster. Unsharded collections are stored on a primary shard. Each database has its own primary shard.
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.
db.adminCommand( { movePrimary: <databaseName>, to: <newPrimaryShard> } )
Answered by Wernfried Domscheit on December 26, 2020
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP