Skip to content

Instantly share code, notes, and snippets.

@KomanRudden
Last active January 19, 2021 18:26
Show Gist options
  • Save KomanRudden/7fb4fe05e332a7fdb755922e6c5e3324 to your computer and use it in GitHub Desktop.
Save KomanRudden/7fb4fe05e332a7fdb755922e6c5e3324 to your computer and use it in GitHub Desktop.
Kafka Topics CLI
List all topics
>kafka-topics.sh --bootstrap-server localhost:9092 --list
my-topic
Create new topic
>kafka-topics.sh --bootstrap-server localhost:9092 --create --topic my-topic --replication-factor 3 --partitions 3
Created topic my-topic
Describe topic
>kafka-topics.sh --bootstrap-server localhost:9092 --topic my-topic --describe
`Topic: my-topic PartitionCount: 3 ReplicationFactor: 1 Configs: segment.bytes=1073741824
Topic: my-topic Partition: 0 Leader: 0 Replicas: 0 Isr: 0
Topic: my-topic Partition: 1 Leader: 0 Replicas: 0 Isr: 0
Topic: my-topic Partition: 2 Leader: 0 Replicas: 0 Isr: 0`
Delete topic
>kafka-topic.sh --bootstrap-server localhost:9092 --topic my-topic --delete
Alter topic partitions
>kafka-topics.sh --bootstrap-server localhost:9092 --alter --topic my-topic --partitions 6
>kafka-topics.sh --bootstrap-server localhost:9092 --topic my-topic --describe
`Topic: my-topic PartitionCount: 6 ReplicationFactor: 1 Configs: segment.bytes=1073741824
Topic: my-topic Partition: 0 Leader: 0 Replicas: 0 Isr: 0
Topic: my-topic Partition: 1 Leader: 0 Replicas: 0 Isr: 0
Topic: my-topic Partition: 2 Leader: 0 Replicas: 0 Isr: 0
Topic: my-topic Partition: 3 Leader: 0 Replicas: 0 Isr: 0
Topic: my-topic Partition: 4 Leader: 0 Replicas: 0 Isr: 0
Topic: my-topic Partition: 5 Leader: 0 Replicas: 0 Isr: 0`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment