Kafka启动及验证(单机版)

一: 下载kafka_2.11-1.0.0.tgz,并解压到磁盘。 安装zookeeper

二: 启动zookeeper

三:配置文件

在${kafka_home}/config 下面,配置文件就不一一介绍

#配置broker.id

# The id of the broker. This must be set to a unique integer for each broker.
broker.id=0

# 配置zk

zookeeper.connect=localhost:2181

# Timeout in ms for connecting to zookeeper

zookeeper.connection.timeout.ms=6000

四:启动

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

启动后可以查看启动日志


可以在zk里面看到 kafka 的节点信息



五:启动topic

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

–replication-factor 1 #复制两份 
–partitions 1 #创建1个分区 
–topic #主题名


查看topic 

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


六: 启动生产者

bin/kafka-console-producer.sh -broker-list localhost:9092 -topic mytopic


七: 启动消费者

bin/kafka-console-consumer.sh -zookeeper localhost:2181 -topic mytopic




猜你喜欢

转载自blog.csdn.net/SDN_SUPERUSER/article/details/80889330
今日推荐