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

  • 相关阅读:
    C语言学习笔记(二)数据类型、常量和变量简介
    将汉字转换为汉语拼音java实现
    C语言学习笔记(四)运算符与表达式(下)
    数组的几种排序算法的实现
    C语言学习笔记(三)运算符与表达式(上)
    java实现二叉树的常见操作
    java解析Internet网页中的内容
    C语言学习笔记(六)分支程序设计
    C语言学习笔记(一)初识C语言
    C语言学习笔记(五)顺序程序设计
  • 原文地址:https://www.cnblogs.com/fansik/p/8252831.html
Copyright © 2011-2022 走看看