1

When I tried to stop the ZooKeeper with command "zkServer stop", I got the following result:

call "C:\Program Files\Java\jdk1.8.0_121"\bin\java "-Dzookeeper.log.dir=C:\zookeeper-3.4.10\bin\.." "-Dzookeeper.root.logger=INFO,CONSOLE" -cp "C:\zookeeper-3.4.10\bin\..\build\classes;C:\zookeeper-3.4.10\bin\..\build\lib\*;C:\zookeeper-3.4.10\bin\..\*;C:\zookeeper-3.4.10\bin\..\lib\*;C:\zookeeper-3.4.10\bin\..\conf" org.apache.zookeeper.server.quorum.QuorumPeerMain "C:\zookeeper-3.4.10\bin\..\conf\zoo.cfg" stop

Output:

2017-09-01 13:55:22,070 [myid:] - INFO  [main:DatadirCleanupManager@78] - autopurge.snapRetainCount set to 3
2017-09-01 13:55:22,072 [myid:] - INFO  [main:DatadirCleanupManager@79] - autopurge.purgeInterval set to 0
2017-09-01 13:55:22,072 [myid:] - INFO  [main:DatadirCleanupManager@101] - Purge task is not scheduled.
2017-09-01 13:55:22,072 [myid:] - WARN  [main:QuorumPeerMain@113] - Either no config or no quorum defined in config, running  in standalone mode
2017-09-01 13:55:22,145 [myid:] - ERROR [main:ZooKeeperServerMain@55] - Invalid arguments, exiting abnormally
java.lang.NumberFormatException: For input string: "C:\zookeeper-3.4.10\bin\..\conf\zoo.cfg"
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
    at java.lang.Integer.parseInt(Integer.java:580)
    at java.lang.Integer.parseInt(Integer.java:615)
    at org.apache.zookeeper.server.ServerConfig.parse(ServerConfig.java:59)
    at org.apache.zookeeper.server.ZooKeeperServerMain.initializeAndRun(ZooKeeperServerMain.java:84)
    at org.apache.zookeeper.server.ZooKeeperServerMain.main(ZooKeeperServerMain.java:53)
    at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:116)
    at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:78)
2017-09-01 13:55:22,148 [myid:] - INFO  [main:ZooKeeperServerMain@56] - Usage: ZooKeeperServerMain configfile | port datadir [ticktime] [maxcnxns]

I am sure I have started the Zookeeper, because when I tried to start a new one, it shows "java.net.BindException: Address already in use: bind"

Another strange problem is that I cannot find Zookeeper in the Windows Service list. However, when I tried to show all port usage in Windows PowerShell by netstat -and, I found the 2181 is in use:

 Proto  Local Address          Foreign Address        State
 TCP    0.0.0.0:2181           0.0.0.0:0              LISTENING
[java.exe]
 TCP    [::1]:2181             [::1]:62268            ESTABLISHED
[java.exe]
 TCP    [::1]:2181             [::1]:62279            ESTABLISHED
[java.exe]
 TCP    [::1]:2181             [::1]:62280            ESTABLISHED
[java.exe]
 TCP    [::1]:2181             [::1]:62281            ESTABLISHED
[java.exe]
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Spider
  • 1,380
  • 4
  • 22
  • 42

2 Answers2

4

I was running ZooKeeper on Windows and wasn't able to stop ZooKeeper running at 2181 port using zookeeper-stop.sh, so I tried this double slash "//" method to taskkill. It worked

1. netstat -ano | findstr :2181

  TCP    0.0.0.0:2181           0.0.0.0:0              LISTENING       8876
  TCP    [::]:2181              [::]:0                 LISTENING       8876

2. taskkill //PID 8876 //F

  SUCCESS: The process with PID 8876 has been terminated.

Credit goes to: How do I kill the process currently using a port on localhost in Windows?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
driven_spider
  • 495
  • 4
  • 16
3

It looks like there is an open bug concerning the start and stop commands in ZooKeeper

  • To start ZooKeeper, omit the start parameter and call bin\zkServer instead.
  • To stop it, if you don't see the process from the task manager. You need to connect to ZooKeeper server as an administrator and perform the kill commands. More details are here.
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
user10089632
  • 5,216
  • 1
  • 26
  • 34
  • 1
    Yeah, thank you! And I killed it by "netstat -ano | findstr :2181" and "taskkill /PID typeyourPIDhere /F". See details at https://stackoverflow.com/questions/39632667/how-to-kill-a-currently-using-port-on-localhost-in-windows – Spider Sep 01 '17 at 13:21
  • I'll add that, to be a more complete answer – user10089632 Sep 01 '17 at 13:24