Linux command
kafka-topics 命令
趣味
复制后可按需替换文件名、目录或参数。
常用示例
Create topic
kafka-topics.sh --create --topic [name] --partitions [3] --replication-factor [1] --bootstrap-server [localhost:9092]
List all topics
kafka-topics.sh --list --bootstrap-server [localhost:9092]
Describe topic
kafka-topics.sh --describe --topic [name] --bootstrap-server [localhost:9092]
Delete topic
kafka-topics.sh --delete --topic [name] --bootstrap-server [localhost:9092]
Alter partitions
kafka-topics.sh --alter --topic [name] --partitions [6] --bootstrap-server [localhost:9092]
说明
kafka-topics.sh manages Kafka topics. Topics are the core abstraction for organizing messages in Kafka, with partitions for parallelism and replication for durability.
参数
- --create
- Create new topic.
- --list
- List all topics.
- --describe
- Show topic details.
- --delete
- Delete topic.
- --alter
- Modify topic configuration.
- --topic _name_
- Topic name.
- --partitions _n_
- Number of partitions.
- --replication-factor _n_
- Replication factor.
- --bootstrap-server _servers_
- Kafka broker addresses.
- --config _key=value_
- Topic configuration.
- --if-exists
- Only if topic exists.
- --if-not-exists
- Only if topic doesn't exist.
FAQ
What is the kafka-topics command used for?
kafka-topics.sh manages Kafka topics. Topics are the core abstraction for organizing messages in Kafka, with partitions for parallelism and replication for durability.
How do I run a basic kafka-topics example?
Run `kafka-topics.sh --create --topic [name] --partitions [3] --replication-factor [1] --bootstrap-server [localhost:9092]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --create do in kafka-topics?
Create new topic.