web-dev-qa-db-ja.com

Kafka Zookeeperに接続できません

Kafka/Zookeperの学習を始めました。私が直面している問題は、コンソールコンシューマーを実行してトピックのメッセージを確認しようとすると、次のエラーが発生することです。

vagrant@debian-70rc1-x64-vbox4210:~$ $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 watcher=org.I0Itec.zkclient.ZkClient@234a98fa (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)

それは言う

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

トピックを確認しましたが、存在しています。何が問題になっていますか。助けてください。

7
S R

私は同じ問題を抱えていましたが、これが私がそれを修正した方法です:

1)すべてのKafkaおよびZookeeperプロセスを停止します

ps -aux | grep Zoo

ps -aux | grep kafka

(次に、上記のジョブからすべてのプロセスIDを強制終了します)

2)飼育係を実行する

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

3)実行kafkaサーバー

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

8
MauricioRoman

試してください-> telnet 192.168.33.10 2181 telnetが失敗する場合、問題は以下の理由によるものです。

ZookeeperサーバーNRPE iptablesチェーンには、デフォルトの受け入れルールがないようです。

NRPEに独自のiptablesチェーンが必要な場合を除き、以下を使用できます。

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

これは問題を解決します。

4
Arijeet Saha

私の場合、それは私が試みていたホストにすでに接続されていたので、ホストに新しい接続を行うことができませんでした。私は設定を変更する必要がありました: maxClientCnxns これにより、そのホストへの接続を増やすことができました。詳細 こちら

0
Saurabh

次のことを試して、効果があるかどうかを確認してください。
1)zookeeperが稼働中であることを確認し、zkCliクライアントを使用してzookeeperに接続してみます。
2)コマンドの最後に--from-beginningを追加して、出力に違いがあるかどうかを確認するため、コマンドを次のように変更する必要があります。

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