zoukankan      html  css  js  c++  java
  • Kafka常用命令

    Kafka常用命令
    启动Kafka服务kafka-server-start.sh
    ./bin/kafka-server-start.sh config/server.properties

    Topic操作Kafka-topics.sh
    创建Topic
    ./bin/kafka-topics.sh --create --topic test-topic --partitions 2 --replication-factor 1 --zookeeper localhost:2181

    删除Topic
    ./bin/kafka-topics.sh --delete --topic test-topic --zookeeper localhost:2181
    如果要删除topic,需先要在配置里添加delete.topic.enable=true

    显示当前所有Topic
    ./bin/kafka-topics.sh --list --zookeeper localhost:2181

    显示指定Topic详细信息
    ./bin/kafka-topics.sh --describe --topic test-topic --zookeeper localhost:2181

    重新分配分区
    ./bin/kafka-topics.sh --zookeeper localhost:2181 -alter --partitions 3 --topic test-topic

    控制台接收消息
    ./bin/kafka-console-consumer.sh --from-beginning --topic test-topic -zookeeper localhost:2181
     
    控制台发送消息
     ./bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test-topic
     
    显示Consumer的Group、Topic、分区ID、分区对应已经消费的Offset、logSize大小,Lag以及Owner等信息
    ./bin/kafka-consumer-offset-checker.sh --zookeeper localhost:2181 --topic test-topic --group xb_id --broker-info

    验证日志索引是否正确,或者想从log文件中直接答应消息
    ./kafka-run-class.sh kafka.tools.DumpLogSegments
    ./kafka-run-class.sh kafka.tools.DumpLogSegments /usr/local/kafka/logs/xb_topic-0/0000000000000000000033.log
    ./kafka-run-class.sh kafka.tools.DumpLogSegments --files /usr/local/kafka/logs/xb_topic-0/0000000000000000000033.log --print--data-log

    导出Zookeer中Group相关的偏移量
    有时候我们需要导出某个Consumer group各个分区的偏移量
    ./kafka-run-class.sh kafka.tools.ExportZKOffsets
    ./kafka-run-class.sh kafka.tools.ExportZKOffsets --group xb_id --zkconnect c13-138:2181,c13-139:2181,c13-141:2181 --output-file ~/offset
    vim ~/offset

  • 相关阅读:
    【模拟】HDU 5752 Sqrt Bo
    【数学】HDU 5753 Permutation Bo
    【模拟】Codeforces 706A Beru-taxi
    【二分】Codeforces 706B Interesting drink
    【动态规划】Codeforces 706C Hard problem
    【字典树】【贪心】Codeforces 706D Vasiliy's Multiset
    【中国剩余定理】POJ 1006 & HDU 1370 Biorhythms
    计算机存储单位
    转载_Linux下查看文件和文件夹大小
    反问题_不适定_正则化
  • 原文地址:https://www.cnblogs.com/fansik/p/8252831.html
Copyright © 2011-2022 走看看