Home  >  Article  >  Java  >  Kafka Common Commands Quick Reference Manual: Essential for Efficient Work

Kafka Common Commands Quick Reference Manual: Essential for Efficient Work

王林
王林Original
2024-01-31 21:25:05689browse

Kafka Common Commands Quick Reference Manual: Essential for Efficient Work

Kafka commands at a glance: Quickly improve work efficiency

Apache Kafka is a popular message queue service that can help you build high-throughput, low-latency applications program. If you need to use Kafka in your application, you need to be familiar with Kafka's various commands.

This article will provide you with an overview of Kafka commands to help you quickly improve your work efficiency.

1. Producer command

  • kafka-console-producer: This command allows you to send data to Kafka from the command line.
  • kafka-producer: This command allows you to send data to Kafka using the Java API.

2. Consumer command

  • kafka-console-consumer: This command allows you to read data from Kafka from the command line.
  • kafka-consumer: This command allows you to read data from Kafka using the Java API.

3. Management command

  • kafka-topics: This command allows you to manage topics in Kafka.
  • kafka-brokers: This command allows you to manage brokers in Kafka.
  • kafka-admin: This command allows you to manage a cluster in Kafka.

4. Tool command

  • kafka-cat: This command allows you to view messages in Kafka.
  • kafka-diff: This command allows you to differentiate clusters in Kafka.
  • kafka-mirror-topics: This command allows you to mirror topics in Kafka to another cluster.

5. Configuration command

  • kafka-configs: This command allows you to manage the configuration files of the cluster in Kafka.

Specific command examples

1. Use kafka-console-producer to send data to Kafka

bin/kafka-console-producer --broker-list localhost:9092 --producer-property parse.key=true --producer-property key.separator=, --producer-property print.key=true --producer-property value.serializer=StringEncoder --producer-property key.serializer=StringEncoder --producer-config config/producer.config --request-required-ACKS=1

2. Use kafka-console-consumer to read from Kafka Get data

bin/kafka-console-consumer --broker-list localhost:9092 --consumer-property auto.offset.reset=earlies --consumer-property group.id=my-consumer-group --consumer-property key.deserializer=StringDecoder --consumer-property value.deserializer=StringDecoder --consumer-config config/consumer.config --from-beginning --max-message-count 10

3. Use kafka-topics to manage topics in Kafka

bin/kafka-topics --create --zookeeper localhost:2181 --replication-failover-replication-set 3 --replication-failover-max-retries 10 --replication-failover-backoff-ms 1000 --default-replication-factors 1 --num-replicas 1 --partitions 1 --describe --list --delete --assignment --authorized-operators

4. Use kafka-brokers to manage brokers in Kafka

bin/kafka-brokers --describe --create-topics --delete-topics --add-replicas-to-broker --remove-replicas-from-broker --enable-controller --shutdown --update-config --config

5. Use kafka- admin manages the cluster in Kafka

bin/kafka-admin --create-topics --delete-topics --describe-topics --create-users --delete-users --describe-users --create-acls --delete-acls --describe-acls --describe-config --config

Summary

This article provides you with an overview of Kafka commands to help you quickly improve work efficiency. These commands help you manage topics, brokers, clusters, and data in Kafka.

If you want to know more about Kafka, you can refer to the official Kafka documentation.

The above is the detailed content of Kafka Common Commands Quick Reference Manual: Essential for Efficient Work. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn