Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kafka Zookeeper - Java.net.BindException: Address already in use

I have Kafka setup on my machine and was running fine.

I then installed NetBeans and I think that messed things up. Now my zookeeper is not starting.

After netBeans installation I faced an error while running it

The JDK is missing and is required to run some netbeans modules

I solved the issue using this post

Now when I start zookeeper using:

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

I get the following traceback:

[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)

I have tried this:

netstat -ant | grep :2181

Gives me the following output:

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

Before installing NetBeans the output was:

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

I think this is the issue, but I don't know how to resolve this.

I have tried sudo lsof -i :2181

Output:

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)
like image 395
el323 Avatar asked Jan 31 '18 12:01

el323


1 Answers

You should go to the config folder. Then there is a file zookeeper.properties open the file and set clientPort=5181(if it is unused port) and set maxClientCnxns=5 (initially here was 0 instead of 5, you can set it as your requirement).

like image 89
punit bamaniya Avatar answered Oct 17 '22 07:10

punit bamaniya