Search code examples
apache-kafkatimeoutexception

Kafka topic is not created (ZooKeeperClientTimeoutException)


I unpack Kafka on my Linux stand, then I did:

start zookeeper:

./zookeeper-server-start.sh

output:

USAGE: ./zookeeper-server-start.sh [-daemon] zookeeper.properties

start kafka-server

./kafka-server-start.sh

output:

USAGE: ./kafka-server-start.sh [-daemon] server.properties [--override property=value]*

then i tried to create topic

./kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic fss-fsstransdata

but got exception

Exception in thread "main" kafka.zookeeper.ZooKeeperClientTimeoutException: Timed out waiting for connection while in state: CONNECTING
        at kafka.zookeeper.ZooKeeperClient$$anonfun$kafka$zookeeper$ZooKeeperClient$$waitUntilConnected$1.apply$mcV$sp(ZooKeeperClient.scala:259)
        at kafka.zookeeper.ZooKeeperClient$$anonfun$kafka$zookeeper$ZooKeeperClient$$waitUntilConnected$1.apply(ZooKeeperClient.scala:255)
        at kafka.zookeeper.ZooKeeperClient$$anonfun$kafka$zookeeper$ZooKeeperClient$$waitUntilConnected$1.apply(ZooKeeperClient.scala:255)
        at kafka.utils.CoreUtils$.inLock(CoreUtils.scala:253)
        at kafka.zookeeper.ZooKeeperClient.kafka$zookeeper$ZooKeeperClient$$waitUntilConnected(ZooKeeperClient.scala:255)
        at kafka.zookeeper.ZooKeeperClient.<init>(ZooKeeperClient.scala:113)
        at kafka.zk.KafkaZkClient$.apply(KafkaZkClient.scala:1857)
        at kafka.admin.TopicCommand$ZookeeperTopicService$.apply(TopicCommand.scala:321)
        at kafka.admin.TopicCommand$.main(TopicCommand.scala:54)
        at kafka.admin.TopicCommand.main(TopicCommand.scala)

Please, help to resolve this problem


Solution

  • As you can see from your outputs:

    USAGE: ./zookeeper-server-start.sh [-daemon] zookeeper.properties
    USAGE: ./kafka-server-start.sh [-daemon] server.properties [--override property=value]*
    

    You need to specify those properties file if you want to start the servers, those files are in config directory under kafka home.

    So to start zookeeper:

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

    then to start kafka-server

    ./kafka-server-start.sh ../config/server.properties
    

    Then, try creating the topics