Kakfa CLI

53 阅读1分钟

创建 topic

./bin/kafka-topics.sh --bootstrap-server kafka:9092 --create --replication-factor 3 --partitions 3 --topic test

查看 topic 配置

./bin/kafka-topics.sh --bootstrap-server kafka:9092 --describe --topic test

增加/修改 topic 配置

./bin/kafka-configs.sh --bootstrap-server kafka:9092 --entity-type topics --entity-name test --alter --add-config retention.hours=24

生产者生产消息

./bin/kafka-console-producer.sh --bootstrap-server kafka:9092 --topic test

消费者消费消息

./bin/kafka-console-consumer.sh --bootstrap-server kakfa:9092 --topic test|grep "工单发送"

可以直接使用 grep 进行过滤查询

查看消费组消费情况, 是否有积压

./bin/kafka-consumer-groups.sh --bootstrap-server kafka:9092 --describe --group event-batch-consumer-group

# 也可以根据 `topic` 名称模糊查询
./bin/kafka-consumer-groups.sh --bootstrap-server kafka:9092 --describe --all-groups|grep workflow_batch_action