创建topic
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
1、启动zk
bin/zookeeper-server-start.sh -daemon config/zookeeper.properties
2、启动kafka
JMX_PORT=9999 bin/kafka-server-start.sh -daemon config/server.properties
3、查看所有topic列表
bin/kafka-topics.sh --zookeeper node01:2181 --list
4、查看指定topic信息
bin/kafka-topics.sh --zookeeper node01:2181 --describe --topic t_cdr
5、控制台向topic生产数据
bin/kafka-console-producer.sh --broker-list node86:9092 --topic t_cdr
6、控制台消费topic的数据
bin/kafka-console-consumer.sh --zookeeper node01:2181 --topic t_cdr --from-beginning
7、查看topic某分区偏移量最大(小)值
bin/kafka-run-class.sh kafka.tools.GetOffsetShell --topic hive-mdatabase-hostsltable --time -1 --broker-list node86:9092 --partitions 0
8、增加topic分区数
bin/kafka-topics.sh --zookeeper node01:2181 --alter --topic t_cdr --partitions 10
9、删除topic,慎用,只会删除zookeeper中的元数据,消息文件须手动删除
bin/kafka-run-class.sh kafka.admin.DeleteTopicCommand --zookeeper node01:2181 --topic t_cdr
10、查看topic消费进度
bin/kafka-run-class.sh kafka.tools.ConsumerOffsetChecker
详细文档:
https://www.vultr.com/docs/how-to-install-apache-kafka-on-centos-7