Hi, do you know kafka MQ and would you please share some common command with me
Certainly! Apache Kafka is a distributed event streaming platform that is commonly used for building real-time data pipelines and streaming applications. Below are some common commands for managing Kafka, including producing and consuming messages, managing topics, and configuring the Kafka environment.
Start Zookeeper (if using Zookeeper):
bin/zookeeper-server-start.sh config/zookeeper.properties
Start Kafka Broker:
bin/kafka-server-start.sh config/server.properties
Create a Topic:
bin/kafka-topics.sh --create --topic <topic_name> --bootstrap-server localhost:9092 --partitions <num_partitions> --replication-factor <replication_factor>
List Topics:
bin/kafka-topics.sh --list --bootstrap-server localhost:9092
Describe a Topic:
bin/kafka-topics.sh --describe --topic <topic_name> --bootstrap-server localhost:9092
Produce Messages to a Topic:
bin/kafka-console-producer.sh --topic <topic_name> --bootstrap-server localhost:9092
After running this command, you can type messages and press Enter to send them.
Consume Messages from a Topic:
bin/kafka-console-consumer.sh --topic <topic_name> --from-beginning --bootstrap-server localhost:9092
Delete a Topic:
bin/kafka-topics.sh --delete --topic <topic_name> --bootstrap-server localhost:9092
View Consumer Groups:
bin/kafka-consumer-groups.sh --list --bootstrap-server localhost:9092
Describe a Consumer Group:
bin/kafka-consumer-groups.sh --describe --group <group_id> --bootstrap-server localhost:9092
Alter a Topic Configuration:
bin/kafka-configs.sh --alter --entity-type topics --entity-name <topic_name> --add-config <config_key>=<config_value> --bootstrap-server localhost:9092
Produce Messages from a File:
bin/kafka-console-producer.sh --topic <topic_name> --bootstrap-server localhost:9092 < /path/to/file.txt
<topic_name>
, <num_partitions>
, <replication_factor>
, and <group_id>
with your specific values.--bootstrap-server
option specifies the Kafka broker to connect to. Adjust the hostname and port as necessary.These commands should help you get started with basic operations in Kafka. If you have any specific use cases or questions, feel free to ask!