Can MongoDB instance be a member of multiple replica sets?

2.2k Views Asked by At

I would like to know if it is possible to have one mongoDB instance that belongs to two replica sets.

E.g: ReplicaSet1 has members 10.10.1.1 and 10.10.2.1 ReplicaSet2 has members 10.10.1.1, 10.10.1.2 and 10.10.1.3

1

There are 1 best solutions below

0
On

No, a single mongod server can not be a member of multiple replica sets. This doesn't seem to be explicitly documented anywhere, so I had to look for something that at least strong implies it. First, every replica in the set has the same databases and collections, and this is maintained by the secondaries replaying the oplog of the primary. A secondary wouldn't be able to replay the oplog from multiple primaries. Second, the db.serverStatus() command returns a document that contains a repl object with the replication status, and it is an object, not an array.

The only way to have a single machine be a member of multiple replica sets is to run multiple mongod servers on that machine.