zookeeper单机创建集群

首先,下载windows版本的zk,自己可以去官网下载

第一步,在/conf下面建立zoo1.cfg、zoo2.cfg、zoo3.cfg三个文件,其中代码如下:

zoo1.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=D:/ProfessionalKl/apache-zookeeper-3.5.5-bin/data/1
# the port at which the clients will connect
clientPort=2181
server.1=127.0.0.1:2888:3888
server.2=127.0.0.1:2889:3889
server.3=127.0.0.1:2890:3890

zoo2.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=D:/ProfessionalKl/apache-zookeeper-3.5.5-bin/data/2
# the port at which the clients will connect
clientPort=2182
server.1=127.0.0.1:2888:3888
server.2=127.0.0.1:2889:3889
server.3=127.0.0.1:2890:3890

zoo3.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=D:/ProfessionalKl/apache-zookeeper-3.5.5-bin/data/3
# the port at which the clients will connect
clientPort=2183
server.1=127.0.0.1:2888:3888
server.2=127.0.0.1:2889:3889
server.3=127.0.0.1:2890:3890

第二步:建立所需的日志文件的存放目录

根据第一步中配置的dataDir目录分别建立对应的目录,如在data文件夹1的文件夹下建立文件myid,该文件没有格式,名称就是myid,其中填写内容,1,另外两个文件也类似,文件夹2下myid的内容为2,文件夹3下myid的内容为3。

第三步:启动脚本

我们打开bin目录下面的zkEnv.cmd文件,发现最后一行代码为:

set ZOOCFG=%ZOOCFGDIR%\zoo.cfg

由此我们可以看出,这里就是读配置的地方。我们分别改成我们第一步中的配置文件,如第一个zk节点,改动完保存一次,然后直接点击zkServer.cmd,此时我们发现zookeeper端口2181已经启动,再继续改成zoo2.cfg,再启动,依次类推。

注意:三个都未完全启动时,先启动的会一直报错,当全部节点启动完成时,才不会报错。

set ZOOCFG=%ZOOCFGDIR%\zoo1.cfg
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值