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权威指南
84
5
修改,而且
broker
要知道如何处理包含了两种消息格式的文件。
Kafka
附带了一个叫
DumpLogSe�ent
的工具,可以用它查看片段的内容。它可以显示每
个消息的偏移量、校验和、魔术数字节、消息大小和压缩算法。运行该工具的方法如下:
bin/kafka-run-class.sh kafka.tools.DumpLogSegments
如果使用了 --deep-iteration 参数,可以显示被压缩到包装消息里的消息。
5.5.4
 索引
消费者可以从
Kafka
的任意可用偏移量位置开始读取消息。假设消费者要读取从偏移量
100
开始的
1MB
消息,那么
broker
必须立即定位到偏移量
100
(可能是在分区的任意一个片段
里),然后开始从这个位置读取消息。为了帮助
broker
更快地定位到指定的偏移量,
Kafka
为每个分区维护了一个索引。索引把偏移量映射到片段文件和偏移量在文件里的位置。
索引也被分成片段,所以在删除消息时,也可以删除相应的索引。
Kafka
不维护索引的
校验和。如果索引出现损坏,
Kafka
会通过重新读取消息并录制偏移量和位置来重新生
成索引。如果有必要,管理员可以删除索引,这样做是绝对安全的,
Kafka
会自动重新
生成这些索引。
5.5.5
 清理
一般情况下,
Kafka
会根据设置的时间保留数据,把超过时效的旧数据删除掉。不过,试
想一下这样的场景,如果你使用
Kafka
保存客户的收货地址,那么保存客户的最新地址比
保存客户上周甚至去年的地址要有意义得多,这样你就不用担心会用错旧地址,而且短时 ...
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