Kafka Zookeeper - Java.net.BindException:地址已在使用中

问题描述 投票:0回答:3

我的机器上安装了 Kafka 并且运行良好。

然后我安装了 NetBeans,我认为这把事情搞砸了。现在我的动物园管理员还没有启动。

安装 netBeans 后,我在运行时遇到错误

缺少 JDK,需要运行一些 netbeans 模块

我使用这篇文章

解决了这个问题

现在当我开始使用 Zookeeper 时:

sudo bin/zookeeper-server-start.sh config/zookeeper.properties

我得到以下回溯:

[2018-01-31 17:30:09,953] INFO Reading configuration from:     config/zookeeper.properties     (org.apache.zookeeper.server.quorum.QuorumPeerConfig)
[2018-01-31 17:30:09,959] INFO autopurge.snapRetainCount set to 3     (org.apache.zookeeper.server.DatadirCleanupManager)
[2018-01-31 17:30:09,959] INFO autopurge.purgeInterval set to 0     (org.apache.zookeeper.server.DatadirCleanupManager)
[2018-01-31 17:30:09,959] INFO Purge task is not scheduled. (org.apache.zookeeper.server.DatadirCleanupManager)
[2018-01-31 17:30:09,959] WARN Either no config or no quorum defined     in config, running  in standalone mode     (org.apache.zookeeper.server.quorum.QuorumPeerMain)
[2018-01-31 17:30:09,979] INFO Reading configuration from:     config/zookeeper.properties     (org.apache.zookeeper.server.quorum.QuorumPeerConfig)
[2018-01-31 17:30:09,980] INFO Starting server     (org.apache.zookeeper.server.ZooKeeperServerMain)
[2018-01-31 17:30:09,991] INFO Server     environment:zookeeper.version=3.4.10-    39d3a4f269333c922ed3db283be479f9deacaa0f, built on 03/23/2017 10:13 GMT     (org.apache.zookeeper.server.ZooKeeperServer)
[2018-01-31 17:30:09,991] INFO Server environment:host.name=jojo     (org.apache.zookeeper.server.ZooKeeperServer)
[2018-01-31 17:30:09,991] INFO Server     environment:java.version=1.8.0_161     (org.apache.zookeeper.server.ZooKeeperServer)
[2018-01-31 17:30:09,992] INFO Server environment:java.vendor=Oracle     Corporation (org.apache.zookeeper.server.ZooKeeperServer)
[2018-01-31 17:30:09,992] INFO Server     environment:java.home=/usr/lib/jvm/java-8-oracle/jre     (org.apache.zookeeper.server.ZooKeeperServer)
[2018-01-31 17:30:09,992] INFO Server     environment:java.class.path=:/opt/Kafka/kafka_2.12-    0.11.0.0/bin/../libs/aopalliance-repackaged-2.5.0-    b05.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/argparse4j-    0.7.0.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/commons-lang3-    3.5.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/connect-api-0.11.0.0.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/connect-file-0.11.0.0.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/connect-json-0.11.0.0.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/connect-runtime-0.11.0.0.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/connect-    transforms-0.11.0.0.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/guava-20.0.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/hk2-api-2.5.0-b05.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/hk2-locator-2.5.0-b05.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/hk2-utils-2.5.0-b05.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/jackson-annotations-2.8.5.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/jackson-core-2.8.5.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/jackson-databind-2.8.5.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/jackson-jaxrs-base-2.8.5.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/jackson-jaxrs-json-provider-2.8.5.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/jackson-    module-jaxb-annotations-2.8.5.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/javassist-3.21.0-GA.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/javax.annotation-api-1.2.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/javax.inject-1.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/javax.inject-2.5.0-b05.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/javax.servlet-api-3.1.0.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/javax.ws.rs-api-2.0.1.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/jersey-client-2.24.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/jersey-common-2.24.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/jersey-container-servlet-2.24.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/jersey-container-servlet-core-2.24.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/jersey-guava-2.24.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/jersey-media-jaxb-2.24.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/jersey-server-2.24.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/jetty-continuation-9.2.15.v20160210.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/jetty-http-9.2.15.v20160210.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/jetty-io-9.2.15.v20160210.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/jetty-security-9.2.15.v20160210.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/jetty-server-9.2.15.v20160210.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/jetty-servlet-9.2.15.v20160210.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/jetty-    servlets-9.2.15.v20160210.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/jetty-util-9.2.15.v20160210.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/jopt-simple-5.0.3.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/kafka_2.12-0.11.0.0.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/kafka_2.12-0.11.0.0-sources.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/kafka_2.12-0.11.0.0-test-sources.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/kafka-clients-    0.11.0.0.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/kafka-log4j-appender-0.11.0.0.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/kafka-streams-0.11.0.0.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/kafka-streams-examples-0.11.0.0.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/kafka-tools-0.11.0.0.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/log4j-1.2.17.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/lz4-1.3.0.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/maven-artifact-3.5.0.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/metrics-core-2.2.0.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/osgi-resource-locator-1.0.1.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/plexus-utils-3.0.24.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/reflections-0.9.11.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/rocksdbjni-5.0.1.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/scala-library-2.12.2.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/scala-parser-combinators_2.12-1.0.4.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/slf4j-api-1.7.25.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/slf4j-log4j12-1.7.25.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/snappy-java-1.1.2.6.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/validation-api-1.1.0.Final.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/zkclient-0.10.jar:/opt/Kafka/kafka_2.12-0.11.0.0/bin/../libs/zookeeper-3.4.10.jar (org.apache.zookeeper.server.ZooKeeperServer)
[2018-01-31 17:30:09,992] INFO Server environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib (org.apache.zookeeper.server.ZooKeeperServer)
[2018-01-31 17:30:09,992] INFO Server environment:java.io.tmpdir=/tmp (org.apache.zookeeper.server.ZooKeeperServer)
[2018-01-31 17:30:09,992] INFO Server environment:java.compiler=<NA> (org.apache.zookeeper.server.ZooKeeperServer)
[2018-01-31 17:30:09,992] INFO Server environment:os.name=Linux (org.apache.zookeeper.server.ZooKeeperServer)
[2018-01-31 17:30:09,992] INFO Server environment:os.arch=amd64 (org.apache.zookeeper.server.ZooKeeperServer)
[2018-01-31 17:30:09,992] INFO Server environment:os.version=4.4.0-112-generic (org.apache.zookeeper.server.ZooKeeperServer)
[2018-01-31 17:30:09,992] INFO Server environment:user.name=root (org.apache.zookeeper.server.ZooKeeperServer)
[2018-01-31 17:30:09,992] INFO Server environment:user.home=/root (org.apache.zookeeper.server.ZooKeeperServer)
[2018-01-31 17:30:09,993] INFO Server environment:user.dir=/opt/Kafka/kafka_2.12-0.11.0.0     (org.apache.zookeeper.server.ZooKeeperServer)
[2018-01-31 17:30:09,999] INFO tickTime set to 3000 (org.apache.zookeeper.server.ZooKeeperServer)
[2018-01-31 17:30:09,999] INFO minSessionTimeout set to -1 (org.apache.zookeeper.server.ZooKeeperServer)
[2018-01-31 17:30:09,999] INFO maxSessionTimeout set to -1 (org.apache.zookeeper.server.ZooKeeperServer)
[2018-01-31 17:30:10,007] INFO binding to port 0.0.0.0/0.0.0.0:2181 (org.apache.zookeeper.server.NIOServerCnxnFactory)
[2018-01-31 17:30:10,008] ERROR Unexpected exception, exiting     abnormally (org.apache.zookeeper.server.ZooKeeperServerMain)
java.net.BindException: Address already in use
    at sun.nio.ch.Net.bind0(Native Method)
    at sun.nio.ch.Net.bind(Net.java:433)
    at sun.nio.ch.Net.bind(Net.java:425)
    at     sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
    at     sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
    at     sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:67)
    at     org.apache.zookeeper.server.NIOServerCnxnFactory.configure(NIOServerCnxnFa    ctory.java:90)
    at     org.apache.zookeeper.server.ZooKeeperServerMain.runFromConfig(ZooKeeperSer    verMain.java:117)
    at     org.apache.zookeeper.server.ZooKeeperServerMain.initializeAndRun(ZooKeeper    ServerMain.java:87)
    at     org.apache.zookeeper.server.ZooKeeperServerMain.main(ZooKeeperServerMain.j    ava:53)
    at     org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumP    eerMain.java:116)
    at     org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:78)

