webentwicklung-frage-antwort-db.com.de

Kafka kann keine Verbindung zu Zookeeper herstellen

Ich habe gerade angefangen, Kafka/Zookeper zu lernen. Wenn ich versuche, den Konsolenbenutzer auszuführen, um die Nachricht für ein Thema zu überprüfen, erhalte ich folgende Fehlermeldung:

[email protected]:~$ $KAFKA_HOME/bin/kafka-console-consumer.sh --zookeeper 192.168.33.10:2181 --topic topic-3
[2015-02-22 22:56:36,666] INFO Verifying properties (kafka.utils.VerifiableProperties)
[2015-02-22 22:56:36,698] INFO Property group.id is overridden to console-consumer-92151 (kafka.utils.VerifiableProperties)
[2015-02-22 22:56:36,699] INFO Property fetch.message.max.bytes is overridden to 1048576 (kafka.utils.VerifiableProperties)
[2015-02-22 22:56:36,700] INFO Property consumer.timeout.ms is overridden to -1 (kafka.utils.VerifiableProperties)
[2015-02-22 22:56:36,700] INFO Property socket.timeout.ms is overridden to 30000 (kafka.utils.VerifiableProperties)
[2015-02-22 22:56:36,700] INFO Property auto.offset.reset is overridden to largest (kafka.utils.VerifiableProperties)
[2015-02-22 22:56:36,701] INFO Property zookeeper.connect is overridden to 192.168.33.10:2181 (kafka.utils.VerifiableProperties)
[2015-02-22 22:56:36,701] INFO Property socket.receive.buffer.bytes is overridden to 2097152 (kafka.utils.VerifiableProperties)
[2015-02-22 22:56:36,701] INFO Property fetch.wait.max.ms is overridden to 100 (kafka.utils.VerifiableProperties)
[2015-02-22 22:56:36,702] INFO Property auto.commit.enable is overridden to true (kafka.utils.VerifiableProperties)
[2015-02-22 22:56:36,702] INFO Property refresh.leader.backoff.ms is overridden to 200 (kafka.utils.VerifiableProperties)
[2015-02-22 22:56:36,702] INFO Property auto.commit.interval.ms is overridden to 60000 (kafka.utils.VerifiableProperties)
[2015-02-22 22:56:36,703] INFO Property fetch.min.bytes is overridden to 1 (kafka.utils.VerifiableProperties)
[2015-02-22 22:56:36,734] INFO [console-consumer-92151_debian-70rc1-x64-vbox4210-1424645796729-11446a89], Connecting to zookeeper instance at 192.168.33.10:2181 (kafka.consumer.ZookeeperConsumerConnector)
[2015-02-22 22:56:36,754] INFO Starting ZkClient event thread. (org.I0Itec.zkclient.ZkEventThread)
[2015-02-22 22:56:36,755] INFO Client environment:zookeeper.version=3.3.3-1203054, built on 11/17/2011 05:47 GMT (org.Apache.zookeeper.ZooKeeper)
[2015-02-22 22:56:36,756] INFO Client environment:Host.name=debian-70rc1-x64-vbox4210.vagrantup.com (org.Apache.zookeeper.ZooKeeper)
[2015-02-22 22:56:36,756] INFO Client environment:Java.version=1.7.0_75 (org.Apache.zookeeper.ZooKeeper)
[2015-02-22 22:56:36,757] INFO Client environment:Java.vendor=Oracle Corporation (org.Apache.zookeeper.ZooKeeper)
[2015-02-22 22:56:36,757] INFO Client environment:Java.home=/usr/lib/jvm/Java-7-openjdk-AMD64/jre (org.Apache.zookeeper.ZooKeeper)
[2015-02-22 22:56:36,757] INFO Client environment:Java.class.path=:/usr/local/kafka/kafka-0.8.0-beta1-src//bin/../core/target/scala-2.8.0/kafka_2.8.0-0.8.0-beta1.jar:/usr/local/kafka/kafka-0.8.0-beta1-src//bin/../core/target/scala-2.8.0/kafka-Assembly-0.8.0-beta1-deps.jar:/usr/local/kafka/kafka-0.8.0-beta1-src//bin/../perf/target/scala-2.8.0/kafka-perf_2.8.0-0.8.0-beta1.jar:/usr/local/kafka/kafka-0.8.0-beta1-src//bin/../libs/*.jar:/usr/local/kafka/kafka-0.8.0-beta1-src//bin/../kafka*.jar (org.Apache.zookeeper.ZooKeeper)
[2015-02-22 22:56:36,758] INFO Client environment:Java.library.path=/usr/Java/packages/lib/AMD64:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib (org.Apache.zookeeper.ZooKeeper)
[2015-02-22 22:56:36,758] INFO Client environment:Java.io.tmpdir=/tmp (org.Apache.zookeeper.ZooKeeper)
[2015-02-22 22:56:36,758] INFO Client environment:Java.compiler=<NA> (org.Apache.zookeeper.ZooKeeper)
[2015-02-22 22:56:36,759] INFO Client environment:os.name=Linux (org.Apache.zookeeper.ZooKeeper)
[2015-02-22 22:56:36,759] INFO Client environment:os.Arch=AMD64 (org.Apache.zookeeper.ZooKeeper)
[2015-02-22 22:56:36,759] INFO Client environment:os.version=3.2.0-4-AMD64 (org.Apache.zookeeper.ZooKeeper)
[2015-02-22 22:56:36,759] INFO Client environment:user.name=vagrant (org.Apache.zookeeper.ZooKeeper)
[2015-02-22 22:56:36,760] INFO Client environment:user.home=/home/vagrant (org.Apache.zookeeper.ZooKeeper)
[2015-02-22 22:56:36,760] INFO Client environment:user.dir=/home/vagrant (org.Apache.zookeeper.ZooKeeper)
[2015-02-22 22:56:36,761] INFO Initiating client connection, connectString=192.168.33.10:2181 sessionTimeout=6000 [email protected] (org.Apache.zookeeper.ZooKeeper)
[2015-02-22 22:56:36,773] INFO Opening socket connection to server /192.168.33.10:2181 (org.Apache.zookeeper.ClientCnxn)
[2015-02-22 22:56:42,778] INFO Terminate ZkClient event thread. (org.I0Itec.zkclient.ZkEventThread)
[2015-02-22 22:56:46,791] INFO Socket connection established to 192.168.33.10/192.168.33.10:2181, initiating session (org.Apache.zookeeper.ClientCnxn)
[2015-02-22 22:56:46,801] INFO Session establishment complete on server 192.168.33.10/192.168.33.10:2181, sessionid = 0x14bb3752996000d, negotiated timeout = 6000 (org.Apache.zookeeper.ClientCnxn)
[2015-02-22 22:56:46,803] INFO Session: 0x14bb3752996000d closed (org.Apache.zookeeper.ZooKeeper)
Exception in thread "main" org.I0Itec.zkclient.exception.ZkTimeoutException: Unable to connect to zookeeper server within timeout: 6000
        at org.I0Itec.zkclient.ZkClient.connect(ZkClient.Java:880)
        at org.I0Itec.zkclient.ZkClient.<init>(ZkClient.Java:98)
        at org.I0Itec.zkclient.ZkClient.<init>(ZkClient.Java:84)
        at kafka.consumer.ZookeeperConsumerConnector.connectZk(ZookeeperConsumerConnector.scala:151)
        at kafka.consumer.ZookeeperConsumerConnector.<init>(ZookeeperConsumerConnector.scala:112)
        at kafka.consumer.ZookeeperConsumerConnector.<init>(ZookeeperConsumerConnector.scala:123)
        at kafka.consumer.Consumer$.create(ConsumerConnector.scala:89)
        at kafka.consumer.ConsoleConsumer$.main(ConsoleConsumer.scala:178)
        at kafka.consumer.ConsoleConsumer.main(ConsoleConsumer.scala)
