Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can MongoDB instance be a member of multiple replica sets?

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

like image 617
user1584660 Avatar asked Nov 12 '14 11:11

user1584660


People also ask

What is the maximum number of member instances a replica set can have in MongoDB replication before version 3.0 0?

A replica set can have up to 50 members but only 7 voting members.

How many types of members exist in replica set?

How many types of members exist in replica set? Explanation: There are two members in replica set-primary and secondary.

What is the maximum number of nodes in MongoDB replica set?

MongoDB supports replica sets, which can have up to 50 nodes.

How does MongoDB replica set work?

MongoDB achieves replication by the use of replica set. A replica set is a group of mongod instances that host the same data set. In a replica, one node is primary node that receives all write operations. All other instances, such as secondaries, apply operations from the primary so that they have the same data set.


Video Answer


1 Answers

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.

like image 177
Tom Panning Avatar answered Oct 08 '22 23:10

Tom Panning