zookeeper在windows上实现单机伪集群模式
复制多个zookeeper
在单机上模拟集群,同一个时间要运行多个zookeeper,所以要复制多个zookeeper,把文件名改成zookeeper1,zookeeper2,zookeeper3
修改zoo.cfg文件
例:zookeeper1的zoo.cfg
tickTime=2000
initLimit=5
syncLimit=2
dataDir=D:\\software\\zookeeper\\data\\zookeeper-cluster\\zookeeper1\\data
dateLogDir=D:\\software\\zookeeper\\data\\zookeeper-cluster\\zookeeper1\\logs
clientPort=12181
server.1=127.0.0.1:12888:13888
server.2=127.0.0.1:14888:15888
server.3=127.0.0.1:16888:17888
然后到zookeeper2和zookeeper3中按照上面修改zoo.cfg文件,主要修改dataDir、dataLogDir和clientPort
去data文件夹下创建myid文件
完成上一步操作后,直接运行,是运行不了的,要去你设置的data文件夹下创建myid文件,注意myid文件是没有后缀的,可以先创建txt文件,然后在myid里输入对应的服务器编号,zookeeper1就是1,zookeeper2和zookeeper3同理,编辑完后删除txt的后缀
按顺序启动zookeeper
之后分别按顺序启动zookeeper,去zookeeper的bin目录下双击zkServer.cmd就可以了 到这里你就实现了zookeeper单机伪集群模式的部署,是不是很简单呢
|