ZooKeeper在windows上的安装与伪集群

先下载配置好jdk已经JAVA_HOME和path

 

下载解压ZooKeeper后,复制粘贴在多个路径中,比如:

server1/zookeeper-3.4.12

server2/zookeeper-3.4.12 

server3/zookeeper-3.4.12

打开conf中的zoo_sample.cfg,修改后另存为zoo.cfg

因为是一台机器模拟的伪集群,三个服务端的ClientPort不能相同,我这里是

ClientPort=2181         ClientPort=2182        和ClientPort=2183

配置三个服务端,server.id(数字)=ip:集群交互端口:选举leader端口

server.1=localhost:2287:3387
server.2=localhost:2288:3388
server.3=localhost:2289:3389

配置保存数据的目录和日志目录,eg:

dataDir=F:/server1/zookeeper-3.4.12/dataTmp

dataDir=F:/server2/zookeeper-3.4.12/dataTmp

dataDir=F:/server3/zookeeper-3.4.12/dataTmp

dataLogDir=\log

 

然后在配置的保存数据目录,分别新建名为myid的txt文件

分别存入 1    2   3 后去掉后缀(若不存,server启动后会不知自己的id而报错)

 

cmd进入各自解压路径的bin目录,启动zkServer.cmd

配置的server没有全部启动时,由于leader选举机制,窗口会不断报错不必理会。

最后三台启动成功,leader选举完成。jps能看到三个QuorumPeerMain进程

可以通过 netstat  -ano 命令查看是否有你配置的 clientPort 端口号在监听服务。

 

以下为zoo.cfg加注释配置:

# The number of milliseconds of each tick
#心跳时间间隔
tickTime=2000
# The number of ticks that the initial 
# synchronization phase can take
#follower与leader之间建立连接后进行同步的最长时间
initLimit=10
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
#配置follower和leader之间发送消息,请求和应答的最大时间长度
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
#保存数据目录,若不单独配置日志路径,默认包含日志
dataDir=F:/server1/zookeeper-3.4.12/dataTmp
#配置日志目录
dataLogDir=\log
# the port at which the clients will connect
#客户端连接服务器的端口,zookeeper会监听并接受访问请求
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the 
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1

#伪集群分布模式,server.id(数字)=ip:集群交互端口:选举leader端口
server.1=localhost:2287:3387
server.2=localhost:2288:3388
server.3=localhost:2289:3389

转载于:https://my.oschina.net/u/4050414/blog/3019261

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值