3
votes

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:

  1. Creating multiple zoo.conf file into conf folder. Structure as below

    zookeeper_home---| conf--| zoo.cfg zoo_2.cfg zoo_3.cfg

  2. 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
  1. zoo_2.cfg
 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
  1. zoo_3.cfg
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
  1. As each file has dataDir, I have created folder as

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.

3
Have you started all three of the servers? These exceptions are a normal part of ZooKeeper's interaction with the ensemble. ZooKeeper is designed to be able to handle not communicating with other servers in a quorum. It's possible that once they're all started you will see these exceptions disappear.kuujo
That's true, but how to start all 3 servers?Bharat

3 Answers

2
votes

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:

  1. either you copy three zookeeper package, and each has its own zoo.cfg, and execute following command for each c:\opt\zookeeper1\bin>zkServer.cmd, c:\opt\zookeeper2\bin>zkServer.cmd, c:\opt\zookeeper3\bin>zkServer.cmd
  2. Or you can modify zkEnv.cmd, and make it accept the parameter as the configuration file, the you can execute 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

1
votes

Google has the answer enter image description here

You can just follow the detail instruction, I cannot copy/paste the whole article, hence attached the image

0
votes

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.