【问题标题】:zookeeper connection timing out, kafa-spark streamingzookeeper 连接超时,kafa-spark 流式传输
【发布时间】:2018-01-12 06:25:52
【问题描述】:

我正在尝试使用 kafka 进行火花流的一些练习。如果我在命令行中使用 kafka 生产者和消费者,我可以在 kafka 中发布和消费消息。当我尝试在 jupyter notebook 中使用 pyspark 时。我收到 zookeeper 连接超时错误。

Client session timed out, have not heard from server in 6004ms for sessionid 0x0, closing socket connection and attempting reconnect
[2017-08-04 15:49:37,494] INFO Initiating client connection, connectString=127.0.0.1:2181 sessionTimeout=6000 watcher=org.I0Itec.zkclient.ZkClient@158da8e (org.apache.zookeeper.ZooKeeper)
[2017-08-04 15:49:37,524] INFO Waiting for keeper state SyncConnected (org.I0Itec.zkclient.ZkClient)
[2017-08-04 15:49:37,527] INFO Opening socket connection to server 127.0.0.1/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)
[2017-08-04 15:49:37,533] WARN Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
java.net.ConnectException: Connection refused
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
    at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)
    at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1141)
[2017-08-04 15:49:38,637] INFO Opening socket connection to server 127.0.0.1/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)
[2017-08-04 15:49:38,639] WARN Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
java.net.ConnectException: Connection refused

`

【问题讨论】:

    标签: apache-spark apache-kafka spark-streaming apache-zookeeper


    【解决方案1】:

    Zookeeper 在使用 localhost (127.0.0.1) 时出现问题。描述于https://issues.apache.org/jira/browse/ZOOKEEPER-1661?focusedCommentId=13599352

    这个小程序解释了以下几点:

    ZooKeeper 确实在连接字符串“localhost:2181”=> 上调用 InetAddress.getAllByName(参见 StaticHostProvider:60),因此它为 localhost 获得了 3 个不同的地址,然后被打乱(Collections.shuffle(this.serverAddresses): L72

    由于改组(随机),对 StaticHostProvider.next 的调用有时会返回 fe80:0:0:0:0:0:0:1%1 地址,正如您从这个小程序中看到的那样超时5 秒后 => 这解释了我正在经历的随机性。

    在我看来,我遇到的是 IPv6 的反向 dns 查找问题。我不知道 ZooKeeper 是否真的需要这种反向 dns 查找。它在 3.3.3 中没有这种行为。

    解决方案,将您的 zookeeper 地址指定为 FQDN,并确保反向查找有效或使用 0.0.0.0 而不是 localhost

    【讨论】:

      猜你喜欢
      • 2017-12-05
      • 2017-09-15
      • 1970-01-01
      • 1970-01-01
      • 2021-12-07
      • 2018-05-27
      • 2012-01-21
      • 2020-07-17
      • 2013-09-24
      相关资源
      最近更新 更多