【问题标题】:yet another Could not contact Elasticsearch at http://logstash.example.com:9200另一个无法通过 http://logstash.example.com:9200 联系 Elasticsearch
【发布时间】:2015-01-13 14:59:00
【问题描述】:

我已将 logstash+elasticsearch+kibana 安装到一台主机中,并收到标题中的错误。我已经用谷歌搜索了所有相关主题,但仍然没有运气,但仍然卡住了。 我将分享我所做的配置:

elasticsearch.yml

cluster.name: hive
node.name: "logstash-central"
network.bind_host: 10.1.1.25

/var/log/elasticsearch/hive.log 的输出

[2015-01-13 15:18:06,562][INFO ][node                     ] [logstash-central] initializing ...
[2015-01-13 15:18:06,566][INFO ][plugins                  ] [logstash-central] loaded [], sites []
[2015-01-13 15:18:09,275][INFO ][node                     ] [logstash-central] initialized
[2015-01-13 15:18:09,275][INFO ][node                     ] [logstash-central] starting ...
[2015-01-13 15:18:09,385][INFO ][transport                ] [logstash-central] bound_address {inet[/10.1.1.25:9300]}, publish_address {inet[/10.1.1.25:9300]}
[2015-01-13 15:18:09,401][INFO ][discovery                ] [logstash-central] hive/T2LZruEtRsGPAF_Cx3BI1A
[2015-01-13 15:18:13,173][INFO ][cluster.service          ] [logstash-central] new_master [logstash-central][T2LZruEtRsGPAF_Cx3BI1A][logstash.tw.intra][inet[/10.1.1.25:9300]], reason: zen-disco-join (elected_as_master)
[2015-01-13 15:18:13,193][INFO ][http                     ] [logstash-central] bound_address {inet[/10.1.1.25:9200]}, publish_address {inet[/10.1.1.25:9200]}
[2015-01-13 15:18:13,194][INFO ][node                     ] [logstash-central] started
[2015-01-13 15:18:13,209][INFO ][gateway                  ] [logstash-central] recovered [0] indices into cluster_state

访问 logstash.example.com:9200 会得到类似 ES 指南中的普通输出:

{
  "status" : 200,
  "name" : "logstash-central",
  "cluster_name" : "hive",
  "version" : {
    "number" : "1.4.2",
    "build_hash" : "927caff6f05403e936c20bf4529f144f0c89fd8c",
    "build_timestamp" : "2014-12-16T14:11:12Z",
    "build_snapshot" : false,
    "lucene_version" : "4.10.2"
},
"tagline" : "You Know, for Search"

}

访问 http://logstash.example.com:9200/_status? 会得到以下信息:

{"_shards":{"total":0,"successful":0,"failed":0},"indices":{}}

Kibanas config.js 是默认的:

 elasticsearch: "http://"+window.location.hostname+":9200"

通过 nginx 使用 Kibana。这是/etc/nginx/conf.d/nginx.conf

server {
listen                *:80 ;
server_name           logstash.example.com;

location / {
root  /usr/share/kibana3;

Logstash 配置文件是 /etc/logstash/conf.d/central.conf

input {
  redis {
    host => "10.1.1.25"
    type => "redis-input"
    data_type => "list"
    key => "logstash"
}

output {
  stdout{ { codec => rubydebug } }
  elasticsearch {
    host => "logstash.example.com"
  }
}

Redis 正在工作,流量在主从之间传递(我已经通过 tcpdump 进行了检查)。

15:46:06.189814 IP 10.1.1.50.41617 > 10.1.1.25.6379: Flags [P.], seq 89560:90064, ack 1129, win 115, options [nop,nop,TS val 3572086227 ecr 3571242836], length 504

netstat -apnt 显示以下内容:

tcp        0      0 10.1.1.25:6379              10.1.1.50:41617             ESTABLISHED 21112/redis-server
tcp        0      0 10.1.1.25:9300              10.1.1.25:44011             ESTABLISHED 22598/java
tcp        0      0 10.1.1.25:9200              10.1.1.35:51145             ESTABLISHED 22598/java
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      22379/nginx    

您能告诉我应该以哪种方式调查这个问题吗?

提前致谢

【问题讨论】:

  • 是类型还是你的集群配置文件真的是elasticsearch.yum?
  • 这是错字,抱歉。已编辑
  • 我不久前遇到了这个错误。我不太确定我给你的答案。

标签: elasticsearch kibana


【解决方案1】:

问题可能是由于 nginx 设置以及 Kibana 安装在您的服务器上时在您的浏览器中运行并尝试从那里访问 Elasticsearch 的事实。解决此问题的典型方法是在 nginx 中设置代理,然后更改您的 config.js。

您似乎为 Kibana 的 nginx 设置了正确的代理,但您需要做一些额外的工作才能让 kibana 能够访问 Elasticsearch。

查看此帖子中的 cmets:http://vichargrave.com/ossec-log-management-with-elasticsearch/

并查看此帖子:https://groups.google.com/forum/#!topic/elasticsearch/7hPvjKpFcmQ

还有这个示例 nginx 配置:https://github.com/johnhamelink/ansible-kibana/blob/master/templates/nginx.conf.j2

【讨论】:

    【解决方案2】:

    您必须在输出部分中为 elasticsearch 提供精确的协议

    elasticsearch {
        host => "logstash.example.com"
        protocol => 'http'
    }
    

    【讨论】:

    • 不幸的是,它不起作用。我的意思是没有结果。顺便说一句,早期它在没有明确设置协议的情况下工作。
    • 他们可能改变了 api!我记得在logstash 1.2之前,我曾经使用elasticsearch_http {...}
    猜你喜欢
    • 2020-09-07
    • 2018-12-12
    • 2017-07-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-16
    • 1970-01-01
    相关资源
    最近更新 更多