3

我是 Storm 的新手。我遇到以下错误

java.net.ConnectException: Connection refused
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:599)
    at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1119)
1178482 [Thread-11-SendThread(localhost:2000)] WARN  org.apache.zookeeper.ClientCnxn  - Session 0x1417cd58578000b for server null, unexpected error, closing socket connection and attempting reconnect

有时我的拓扑工作正常,但当我再次尝试时,我得到了上述错误。在谷歌中搜索了很多但找不到任何线索。我在本地集群中运行我的拓扑..请提出一些解决方案

请在下面找到更多日志:-

2595 [Thread-11-EventThread] INFO  com.netflix.curator.framework.state.ConnectionStateManager  - State change: SUSPENDED
2596 [Thread-11-EventThread] WARN  backtype.storm.cluster  - Received event :disconnected::none: with disconnected Zookeeper.
2596 [ConnectionStateManager-0] WARN  com.netflix.curator.framework.state.ConnectionStateManager  - There are no ConnectionStateListeners registered.
3592 [Thread-11-SendThread(localhost:2000)] WARN  org.apache.zookeeper.ClientCnxn  - Session 0x1417e6596c7000b for server null, unexpected error, closing socket connection and attempting reconnect
java.net.ConnectException: Connection refused
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:599)
    at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1119)
3895 [Thread-11-SendThread(localhost:2000)] WARN  org.apache.zookeeper.ClientCnxn  - Session 0x1417e6596c7000b for server null, unexpected error, closing socket connection and attempting reconnect
org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss
    at org.apache.zookeeper.KeeperException.create(KeeperException.java:90)
    at com.netflix.curator.framework.imps.CuratorFrameworkImpl.processBackgroundOperation(CuratorFrameworkImpl.java:380)
    at com.netflix.curator.framework.imps.BackgroundSyncImpl$1.processResult(BackgroundSyncImpl.java:49)
    at org.apache.zookeeper.ClientCnxn$EventThread.processEvent(ClientCnxn.java:617)
    at org.apache.zookeeper.ClientCnxn$EventThread.run(ClientCnxn.java:506)

请查找更多日志:-

java.net.ConnectException: Connection refused
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:599)
    at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1119)
50454 [Thread-15] ERROR com.netflix.curator.ConnectionState  - Connection timed out
org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss
    at com.netflix.curator.ConnectionState.getZooKeeper(ConnectionState.java:72)
    at com.netflix.curator.CuratorZookeeperClient.getZooKeeper(CuratorZookeeperClient.java:74)
    at com.netflix.curator.framework.imps.CuratorFrameworkImpl.getZooKeeper(CuratorFrameworkImpl.java:353)
    at com.netflix.curator.framework.imps.ExistsBuilderImpl$2.call(ExistsBuilderImpl.java:149)
    at com.netflix.curator.framework.imps.ExistsBuilderImpl$2.call(ExistsBuilderImpl.java:138)
    at com.netflix.curator.RetryLoop.callWithRetry(RetryLoop.java:85)
    at com.netflix.curator.framework.imps.ExistsBuilderImpl.pathInForeground(ExistsBuilderImpl.java:134)
    at com.netflix.curator.framework.imps.ExistsBuilderImpl.forPath(ExistsBuilderImpl.java:125)
    at com.netflix.curator.framework.imps.ExistsBuilderImpl.forPath(ExistsBuilderImpl.java:34)
    at backtype.storm.zookeeper$exists_node_QMARK_.invoke(zookeeper.clj:78)
    at backtype.storm.zookeeper$exists.invoke(zookeeper.clj:117)
    at backtype.storm.cluster$mk_distributed_cluster_state$reify__1996.set_data(cluster.clj:70)
    at backtype.storm.cluster$mk_storm_cluster_state$reify__2415.worker_heartbeat_BANG_(cluster.clj:276)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:93)
    at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:28)
    at backtype.storm.daemon.worker$do_executor_heartbeats.doInvoke(worker.clj:35)
    at clojure.lang.RestFn.invoke(RestFn.java:439)
    at backtype.storm.daemon.worker$fn__4348$exec_fn__1228__auto____4349$fn__4352.invoke(worker.clj:346)
    at backtype.storm.timer$schedule_recurring$this__1776.invoke(timer.clj:69)
    at backtype.storm.timer$mk_timer$fn__1759$fn__1760.invoke(timer.clj:33)
    at backtype.storm.timer$mk_timer$fn__1759.invoke(timer.clj:26)
    at clojure.lang.AFn.run(AFn.java:24)
    at java.lang.Thread.run(Thread.java:680)
4

1 回答 1

7

我也刚遇到这个问题。我的问题是运行时间设置的太短了。zookeeper没有足够的时间正常关闭。看下面的代码:

    builder.createTopology());

    try {
        Thread.sleep(20000);
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    cluster.shutdown();
}

您应该在调用 cluster.shutdown() 之前设置足够的时间。一开始我设置了Thread.sleep(1000),然后出现了和你一样的问题。改了时间之后,这个问题就再也没有出现过。

于 2014-03-31T09:42:28.483 回答