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 2023-06-19 17:50  石墨方  阅读(6)  评论(0编辑  收藏  举报

导航