Elasticsearch错误无法连接到master - 没有到主机的路由

时间:2014-09-17 08:08:54

标签: elasticsearch

当我使用命令bin/elasticsearch -f运行elasticsearch 0.90.0时,我收到此错误:

[2014-09-17 15:00:27,998][INFO ][node                     ] [Myers, Fred] {0.90.0}[8030]: initializing ...
[2014-09-17 15:00:28,005][INFO ][plugins                  ] [Myers, Fred] loaded [], sites []
[2014-09-17 15:00:30,508][INFO ][node                     ] [Myers, Fred] {0.90.0}[8030]: initialized
[2014-09-17 15:00:30,508][INFO ][node                     ] [Myers, Fred] {0.90.0}[8030]: starting ...
[2014-09-17 15:00:30,762][INFO ][transport                ] [Myers, Fred] bound_address {inet[/0:0:0:0:0:0:0:0:9301]}, publish_address {inet[/192.168.0.108:9301]}
[2014-09-17 15:00:36,874][WARN ][discovery.zen            ] [Myers, Fred] failed to connect to master [[Holly][nlr9o-yfSQ6MsTtYlTlqlw][inet[/192.168.1.6:9300]]], retrying...
org.elasticsearch.transport.ConnectTransportException: [Holly][inet[/192.168.1.6:9300]] connect_timeout[30s]
    at org.elasticsearch.transport.netty.NettyTransport.connectToChannels(NettyTransport.java:671)
    at org.elasticsearch.transport.netty.NettyTransport.connectToNode(NettyTransport.java:610)
    at org.elasticsearch.transport.netty.NettyTransport.connectToNode(NettyTransport.java:580)
    at org.elasticsearch.transport.TransportService.connectToNode(TransportService.java:127)
    at org.elasticsearch.discovery.zen.ZenDiscovery.innterJoinCluster(ZenDiscovery.java:337)
    at org.elasticsearch.discovery.zen.ZenDiscovery.access$500(ZenDiscovery.java:76)
    at org.elasticsearch.discovery.zen.ZenDiscovery$1.run(ZenDiscovery.java:290)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.net.NoRouteToHostException: No route to host
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:739)
    at org.elasticsearch.common.netty.channel.socket.nio.NioClientBoss.connect(NioClientBoss.java:150)
    at org.elasticsearch.common.netty.channel.socket.nio.NioClientBoss.processSelectedKeys(NioClientBoss.java:105)
    at org.elasticsearch.common.netty.channel.socket.nio.NioClientBoss.process(NioClientBoss.java:79)
    at org.elasticsearch.common.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:312)
    at org.elasticsearch.common.netty.channel.socket.nio.NioClientBoss.run(NioClientBoss.java:42)
    at org.elasticsearch.common.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
    at org.elasticsearch.common.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
    ... 3 more
[2014-09-17 15:00:36,874][WARN ][transport.netty          ] [Myers, Fred] exception caught on transport layer [[id: 0x361eaf47]], closing connection
java.net.NoRouteToHostException: No route to host
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:739)
    at org.elasticsearch.common.netty.channel.socket.nio.NioClientBoss.connect(NioClientBoss.java:150)
    at org.elasticsearch.common.netty.channel.socket.nio.NioClientBoss.processSelectedKeys(NioClientBoss.java:105)
    at org.elasticsearch.common.netty.channel.socket.nio.NioClientBoss.process(NioClientBoss.java:79)
    at org.elasticsearch.common.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:312)
    at org.elasticsearch.common.netty.channel.socket.nio.NioClientBoss.run(NioClientBoss.java:42)
    at org.elasticsearch.common.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
    at org.elasticsearch.common.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
[2014-09-17 15:00:42,892][WARN ][transport.netty          ] [Myers, Fred] exception caught on transport layer [[id: 0x2656abc9]], closing connection
java.net.NoRouteToHostException: No route to host
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:739)
    at org.elasticsearch.common.netty.channel.socket.nio.NioClientBoss.connect(NioClientBoss.java:150)
    at org.elasticsearch.common.netty.channel.socket.nio.NioClientBoss.processSelectedKeys(NioClientBoss.java:105)
...

我没有安装logstash。 当我访问localhost:9200时,我得到了

{
  ok: true,
  status: 503,
  name: "Haywire",
  version: {
    number: "0.90.0",
    snapshot_build: false
  },
  tagline: "You Know, for Search"
}

有人可以帮我解决这个问题吗?

3 个答案:

答案 0 :(得分:13)

您的ElasticSearch实例正在尝试加入群集(可能是您网络上的其他人)但却失败了。您应该禁用自动群集发现。

  1. /etc/elasticsearch/elasticsearch.yml

  2. 中找到“发现”部分
  3. 取消注释此行,禁用多播发现(默认情况下启用):

  4. # discovery.zen.ping.multicast.enabled: false

    编辑:我刚刚发现即使禁用“zen multicast discovery”也会发生此错误。如果(像我一样)network.bind_host: 127.0.0.1中有elasticsearch.yml(仅允许本地连接到ElasticSearch),您还必须设置network.host: 127.0.0.1。否则,ElasticSearch将无法连接到自身(由于某种原因,它需要)。

答案 1 :(得分:6)

为群集命名,问题将得到解决。

在弹性搜索目录中修改config/elasticsearch.yml

取消注释cluster.name: elasticsearch并将其更改为cluster.name: your_hostname

然后尝试再次启动elasticsearch。

答案 2 :(得分:0)

您的网络上有人正在运行elasticsearch,您无法访问其服务器。将您的群集名称设置为其他名称,您将不会遇到该问题:

bin/elasticsearch --Des.cluster.name=your_name

当ES启动时,它使用多播发现来查找具有相同群集名称的其他节点。默认的群集名称为elasticsearch,因此多播正在运行并找到另一个ES主机。当您尝试加入它时,它会切换到TCP并尝试直接连接到IP地址,并且您的网络拓扑正在阻止它(因此无路由主机)。