zoukankan      html  css  js  c++  java
  • Elasticsearch5.x Head插件安装

    在5.0版本中不支持直接安装head插件,需要启动一个服务。

    由于head插件本质上还是一个nodejs的工程,因此需要安装node,使用npm来安装依赖的包。(npm可以理解为maven)

    1、安装Node.js

    官网nodejs,https://nodejs.org/en/download/

    wget https://nodejs.org/dist/v6.10.2/node-v6.10.2-linux-x64.tar.xz
         
    xz –d node-v6.10.2-linux-x64.tar.xz
    tar xvf node-v6.10.2-linux-x64.tar
    mv node-v6.10.2-linux-x64 /usr/local/node
    
    vim /etc/profile
    export NODE_HOME=/usr/local/node
    export PATH=$PATH:$NODE_HOME/bin
    
    source /etc/profile
    
     
    # node –v
    v6.10.2
    
    # npm –v
    3.10.10

    说明:前面讲了,npm相当于是maven,但npm究竟在哪?其实npm已经在Node.js安装的时候顺带装好了。

    2、下载插件包

    如果找不到git,请先安装:

    yum install –y git
    git clone https://github.com/mobz/elasticsearch-head.git

    3、安装grunt

    cd elasticsearch-head
    npm install -g grunt --registry=https://registry.npm.taobao.org

    4、安装Head插件

    npm install

    在elasticsearch-head目录下node_modules/grunt下如果没有grunt二进制程序,需要执行:

    cd elasticsearch-head
    npm install grunt --save

    5、修改配置

    修改elasticsearch-head下Gruntfile.js文件,默认监听在127.0.0.1下9200端口:

    hostname: ‘192.168.33.50’,

    修改 _site/app.js

    修改http://localhost:9200字段到本机ES端口与IP:

    21行:http://192.168.33.50:9200

    6、修改Elasticsearch配置

    修改elasticsearch.yml文件加入以下内容:

    # 是否支持跨域
    http.cors.enabled: true
    
    # *表示支持所有域名
    http.cors.allow-origin: "*"

    7、启动服务

    /elasticsearch-head/node_modules/grunt/bin/grunt server (后台运行 + &)

    浏览器访问 http://192.168.33.50:9100/

    附:

    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,那么会返回给客户端。

  • 相关阅读:
    spring----RESTful API
    spring----模块之间的通讯问题
    PHP错误与异常处理
    微信支付:curl出错,错误码:60
    jquery判断checkbox是否选中
    微信网页授权的问题
    TP5更新数据成功,但判断结果不符
    190719有个织梦专题标题长度限制问题
    判断手机浏览器还是微信浏览器(PHP)
    TP5关联模型出现疑问,待解决
  • 原文地址:https://www.cnblogs.com/hunttown/p/6723286.html
Copyright © 2011-2022 走看看