Search code examples
mongodbreplicationnosql

Mongo DB replication


Im a total newbie to MongoDB and was watching some videos and really liked the replication setup that Mongo offers.

Scenario

I want to know if the following scenario is possible with MongoDB.

lets say I have 3 MongoDB servers

  1. a server in the Cloud (CloudMongo)
  2. 2 servers running on 2 terminal machines (T1 and T2)

The CloudMongo has a database called Enterprise with Tables AllSales and Promotions
The Terminal machines both have databases POS with tables Sales and Promotions

Questions

  1. Can CloudMongo replicate a subset of the Promotions data to T1 and another subset to T2?
  2. Can Terminals T1 and T2 replicate their sales data to be consolidated to the AllSales table/collection on CloudMongo?

Solution

  • Replication in Mongo is for data durability (and in some cases, read scaling). It's not meant for application-level data management. Selective replication is not supported.

    Collections in the data path of the servers in the replica set will be replicated in their entirety.

    It sounds like what you want to do is copy certain pieces of data around to different members of your set. This is certainly automatable at the application level by building specific queries.