kafka命令

  • 启动 zookeeper server
bin/zookeeper-server-start.sh config/zookeeper.properties
  • 启动 kafka server
bin/kafka-server-start.sh config/server.properties
  • 创建topic
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
  • 删除topic
./kafka-topics.sh --delete --zookeeper 10.99.2.30:2181 --topic test

Topic ngix is marked for deletion.
Note: This will have no impact if delete.topic.enable is not set to true.
  • 查看有存在的topic
bin/kafka-topics.sh --list --zookeeper 127.0.0.1:2181
  • 查看所有主题信息
./kafka-topics.sh --describe --zookeeper 10.99.2.30:2181
  • 查看指定主题分区及副本分布信息
./kafka-topics.sh --describe --zookeeper 10.99.2.30:2181 --topic test

Topic:wang  PartitionCount:1    ReplicationFactor:1 Configs:
    Topic: wang Partition: 0    Leader: 0   Replicas: 0 Isr: 0
  • 向topic发消息测试
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
this is a message
  • 消费者查看消息
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning
this is a message
  • 查看kafka有哪些消费组
./bin/kafka-consumer-groups.sh --list --new-consumer --bootstrap-server localhost:9092
  • 查看这些消费组里面的ip地址和客户端情况
./bin/kafka-consumer-groups.sh --describe --new-consumer --bootstrap-server localhost:9092 --group logstash-es
  • 增加topic的分区数
./bin/kafka-topics.sh --zookeeper 127.0.0.1:2181 --topic filebeat --alter --partitions 5
  • 将二进制分段日志文件转储为字符类型的文件
./kafka-run-class.sh kafka.tools.DumpLogSegments --files /tmp/kafka-logs/test-0/00000000000000000008.log --print-data-log

Dumping /tmp/kafka-logs/test-0/00000000000000000008.log
Starting offset: 8

你可能感兴趣的:(linux基础)