Windows操纵kafka

启动kafk

安装目录下

 .\bin\windows\kafka-server-start.bat .\config\server.properties

创建一个测试主题

安装目录下

.\bin\windows\kafka-topics.bat --create --topic first --bootstrap-server localhost:9092 --partitions 1 --replication-factor 1

参数 描述

  • bootstrap-server <String: server toconnect to> 连接的 Kafka Broker 主机名称和端口号。
  • topic <String: topic> 操作的 topic 名称。
  • create 创建主题。
  • delete 删除主题。
  • alter 修改主题。
  • list 查看所有主题。
  • describe 查看主题详细描述。
  • partitions <Integer: # of partitions> 设置分区数。
  • replication-factor<Integer: replication factor> 设置分区副本。
  • config <String: name=value> 更新系统默认的配置。

查看所有主题

.\bin\windows\kafka-topics.bat --bootstrap-server localhost:9092 --list

查看first详细信息

.\bin\windows\kafka-topics.bat --bootstrap-server localhost:9092 --describe --topic first

在这里插入图片描述

  • PartitionCount
  • ReplicationFactor
  • Partition

修改分区数(分区数只能增加 不能减少)

.\bin\windows\kafka-topics.bat --bootstrap-server 
localhost:9092 --alter --topic first --partitions 3

删除主题

.\bin\windows\kafka-topics.bat --bootstrap-server 
localhost:9092  --delete--topic first

生产者生产数据

.\bin\windows\kafka-console-producer.bat --bootstrap-server localhost:9092 --topic first

在这里插入图片描述

消费命令

.\bin\windows\kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic first --from-beginning
  • bootstrap-server <String: server toconnect to> 连接的 Kafka Broker 主机名称和端口号。
  • topic <String: topic> 操作的 topic 名称
  • from-beginning 从头开始消费。
  • group <String: consumer group id> 指定消费者组名称。
    在这里插入图片描述
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值