Wiliam
Wiliam

Reputation: 3754

Three nodes using replica-set in MongoDb and 2 are down

in a 3-node replicaSet why when 2 are down the third become SECONDARY and not PRIMARY?

I want to have 2 mongod inside a DataCenter and one outside, so if the Datacenters fails I wanna the third outside mongod becomes the Primary.

It's possible without and arbiter?

Upvotes: 7

Views: 4294

Answers (2)

Samuel García
Samuel García

Reputation: 2225

Always you end up with (cluster_participants/2) + 1 nodes down (assuming you have odd number of participants), the cluster enters in read only mode. A candidate noDe needs the majority of all nodes to be elected as primary.

For example, if you have 5 noDe cluster and 3 nodes blow away, the others will stay as secondary, because none of them are able to get 3 votes.

For more information: http://docs.mongodb.org/manual/core/replication-internals/#replica-set-election-internals

Upvotes: 3

Wiliam
Wiliam

Reputation: 3754

Ok, found response:

http://tebros.com/2010/11/mongodb-arbiters-with-only-two-replicas/

What happend?! It turns out that when a mongod instance is isolated, it cannot vote for itself to be primary. This makes sense when you think about it. If a network link went down and separated your two replicas, you wouldn’t want them both to elect themselves as primary. So in my case, when rep1-1 noticed that it was isolated from the rest of the replica set, it made itself secondary and stopped accepting writes.

Upvotes: 9

Related Questions