Kafka常用命令
开启和关闭kafka
nohup ./bin/kafka-server-start.sh ./config/server.properties &
bin/kafka-server-stop.sh
关于topic
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic topicname
bin/kafka-topics.sh --list --zookeeper localhost:2181
bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic my-replicated-topic
bin/kafka-topics.sh --topic topicname --describe --zookeeper localhost:2181
bin/kafka-topics.sh --delete --zookeeper localhost:2181 --topic topicname
* 注意:删除操作需要在server.properties中设置delete.topic.enable=true,否则只是标记删除或者直接重启了。
bin/kafka-topics.sh --zookeeper localhost --alter --partitions 10 --topic topicname
生产者
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic topicname
消费者
bin/kafka-console-consumer.sh --zookeeper localhost:2181 --from-beginning --topic topicname
bin/kafka-run-class.sh kafka.tools ConsumerOffsetChecker --zookeeper localhost:2181 --group testGroupname