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版)
212
11
ROLLBACK
当成员正在回滚数据时会处于此状态,如
1
1.4
节所述。在回滚过程结束时,服务器会
转换回
RECOVERING
状态,然后成为从节点。
11.3
 选举
当一个成员无法访问到主节点(而且本身有资格成为主节点)时,便会申请选举。申请选举
的成员会向其所能访问到的所有成员发出通知。如果这个成员不适合作为主节点,那么其他
成员会知道原因:可能这个成员的数据落后于副本集,或者已经有一个主节点在申请选举,
而那个失败的成员无法访问到此节点。在这些情况下,其他成员将投票反对该成员的申请。
假如没有理由反对,其他成员就会为申请当选的成员投赞成票。如果申请选举的成员从副
本集中获得了大多数选票,选举就成功了,该成员将过渡到
PRIMAR
Y
状态。如果没有获
得大多数选票,那么它会继续处于从节点状态,以后可能会试图再次成为主节点。主节点
会一直处于主节点状态,直到不能满足“大多数”的要求、停止运行、降级,或者副本集
被重新配置为止。
如果网络状态正常并且大多数服务器正常运行,那么选举过程应该是很快的。如果主节点
不可用,那么两秒(由于前面提到过心跳的间隔是两秒)之内就会有成员发现这个问题,
它会立即开始一个选举,而这个过程应该只需要几毫秒。然而,实际情况不会这么理想:
选举可能由网络问题或服务器过载导致的响应过慢而触发。在这些情况下,选举过程可能
需要更多的时间,甚至会花几分钟。
11.4
 回滚
上一节所描述的选举过程意味着,如果主节点执行一个写操作之后停止了运行,而从节点
还没来得及复制此操作,那么新选举出的主节点可能会丢失这个写操作。假设有两个数据 ...
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