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版)
226
12
版本检查
Kafka
的很多命令行工具对
Kafka
版本有所依赖
,一些命令可能会将数据保
存在
ZooKeeper
中而不是
broker
中。因此,你需要确保命令行工具的版本与
集群
broker
的版本相匹配。直接使用
broker
自带的命令行工具是最保险的。
12.1.1
 创建新主题
在使用
--create
命令创建新主题时,必须提供几个参数,即使其中一些参数可能已经有了
broker
级别的默认值
。还可以通过
--config
选项指定其他参数和覆盖默认值,本章将在后
面部分讨论这方面的内容。下面是必须提供的
3
个参数。
--topic
想要创建的主题的名字。
--replication-factor
主题的副本数量。
--partitions
主题的分区数量。
主题命名最佳实践
主题的名字可以包含字母数字字符、下划线、破折号和点号,但不建议使用
点号。
Kafka
的内部指标会将点号转成下划线
(例如,“
topic.1
”在指标中会
变成“
topic_1
)
,这可能会导致主题名称冲突。
另外,避免使用双下划线作为主题名字的前缀。根据约定,
Kafka
内部主题的
名字以双下划线开头(例如,用于保存消费者组偏移量的
__consumer_offsets
主题)。因此,为了避免冲突,不建议使用以双下划线开头的主题名字。
创建一个新主题非常简单,只需像下面这样运行
kafka-topics.sh
# kafka-topics.sh --bootstrap-server <connection-string>:<port> --create ...
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