Send and consume

Producers of the download:Kafka core source code interpretation

bin/kafka-console-producer.sh –broker-list localhost:9092 –topic test

consumers

bin/kafka-console-consumer.sh –zookeeper localhost:2181 –topic test

New producer (support version 0.9 +)

bin/kafka-console-producer.sh –broker-list localhost:9092 –topic test –producer.config config/producer.properties

New Consumer (support version 0.9 +)

bin/kafka-console-consumer.sh –bootstrap-server localhost:9092 –topic test –new-consumer –from-beginning –consumer.config config/consumer.properties

Kafka-verifiable -consumer.sh kafka-verifiable-consumer.sh

bin/kafka-verifiable-consumer.sh –broker-list localhost:9092 –topic test –group-id groupName

Advanced point usage

bin/kafka-simple-consumer-shell.sh –brist localhost:9092 –topic test –partition 0 –offset 1234 –max-messages 10 Copy switch leader

Kafka version <= 2.4

bin/kafka-preferred-replica-election.sh –zookeeper zk_host:port/chroot

Kafka new version

bin/kafka-preferred-replica-election.sh –bootstrap-server broker_host:port

Copy kafka comes with a throughput command bin/kafka-producer-perf-test.sh –topic test –num-records 100 –record-size 1 –throughput 100 –producer-props bootstrap.servers=localhost:9092 Copy Kafka keeps sending messages to the specified topic, and each message has a response:

kafka-verifiable-producer.sh –broker-list $(hostname -i):9092 –topic test –max-messages 100000 Copy Zookeeper-shell. sh If the KAFka cluster zK is configured with the chroot path, /path is required.

bin/zookeeper-shell.sh localhost:2181[/path] ls /brokers/ids get /brokers/ids/0