Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Two nodes MongoDB replica set without arbiter

Is it possible to create a MongoDB replica set consisting of only 1 primary and 1 secondary member? I would like to have delayed replica set that will copy data from primary with delay of 24 hours. I know I can put arbiter on one of the servers (primary or secondary, I know this is not advised but my only wish is to run this configuration on two servers) and it would run fine, but I want to know if it is possible to completely kick arbiter out. It would look like this: Two nodes replica set without arbiter

like image 954
Drag0 Avatar asked Aug 26 '14 09:08

Drag0


3 Answers

Short answer: don't.

Long answer: the way automatic failover works in MongoDB is that a replica set needs a qualified majority to successfully elect a new primary. Delayed members do have votes in elections. So if either of your nodes fails the replica set finds out that it doesn't have this majority and the current primary steps down even if it didn't fail. So what you essentially do is doubling the chances of making your replica set fail. An arbiter is a very cheap process, in term of RAM usage, CPU and even disk space when run with --smallfiles --no-journal --noprealloc or the equivalent options set in the config file. Note that the mentioned options are safe to use, since an arbiter essentially only checks the heartbeats of the data bearing nodes. You could put the arbiter on the application server for example.

Disclaimer: the following procedure is strongly discouraged to use. Proceed at your own risk.

You could set the votes of the delayed server to 0. This way the undelayed node will call for an election in case the delayed member fails, comes to the conclusion that it is the only node online of the replica set and that it has the majority of votes (1/1) and will continue to work as expected. This course of action needs some attention, as you will have an even number of votes again in case you add a member to the replica set later and makes it necessary to reconfigure the replica set. It also has serious implications with network fragmentation issues. Again: Use at your own risk

like image 87
Markus W Mahlberg Avatar answered Oct 14 '22 10:10

Markus W Mahlberg


Yes, it is possible but not recommended. The caveat of this approach is no automatic failovers.

If you primary goes down then you will have to manually make the other server as primary.

If you are keeping you secondary only as a mirror of your primary and you are fine with manual failover then it should work for you.

More info here:

http://openmymind.net/Does-My-Replica-Set-Need-An-Arbiter/

like image 35
Lalit Agarwal Avatar answered Oct 14 '22 08:10

Lalit Agarwal


Yes you can and all you really need to do is set the member to not be eligible for primary.

There is documentation on how to make sure a member cannot be elected as primary here: http://docs.mongodb.org/manual/tutorial/configure-secondary-only-replica-set-member/

like image 26
Sammaye Avatar answered Oct 14 '22 09:10

Sammaye