kafka常用命令
以下是kafka常用命令行总结:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| 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
**<<** 更多精彩尽在『程序萌部落』**>>** **<<** [https://www.cxmoe.com](https://www.cxmoe.com) **>>**
[成功]
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
|