Kafka高可用集群搭建
环境基于docker搭建,3个zookeeper节点,3个kafka节点
1 整体环境规划
step1, 创建docker网络
docker network create --subnet=192.168.200.0/24 net_kafka
host | ip | port | remark |
---|---|---|---|
zookeeper1 | 192.168.200.11 | 12181 | zookeeper集群node1 |
zookeeper2 | 192.168.200.12 | 12182 | zookeeper集群node2 |
zookeeper3 | 192.168.200.13 | 12183 | zookeeper集群node2 |
kafka1 | 192.168.200.21 | 9092 | |
kafka2 | 192.168.200.22 | 9092 | |
kafka3 | 192.168.200.23 | 9092 |
2 zookeeper集群搭建
step1. 创建配置文件zoo.cfg
不同的node只需要修改clientPort和myid
clientPort=12181
dataDir=/data
dataLogDir=/datalog
tickTime=2000
initLimit=5
syncLimit=2
autopurge.snapRetainCount=3
autopurge.purgeInterval=0
maxClientCnxns=60
server.1=192.168.200.11:2888:3888
server.2=192.168.200.12:2888:3888
server.3=192.168.200.13:2888:3888
myid=1
step2. 启动zookeeper的docker集群
docker run -p 12181:12181 --name zookeeper1 --hostname=zookeeper1 --net=net_kafka --ip=192.168.200.11 -v /home/mt/zookeeper/zookeeper1/zoo.cfg:/conf/zoo.cfg -v /home/mt/zookeeper/zookeeper1:/home/zookeeper -d zookeeper:3.4.13
docker run -p 12182:12182 --name zookeeper