1 下载 wget http://mirrors.tuna.tsinghua.edu.cn/apache/kafka/2.0.0/kafka_2.12-2.0.0.tgz
2 tar -zxvf kafka_2.12-2.0.0.tgz -C kafka
3 进入到config下( /root/kafka/kafka_2.12-2.0.0/config): 修改zookeeper.properties, 配置三台servers.
4: 创建myid文件,进入/usr/local/kafka/zookeeper,创建myid文件,将三个服务器上的myid文件分别写入1,2,3.
5: 进入kafka目录 执行启动zookeeper命令:
./bin/zookeeper-server-start.sh config/zookeeper.properties
6: 配置kafka, 在kafka的 confi/server.properties
broke.id 要分别配置三个值: 0,1,2
zookeeper要配置三个地址:
log.dirs 指定地址。
7; 启动kafka: bin/kafka-server-start.sh config/server.properties(保证前面zookeeper也已经启动)
8: 创建 TOPIC: bin/kafka-topics.sh --create --zookeeper XXX.XXX.XXX.XXX:2181,XXX.XXX.XXX.XXX:2181,XXX.XXX.XXX.XXX:2181 --replication-factor 1 --partitions 3 --topic kfk
9: 创建生产者: bin/kafka-console-producer.sh --broker-list ip1:9092,ip2:9092ip3:9092 --topic kfk
bin/kafka-console-producer.sh --broker-list 9.37.138.215:9092,9.42.18.65:9092,9.37.201.53:9092 --topic kfk
10: 创建消费者: ./kafka-console-consumer.sh --topic kfk --bootstrap-server 9.37.138.215:9092 --from-beginning