一、概念
https://zookeeper.apache.org/doc/r3.4.13/zookeeperStarted.html
replicated mode:复制模式,A replicated group of servers in the same application is called a quorum, and in replicated mode, all servers in the quorum have copies of the same configuration file
二、docker部署
编写stack.yml:见https://hub.docker.com/_/zookeeper
swarm启动:docker stack deploy -c stack.yml zookeeper
docker-compose启动:docker-compose -f stack.yml up
一个服务挂了,docker swarm会自动重启
三、配置讲解
clientPort=2181
dataDir=/data
dataLogDir=/datalog
tickTime=2000
initLimit=5
syncLimit=2
server.1=0.0.0.0:2888:3888
server.2=zoo2:2888:3888
server.3=zoo3:2888:3888
-
server.X : When the server starts up, it knows which server it is by looking for the file myid in the data directory. That file has the contains the server number, in ASCII(between 1 and 255)
-
端口用途
-
2181:对client端提供服务
-
2888:集群内机器通讯使用(Leader监听此端口)
-
3888:选举leader使用
-