Reputation: 417
I am able to run single zookeeper instance on my windows machine. but getting success to setup multiple zookeeper instances on single windows machine.
As per guideline I did following steps:
Creating multiple zoo.conf file into conf folder. Structure as below
zookeeper_home---| conf--| zoo.cfg zoo_2.cfg zoo_3.cfg
zoo.cfg
tickTime=2000 initLimit=10 syncLimit=5 dataDir=c:/opt/zookeeper/data clientPort=2181 server.1=localhost:2888:3888 server.2=localhost:2889:3889 server.3=localhost:2890:3890
tickTime=2000 initLimit=10 syncLimit=5 dataDir=c:/opt/zookeeper/data2 clientPort=2182 server.1=localhost:2888:3888 server.2=localhost:2889:3889 server.3=localhost:2890:3890
tickTime=2000 initLimit=10 syncLimit=5 dataDir=c:/opt/zookeeper/data3 clientPort=2183 server.1=localhost:2888:3888 server.2=localhost:2889:3889 server.3=localhost:2890:3890
c:/opt/zookeeper/data
c:/opt/zookeeper/data2
c:/opt/zookeeper/data3
Also created myid file in each of above folder with number 1,2,3 respectively.
now whenever I am trying to start server as c:\opt\zookeeper\bin>zkServer.cmd
it is throwing an error as
Cannot open channel to 2 at election address localhost/127.0.0.1:3889
Cannot open channel to 3 at election address localhost/127.0.0.1:3890
java.net.ConnectException: Connection refused: connect
looks like server not started, but how I can start these server parallely? or is I have to user any other approach.
Upvotes: 4
Views: 2840
Reputation: 2953
You can just follow the detail instruction, I cannot copy/paste the whole article, hence attached the image
Upvotes: 0
Reputation: 594
Probably, you've not created myid file in dataDir of all zookeeper instances.
Make this file for all zookeeper instances and write corresponding server id such as 1 for first instance,2 for second instance,3 for third instance.
Save all files and first restart your all three instances and then check their status.
Upvotes: 0
Reputation: 164
Because by default, zkEnv.cmd will use the zoo.cfg as the default configuration file. And if you execute your command c:\opt\zookeeper\bin>zkServer.cmd
, then only one instance start up with configuration zoo.cfg
So if you want to start up three instances:
c:\opt\zookeeper1\bin>zkServer.cmd
, c:\opt\zookeeper2\bin>zkServer.cmd
, c:\opt\zookeeper3\bin>zkServer.cmd
zkServer.cmd ../conf/zoo.cfg
, zkServer.cmd ../conf/zoo2.cfg
, zkServer.cmd ../conf/zoo3.cfg
For alternative #2, you also need to update log4j configuration, so you can have different log file for each instances, so simply, just copy 3 folders, and modify each zoo.cfg
Check the code:
zkEnv.cmd
set ZOOCFG=%ZOOCFGDIR%\zoo.cfg
Upvotes: 2