ElasticSearch学习 - (三)windows下安装ElasticSearch6.X head插件

1、安装node.js

ElasticSearch学习 - (二)中有详解

查看node.js版本 

node -v

查看npm版本

npm -v

2、安装grunt

使用npm安装grunt  

npm install -g grunt -cli

查看grunt版本

grunt -version

3、下载ElasticSearch-head压缩包

下载地址:https://github.com/mobz/elasticsearch-head,下载后解压缩。

4、修改head源码(也可以不修改,直接跳过这一步)

由于head的代码还是2.6版本的,直接执行有很多限制,比如无法跨机器访问。因此需要用户修改两个地方:

一、目录:head/Gruntfile.js:

connect: {
    server: {
        options: {
            port: 9100,
            hostname: '*',
            base: '.',
            keepalive: true
        }
    }
}

增加hostname属性,设置为*

二、修改连接地址: 目录:head/_site/app.js

修改head的连接地址:this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://localhost:9200";(大约4354行)

把localhost修改成你es的服务器地址

5、修改ElasticSearch的配置

目录config/elasticsearch.yml

在配置文件末尾追加一下内容:

# 增加新的参数,这样head插件可以访问es
http.cors.enabled: true
http.cors.allow-origin: "*"

注意,yml文件设置参数的时候:后面要有空格!

6、npm安装依赖

到elasticsearch-head-master目录下,运行命令:npm install

本人在安装时候失败,如下图:

如果速度较慢或者安装失败,可以使用国内镜像: 建议使用这种方式,速度更快:

npm install -g cnpm --registry=https://registry.npm.taobao.org

安装成功如下图:

初次运行安装可能会报警告或错误。可以重新运行一次npm install。

最后,在head源代码目录下启动nodejs:grunt server

启动成功如下图:

若启动失败则如下图:(本人启动成功),以下是失败后的解决方案

Gruntfile.js引起的,缺少以下包 
启动有可能报错,执行以下命令:

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

7、访问head

这个时候,访问http://localhost:9100就可以访问head插件了(记得要先启动ElasticSearch,再启动head插件)

windows下启动 : 双击bin目录下的elasticsearch.bat即可

linux系统启动es : ./bin/elasticsearch -d (-d为在后台启动,不加-d时可以看到启动过程,出现started时启动完成)

---------------------------------------------------------------

启动head插件:在head源代码目录下执行:grunt server

启动如下:

猜你喜欢

转载自blog.csdn.net/wangqing84411433/article/details/85264465