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

    config.properties

    server.properties

    server.1=172.28.92.39:2888:3888

    server.2=172.28.92.37:2888:3888

    server.3=172.28.92.38:2888:3888

    server

    start

    ./bin/zookeeper-server-start.sh -daemon ./config/zookeeper.properties
    

    stop

    ./bin/kafka-server-start.sh -daemon ./config/server.properties
    

    分区

    修改分区

    ./bin/kafka-topics.sh --zookeeper 127.0.0.1:2181 --alter --partitions 3 --topic monitor-log
    

    消费

    手动消费

    ./bin/kafka-console-consumer.sh --bootstrap-server 172.28.92.37:9092,172.28.92.38:9092,172.28.92.39:9092  --topic monitorlog --from-beginning
    
    ./bin/kafka-console-consumer.sh --zookeeper localhost:2181  --topic log.test
    
    ./bin/kafka-console-consumer.sh --bootstrap-server 172.20.61.203:6667,172.20.61.204:6667,172.20.61.205:6667 --topic monitor-log
    

    查看group消费情况

    ./bin/kafka-consumer-groups.sh --bootstrap-server 172.28.92.39:9092 --describe --group 1
    
    ./bin/kafka-consumer-groups.sh --zookeeper 127.0.0.1:2181 --describe --group 1
    

    topic

    create

    bin/kafka-topics.sh --create --bootstrap-server 172.28.92.37:9092 --replication-factor 1 --partitions 1 --topic monitor-alerts
    

    delete

    bin/kafka-topics.sh --bootstrap-server 172.28.92.37:9092 --delete --topic monitorlog
    

    list

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

    describe

    ./bin/kafka-topics.sh --zookeeper 127.0.0.1:2181 --describe  --topic monitor-log
    

    delete topic

    ./bin/kafka-topics.sh --zookeeper 127.0.0.1:2181 --delete --topic xxxxx
    

    config

    查看所有topic的config

    ./bin/kafka-configs.sh --zookeeper 127.0.0.1:2181 --describe --entity-type topics
    

    查看配置

    ./bin/kafka-configs.sh --zookeeper localhost:2181 --describe --entity-type topics --entity-name monitor-alerts
    

    设置retention

    ./bin/kafka-configs.sh --zookeeper localhost:2181 --alter --entity-type topics --entity-name monitor-alerts  --add-config retention.ms=86400000
    

    DumpLogSegments

    ~/kafka_2.12-2.3.0/bin/kafka-run-class.sh kafka.tools.DumpLogSegments --files=/data/kafka/logs/monitor-log-1/00000000000336375351.log --print-data-log > 00000000000336375351.log
    
    ~/kafka_2.12-2.3.0/bin/kafka-run-class.sh kafka.tools.DumpLogSegments --files=/data/kafka/logs/monitor-log-1/00000000000336375351.index --print-data-log > 00000000000336375351.index
    
    ~/kafka_2.12-2.3.0/bin/kafka-run-class.sh kafka.tools.DumpLogSegments --files=/data/kafka/logs/monitor-log-1/00000000000336375351.timeindex --print-data-log > 00000000000336375351.timeindex
    

    consumer

    bin/kafka-console-consumer.sh --bootstrap-server 172.28.92.37:9092,172.28.92.38:9092,172.28.92.39:9092 --topic monitor-alerts --from-beginning
    

    offset

    ./bin/kafka-run-class.sh kafka.tools.GetOffsetShell --topic hive-mdatabase-hostsltable  --time -1 --broker-list 172.20.61.203:6667 --partitions 0
    
    ./bin/kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list 172.20.61.203:6667 --time -1 --topic monitor-log
    
  • 相关阅读:
    你所不知道的React Hooks
    DataRow的RowState属性变化
    gRPC详解
    Protobuf简明教程
    docker容器内没有权限
    Locust高并发情况下的性能优化与分布式场景的应用
    Docker容器日志打满机器的解决方式
    Django单测详解
    使用Flask+uwsgi+Nginx部署Flask正式环境
    Locust-分布式执行
  • 原文地址:https://www.cnblogs.com/zhouj-happy/p/11375686.html
Copyright © 2011-2022 走看看