美文网首页
Elasticsearch 5.5 安装 head 插件

Elasticsearch 5.5 安装 head 插件

作者: Dandelion丶 | 来源:发表于2017-07-26 21:19 被阅读0次

写在前面

通过查看官方文档可知,Elasticsearch 5 以上版本已经不支持 site plugins 的方式了,所以 head 需要作为一个单独的服务进行安装。

  • for Elasticsearch 5.x: site plugins are not supported. Run as a standalone server
  • for Elasticsearch 2.x: sudo elasticsearch/bin/plugin install mobz/elasticsearch-head
  • for Elasticsearch 1.x: sudo elasticsearch/bin/plugin -install mobz/elasticsearch-head/1.x
  • for Elasticsearch 0.x: sudo elasticsearch/bin/plugin -install mobz/elasticsearch-head/0.9

准备工作

我们需要准备以下安装包

安装

安装 node

  • 安装 node 需要的基础环境

    yum -y install gcc make gcc-c++ openssl-devel wget
    
  • 解压 node

    cd /opt/es/node
    
    tar -zxvf node-v8.1.4-linux-x64.tar.gz
    
  • 配置环境变量

    配置NODE_HOME,进入profile编辑环境变量

    vim /etc/profile
    

    设置nodejs环境变量,在 export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL 一行的上面添加如下内容:

    #set for nodejs
    export NODE_HOME=/opt/es/node/node-v8.1.4-linux-x64
    export PATH=$NODE_HOME/bin:$PATH
    

    :wq 保存并退出,编译/etc/profile 使配置生效

    source /etc/profile
    

    验证是否安装配置成功

    node -v
    
    输出: v8.1.4
    
    npm -v
    
    输出:5.0.3
    

安装 head

  • 解压 elasticsearch-head-master.zip ,并进入

    unzip elasticsearch-head-master.zip
    
    cd elasticsearch-head-master
    
  • 执行 npm install

    npm install 
    
  • 安装 grunt

    grunt 是一个很方便的构建工具,可以进行打包压缩、测试、执行等工作,5.0里的head插件就是通过grunt启动的,因此需要安装 grunt 。

    linux:npm install grunt-cli
    
    windows:npm install grunt-cli -g
    

    安装完成后检查一下

    grunt --version
    
    输出:grunt-cli v1.2.0
    

修改配置文件

  • 修改 Gruntfile.js

    路径:elasticsearch-head-master/Gruntfile.js

    增加hostname属性,设置为*

    connect: {
        server: {
            options: {
                port: 9100,
                hostname: '*',
                base: '.',
                keepalive: true
            }
        }
    }
    
  • 修改连接 Elasticsearch 的地址

    路径:elasticsearch-head-master/_site/app.js

    修改 localhost:9200 为实际 Elasticsearch 的地址

    修改前:
    
    this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://localhost:9200";
    
    修改后:
    
    this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://172.16.X.X:9200";
    
  • 修改 Elasticsearch 配置文件

    路径:elasticsearch-5.5.0/config/elasticsearch.yml

    增加下面两个配置

    http.cors.enabled: true
    http.cors.allow-origin: "*"
    

启动 head

启动 head 插件之前,需要先启动 Elasticsearch 服务

  • 直接启动

    grunt server
    
  • 后台启动

    nohup grunt server 
    

写在最后

不积跬步,无以至千里,不积小流,无以成江海。
希望自己可以一直坚持下去

相关文章

网友评论

      本文标题:Elasticsearch 5.5 安装 head 插件

      本文链接:https://www.haomeiwen.com/subject/buzokxtx.html