Kafka 使用命令

    xiaoxiao2022-06-29  55

    1.创建topic

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

    2.查看topic

    (1)bin/kafka-topics.sh --list --zookeeperlocalhost:2181

    (2)./kafka-topics.sh --describe --zookeeper localhost:2181 --topic test (查看topic为test 的信息分区,复制等)

    .

    leader :负责处理消息的读和写,leader是从所有节点中随机选择的. replicas :列出了所有的副本节点,不管节点是否在服务中. isr :是正在服务中的节点.

    3.向topic 发送数据

     bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test 

    4.查看consumer的信息

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

    5.后台启动Kafka

    nohup bin/kafka-server-start.sh config/server.properties & 6.查看消费组

    ./kafka-consumer-groups.sh  --list --zookeeper localhost:2181

    7.查看topic的最小和最大offset

    ./kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list localhost:9092 -topic topic --time -2(最小)

    ./kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list localhost:9092 -topic topic --time -1(最大)

    转载请注明原文地址: https://ju.6miu.com/read-1125374.html

    最新回复(0)