← 返回命令列表

Linux command

kafka 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

Start Kafka server

kafka-server-start.sh [config/server.properties]

Stop Kafka server

kafka-server-stop.sh

Create a topic with partitions and replication

kafka-topics.sh --create --topic [mytopic] --partitions [3] --replication-factor [1] --bootstrap-server [localhost:9092]

List all topics

kafka-topics.sh --list --bootstrap-server [localhost:9092]

Describe a topic

kafka-topics.sh --describe --topic [mytopic] --bootstrap-server [localhost:9092]

Produce messages to a topic

kafka-console-producer.sh --topic [mytopic] --bootstrap-server [localhost:9092]

Consume messages from the beginning

kafka-console-consumer.sh --topic [mytopic] --from-beginning --bootstrap-server [localhost:9092]

说明

Apache Kafka is a distributed event streaming platform. It provides high-throughput, low-latency message handling for real-time data pipelines and streaming applications. Kafka organizes messages into topics, with partitions for parallelism and replication for fault tolerance. Producers send messages; consumers read them.

FAQ

What is the kafka command used for?

Apache Kafka is a distributed event streaming platform. It provides high-throughput, low-latency message handling for real-time data pipelines and streaming applications. Kafka organizes messages into topics, with partitions for parallelism and replication for fault tolerance. Producers send messages; consumers read them.

How do I run a basic kafka example?

Run `kafka-server-start.sh [config/server.properties]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

Where can I find more kafka examples?

This page includes 7 examples for kafka, plus related commands for nearby Linux tasks.