我试过这个:

netstat -ant | grep :2181

给我以下输出:

tcp6       0      0 :::2181                 :::*                    LISTEN     
tcp6       0      0 127.0.0.1:43566         127.0.0.1:2181          ESTABLISHED
tcp6       0      0 127.0.0.1:2181          127.0.0.1:43566         ESTABLISHED

在安装 NetBeans 之前,输出为:

tcp6       0      0 :::2181                 :::*                    LISTEN  

我认为这是问题所在,但我不知道如何解决。

我已经尝试过

sudo lsof -i :2181

输出:

COMMAND   PID      USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
java     1005 zookeeper   33u  IPv6  17209      0t0  TCP *:2181 (LISTEN)
java     1005 zookeeper   34u  IPv6 327225      0t0  TCP localhost:2181->localhost:43566 (ESTABLISHED)
java    22585      root   88u  IPv6 324552      0t0  TCP localhost:43566->localhost:2181 (ESTABLISHED)
apache-kafka apache-zookeeper
3个回答
20
投票

转到安装的 Kafka 文件夹并输入以下命令:

sudo bin/zookeeper-server-stop.sh

然后尝试执行以下命令:

bin/zookeeper-server-start.sh config/zookeeper.properties

希望您能摆脱错误。


18
投票

您应该转到配置文件夹。然后有一个文件zookeeper.properties,打开该文件并设置clientPort=5181(如果是未使用的端口)并设置maxClientCnxns=5(最初这里是0而不是5,您可以根据需要设置它)。


0
投票

看来zookeeper已经在端口2181上运行了。尝试通过运行以下命令来获取pid

netstat -tupln | grep 2181

获取pid后,使用以下命令杀死它

kill -9 <pid>

然后尝试开始

© www.soinside.com 2019 - 2024. All rights reserved.