Skip to Content
Kafka权威指南(第2版)
book

Kafka权威指南(第2版)

by Gwen Shapira, Todd Palino, Rajini Sivaram, Krit Petty
November 2022
Beginner to intermediate
346 pages
11h
Chinese
Posts & Telecom Press
Content preview from Kafka权威指南(第2版)
精确一次性语义
137
这两条消息有不同的生产者
ID
和序列号,将被视为两条不同的消息。需要注意的是,如
果一个旧生产者被挂起,但在替代它的新生产者启动之后又“活”过来了,那么情况也一
样——旧生产者不会被认为是“僵尸”,它们是两个拥有不同
ID
的生产者。
2. broker
故障
当一个
broker
发生故障时
,控制器将为首领副本位于这个
broker
上的分区选举新首领。假
设我们有一个生产者,它向主题
A
的分区
0
生成消息
,分区
0
的首领副本在
broker 5
上,
跟随者副本在
broker
3
上。如果
broker 5
发生故障,那么
broker 3
就会成为新首领。生产
者通过元数据协议发现
broker 3
是新首领,并开始向它生成消息。
broker3
如何知道哪些序列号已经生成过了?
每次生成新消息时,首领都会用最后
5
个序列号更新内存中的生产者状态
。每次从首领复
制新消息时,跟随者副本都会更新自己的内存。当跟随者成为新首领时,它的内存中已经
有了最新的序列号,并且可以继续验证新生成的消息,不会有任何问题或延迟。
但是,如果旧首领又“活”过来了,会发生什么呢?在重启之后,内存中没有旧首领的生
产者状态。为了能够恢复状态,每次在关闭或创建日志片段时
broker
会将生产者状态快
照保存到文件中。
broker
在启动时会从快照文件中读取最新状态
,然后通过复制当前首领
来更新生产者状态。当它准备好再次成为首领时,内存中已经有了最新的序列号。
如果
broker
发生崩溃
,但没有更新最后一个快照,会发生什么呢?生产者
ID
和序列号也 ...
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

时间序列分析实战:基于机器学习和统计学

时间序列分析实战:基于机器学习和统计学

Aileen Nielsen
Spark机器学习实战

Spark机器学习实战

Posts & Telecom Press, Siamak Amirghodsi, Meenakshi Rajendran, Broderick Hall, Shuen Mei
写给系统管理员的Python脚本编程指南

写给系统管理员的Python脚本编程指南

Posts & Telecom Press, Ganesh Sanjiv Naik
Kubernetes编程

Kubernetes编程

Michael Hausenblas, Stefan Schimanski

Publisher Resources

ISBN: 9787115601421