Elasticsearch 无法解析主机

迪帕克

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

配置:

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] failed to resolve host [[ElasticSearch-i-036a95f01a737f4a2]
java.lang.IllegalArgumentException: Invalid bracketed host/port range: [ElasticSearch-i-036a95f01a737f4a2
        at 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]
        at 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]
        at 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]
        at java.lang.Thread.run(Thread.java:745) [?:1.8.0_111]
[2017-07-21T06:20:31,984][WARN ][o.e.d.z.UnicastZenPing   ] [ElasticSearch-i-051b2c3eea79d3f62] failed to resolve host [ElasticSearch-i-051b2c3eea79d3f62]]
java.net.UnknownHostException: ElasticSearch-i-051b2c3eea79d3f62]: Name or service not known
        at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method) ~[?:1.8.0_111]
        at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:928) ~[?:1.8.0_111]
        at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323) ~[?:1.8.0_111]
        at java.net.InetAddress.getAllByName0(InetAddress.java:1276) ~[?:1.8.0_111]
        at java.net.InetAddress.getAllByName(InetAddress.java:1192) ~[?:1.8.0_111]
        at java.net.InetAddress.getAllByName(InetAddress.java:1126) ~[?:1.8.0_111]
        at 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]
        at 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]
        at 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]
        at java.lang.Thread.run(Thread.java:745) [?:1.8.0_111]
[2017-07-21T06:20:35,010][INFO ][o.e.c.s.ClusterService   ] [ElasticSearch-i-051b2c3eea79d3f62] new_master {ElasticSearch-i-051b2c3eea79d3f62}{_WzMZ_7mScOoIBjeA8Hoow}{N46xjTXWT8qIQNuRONh8PA}{172.18.50.225}{172.18.50.225:9300}, reason: zen-disco-elected-as-master ([0] nodes joined)

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]"
代码护林员

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

你的意思是要做到这一点以后:'discovery.zen.ping.unicast.hosts' => elk_nodes_ips,不需要字符串处理,自定义资源将为您处理(通过 YAML 序列化)。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章