LinuxCommandLibrary

kafka-topics

manages Kafka topics

TLDR

Create topic

$ kafka-topics.sh --create --topic [name] --partitions [3] --replication-factor [1] --bootstrap-server [localhost:9092]
copy
List all topics
$ kafka-topics.sh --list --bootstrap-server [localhost:9092]
copy
Describe topic
$ kafka-topics.sh --describe --topic [name] --bootstrap-server [localhost:9092]
copy
Delete topic
$ kafka-topics.sh --delete --topic [name] --bootstrap-server [localhost:9092]
copy
Alter partitions
$ kafka-topics.sh --alter --topic [name] --partitions [6] --bootstrap-server [localhost:9092]
copy

SYNOPSIS

kafka-topics.sh [options]

DESCRIPTION

kafka-topics.sh manages Kafka topics. Topics are the core abstraction for organizing messages in Kafka, with partitions for parallelism and replication for durability.

PARAMETERS

--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.

TOPIC CONFIGURATIONS

$ # Set retention
--config retention.ms=86400000

# Set cleanup policy
--config cleanup.policy=compact

# Set max message size
--config max.message.bytes=1048576
copy

CAVEATS

Partitions can only be increased, not decreased. Replication factor limited by broker count. Deletion may need to be enabled in config. ZooKeeper connection deprecated.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community