Kafka 命令总结

//列出所有的topic
kafka-topics --zookeeper localhost:2181 --list
//查看指定topic的分区、副本情况
kafka-topics --zookeeper localhost:2181 --topic test_topic --describe

//消费某个topic,可以从头消费,也可以指定分区或带过滤条件消费
kafka-console-consumer --bootstrap-server localhost:9092 --topic test_topic --from-beginning 
kafka-console-consumer --bootstrap-server localhost:9092 --topic test_topic --partition 2 | grep "test"

//在某个topic生成数据
kafka-console-producer --broker-list localhost:9092 --topic test_topic

//创建topic,可以设定分区、副本,也可以配置一些内容
kafka-topics --create --zookeeper localhost:2181 --replication-factor 2 --partitions 2 --topic test_topic --config message.timestamp.type=CreateTime
//修改某个topic的分区数或配置信息
kafka-topics --alter --zookeeper localhost:2181 --topic test_topic --partitions 4 
kafka-topics --zookeeper localhost:2181 --alter --topic test_topic --config max.partition.fetch.bytes=5252880
//删除某个topic
kafka-topics --zookeeper localhost:2181 --delete --topic test_topic

//获取Kafka每个分区最新Offset的几种方法
kafka-run-class kafka.tools.GetOffsetShell --broker-list localhost:9092 --topic test_topic

//消费组
kafka-consumer-groups --bootstrap-server localhost:9092 --list  //列出当前集群中所有的消费组名称
kafka-consumer-groups --bootstrap-server localhost:9092 --group test_group --describe  //展示消费组test_group的详细信息
kafka-consumer-groups --bootstrap-server localhost:9092 --describe --group test_group --state //展示消费组test_group状态
kafka-consumer-groups --bootstrap-server localhost:9092 --describe --group test_group --members --verbose//展示消费组test_group成员
kafka-consumer-groups --bootstrap-server localhost:9092 --group test_group --delete//删除消费组test_group

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值