版权声明:未经允许,随意转载,请附上本文链接谢谢(づ ̄3 ̄)づ╭❤~
https://blog.csdn.net/xiaoduan_/article/details/79777829
Kafka单节点单broker的部署及使用
Zookeeper启动
Kafka 需要配合Zookeeper使用
# zkServer.sh start
Kafka启动
# kafka-server-start.sh $KAFKA_HOME/config/server.properties
创建topic
# kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic hello_topic
发送消息
kafka-console-producer.sh --broker-list localhost:9092 --topic hello_topic
消费消息
kafka-console-consumer.sh --zookeeper localhost:2181 --topic hello_topic --from-beginning
from-beginning的使用
这个参数表示是否从头开始接受消息,如果有的话会接受到消费者启动前生产者生产的消息Kafka常用命令
查看所有topic
kafka-topics.sh --list --zookeeper localhost:2181
查看所有topic的详细信息:
kafka-topics.sh --describe --zookeeper localhost:2181
查看指定topic的详细信息:
kafka-topics.sh --describe --zookeeper localhost:2181 --topic hello_topic