所有操作位于/usr/local/kafka_2.12-3.5.1/bin。
root@ubuntu2203:/usr/local/kafka_2.12-3.5.1/bin# pwd /usr/local/kafka_2.12-3.5.1/bin root@ubuntu2203:/usr/local/kafka_2.12-3.5.1/bin# ls connect-distributed.sh kafka-delegation-tokens.sh kafka-mirror-maker.sh kafka-verifiable-consumer.sh connect-mirror-maker.sh kafka-delete-records.sh kafka-producer-perf-test.sh kafka-verifiable-producer.sh connect-standalone.sh kafka-dump-log.sh kafka-reassign-partitions.sh trogdor.sh kafka-acls.sh kafka-e2e-latency.sh kafka-replica-verification.sh windows kafka-broker-api-versions.sh kafka-features.sh kafka-run-class.sh zookeeper-security-migration.sh kafka-cluster.sh kafka-get-offsets.sh kafka-server-start.sh zookeeper-server-start.sh kafka-configs.sh kafka-jmx.sh kafka-server-stop.sh zookeeper-server-stop.sh kafka-console-consumer.sh kafka-leader-election.sh kafka-storage.sh zookeeper-shell.sh kafka-console-producer.sh kafka-log-dirs.sh kafka-streams-application-reset.sh kafka-consumer-groups.sh kafka-metadata-quorum.sh kafka-topics.sh kafka-consumer-perf-test.sh kafka-metadata-shell.sh kafka-transactions.sh
1、查看tocpic
./kafka-topics.sh --bootstrap-server localhost:9092 --list
2、创建一个topic
./kafka-topics.sh --bootstrap-server localhost:9092 --topic first --create --partitions 1
3、查看主题详细信息
./kafka-topics.sh --bootstrap-server localhost:9092 --topic first --describe
4、修改topci分区数
只能增加,不能减少
./kafka-topics.sh --bootstrap-server localhost:9092 --topic first --alter --partitions 2
5、生产者生产数据
/usr/local/kafka_2.12-3.5.1/bin# ./kafka-console-producer.sh --bootstrap-server localhost:9092 --topic first
生产数据流程
6、消费者消费数据
--from-beginning:表示从头消费数据,按需添加
/usr/local/kafka_2.12-3.5.1/bin# ./kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic first --from-beginning