Contents
1. 安装zookeeper
kafka要先安装zookepper
1.1下载解压zookeeper
1.2 conf/zoo_sample.cfg 复制为zoo.cfg
dataDir=/Users/walle/data/zookeeper 修改下dataDir 目录即可
1.3 运行zookeeper
zkServer.sh start
2. 下载解压kafka
3. 修改 config/server.properties
host.name=localhost
log.dirs=/Users/walle/data/log/kafka
zookeeper.connect=localhost:2181
4. 启动kafka
bin/kafka-server-start.sh config/server.properties
5. 创建一个topic
bin
/kafka-topics
.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic
test
6.显示已经创建的topic
bin/kafka-topics.sh --list --zookeeper localhost:2181
7. 发送消息
bin
/kafka-console-producer
.sh --broker-list localhost:9092 --topic
test
8. 消费消息
bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning
新版写法
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test4185