Zookeeper Windows集群搭建

首先我们在自己本地将解压,这里解压之后有配置过一些东西,具体请移步dubbo和zookeeper。另外新建两个文件夹,将zookeeper-3.4.14文件中的信息全部复制到新建的zookeeper2和zookeeper3文件下。具体的修改之后的三者的区别请往下看。

 

上诉三个文件夹是同一个安装包解压后的文件信息,修改的具体内容及三者的不同看下面。

  • zookeeper-3.4.14文件中的D:\zookeeper-3.4.14\conf目录下的zoo的配置如下
# 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:\\zookeeper-3.4.14\\data
# 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
server.1=127.0.0.1:2887:3881
server.2=127.0.0.1:2888:3882
server.3=127.0.0.1:2889:3883

注意这里dataDir=D:\\zookeeper-3.4.14\\data要用反斜杠

D:\zookeeper-3.4.14目录下新建data文件夹,之后在该文件下 cmd并输入命令echo 1 > myid来创建内容为1的myid文件。

注意如果报错java.lang.IllegalArgumentException: serverid 1  is not a number,则打开该新建的myid文件,按下删除键你会发现1后面出现个空格,去掉这个空格并保存。

  • zookeeper2文件下,如下图目录下的这个zoo文件的配置内容

# 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:\\zookeeper2\\data
# the port at which the clients will connect
clientPort=2182
# 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.1=127.0.0.1:2887:3881
server.2=127.0.0.1:2888:3882
server.3=127.0.0.1:2889:3883

同样的注意dataDir=D:\\zookeeper2\\data为反斜杠,同样的在D:\zookeeper2目录下新建data文件夹,同样的在D:\zookeeper2\data目录下cmd新建内容为2的myid文件,同样的如果报java.lang.IllegalArgumentException: serverid 2  is not a number,同样的打开该新建的myid文件,按下删除键你会发现2后面出现个空格,去掉这个空格并保存。

  • zookeeper3文件下,zoo文件的配置内容如下
# 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:\\zookeeper3\\data
# the port at which the clients will connect
clientPort=2183
# 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.1=127.0.0.1:2887:3881
server.2=127.0.0.1:2888:3882
server.3=127.0.0.1:2889:3883

zoo文件所在的位置如下

同样的注意dataDir=D:\\zookeeper3\\data为反斜杠,同样的在D:\zookeeper3目录下新建data文件夹,同样的在D:\zookeeper3\data目录下cmd新建内容为3的myid文件,同样的如果报java.lang.IllegalArgumentException: serverid 3  is not a number,同样的打开该新建的myid文件,按下删除键你会发现3后面出现个空格,去掉这个空格并保存。

启动

启动

启动

启动上诉三个zookeeper的时候会相互心跳,查找对方组为集群,所以若这三台服务没有启动完,报拒绝连接等先不用管,等所有服务启动完成即可。三台服务都启动完成之后,结果依次为下图所示

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值