在Kafka目录下使用命令:
启动zookeeper:bin/zookeeper-server-start.sh -daemon config/zookeeper.properties
启动Kafka:bin/kafka-server-start.sh config/server.properties
创建topic:bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
查看topic:bin/kafka-topics.sh --list --zookeeper localhost:2181
生产消息:bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
消费消息:bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning(0.9以前版本使用)
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning(0.9版本以后使用)
查看topic信息:bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic test
删除topic:bin/kafka-topics.sh --delete --zookeeper localhost:2181 --topic test
关闭kafka和zookeeper:jps 查看kafka和zookeeper的pid,然后kill -9 (pid)关闭kafka和zookeeper服务
Centos 7上使用Kafka 2.1.0启动关闭与测试命令笔记
最新推荐文章于 2025-03-03 17:12:35 发布