1、下载插件

https://github.com/mobz/elasticsearch-head

elasticsearch-head-master.zip

2、nodejs官网下载安装包

https://nodejs.org/dist/

node-v6.9.2-linux-x64.tar.xz

3、将elasticsearch-head-master.zip和node-v6.9.2-linux-x64.tar.xz都导入到linux的/usr/local/src目录(自己的路径)。

4、安装nodejs

[root@master src]$ tar -zxvf node-v6.9.2-linux-x64.tar.gz

5、配置nodejs环境变量

[root@master src]# vi ~/.bashrc

export NODE_HOME=/usr/local/src/node-v6.9.2-linux-x64

export PATH=$PATH:$NODE_HOME/bin

[root@master src]# source ~/.bashrc

6)查看node和npm版本

[root@master src]# node -v

v6.9.2

[root@master src]# npm -v

3.10.9

7)解压head插件到/usr/local/src目录下

[root@master src]# unzip elasticsearch-head-master.zip

8)查看当前head插件目录下有无node_modules/grunt目录:

没有:执行命令创建:

[root@master elasticsearch-head-master]$ npm install grunt --save

9)安装head插件:

[root@master elasticsearch-head-master]$ npm install -g cnpm --registry=https://registry.npm.taobao.org

(这里很慢)

10)安装grunt:

[root@master elasticsearch-head-master]$ npm install -g grunt-cli

11)编辑Gruntfile.js

[root@master elasticsearch-head-master]$ vim Gruntfile.js

文件93行添加hostname:'0.0.0.0' (93+shift+g定位到93行)

options: {

        hostname:'0.0.0.0',

        port: 9100,

        base: '.',

        keepalive: true

      }

12)检查head根目录下是否存在base文件夹

没有:将 _site下的base文件夹及其内容复制到head根目录下

[root@master elasticsearch-head-master]$ mkdir base

[root@master _site]$ cp base/* ../base/

(sudo chown -R es:elasticsearch elasticsearch-head-master)

13)启动grunt server:

[root@master elasticsearch-head-master]$ grunt server -d

(刚刚开始测试的时候可以不加 -d,-d表示后台运行)

Running "connect:server" (connect) task

[D] Task source: /opt/module/elasticsearch-head-master/node_modules/grunt-contrib-connect/tasks/connect.js

Waiting forever...

Started connect web server on ​​http://localhost:9100​​


如果提示grunt的模块没有安装:

Local Npm module “grunt-contrib-clean” not found. Is it installed? 

Local Npm module “grunt-contrib-concat” not found. Is it installed? 

Local Npm module “grunt-contrib-watch” not found. Is it installed? 

Local Npm module “grunt-contrib-connect” not found. Is it installed? 

Local Npm module “grunt-contrib-copy” not found. Is it installed? 

Local Npm module “grunt-contrib-jasmine” not found. Is it installed? 

Warning: Task “connect:server” not found. Use –force to continue. 

执行以下命令: 

npm install grunt-contrib-clean -registry=​​https://registry.npm.taobao.org​

npm install grunt-contrib-concat -registry=​​https://registry.npm.taobao.org​

npm install grunt-contrib-watch -registry=​​https://registry.npm.taobao.org​​ 

npm install grunt-contrib-connect -registry=​​https://registry.npm.taobao.org​

npm install grunt-contrib-copy -registry=​​https://registry.npm.taobao.org​​ 

npm install grunt-contrib-jasmine -registry=​​https://registry.npm.taobao.org​

最后一个模块可能安装不成功,但是不影响使用。

14)浏览器访问head插件:

http://master:9100


Elasticsearch head插件安装_linux

也可将localhost改为master(自己的结点名称)

15)启动集群插件后发现集群未连接

在/usr/local/src/elasticsearch-5.2.2/config路径下修改配置文件elasticsearch.yml,在文件末尾增加

[root@master config]$ pwd

/usr/local/src/elasticsearch-5.2.2/config

[root@master config]$ vi elasticsearch.yml


http.cors.enabled: true

http.cors.allow-origin: "*"

再重新启动elasticsearch。

Elasticsearch head插件安装_bash_02