0

We have a sharded mongo cluster with a database per client model. Given many roughly same size clients - the default db creation has proven to work well at evenly distributing the load, while avoiding multi-shard queries.

Up till now, all shards were homogeneous SSD based deployments, however now, we are trying to add heterogeneous larger but slower HDD based shards - so each clients can have few large bulk collections located there (while their primary shard stays on SSD). This is easliy accomplished with the zoning method (2 zones, hdd and ssd) - and would work very well if for one issue:

TL;DR: Are there any ways to restrict new database creation to only happen on SSD shards?

Only way I know of is to let DB creation happen, then check where it got created and use movePrimary if it is in wrong zone. Issue with this is that process is manual and involves hunting down and restarting every mongos router - as movePrimary was not quite designed to be production ready....

0

Answer is yes and no. Clustered system marks DB's primary location to shard what have less DB's. Trying to distribute evently. So, automatically you cannot define that location.

IF you log into specific replica set directly and create DB there, then that's it DB's primary location then.

However, you can use that movePrimary command (without mongos reboot) if you move sharded collection. You can shard collection what don't exists, you move that non-existing collection to wanted location and then "drop" that collection. DB have new primary location and all mongos knows now that new location. ;-)

3
  • Can you elaborate how can you use movePrimary w/o mongos reboot? The steps I have right now is - a) Create DB (by creating collection), movePrimary, enableSharding (on that DB), enable sharding on collection, move collection, drop collection.... is this right? – Leszek R. Sep 22 '17 at 0:23
  • As documentation says, if you use movePrimary for un-sharded collection, you need to restart mongos. It means that, if DB have sharded collection, it's primary can be moved without mongos reboot. Yes, thats right steps. – JJussi Sep 22 '17 at 3:43
  • .. when we change that "move collection" to command movePrimary. ;-) – JJussi Sep 22 '17 at 4:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.