zoukankan      html  css  js  c++  java
  • Elasticsearch 5.2.x 使用 Head 插件连接不上集群

    0、前言

    时光荏苒,ES转眼间就从2.X跳到了5.X。。。
    忆往昔峥嵘岁月,奈何ES社区太活跃,版本跳的比房价还快啊。。。
     
    话说回来,需要部署一套Elasticsearch 5.2.1 即本月最新推出的ES新力作,发现很多用法已经不一样了。。。
     
    本次首先说Head插件的安装: 

    1、安装插件head

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    # 去github上下载head
    git clone git://github.com/mobz/elasticsearch-head.git
    # 由于head基于nodejs所以安装它
    yum -y install nodejs npm
    npm install grunt-cli
    npm install grunt
    grunt -version
    # 修改配置文件
    cd elasticsearch-head
    vim _site/app.js
    # 修改 『http://localhost:9200』字段到本机ES端口与IP

    2、启动head

    1
    2
    3
    cd elasticsearch-head
    grunt server
    # 打开浏览器 http://localhost:9100

    3、出现问题

    head主控页面是可以显示的,但是显示连接失败
    “集群健康值: 未连接”

    4、解决方案

    修改elasticsearch.y
    1
    2
    3
    4
    vim $ES_HOME$/config/elasticsearch.yml
    # 增加如下字段
    http.cors.enabled: true
    http.cors.allow-origin: "*"

    重启es和head即可

    5、CORS是什么(这个格式我真服了博客园了)

    wiki上的解释是 Cross-origin resource sharing (CORS) is a mechanism that allows restricted resources ,即跨域访问。

    这个字段默认为false,在Elasticsearch安装集群之外的一台机上用Sense、Head等监控插件访问Elasticsearch是不允许的。这个字段最早可以追溯到1.4.x版本,而非5.x特有。

    具体这个http.cors.x字段还有哪些用途和用法,见下表:

    http.cors.enabled 是否支持跨域,默认为false
    http.cors.allow-origin 当设置允许跨域,默认为*,表示支持所有域名,如果我们只是允许某些网站能访问,那么可以使用正则表达式。比如只允许本地地址。 /https?://localhost(:[0-9]+)?/
    http.cors.max-age 浏览器发送一个“预检”OPTIONS请求,以确定CORS设置。最大年龄定义多久的结果应该缓存。默认为1728000(20天)
    http.cors.allow-methods 允许跨域的请求方式,默认OPTIONS,HEAD,GET,POST,PUT,DELETE
    http.cors.allow-headers 跨域允许设置的头信息,默认为X-Requested-With,Content-Type,Content-Length
    http.cors.allow-credentials 是否返回设置的跨域Access-Control-Allow-Credentials头,如果设置为true,那么会返回给客户端。
     
     
  • 相关阅读:
    分组取最大值SQL 牛XXXX啊 我艹
    windows自带的可生成各种数据库连接字符串工具打开方法
    ashx.cs 读写session
    ASP.NET温故而知新学习系列之深度剖析ASP.NET架构—ASP.NET请求的处理过程(一)
    为什么从5000个数中找出10个最大的堆排序最快?
    net自带wsdl.exe的用法与参数说明
    负载均衡的集中实现方式
    18款 非常实用 jquery幻灯片图片切换
    MSSQL 导入用法总结 太方便了
    爱的无助
  • 原文地址:https://www.cnblogs.com/myall/p/6684791.html
Copyright © 2011-2022 走看看