kafka常用基本命令

kafka常用基本命令

  1. 启动kafka命令
    bin/kafka-server-start.sh config/server.properties &

  2. 停止命令:
    ./bin/kafka-server-stop.sh,或者 ps -ef |grep kafka|grep -v grep|awk ‘{print $2}’ |xargs kill -9

  3. 创建topic
    ./bin/kafka-topic.sh --create --bootstrap-server IP:9092 [–relication-factor 3] [–partition 3] --topic test
    可选: [–relication-factor 3] 副本数量,数量应该少于等于节点数
    [–partition 3] 分区数量,分区相当于工作区域。不通的分区不同的工作内容。

  4. 删除topic
    ./bin/kafka-topic.sh --bootstrap-server IP:9092 --delete --topic test
    删除topic 慎用,删除后这个分区的消费队列也没了。

  5. 查询topic
    查看服务器上topic列表 ./bin/kafka-topic.sh --bootstrap-server IP:9092 --list
    查询topic是test的详细信息
    ./bin/kafka-topic.sh --bootstrap-server IP:9092 --describe --topic test

  6. 查看消费者组
    ./bin/kafka-consumer-groups.shh --bootstrap-server IP地址:9092 --list

  7. 查看指定消费者组的 消费偏移量
    ./bin/kafka-consumer-groups.sh --bootstrap-server IP地址:9092 --describe --group test
    current-offset:目前已经消费的位置
    log-end-offset: 消费组 当前所有的消息
    在这里插入图片描述

  8. 查看指定消费偏移量的消息内容
    ./bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --partition 0 --offset 100
    –partition 分区数量,指定查看偏移量一定要有分区
    –offset 偏移量的指定
    这个命令是从 偏移量开始在界面展示,想要看那一条,执行完看到界面有回显就要ctrl +c 终止命令。

  9. 查看历史消费信息
    bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning
    从kafka 重启只有开始的消费内容

  10. kafka界面化工具 kafka-map

    可以安装kafkamap这个工具进行监控kafka的消息队列
    在这里插入图片描述

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值