无法在Windows中停止ZooKeeper

r8xiu3jd  于 2022-12-09  发布在  Apache
关注(0)|答案(2)|浏览(152)

当我试图使用命令“zkServer stop“停止ZooKeeper时,得到了以下结果:

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

输出量:

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]

我确信我已经启动了Zookeeper,因为当我试图启动一个新的时,它显示“java.net.BindException: Address already in use: bind
另一个奇怪的问题是,我在Windows服务列表中找不到Zookeeper。然而,当我试图通过netstat -and显示Windows PowerShell中的所有端口使用情况时,我发现2181正在使用中:

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]
7uzetpgm

7uzetpgm1#

我在Windows上运行ZooKeeper,但无法使用www.example.com阻止ZooKeeper在2181端口运行zookeeper-stop.sh,所以我尝试使用双斜杠“//”方法来执行taskkill。

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.

功劳归于:***

4ioopgfo

4ioopgfo2#

看起来有一个open bug concerning the start and stop commands in ZooKeeper

  • 若要启动ZooKeeper,请省略start参数并改为调用bin\zkServer
  • 如果您在任务管理器中看不到进程,您需要以管理员身份连接到ZooKeeper服务器并执行kill命令。更多details are here

相关问题