未创建Kafka主题(ZooKeeperClientTimeoutException)

时间:2020-03-26 15:22:55

标签: apache-kafka timeoutexception

我在Linux展台上打开Kafka的包装,然后这样做:

启动Zookeeper:

./zookeeper-server-start.sh

输出:

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

启动kafka服务器

./kafka-server-start.sh

输出:

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

然后我尝试创建主题

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

但有例外

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)

请帮助解决此问题

1 个答案:

答案 0 :(得分:1)

从输出中可以看到:

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

如果要启动服务器,则需要指定这些properties文件,这些文件位于kafka主页下的config目录中。

所以要启动Zookeeper:

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

然后启动kafka服务器

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

然后,尝试创建主题