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
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值