Kafka3.x KRaft 模式 (没有zookeeper) 常用命令

版本号:kafka_2.12-3.7.0

说明:如有多个地址,用逗号分隔

创建主题

复制代码
bin/kafka-topics.sh --bootstrap-server localhost:9092 --create --topic demo --partitions 1 --replication-factor 1

删除主题

复制代码
bin/kafka-topics.sh  --delete --bootstrap-server localhost:9092 --topic demo

查看所有主题

复制代码
bin/kafka-topics.sh  --list  --bootstrap-server localhost:9092 

查看单个主题详细

复制代码
bin/kafka-topics.sh  --bootstrap-server localhost:9092  --describe --topic test

查看所有消费组

复制代码
bin/kafka-consumer-groups.sh --bootstrap-server  localhost:9092 --list

查看单个消费组情况

复制代码
bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe  --group test_group

删除消费组

复制代码
bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --delete --group test_group

数据保留时间

bash 复制代码
bin/kafka-configs.sh --bootstrap-server localhost:9092 --alter --entity-type topics --entity-name test --add-config retention.ms=3600000

参数解释:

  • --bootstrap-server localhost:9092:指定 Kafka broker 地址。
  • --alter:表示你要修改现有的配置。
  • --entity-type topics:指定要修改的对象类型是 topic。
  • --entity-name test:指定要修改的主题名称,这里是 test
  • --add-config retention.ms=3600000:设置 retention.ms 配置为 3600000 毫秒(1小时)。
相关推荐
whaledown13 小时前
互联网大厂Java求职面试三轮提问详解(涵盖Spring Boot、微服务、Kafka等核心技术)
java·jvm·数据库·spring boot·微服务·面试·kafka
梦想的颜色1 天前
【Docker部署插件】:使用 Docker 部署生产级 Kafka 完整版教程
安全·docker·中间件·kafka·消息队列·docker-compose·后端开发
考虑考虑1 天前
kafka4安装
后端·kafka·自动化运维
lzhcoder2 天前
Spring Boot 集成 Kafka:先跑通 Demo,再避开那 80% 的人踩过的坑
java·kafka
Kyrie_Li4 天前
Spring Boot Kafka 生产级配置全解析:从入门到精通
spring boot·后端·kafka
2301_801184754 天前
kafka-zookeeper
分布式·zookeeper·kafka
Devin~Y4 天前
抖音级短视频推荐与直播带货平台面试实战:从 Java 微服务到 RAG 智能客服全链路解析
java·spring boot·redis·spring cloud·kafka·agent·rag
livemetee5 天前
关于【Kafka高可用配置】
分布式·kafka
TTBIGDATA5 天前
【Ambari Plus】11.Kafka 安装
大数据·hadoop·分布式·kafka·ambari·hdp·ambari plus
rebibabo5 天前
Java基础(番外) | Kafka 入门:分区、副本与消费者组原理
java·分布式·kafka·学习笔记·副本·分区·异步日志