Kafka操作

目录

一、创建主题

二、查看主题

三、修改分区数

四、删除主题

五、生产数据

六、创建消费组


一、创建主题

--- kafka-topics.sh

---bootstrap-server 指定连接的kafka服务

  • --create 创建主题

  • --partitions 指定分区数 默认一个

  • --replication-factor 指定分区中的副本数量 默认一个

  • --topic 指定主题名称

kafka-topics.sh --bootstrap-server node1:9092 --create --partitions 3 --replication-factor 3 --topic test1

二、查看主题

  • --kafka-topics.sh

  • --bootstrap-server 指定连接的kafka服务

  • --list 查看所有主题

  • --describe 查看详情信息

  • --describe --topic itcast 查看某个主题详情信息

查看有哪些主题

kafka-topics.sh --bootstrap-server node1:9092 --list

查看所有主题详情信息

kafka-topics.sh --bootstrap-server node1:9092 --describe

查看某个具体主题详请

kafka-topics.sh --bootstrap-server node1:9092 --describe --topic test1

三、修改分区数

-- - kafka-topics.sh

  • --bootstrap-server 指定连接的kafka服务

  • --alter 修改主题
    kafka-topics.sh --bootstrap-server node1:9092 --alter --partitions 3 --topic test01

四、删除主题

  • --kafka-topics.sh

  • --bootstrap-server 指定连接的kafka服务

  • --delete 删除主题
    kafka-topics.sh --bootstrap-server node1:9092 --delete --topic test01

五、生产数据

--kafka-console-producer.sh --brooker-list node1 --topic test

六、创建消费组

数据源,创建消费者组消费指定topic,并从指定 offset 开始消费数据

相关推荐
pnoker1 天前
IoT DC3 消息总线:六适配器可插拔设计
物联网·架构·kafka·消息队列·rabbitmq
cxhello1 天前
消费者活着、心跳正常、日志干净,但它七天没拉过一条消息
python·kafka
Lost of 程序猿1 天前
ASP.NET Core Saga 分布式事务深度实战:备件采购跨服务长流程,如何保证“要么全成,要么全回“
分布式·后端·asp.net
XiYang-DING1 天前
地图城市缓存优化:ApplicationReadyEvent + Caffeine + Redis + Redisson 分布式锁
redis·分布式·缓存
2601_962175661 天前
RabbitMQ 的工作模式
分布式·rabbitmq
头茬韭菜2 天前
图解 Fluss(四):分布式协调 —— 选举、副本状态机与
分布式·fluss
2601_962218612 天前
万象生鲜系统全链路溯源一码查询技术实现食材来源可查
分布式·微服务·云原生·架构
Dreams_l2 天前
RabbitMQ介绍及其工作模式
分布式·rabbitmq
2601_962218612 天前
万象生鲜系统大数据采购预测算法降低库存积压稳居第一
分布式·微服务·云原生·架构
程序员夏洛2 天前
Redis 中如何实现分布式锁?
数据库·redis·分布式