kafka脚本总结

//新建topic

./bin/kafka-topics.sh --create --zookeeper node:2181 --topic test --partitions 2 --replication-factor 1


//修改partition数 只能增

./bin/kafka-topics.sh --alter --topic test2 --zookeeper node:2181 --partitions 3  


//删除topic

./bin/kafka-topics.sh  --delete --topic test --zookeeper node:2181


//查看topic列表

./bin/kafka-topics.sh --list --zookeeper node:2181


//查看消费情况

./bin/kafka-run-class.sh kafka.tools.ConsumerOffsetChecker  --zookeeper node:2181  --group jd-group4 --topic test2


//启动消费者

./bin/kafka-console-consumer.sh --topic test6 --zookeeper node:2181

# 启用删除主题
delete.topic.enable=true
# 检查日志段文件的间隔时间,以确定是否文件属性是否到达删除要求。
log.retention.check.interval.ms=1000


注意:这2行配置必须存在,否则清除策略失效!

log.retention.check.interval.ms 参数的单位是微秒,这里表示间隔1秒钟


//启动生产者

./bin/kafka-console-producer.sh  --topic test6 --broker-list node:9092


//从头开始消费

./bin/kafka-console-consumer.sh --zookeeper node:2181 --topic test --from-beginning

//查看消费积压

./bin/kafka-run-class.sh kafka.tools.ConsumerOffsetChecker  --zookeeper zkserver1:2181 --group test --topic major_info

#查看consumer group列表


./bin/kafka-consumer-groups.sh --new-consumer --bootstrap-server 192.168.10.182:9092 --list

# 查看指定consumer group详情

./bin/kafka-consumer-groups.sh --new-consumer --bootstrap-server 192.168.10.182:9092 --group yimin_002 --describe


#查看指定group_id对指定group的消费情况

./bin/kafka-run-class.sh kafka.tools.ConsumerOffsetChecker --zookeeper xx.xx.10.182:2181   --topic news_ref_zh_entity --group yimin_zh


#查看kafka特定topic的详情,使用–topic与–describe参数


./bin/kafka-topics.sh --zookeeper xx.xx.10.182:2181 --topic news_ref_zh_entity --describe

#查看积压

bin/kafka-consumer-groups.sh --bootstrap-server xxx:9092 --group documentcollection_online_v1 --describe | grep -v TOPIC | awk '{sum+=$5} END{print sum}'

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值