乐趣区

kafka5常用命令

kafka 常用命令

  1. 创建 topic

    bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 3 --partitions 1 --topic my-replicated-topic --config message.timestamp.type=CreateTime

    –config 可以指定 topic 的配置,message.timestamp.type 指定 topic 的时间戳使用方式,其他配置见

    https://kafka.apache.org/docu…

  2. 查看 topic 状态

    bin/kafka-topics.sh --describe --bootstrap-server localhost:9092 --topic my-replicated-topic

  3. 生产者

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

  4. 消费者

    bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --from-beginning --topic my-replicated-topic

  5. 查看 segment 文件信息

    kafka-run-class.sh kafka.tools.DumpLogSegments --print-data-log --files xxxxxxxxxxxx.log

退出移动版