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权威指南
管理
Kafka
137
9.1.1
 创建主题
在集群里创建一个主题需要用到
3
个参数。这些参数是必须提供的,尽管有些已经有了
broker
级别的默认值。
主题名字
想要创建的主题的名字。
复制系数
主题的副本数量。
分区
主题的分区数量。
指定主题配置
可以在创建主题时显式地指定复制系数或者对配置进行覆盖,不过我们不打
算在这里介绍如何做到这些。稍后会介绍如何进行配置覆盖,它们是通过向
kafka-topics.sh
传递
--config
参数来实现的。本章还会介绍分区的重分配。
主题名字可以包含字母、数字、下划线以及英文状态下的破折号和句号。
主题的命名
主题名字的开头部分包含两个下划线是合法的,但不建议这么做。具有这种
格式的主题一般是集群的内部主题(比如
__consumer_offsets
主题用于保存
消费者群组的偏移量)。也不建议在单个集群里使用英文状态下的句号和下
划线来命名,因为主题的名字会被用在度量指标上,句号会被替换成下划线
(比如“
topic.1
”会变成“
topic_1
”)。
试着运行下面的命令:
kafka-topics.sh --zookeeper <zookeeper connect> --create --topic <string>
--replication-factor <integer> --partitions <integer>
这个命令将会创建一个主题,主题的名字为指定的值,并包含了指定数量的分区。集群会
为每个分区创建指定数量的副本。如果为集群指定了基于机架信息的副本分配策略,那么
分区的副本会分布在不同的机架上。如果不需要基于机架信息的分配策略,可以指定参数 ...
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