Skip to Content
Kafka权威指南
book

Kafka权威指南

by Neha Narkhede, Gwen Shapira, Todd Palino
January 2018
Beginner to intermediate
234 pages
7h 8m
Chinese
Posts & Telecom Press
Content preview from Kafka权威指南
可靠的数据传递
91
如果不同步的副本不能被提升为新首领,那么分区在旧首领(最后一个同步副本)恢复
之前是不可用的。有时候这种状态会持续数小时(比如更换内存芯片)。
如果不同步的副本可以被提升为新首领,那么在这个副本变为不同步之后写入旧首领的
消息会全部丢失,导致数据不一致。为什么会这样呢?假设在副本
0
和副本
1
不可用时,
偏移量
100~200
的消息被写入副本
2
(首领)。现在副本
2
变为不可用的,而副本
0
为可用的。副本
0
只包含偏移量
0~100
的消息,不包含偏移量
100~200
的消息。如果我
们允许副本
0
成为新首领,生产者就可以继续写入数据,消费者可以继续读取数据。于是,
新首领就有了偏移量
100~200
的新消息。这样,部分消费者会读取到偏移量
100~200
旧消息,部分消费者会读取到偏移量
100~200
的新消息,还有部分消费者读取的是二者
的混合。这样会导致非常不好的结果,比如生成不准确的报表。另外,副本
2
可能会重
新变为可用,并成为新首领的跟随者。这个时候,它会把比当前首领旧的消息全部删除,
而这些消息对于所有消费者来说都是不可用的。
简而言之,如果我们允许不同步的副本成为首领,那么就要承担丢失数据和出现数据不一
致的风险。如果不允许它们成为首领,那么就要接受较低的可用性,因为我们必须等待原
先的首领恢复到可用状态。
如果把
unclean.leader.election.enable
设为
true
,就是允许不同步的副本成为首领(也
就是“不完全的选举”),那么我们将面临丢失消息的风险。如果把这个参数设为 ...
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

精通機器學習

精通機器學習

Aurélien Géron
精通特征工程

精通特征工程

Alice Zheng, Amanda Casari
高效能PYTHON程式設計

高效能PYTHON程式設計

Micha Gorelick, Ian Ozsvald

Publisher Resources

ISBN: 9787115473271