Splitting MongoDB collections on multiple servers via mongos Router

Having a MongoDB database called maindatabase , which has 3 collections of documents named by users, tags and categories, I would like to know if it is possible to separate them on three different servers separately (on different cloud service providers).

I do not mean a replica, but only one collection for the server (one db with only a collection of categories on the server, one with users on another server and one for tags on the third server), can be selectively routed by the mongos router.

Does anyone know if this is possible?

+4
source share
2 answers

In addition to @matulef’s answer regarding manual database management with movePrimary , this may require a simpler solution to only maintain three database connections: one for each server, each located in a different cloud provider data center, as you originally indicated . You would not have the simplicity of a single mongos connection point, but with your three connections you could directly manipulate users , tags and categories for each of your respective connections.

+1
source

Unfortunately, you cannot split collections in one database this way. However, this can be done if you put each collection in a different database. In a plastered system, each database has an associated “primary fragment” in which all unprotected collections in this database live. If you divide your 3 collections into 3 different databases, you can individually move them to different fragments using the movePrimary command:

http://www.mongodb.org/display/DOCS/movePrimary+Command

However, there is some overhead associated with creating more databases, so it is not clear if this is the best solution for your needs.

0
source

Source: https://habr.com/ru/post/1413765/


All Articles