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权威指南
74
5
在关闭
broker
时,它对应的节点也会消失,不过它的
ID
会继续存在于其他数据结构中。
例如,主题的副本列表(下面会介绍)里就可能包含这些
ID
。在完全关闭一个
broker
后,如果使用相同的
ID
启动另一个全新的
broker
,它会立即加入集群,并拥有与旧
broker
相同的分区和主题。
5.2
 控制器
控制器其实就是一个
broker
,只不过它除了具有一般
broker
的功能之外,还负责分区
首领的选举(我们将在
5.3
节讨论分区首领选举)。集群里第一个启动的
broker
通过在
Zookeeper
里创建一个临时节点 /controller
让自己成为控制器。其他
broker
在启动时也
会尝试创建这个节点,不过它们会收到一个“节点已存在”的异常,然后“意识”到控制
器节点已存在,也就是说集群里已经有一个控制器了。其他
broker
在控制器节点上创建
Zookeeper
watch
对象,这样它们就可以收到这个节点的变更通知。这种方式可以确保集群
里一次只有一个控制器存在。
如果控制器被关闭或者与
Zookeeper
断开连接,
Zookeeper
上的临时节点就会消失。集群
里的其他
broker
通过 watch 对象得到控制器节点消失的通知,它们会尝试让自己成为新的
控制器。第一个在
Zookeeper
里成功创建控制器节点的
broker
就会成为新的控制器,其他
节点会收到“节点已存在”的异常,然后在新的控制器节点上再次创建 watch 对象。每个
新选出的控制器通过
Zookeeper
的条件递增操作获得一个全新的、数值更大的 ...
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