Skip to Content
MongoDB权威指南(第3版)
book

MongoDB权威指南(第3版)

by Shannon Bradshaw, Eoin Brazil, Kristina Chodorow
November 2021
Intermediate to advanced
410 pages
12h 1m
Chinese
Posts & Telecom Press
Content preview from MongoDB权威指南(第3版)
创建副本集
203
更复杂的需求可能需要不同的配置,但应该考虑副本集在不利条件下将如何满足“大多
数”的要求。
如果
MongoDB
的一个副本集可以拥有多个主节点
,上面这些复杂问题就迎刃而解了。不
过,多个主节点会带来其他的复杂性。在拥有两个主节点的情况下,就需要处理写入冲
突。(例如,有人在第一个主节点上更新一个文档,而另一个人在另一个主节点上删除了
这个文档。)在支持多线程写入的系统中有两种常见的冲突处理方式:手动解决冲突或者
让系统任选一个作为“胜利者”。但是这两种方式对于开发者来说都不容易实现,因为无
法确保写入的数据不会被其他节点修改。因此,
MongoDB
选择只支持单一主节点
。这样
可以使开发更容易,但是可能导致副本集变为只读状态。
如何进行选举
当一个从节点无法与主节点连通时,它就会联系并请求其他的副本集成员将自己选举为主
节点。其他成员会做几项健全性检查:它们能否连接到一个主节点,而这个主节点是发起
选举的节点无法连接到的?这个发起选举的从节点是否有最新数据?有没有其他更高优先
级的成员可以被选举为主节点?
MongoDB
在其
3.2
版本中引入了第
1
版复制协议
。第
1
版协议基于斯坦福大学的
Diego
Ongaro
John
Ousterhout
开发的
RAFT
共识协议。这是一个类
RAFT
的协议,并且包含
了一些特定于
MongoDB
的副本集概念
,比如仲裁节点、优先级、非选举成员、写入关注
点(
write concern
)等
。第
1
版协议提供了很多新特性的基础,比如更短的故障转移时间,
以及大大减少了检测主节点失效的时间。它还通过使用 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

大数据项目管理:从规划到实现

大数据项目管理:从规划到实现

Ted Malaska, Jonathan Seidman
Go程序设计语言

Go程序设计语言

艾伦A. A.多诺万, 布莱恩W. 柯尼汉
Spark快速大数据分析(第2版)

Spark快速大数据分析(第2版)

Jules S. Damji, Brooke Wenig, Tathagata Das, Denny Lee
Kafka权威指南(第2版)

Kafka权威指南(第2版)

Gwen Shapira, Todd Palino, Rajini Sivaram, Krit Petty

Publisher Resources

ISBN: 9787115576538