[2015-02-22 22:56:46,804] INFO EventThread shut down (org.Apache.zookeeper.ClientCnxn)

Es sagt-

Exception in thread "main" org.I0Itec.zkclient.exception.ZkTimeoutException: Unable to connect to zookeeper server within timeout: 6000

Ich habe das Thema überprüft und es ist anwesend. Was läuft schief? Bitte helfen.

7
S R

Ich hatte das gleiche Problem und hier ist, wie ich es behoben habe:

1) Stoppen Sie alle Kafka- und Zookeeper-Prozesse

ps -aux | grep Zoo

ps -aux | grep kafka

(Fahren Sie dann fort, um alle Prozess-IDs von den obigen Jobs zu beenden.)

2) Zookeeper ausführen

<kafka_dir>/bin/zookeeper-server-start.sh ../config/zookeeper.properties

3) Führen Sie den Kafka-Server aus

<kafka_dir>/bin/kafka-server-start.sh ../config/server.properties

6
MauricioRoman

Versuchen Sie, -> telnet 192.168.33.10 2181 Wenn das Telnet ausfällt, liegt das Problem an einer der folgenden Ursachen.

Die Echo-Kette von Zookeeper Server NRPE scheint keine Standardannahmeregel zu haben.

Wenn Sie nicht nur eine eigene iptables-Kette für NRPE wünschen, können Sie Folgendes verwenden:

iptables -I INPUT -s 0/0 -p tcp --dport 2181 -j ACCEPT

Dies löst das Problem.

4
Arijeet Saha

In meinem Fall war es bereits mit dem Host verbunden, von dem aus ich versuchte, es konnte also keine neue Verbindung zum Host hergestellt werden. Ich musste die config ändern: maxClientCnxns , damit mehr Verbindungen zu diesem Host hergestellt werden konnten. Weitere Details hier .

0
Saurabh

Sie können die folgende Anleitung ausprobieren, um zu sehen, ob es hilft.
1) Stellen Sie sicher, dass der Zookeeper läuft, und versuchen Sie, eine Verbindung mit dem zkCli-Client herzustellen. 
2) Hängen Sie --from-beginning am Ende Ihres Befehls an, um zu sehen, ob sich in der Ausgabe Unterschiede ergeben. Daher sollte der Befehl folgendermaßen geändert werden:

    $KAFKA_HOME/bin/kafka-console-consumer.sh --zookeeper xxx.xx.xx.xxx:2181 --topic topic-3 --from-beginning
0
user2720864