Search code examples
mongodbreplication

mongodb single DB replication


I've a working MongoDB "replica set" made up by 3 servers. It is storing two DBs, I wonder if is it possible to replicate only one of the DBs without running more than one mongoDB instance(one per DB).

Here is a sketch of the "problem"

      Server1   Server2   Server3
DB1      X         X         X
DB2      X         X

X stands for Server where DBs have to be replicated in.

thank


Solution

  • I don't believe it is possible.

    Unlike sharding, where you specify down to the collection level what gets sharded, with replica sets you're defining that a given MongoDB instance is part of a replica set. As only one node in a replica set can be the master at any given time, based on the scenario you are talking about, then there would be a problem if e.g. Server1 went down and Server3 was promoted to master - as DB2 would then not be able to be written to.