【问题标题】:ES reachable from curl but not from Marvel/SenseES 可从 curl 访问,但不能从 Marvel/Sense
【发布时间】:2015-04-05 22:21:15
【问题描述】:

我正处于 2 小时的 Elastic Search 沉浸式体验中。我成功地用 Marvel 安装了 ES(在 config/elasticsearch.yml 中有marvel.agent.enabled: false),并且能够从 Sense 发出成功的请求。我重新启动了我的开发机器,现在当我在 Sense 上发出以下请求时,它会响应:

Request failed to get to the server (status code: 0):

Elasticsearch may not be reachable or you may need to check your CORS settings.If CORS is enabled, try turning off Sense's Basic Authentication support under Setting (cog icon).This will result in a less strict CORS enforcement by the browser.
Please check the marvel documentation for more information.

请求(source):

PUT /megacorp/employee/1
{
"first_name" : "John",
"last_name" :  "Smith",
"age" :        25,
"about" :      "I love to go rock climbing",
"interests": [ "sports", "music" ]
}

按照指示,我通过在 curl 上发出类似请求来检查 ES 是否可访问:

请求:

curl -XPUT http://localhost:9200/megacorp/employee/100 -d '{ "first_name" : "test" }'

回复:

{"_index":"megacorp","_type":"employee","_id":"100","_version":1,"created":true}

这让我认为 ES 是可用的。

继续下一项检查“您可能需要检查您的 CORS 设置。”。我基于this recommendation在elasticsearch.yml中添加了以下配置(并重启了ES):

http.cors.enabled: true
http.cors.allow-origin: /.*/  
http.cors.allow-credentials: true

但是行为没有变化。

在 Marvel/Smart 设置中切换“支持基本身份验证”也没有影响。

欢迎任何关于可能出错的指示。

【问题讨论】:

  • @jimstat 在您的 ES 集群日志中(在一个节点中)找到类似于 [INFO ][http ] [c7_64] bound_address {inet[/0:0:0:0:0:0:0:0:9201]}, publish_address {inet[/192.168.88.128:9201]} 的行。您对publish_address 之后的内容感兴趣。访问 Sense 时,请使用您在此处看到的 IP:PORT。在我的示例中:http://192.168.88.128:9201/_plugin/marvel/sense/index.html.
  • 没有任何答案有帮助,或者您没有将答案标记为已接受?会帮助我知道你有什么诀窍:)

标签: elasticsearch elasticsearch-marvel


【解决方案1】:

尝试在其他浏览器上或以私密/隐身模式运行 marvel/sense html 页面。我有同样的问题,这样做解决了它。我认为这是由于存储在 cookie 上的设置或某些不确定的原因。

【讨论】:

  • 这条评论和@Saichan 的评论(启用 CORS)的组合对我有用。
【解决方案2】:

我也遇到了同样的问题,根据此处的 Elasticsearch 文档:http://www.elastic.co/guide/en/marvel/current/configuration.html#cors,您必须启用 CORS。

总结一下,打开config/文件夹下的elasticsearch.yml文件,放这个

http.cors.enabled: true
http.cors.allow-origin: /.*/  
http.cors.allow-credentials: true 

在那里的某个地方,可能是“网络和 HTTP”部分。

然后,在我重新启动 elasticsearch 后,它在 Marvel Sense 中对我来说运行良好。

【讨论】:

    【解决方案3】:

    我也遇到了同样的问题。 确保服务器字段不为空。 用 local 填写字段后,我的问题得到了解决

    【讨论】:

      【解决方案4】:

      因此,当尝试运行有意义的命令时,请尝试使用托管服务器的机器的 IP 地址,而不是使用http://localhost:9200/_plugin/marvel/sense/index.html。 这对我有用。

      【讨论】:

        【解决方案5】:

        在您的 ES 集群日志中(在一个节点中)找到一行看起来像

        [INFO ][http ] [c7_64] bound_address {inet[/0:0:0:0:0:0:0:0:9201]}, publish_address {inet[/192.168.88.128:9201]}
        

        您对publish_address 之后的内容感兴趣。访问 Sense 时,请使用您在此处看到的 IP:PORT。在我的示例中,Sense URL 如下所示:

        http://192.168.88.128:9201/_plugin/marvel/sense/index.html
        

        CORS 部分主要适用于 Marvel 安装在单独集群中的场景,当 Marvel 安装在与受监控节点相同的集群中时不需要它。在集群中安装 Shield 时也是 needed

        【讨论】:

          【解决方案6】:

          我在使用 Chrome 时遇到了同样的问题。清除浏览器数据解决了我的问题。它在历史记录下 -> 清除浏览器数据 -> 检查 cookie 和其他站点和插件数据、缓存的图像和文件、自动填充表单数据、托管应用程序数据。

          不确定是哪一个成功了,但我就是这样做的,而且成功了。希望这会有所帮助。

          【讨论】:

            【解决方案7】:

            与 Marvel 没有严格关系,但是当我从需要的服务器“外部”连接到 elasticsearch 时遇到问题。

            更改elasticsearch.ymlconfig,主机监听的地方——listen to all network interfaces

            network.host: 0.0.0.0
            

            之后,根据您的服务器,您应该在防火墙上打开 tcp 端口(如果您使用 elasticsearch 的默认端口:9200)。例如在 Centos(或 RHEL)上,你应该运行:

            sudo firewall-cmd --zone=public --add-port=9200/tcp --permanent
            sudo firewall-cmd --reload
            

            【讨论】:

              猜你喜欢
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 2013-05-11
              • 2020-04-18
              • 2012-08-13
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              相关资源
              最近更新 更多