kafka常用命令
以下是kafka常用命令行总结:
1、kafka服务启动
./kafka-server-start.sh -daemon ../config/server.properties
<!-- more -->
2、创建topic
./kafka-topics.sh --create --zookeeper hadoop01:2181 --replication-factor 1 --partitions 1 --topic test
2.1、为topic增加副本
./kafka-reassign-partitions.sh -zookeeper hadoop01:2181 -reassignment-json-file json/partitions-to-move.json -execute
2.2、为topic增加partition
./bin/kafka-topics.sh –zookeeper hadoop01:2181 –alter –partitions 20 –topic test
3、查看有哪些topic:
./kafka-topics.sh --list --zookeeper hadoop01:2181
4、查看topic的详细信息
./kafka-topics.sh -zookeeper hadoop01:2181 -describe -topic test
5、kafka生产者客户端命令
./kafka-console-producer.sh --broker-list hadoop01:9092 --topic test
6、kafka消费者客户端命令
./kafka-console-consumer.sh -zookeeper hadoop01:2181 --from-beginning --topic test
[成功]
7、下线broker
./kafka-run-class.sh kafka.admin.ShutdownBroker --zookeeper hadoop01:2181 --broker #brokerId# --num.retries 3 --retry.interval.ms 60
shutdown broker
8、删除topic
./kafka-run-class.sh kafka.admin.DeleteTopicCommand --topic test --zookeeper hadoop01:2181
./kafka-topics.sh --zookeeper hadoop01:2181 --delete --topic test
实际不会删除,只会显示marked for deletion
9、查看consumer组内消费的offset
./kafka-run-class.sh kafka.tools.ConsumerOffsetChecker --zookeeper hadoop01:2181 --group test --topic test
./kafka-consumer-offset-checker.sh --zookeeper hadoop01:2181 --group group1 --topic group1
😒 留下您对该文章的评价 😄