搭建kafka集群

搭建kafka集群

   小白     2021年6月12日 17:22     324    

1、系统环境

Centos7

Ip

Zookeeper cluster

port

192.168.153.3

192.168.153.3:2181

9092

192.168.153.4

192.168.153.4:2181

9092

192.168.153.5

192.168.153.5:2181

9092

 

2、搭建zk集群

参照文章https://www.yunweigonghui.com/column/Zookeeper/357/

 

3、搭建kafkajiqun

可以参照https://www.yunweigonghui.com/column/Kafka/356/

下载和安装和搭建单节点没有什么区别

 

4、修改配置文件

三个服务器分别配置

192.168.153.3:

borker.id=0

listeners=PLAINTEXT://192.168.153.3:9092

log.dirs=/usr/local/src/kafka/data

zookeeper.connect=192.168.153.3:2181,192.168.153.4:2181,192.168.153.5:2181

 

192.168.153.4:

borker.id=1

listeners=PLAINTEXT://192.168.153.4:9092

log.dirs=/usr/local/src/kafka/data

zookeeper.connect=192.168.153.3:2181,192.168.153.4:2181,192.168.153.5:2181

 

192.168.153.5:

borker.id=2

listeners=PLAINTEXT://192.168.153.5:9092

log.dirs=/usr/local/src/kafka/data

zookeeper.connect=192.168.153.3:2181,192.168.153.4:2181,192.168.153.5:2181

 

5、启动kafka

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

 

6、创建topic

./kafka-topics.sh \

 --create \

 --zookeeper 192.168.153.3:2181,192.168.153.4:2181,192.168.153.5:2181 \

 --topic clusterinfo \

 --replication-factor 3 \

 --partitions 5

7、启动producerconsumer

启动producer

./kafka-console-producer.sh \

 --broker-list 192.168.153.3:9092,192.168.153.4:9092,192.168.153.5:9092 \

 --topic clusterinfo

 

启动consumer

./kafka-console-consumer.sh \

 --bootstrap-server 192.168.153.3:9092,192.168.153.4:9092,192.168.153.5:9092  \

 --topic clusterinfo


文章评论

0

其他文章