# 一、下载zookeeper

https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/

# 二、配置zookeeper

## 1.解压到三个目录

server1 : F:\paths\zookeeper\server1\zookeeper-3.3.6
server2 : F:\paths\zookeeper\server2\zookeeper-3.3.6
server3 : F:\paths\zookeeper\server3\zookeeper-3.3.6

## 2.创建配置文件（cfg文件）

# The number of milliseconds of each tick
tickTime=2000（2000ms，心跳间隔，也是zookeeper的时间单位）
# The number of ticks that the initial synchronization phase can take
initLimit=10（10*tickTime = 20s，定义初始化的时间限制）
# The number of ticks that can pass between sending a request and getting an acknowledgement
syncLimit=5 （5*tickTime = 10s，定义同步的时间限制）
# the directory where the snapshot is stored.
dataLogDir=F:\paths\zookeeper\server1\zookeeper-3.3.6\log （自定义日志存放目录，log目录需要自行创建）
# the port at which the clients will connect
clientPort=2181 （zookeeper服务端口）
server.1=localhost:2887:3887 （伪集群zookeeper的server1标识）
server.2=localhost:2888:3888 （伪集群zookeeper的server2标识）
server.3=localhost:2889:3889 （伪集群zookeeper的server3标识）

server2的zoo.cfg

# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial synchronization phase can take
initLimit=10
# The number of ticks that can pass between sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
dataLogDir=F:\paths\zookeeper\server2\zookeeper-3.3.6\log
# the port at which the clients will connect
clientPort=2182
server.1=localhost:2887:3887
server.2=localhost:2888:3888
server.3=localhost:2889:3889
server3的zoo.cfg

# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial synchronization phase can take
initLimit=10
# The number of ticks that can pass between sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
dataLogDir=F:\paths\zookeeper\server3\zookeeper-3.3.6\log
# the port at which the clients will connect
clientPort=2183
server.1=localhost:2887:3887
server.2=localhost:2888:3888
server.3=localhost:2889:3889

• 评论

1

• 下一篇
• 上一篇