Learn to use common Kafka commands and flexibly respond to various scenarios.
Essentials for learning Kafka: master common commands and easily cope with various scenarios
1. Create a Topic
bin/kafka-topics.sh --create --topic my-topic --partitions 3 --replication-factor 2
2. List Topic
bin/kafka-topics.sh --list
3. View Topic details
bin/kafka-topics.sh --describe --topic my-topic
4. Production message
bin/kafka-console-producer.sh --topic my-topic --message "Hello, Kafka!"
5. Consume messages
bin/kafka-console-consumer.sh --topic my-topic --from-beginning
6. Change the number of partitions
bin/kafka-topics.sh --alter --topic my-topic --partitions 5
7. Change Number of copies
bin/kafka-topics.sh --alter --topic my-topic --replication-factor 3
8. Delete Topic
bin/kafka-topics.sh --delete --topic my-topic
9. Create consumer group
bin/kafka-consumer-groups.sh --create --group my-group
10. List consumer groups
bin/kafka-consumer-groups.sh --list
11. View consumer group details
bin/kafka-consumer-groups.sh --describe --group my-group
12. Add consumers to consumers Group
bin/kafka-consumer-groups.sh --join --group my-group --topic my-topic
13. Remove the consumer from the consumer group
bin/kafka-consumer-groups.sh --leave --group my-group --topic my-topic
14. Delete the consumer group
bin/kafka-consumer-groups.sh --delete --group my-group
15. Get the offset of Topic
bin/kafka-run-class kafka.tools.GetOffsetShell --topic my-topic --group my-group
16. Set the offset of Topic
bin/kafka-run-class kafka.tools.OffsetResetTool --topic my-topic --group my-group --to-earliest
17. Monitor the Kafka cluster
bin/kafka-server-start.sh --daemon --console
18. Shut down the Kafka cluster
bin/kafka-server-stop.sh
19. Diagnose the Kafka cluster
bin/kafka-run-class kafka.tools.JmxTool --query "kafka.server:type=*,name=*,clientId=*"
20. Export the configuration of the Kafka cluster
bin/kafka-run-class kafka.tools.DumpLogSegments --print-data --source /tmp/kafka-logs
21. Import the configuration of the Kafka cluster
bin/kafka-run-class kafka.tools.LoadLogSegments --source /tmp/kafka-logs
22. Upgrade the Kafka cluster
bin/kafka-upgrade-kafka.sh --target-version 3.0.0
23. Downgrade the Kafka cluster
bin/kafka-downgrade-kafka.sh --target-version 2.8.0
The above is the detailed content of Learn to use common Kafka commands and flexibly respond to various scenarios.. For more information, please follow other related articles on the PHP Chinese website!

The article discusses using Maven and Gradle for Java project management, build automation, and dependency resolution, comparing their approaches and optimization strategies.

The article discusses creating and using custom Java libraries (JAR files) with proper versioning and dependency management, using tools like Maven and Gradle.

The article discusses implementing multi-level caching in Java using Caffeine and Guava Cache to enhance application performance. It covers setup, integration, and performance benefits, along with configuration and eviction policy management best pra

The article discusses using JPA for object-relational mapping with advanced features like caching and lazy loading. It covers setup, entity mapping, and best practices for optimizing performance while highlighting potential pitfalls.[159 characters]

Java's classloading involves loading, linking, and initializing classes using a hierarchical system with Bootstrap, Extension, and Application classloaders. The parent delegation model ensures core classes are loaded first, affecting custom class loa


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version
Visual web development tools

Notepad++7.3.1
Easy-to-use and free code editor