How to create a topic using the Kafka command line tool
Overview
The Kafka command line tool is A powerful tool for managing Kafka clusters. It can be used to create, delete, list, and describe topics, as well as produce and consume messages. In this article, we will show you how to create a topic using the Kafka command line tool.
Prerequisites
Steps
kafka-topics --create --topic test-topic --partitions 1 --replication-factor 1
This command will create a topic named "test-topic" with 1 partition and 1 replica.
Parameters
--create
: Specify the topic to be created. --topic
: Specify the name of the topic to be created. --partitions
: Specify the number of partitions for the topic. --replication-factor
: Specifies the number of replicas of the topic. Other options
In addition to the above parameters, the Kafka command line tool also provides many other options. For more information, see the man page of the Kafka command line tool.
Examples
The following are some examples of creating topics using the Kafka command line tools:
kafka-topics --create --topic test-topic --partitions 1 --replication-factor 1
kafka-topics --create --topic test-topic --partitions 3 --replication-factor 2
kafka-topics --create --topic test-topic --partitions 1 --replication-factor 3
Conclusion
The Kafka command line tool is a powerful tool that can be used to manage Kafka clusters. It can be used to create, delete, list, and describe topics, as well as produce and consume messages. In this article, we showed you how to create a topic using the Kafka command line tool.
The above is the detailed content of Steps to create a topic using Kafka command line tool. For more information, please follow other related articles on the PHP Chinese website!