balancing databases within a cluster

35 views
Skip to first unread message

Yann Simon

unread,
Apr 12, 2016, 11:38:16 AM4/12/16
to mongodb-user
Hi,

we have a mongo cluster with one replica set and a lot of databases.

To balance the write load, we are thinking about balancing these databases in different replica sets to use different mongo primaries.
And one database could be migrated from one replica set to another one, preferably based on tags.

We do not want to shard the collections themselves.

I could find a lot of documentation about sharding collections.
But I do not think it is what I need.

Any idea?
Thanks in advance,
Yann

William Byrne III

unread,
Apr 26, 2016, 8:35:08 AM4/26/16
to mongodb-user

Yann,

When you create a database (by creating the first collection in it) in a sharded cluster, the mongos will set a primary shard for the database. This is where all un-sharded collections for that database will be stored. As you don’t plan to shard any of your collections, all collections for each database will be stored on its primary shard.

You can see databases and their primary shards in the output of sh.status(), or by displaying the contents of the config.databases collection:

use config;
db.databases.find()

Primary shards are chosen for new databases on the basis of which shard has the most free space at the time the database is created. You can change the primary chunk of a database with the movePrimary command:

db.adminCommand({movePrimary:"salesDB", to:"shard0003"});

Tag aware sharding can only be used to control the location of ranges of documents within sharded collections, so using tags to migrate databases will not be an option until you fully implement sharding.

Regards,

III



Yann Simon

unread,
Apr 26, 2016, 10:40:36 AM4/26/16
to mongodb-user
Thanks for this great answer!

Sharding may not be what we need for our current needs. (We may need that in the future though for huge collections.)

Regards,
Yann

--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: https://docs.mongodb.org/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/c364ec07-4e22-4648-b8ac-2493a8b6a4dd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages