All Kafka Development Commands Explained – 2026 Edition
This guide walks through the essential Kafka command‑line tools for creating, listing, describing, and altering topics, producing and consuming messages, and managing consumer groups, providing concrete examples and key parameters for each operation.
Kafka command‑line utilities for development and testing.
Create a Topic
kafka-topics.sh \
--create \
--topic order \
--bootstrap-server localhost:9092 \
--partitions 3 \
--replication-factor 1Core parameters: --topic: topic name --partitions: number of partitions --replication-factor: number of replicas --bootstrap-server: broker address
Resulting structure:
order-topic
├── Partition0
├── Partition1
└── Partition2List all Topics
kafka-topics.sh \
--list \
--bootstrap-server localhost:9092Typical output:
order-topic
user-topic
payment-topicDescribe Topic Details
kafka-topics.sh \
--describe \
--topic order \
--bootstrap-server localhost:9092Key fields:
PartitionCount
Leader
Replicas
ISR (in‑sync replicas)
ISR anomalies are a primary entry point for troubleshooting replica synchronization issues.
Increase Topic Partitions
kafka-topics.sh \
--alter \
--topic order \
--partitions 6 \
--bootstrap-server localhost:9092Note: Kafka can only increase partitions; it cannot decrease them directly.
Delete a Topic
kafka-topics.sh \
--delete \
--topic order \
--bootstrap-server localhost:9092Deletion in production should be performed with caution; verify the topic list first.
Produce Messages
kafka-console-producer.sh \
--topic order \
--bootstrap-server localhost:9092Example input:
order-1001
order-1002
order-1003Messages are sent to order-topic.
Consume Messages
kafka-console-consumer.sh \
--topic order \
--bootstrap-server localhost:9092The consumer continuously reads new messages.
Consume from the Beginning
kafka-console-consumer.sh \
--topic order \
--bootstrap-server localhost:9092 \
--from-beginningUseful for development testing, message loss investigation, and historical verification.
List Consumer Groups
kafka-consumer-groups.sh \
--list \
--bootstrap-server localhost:9092Typical groups: order-service-group, payment-service-group, user-service-group.
Describe Consumer Group Consumption
kafka-consumer-groups.sh \
--describe \
--bootstrap-server localhost:9092 \
--group order-service-groupSample output shows each partition’s current offset, log end offset, and lag:
TOPIC PARTITION CURRENT-OFFSET LOG-END-OFFSET LAG
order-topic 0 1000 1050 50
order-topic 1 1200 1200 0
order-topic 2 900 1000 100Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Architect Chen
Sharing over a decade of architecture experience from Baidu, Alibaba, and Tencent.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
