Kafka学习

Kafka学习

https://blog.csdn.net/Eternal_Blue/article/details/95598942

https://www.cnblogs.com/swordfall/p/10014300.html

常用命令

启停

开启zookeeper:

./zkServer.sh start关闭zookeeper: ./zkServer.sh stop

查看zookeeper的启动状态:

./zkServer.sh status

Kafka启动命令常规模式启动

./bin/kafka-server-start.sh config/server.properties

进程守护模式启动kafka:

nohup ./bin/kafka-server-start.sh config/server.properties &

or

nohup bin/kafka-server-start.sh config/server.properties >/dev/null 2>&1 &

nohup /data/kafka_2.12-2.3.0/bin/kafka-server-start.sh /data/kafka_2.12-2.3.0/config/server.properties & 或 /data/kafka_2.12-2.3.0/bin/kafka-server-start.sh -daemon /data/kafka_2.12-2.3.0/config/server.properties

Kafka关闭命令: bin/kafka-server-stop.sh

消息的生产和消费

需要设置hosts localhost ip

创建topic:

./bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test_gorv

查看topic:./bin/kafka-topics.sh --list --zookeeper localhost:2181

生产消息:./bin/kafka-console-producer.sh --broker-list localhost:9092 --topic

消费消息:sh bin/kafka-console-consumer.sh --bootstrap-server 127.0.0.1:9092 --topic testTopic --from-beginning

kafka命令:

创建topic:sh bin/kafka-topics.sh --create --bootstrap-server 127.0.0.1:9092 --replication-factor 1 --partitions 1 --topic testTopic2

查看topic:sh bin/kafka-topics.sh --list --bootstrap-server 127.0.0.1:9092

生产消息:sh bin/kafka-console-producer.sh --broker-list 127.0.0.1:9092 --topic testfy

消费消息:sh bin/kafka-console-consumer.sh --bootstrap-server 127.0.0.1:9092 --topic testfy2 --from-beginning

删除topic:./bin/kafka-topics.sh --delete --topic test_gov_serv --zookeeper 127.0.0.1:2181

清空消息:./bin/kafka-topics.sh --bootstrap-server 127.0.0.1:9092 --delete --topic fytestTopic

posted on   石墨方  阅读(8)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
历史上的今天:
2018-06-19 android项目中遇到的杂七杂八问题

导航

< 2025年3月 >
23 24 25 26 27 28 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 1 2 3 4 5
点击右上角即可分享
微信分享提示