[MONGODB]: WHEN ARBITER REQUIRED FOR REPLICA SET
MongoDB replica sets provide a number of features that most MongoDB users are going to want to leverage. Best of all they are relatively easy to setup. However, first timers often hesitate when it comes to the role of arbiters. Knowing whether or not you need an arbiter is dead simple. Understanding why is critical.
You need an arbiter if you have an even number of votes. As an extension to this, at most you should only ever have 1 arbiter. If you aren’t sure how many votes you have, it’s probably the same as the number of servers in the set you have (including slaves, hidden, arbiters).
Elections and Majority
When the primary becomes unavailable, an election is held to pick a new primary server from those servers still available. One of the key points to understand is that a majority is required to elect a new primary. Not just a majority from available servers, but a majority from all of the servers in the set.
For example if you have 3 servers, A(primary), B and C then it’ll always take 2 servers to elect a new primary. If A(p) goes down, then B and C can and will elect a primary. However, if B also goes down, C will not elect itself as primary because it will only get 1/3 of the votes (as opposed to the necessary 2/3).
In other words, a 3 server replica set can tolerate a single failure. A 5 server replica set can tolerate 2 failed servers (3/5 is a majority). A 7 server replica set can survive 3 failed servers (4/7).
Network Splits and Ties
To understand the other key point it helps if we change our perspective from thinking of servers going down, to thinking in terms of network splits. What?
You see, when you think of servers crashing, it’s reasonable to expect any remaining server to be elected – even without a majority. Instead of servers going down, consider what would happen if the servers all remain operational but can’t see each other. Let’s look at an example
Pretend we have 4 servers – representing a [evil] even number of votes: A, B, C and D. AB are in one data center (or availability zone) while CD are in another. Now, the link between the two data-centers dies. What would happen? Each group thinks the other is down and could both elect their own primary. This would cause data conflicts (two servers would be accepting writes).
So let’s introduce an arbiter (E) and with it, an uneven number of votes. Now each servers knows that the set is made up of 5 votes, and thus 3 votes are required to elect a new primary. Whatever group E ends up with (either ABE or CDE) a primary will be elected, and, more importantly, whatever group E doesn’t end up with won’t be able to elect a primary.
What happens if AB, CD and E do a three way split? Then there is no majority and thus no primary and the set will go down (but that’s much better than having 2 primaries).
Separate Servers?
People often wonder whether an arbiter can run on the same box as one of the main mongod
processes? Ideally, no. Imagine we have AB and C where B is arbiter running on the same server as A. If that server goes down you’ve lost your majority. In other words, in this set up, if the wrong server goes down you have no redundancy. However, if C goes down, AB can and will remain a primary (and if you think you can just stick a 2nd arbiter on C, then this article has failed you miserably, and I’m very sorry for having wasted your time).
Arbiters don’t store any of the data and is a lightweight process. An Amazon’s EC2 micro instance is more than powerful enough.
Conclusion
The most important thing is to have an uneven number of votes. Knowing this, it should be obvious that you either want 0 arbiters or 1…but never, ever more.
It’s also important to understand that election doesn’t rely on the majority of available servers, but of all servers in the set. A 3-server replica set will not tolerate 2 servers failing. Thinking in terms of network splits in the context of separate data centers helps me visualize this.
[MONGODB]: WHEN ARBITER REQUIRED FOR REPLICA SET的更多相关文章
- NoSQL数据库Mongodb副本集架构(Replica Set)高可用部署
NoSQL数据库Mongodb副本集架构(Replica Set)高可用部署 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. MongoDB 是一个基于分布式文件存储的数据库.由 C ...
- Mongodb集群搭建之 Replica Set
Mongodb集群搭建之 Replica Set Replica Set 中文翻译叫做副本集,不过我并不喜欢把英文翻译成中文,总是感觉怪怪的.其实简单来说就是集群当中包含了多份数据,保证主节点挂掉了, ...
- MongoDB的集群模式--Replica Set
一.Replica Set 集群分为两种架构: 奇数个节点构成Replica Set,所有节点拥有数据集.最小架构: 1个Primary节点,2个Secondary节点 偶数个节点 + 一个仲裁节点 ...
- MongoDB高可用架构:Replica Sets+Sharding
MongoDB的sharding解决了海量存储和动态扩容的问题.但是遇到单点故障就显得无能为力了.MongoDB的副本集可以很好的解决单点故障的问题.所以就有了Sharding+Replica Set ...
- MongoDB:搭建三节点 Replica Set 环境
今天学习了搭建 MongDB 复制环境,实验环境是在虚拟机上同一系统,并搭建三节点 Replica Set,根据文档上的描述,mongodb 复制配置简单,并且能够自动 failover,这些高级特性 ...
- 关于MongoDb Replica Set的故障转移集群——实战篇
如果你还不了解Replica Set的相关理论,请猛戳传送门阅读笔者的上一篇博文. 因为Replica Set已经属于MongoDb的进阶应用,下文中关于MongoDb的基础知识笔者就不再赘述了,请参 ...
- Mongodb集群搭建之 Sharding+ Replica Sets集群架构
1.本例使用1台Linux主机,通过Docker 启动三个容器 IP地址如下: docker run -d -v `pwd`/data/master:/mongodb -p 27017:27017 d ...
- MongoDB Replica Set搭建集群
MongoDB做集群,版本3.2官网推荐的集群方式Replica Set 准备服务器3台 两个standard节点(这两个节点直接可以互切primary secondary). 一个arbiter节点 ...
- Configure MongoDB Replica Set
Table of Contents Introduction Requirements Create Replica Set Add Secondary Members Add an Arbiter ...
随机推荐
- paip.输入法英文词库的处理 python 代码 o4
paip.输入法英文词库的处理 python 代码 o4 目标是eng>>>中文>>atian 当输入非atian词的时候儿,能打印出 atian pinyin > ...
- JavaScript-语法基础
在学习任何一门编程语言之前,我们都需要了解这门语言并学习这么语言的语法基础,掌握语法基础之后才可以进行一门语言的使用,本文在这里将详细介绍JavaScript的语法基础,使得以后能够快速的进行Java ...
- 定义一个时钟类——Clock,它包括三个int型 成员变量分别表示时、分、秒,一个构造方法用于对三个成员变量(时、分、秒) 进行初始化,还有一个成员方法show()用于显示时钟对象的时间。其次,再定义 一个主类——TestClass,在主类的main方法中创建多个时钟类的对象,使用这 些对象调用方法show()来显示时钟的时间
package java1; public class Clock { int hhh; int mmm; int sss; Clock(int h,int m,int s) { hhh=h; mmm ...
- Android MultiDex兼容包怎么使用?
在Android系统中安装应用的时候,需要对Dex进行优化,但由于其处理工具DexOpt的限制,导致其id的数目不能够超过65536个.而MultiDex兼容包的出现,就很好的解决了这个问题,它可以配 ...
- python常用sql语句
#coding=utf-8 import MySQLdb conn = MySQLdb.Connect(host = '127.0.0.1',port=3306,user='root',passwd= ...
- [原创]推荐一款强大的.NET程序内存分析工具.NET Memory Profiler
[原创]推荐一款强大的.NET程序内存分析工具.NET Memory Profiler 1 官方网站:http://memprofiler.com/2 下载地址:http://memprofiler. ...
- 微信商城系统与手机APP的优势对比!
随着移动互联网的大势到来,手机移动应用已经成为未来的主流市场,很多企业也在投入精力和财力进行研发自己的手机APP,以便更好的迎合市场的需求. 然而当微信公众平台开放以后,新的机会出现了! 很多企业已经 ...
- 使用MFC提供的Http类下载和上传文件
1.下载文件 Download(const CString& strFileURLInServer, //待下载文件的URL const CString & strFileLocalF ...
- LPC4370 ACDHS speed and DMA
LPC4370 ACDHS speed AHB clock BASE_M4_CLK CLK_M4_ADCHS up to 204 MHz. For register interface. ADCHS ...
- Linux环境安装jdk
Linux中JDK1.6的安装和配置方法 一.安装 创建安装目录,在/usr/java下建立安装路径,并将文件考到该路径下: # mkdir /usr/java 1.jdk-6u11-linux-i5 ...