1. 安装node 和 grunt

  2. 下载 elasticsearch-head-master

    wget  https://github.com/mobz/elasticsearch-head/archive/master.zip

  3. 解压elasticsearch-head-master 到 /usr/local下

  4. 进入/usr/local/elasticsearch-head-master  更改中国镜像npm install -g cnpm –registry=https://registry.npm.taobao.org

  5. 安装   cnpm install

2.2 Head插件安装

(1)安装NodeJS

[root@node1 ~]# yum install -y nodejs1

(2)安装npm

[root@node1 ~]#  npm install -g cnpm --registry=https://registry.npm.taobao.org1

(3)使用npm安装grunt

[root@node1 ~]# npm install -g gruntnpm WARN deprecated coffee-script@1.10.0: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
npm WARN gentlyRm not removing /usr/bin/grunt as it wasn't installed by /usr/lib/node_modules/grunt
/usr/bin/grunt -> /usr/lib/node_modules/grunt/bin/grunt
/usr/lib
└── grunt@1.0.1 [root@node1 ~]# 12345678

[root@node1 ~]# npm install -g grunt-cli –registry=https://registry.npm.taobao.org –no-proxy/usr/bin/grunt -> /usr/lib/node_modules/grunt-cli/bin/grunt
/usr/lib
└─┬ grunt-cli@1.2.0
 ├─┬ findup-sync@0.3.0
 │ └─┬ glob@5.0.15
 │   ├─┬ inflight@1.0.6
 │   │ └── wrappy@1.0.2
 │   ├── inherits@2.0.3
 │   ├─┬ minimatch@3.0.4
 │   │ └─┬ brace-expansion@1.1.8
 │   │   ├── balanced-match@1.0.0
 │   │   └── concat-map@0.0.1
 │   ├── once@1.4.0
 │   └── path-is-absolute@1.0.1
 ├── grunt-known-options@1.1.0
 ├─┬ nopt@3.0.6
 │ └── abbrev@1.1.1
 └── resolve@1.1.7 [root@node1 ~]#

(4)版本确认

[es@node1 ~]$ node -v
v6.12.0[es@node1 ~]$ npm -v3.10.10[es@node1 ~]$ grunt -version
grunt-cli v1.2.0[es@node1 ~]$

2.3 配置

(0)停止ElasticSearch 
如果ElasticSearch已经启动,需要先停止

[es@node1 ~]$ jps
3261 Elasticsearch
3375 Jps
[es@node1 ~]$ kill 32611234

(1)配置 ElasticSearch,使得HTTP对外提供服务

[es@node1 elasticsearch-6.1.1]$ vi config/elasticsearch.yml1

添加如下内容

# 增加新的参数,这样head插件可以访问es。设置参数的时候:后面要有空格

http.cors.enabled: true

http.cors.allow-origin: "*"

(2)修改Head插件配置文件

[es@node1 elasticsearch-head-master]$ vi Gruntfile.js1

找到connect:server,添加hostname一项,如下

connect: {

        server: {

             options: {

                     hostname: 'node1',

                     port: 9100,

                     base: '.',

                     keepalive: true

          }

     }

}

2.4 启动

(1)启动elasticsearch 
首先确认elasticsearch已经启动

[es@node1 elasticsearch-6.1.1]$ bin/elasticsearch -d

[es@node1 elasticsearch-6.1.1]$ jps

3451 Jps

3436 Elasticsearch

[es@node1 elasticsearch-6.1.1]$


(2)启动head 

通过命令grunt server启动head

[es@node1 elasticsearch-head-master]$ grunt server

Running "connect:server" (connect) task
Waiting forever…
Started connect web server on http://node1:910012345

或者通过命令npm run start也可以启动head

[es@node1 elasticsearch-head-master]$ npm run start

> elasticsearch-head@0.0.0 start /home/es/elasticsearch-head-master
> grunt server

Running "connect:server" (connect) task
Waiting forever…
Started connect web server on http://node1:9100

(3)访问9100端口 
http://node1:9100/

1 thought on “elasticsearch6 安装 elasticsearch-head-master”

发表评论

电子邮件地址不会被公开。 必填项已用*标注