Home > Java > javaTutorial > Steps to create a topic using Kafka command line tool

Steps to create a topic using Kafka command line tool

WBOY
Release: 2024-01-31 18:34:06
Original
677 people have browsed it

Steps to create a topic using Kafka command line tool

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

  • Kafka installed
  • Kafka cluster started
  • Kafka command line tool installed

Steps

  1. Open the command line terminal.
  2. Navigate to the installation directory of the Kafka command line tool.
  3. Run the following command to create a topic:
kafka-topics --create --topic test-topic --partitions 1 --replication-factor 1
Copy after login
Copy after login

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:

  • Create a topic named "test-topic" topic with 1 partition and 1 replica:
kafka-topics --create --topic test-topic --partitions 1 --replication-factor 1
Copy after login
Copy after login
  • Create a topic named "test-topic" with 3 partitions and 2 replicas:
kafka-topics --create --topic test-topic --partitions 3 --replication-factor 2
Copy after login
  • Create a topic named "test-topic" with 1 partition and 3 replicas:
kafka-topics --create --topic test-topic --partitions 1 --replication-factor 3
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template