zookeeper伪集群配置

1  环境 win7-64位环境  zookeeper-3.4.11

2 将 zookeeper-3.4.11拷贝三份放置目录结构如下
    
D:\Program Files\zookeeper\zookeeper-cluster\zk001\zookeeper-3.4.11
D:\Program Files\zookeeper\zookeeper-cluster\zk002\zookeeper-3.4.11
D:\Program Files\zookeeper\zookeeper-cluster\zk003\zookeeper-3.4.11

3 配置服务zk001 的配置文件
   配置文件目录:D:\Program Files\zookeeper\zookeeper-cluster\zk001\zookeeper-3.4.11\conf
  将zoo_sample.cfg拷贝一份zoo.cfg
   zoo.cfg内容如下:
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:/Program Files/zookeeper/zookeeper-cluster/zk001/zookeeper-3.4.11/data
dataLogDir=D:/Program Files/zookeeper/zookeeper-cluster/zk001/zookeeper-3.4.11/logs
# the port at which the clients will connect
clientPort=2181
server.1=localhost:2887:3887
server.2=localhost:2888:3888
server.3=localhost:2889:3889
4 配置服务zk002 的配置文件
参考步骤3
# 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:/Program Files/zookeeper/zookeeper-cluster/zk002/zookeeper-3.4.11/data
dataLogDir=D:/Program Files/zookeeper/zookeeper-cluster/zk002/zookeeper-3.4.11/logs
# 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
5 配置服务zk003 的配置文件
参考步骤3
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:/Program Files/zookeeper/zookeeper-cluster/zk003/zookeeper-3.4.11/data
dataLogDir=D:/Program Files/zookeeper/zookeeper-cluster/zk003/zookeeper-3.4.11/logs
# 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
6 配置文件说明
  server.id=host:port:port.   ”指示了不同的   ZooKeeper   服务器的自身标识,作为集群的一部分的机器应该知道   ensemble   中的其它机器。用户可以从“   server.id=host:port:port.   ”中读取相关的信息。   在服务器的 data dataDir 参数所指定的目录)目录下创建一个文件名为 myid 的文件,这个文件中仅含有一行的内容,指定的是自身的 id  比如,服务器“  1 ”应该在 myid 文件中写入“ 1  ”。这个   id   值必须是   ensemble   中唯一的,且大小在   1     255   之间。这一行配置中,第一个端口(   port   )是从(   follower   )机器连接到主(   leader   )机器的端口,第二个端口是用来进行   leader   选举的端口。

6 部署myid文件
  D:\Program Files\zookeeper\zookeeper-cluster\zk001\zookeeper-3.4.11\data\myid    文件内容 1
  D:\Program Files\zookeeper\zookeeper-cluster\zk002\zookeeper-3.4.11\data\myid    文件内容 2
  D:\Program Files\zookeeper\zookeeper-cluster\zk003\zookeeper-3.4.11\data\myid    文件内容 3
 

7 分别启动3个服务
D:\Program Files\zookeeper\zookeeper-cluster\zk001\zookeeper-3.4.11\bin\zkServer.cmd
D:\Program Files\zookeeper\zookeeper-cluster\zk002\zookeeper-3.4.11\bin\zkServer.cmd
D:\Program Files\zookeeper\zookeeper-cluster\zk003\zookeeper-3.4.11\bin\zkServer.cmd

8 三个服务器没启动完成时,各个服务器会报错,都启动完成后,停止报错

 

 
 zk002当选为leader
 
 

 

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值