window系统下搭建zookeeper集群

1、官网下载zookeeper

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

2、配置zookeeper

一、解压zookeeper到目录中,保证目录名字中不能包含空格。
我的文件名为:C:\software\zookeeper\zookeeper-3.4.12
进入conf文件目录,找到zoo_sample.cfg文件,复制一份命名为zoo.cfg。
修改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.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
dataDir=/tmp/zookeeper
# the port at which the clients will connect
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

dataDir=C:/software/zookeeper/zookeeper-3.4.12/data
dataLogDir=C:/software/zookeeper/zookeeper-3.4.12/zkLog
server.1=127.0.0.1:1288:1388
server.2=127.0.0.1:1289:1389
server.3=127.0.0.1:1287:1387

dataDir:存储内存中数据库快照的位置,如果不设置参数,更新事务日志将被存储到默认位置
dataLogDir:日志文件的位置
clientPort:监听端口。
集群配置格式: server.A = B:C:D
A:是一个数字,表示第几号服务器
B:服务器IP地址
C:是一个端口号,用来集群成员的信息交换,表示这个服务器与集群中的leader服务器交换信息的端口
D:是在leader挂掉时专门用来进行选举leader所用的端口
复制配置好的zookeeper文件,共三份文件。
在这里插入图片描述
修改conf下的zoo.cfg文件中clientPort字段。
zookeeper-3.4.12对应的是clientPort:2181
修改zookeeper-3.4.12-2对应的是clientPort:2182
修改zookeeper-3.4.12-3对应的是clientPort:2183
这时候,命令行,你切换到任何一个zookeeper文件bin目录下输入zkserver.cmd
在这里插入图片描述
会报错误:
在这里插入图片描述
当你创建集群时,你需要为zookeeper指明所对应的server服务器

创建myid文件
我们在dataDir中指定了快照存放目录,切换到各目录下,分别创建一个文件名为myid的文件(没有后缀名)。我的对应的是data目录。文件内容为一个整型数。
zookeeper-3.4.12对应的myid文件内容为1
zookeeper-3.4.12-2对应的myid文件内容为2
zookeeper-3.4.12-3对应的myid文件内容为3
基本配置完毕,启动zookeeper

启动zookeeper

打开命令行,切换到C:\software\zookeeper\zookeeper-3.4.12\bin目录。会报当前错误:
在这里插入图片描述
当前情况是我们zookeeper集群没有全部启动,把3个都启动起来,至此就完成。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值