Elasticsearch无法解析主机

时间:2017-07-21 06:16:36

标签: elasticsearch chef kibana

我们已将elasticsearch从2.3.1升级到5.x版本,问题是多个弹性支持实例之间的同步没有发生,我可以在2.3.1版本中没有出现的日志中看到这个特殊的异常。 / p>

Configuretion:

    elk_nodes_ips = []
    elk_nodes_results = search(:node, "roles:elasticsearch")
    unless elk_nodes_results.empty?
      elk_nodes_results.sort!{|node1, node2| node1.name <=> node2.name}
      elk_nodes_results.map{ |server| 
    elk_nodes_ips.push(server['hostname'])}
    else
      elk_nodes_ips.push('127.0.0.1')
    end

    data = "[#{elk_nodes_ips.join(",")}]"

    elasticsearch_configure 'elasticsearch' do
      # if you override one of these, you probably want to override all
    path_data  node['ElasticsearchWrapper']['path']['data']
    path_logs  node['ElasticsearchWrapper']['path']['logs']
    configuration ({
          'network.host' => '0.0.0.0',
          'http.port' => 9200,
          'discovery.zen.ping.unicast.hosts' => data
        })
      action :manage
    end

例外:

[2017-07-21T06:20:31,976] [WARN] [o.e.d.z.UnicastZenPing] [ElasticSearch-i-051b2c3eea79d3f62]无法解析主机[[ElasticSearch-i-036a95f01a737f4a2] java.lang.IllegalArgumentException:无效的括号内主机/端口范围:[ElasticSearch-i-036a95f01a737f4a2         在org.elasticsearch.transport.TcpTransport.parse(TcpTransport.java:871)〜[elasticsearch-5.4.1.jar:5.4.1]         at org.elasticsearch.transport.TcpTransport.addressesFromString(TcpTransport.java:852)〜[elasticsearch-5.4.1.jar:5.4.1]         at org.elasticsearch.transport.TransportService.addressesFromString(TransportService.java:674)〜[elasticsearch-5.4.1.jar:5.4.1]         at org.elasticsearch.discovery.zen.UnicastZenPing.lambda $ null $ 0(UnicastZenPing.java:213)〜[elasticsearch-5.4.1.jar:5.4.1]         在java.util.concurrent.FutureTask.run(FutureTask.java:266)〜[?:1.8.0_111]         at org.elasticsearch.common.util.concurrent.ThreadContext $ ContextPreservingRunnable.run(ThreadContext.java:569)[elasticsearch-5.4.1.jar:5.4.1]         在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[?:1.8.0_111]         at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)[?:1.8.0_111]         在java.lang.Thread.run(Thread.java:745)[?:1.8.0_111] [2017-07-21T06:20:31,984] [警告] [o.e.d.z.UnicastZenPing] [ElasticSearch-i-051b2c3eea79d3f62]未能解析主持人[ElasticSearch-i-051b2c3eea79d3f62]] java.net.UnknownHostException:ElasticSearch-i-051b2c3eea79d3f62]:名称或服务未知         at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)〜[?:1.8.0_111]         在java.net.InetAddress $ 2.lookupAllHostAddr(InetAddress.java:928)〜[?:1.8.0_111]         在java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323)〜[?:1.8.0_111]         在java.net.InetAddress.getAllByName0(InetAddress.java:1276)〜[?:1.8.0_111]         在java.net.InetAddress.getAllByName(InetAddress.java:1192)〜[?:1.8.0_111]         在java.net.InetAddress.getAllByName(InetAddress.java:1126)〜[?:1.8.0_111]         在org.elasticsearch.transport.TcpTransport.parse(TcpTransport.java:897)〜[elasticsearch-5.4.1.jar:5.4.1]         at org.elasticsearch.transport.TcpTransport.addressesFromString(TcpTransport.java:852)〜[elasticsearch-5.4.1.jar:5.4.1]         at org.elasticsearch.transport.TransportService.addressesFromString(TransportService.java:674)〜[elasticsearch-5.4.1.jar:5.4.1]         at org.elasticsearch.discovery.zen.UnicastZenPing.lambda $ null $ 0(UnicastZenPing.java:213)〜[elasticsearch-5.4.1.jar:5.4.1]         在java.util.concurrent.FutureTask.run(FutureTask.java:266)〜[?:1.8.0_111]         at org.elasticsearch.common.util.concurrent.ThreadContext $ ContextPreservingRunnable.run(ThreadContext.java:569)[elasticsearch-5.4.1.jar:5.4.1]         在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[?:1.8.0_111]         at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)[?:1.8.0_111]         在java.lang.Thread.run(Thread.java:745)[?:1.8.0_111] [2017-07-21T06:20:35,010] [INFO] [oecsClusterService] [ElasticSearch-i-051b2c3eea79d3f62] new_master {ElasticSearch-i-051b2c3eea79d3f62} {_ WzMZ_7mScOoIBjeA8Hoow} {N46xjTXWT8qIQNuRONh8PA} {172.18.50.225} {172.18.50.225:9300 },原因:zen-disco-election-as-master([0]节点加入)

elasticsearch.yml文件

    cluster.name: elasticsearch
    node.name: ElasticSearch-i-012d2c56e9920ec75
    path.conf: "/etc/elasticsearch"
    path.data: "/vol/data/elasticsearch"
    path.logs: "/vol/log/elasticsearch"
    network.host: 0.0.0.0
    http.port: 9200
    discovery.zen.ping.unicast.hosts: "[172.18.51.98]"

2 个答案:

答案 0 :(得分:2)

这一行是问题所在:data = "[#{elk_nodes_ips.join(",")}]"

您的意思是稍后执行此操作:'discovery.zen.ping.unicast.hosts' => elk_nodes_ips,。不需要字符串修改,自定义资源将为您处理(通过YAML序列化)。

答案 1 :(得分:0)

仔细查看此错误消息

failed to resolve host [[ElasticSearch-i-036a95f01a737f4a2]

你发现前面有两个支架。一个源于ES使用的日志格式,但另一个似乎已经以某种方式潜入您的主机名。您可以通过查看elasticsearch.yml文件验证吗?