kafka常用命令


– 查看消费者列表–list
./kafka-consumer-groups.sh –bootstrap-server localhost:9092 –list

– 查看指定消费组详情–group
./kafka-consumer-groups.sh –bootstrap-server localhost:9092 –describe –group refundGroup

– 查看kafka所有topic
./kafka-topics.sh –list –bootstrap-server localhost:9092

– 创建Topic
./kafka-topics.sh –create –bootstrap-server localhost:9092 –replication-factor 1 –partitions 1 –topic test

– 查看Topic
./kafka-topics.sh –list –zookeeper localhost:2181
– 删除Topic
./kafka-topics.sh –zookeeper localhost:2181 –delete –topic test

– 发送和消费数据
– 发送数据
./kafka-console-producer.sh –broker-list localhost:9092 –topic test
//输入内容
hi
xiaoming

– 消费数据
./kafka-console-consumer.sh –zookeeper localhost:2181 –topic test –from-beginning
//内容
hi
xiaoming

– 查看kafka版本
find ./libs/ -name ‘kafka_*.jar.asc’ |head -n1 | cut -d’/‘ -f3

– 查看kafka某个topic下partition信息
./kafka-topics.sh –zookeeper localhost:2181 –topic topic1111 –describe

– 修改topic的分区,注意:分区数量只能增加,不能减少
./kafka-topics.sh –zookeeper localhost:2181 –alter –topic test –partitions 5

– kafka启动
./kafka-server-start.sh -daemon config/server.properties


文章作者: Trevor Zhang
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 Trevor Zhang !
评论
  目录