一、elasticsearch-head插件的作用
ealsticsearch是一个分布式、RESTful 风格的搜索和数据分析引擎,所有的数据都是后台服务存储着,类似于Mysql服务器,因此如果我们需要直观的查看数据,就需要使用可视化工具了。elasticsearch-head是Web前端,用于浏览和与Elastic Search集群进行交互,可用于集群管理、数据可视化、增删改查工具Elasticsearch语句可视化等。
二、elasticsearch-head插件的安装下载elasticsearch-head插件,地址:https://github.com/mobz/elasticsearch-head
进入elasticsearch-head源码目录中,执行 npm install
在运行npm install时,可能会存在Head插件phantomjs权限问题
npm WARN deprecated phantomjs-prebuilt@2.1.16: this package is now deprecatednpm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this
npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
> phantomjs-prebuilt@2.1.16 install E:\JavaDevelopment\elasticsearch\elasticsearch-head-master\node_modules\phantomjs-prebuilt
> node install.js
PhantomJS not found on PATH
Downloading https://github.com/Medium/phantomjs/releases/download/v2.1.1/phantomjs-2.1.1-windows.zip
Saving to C:\Users\ysxx\AppData\Local\Temp\phantomjs\phantomjs-2.1.1-windows.zip
Receiving...
Error making request.
Error: connect ETIMEDOUT 140.82.114.4:443
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1107:14)
Please report this full log at https://github.com/Medium/phantomjs
npm WARN elasticsearch-head@0.0.0 license should be a valid SPDX license expression
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! phantomjs-prebuilt@2.1.16 install: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the phantomjs-prebuilt@2.1.16 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\ysxx\AppData\Roaming\npm-cache\_logs\2020-12-28T01_28_03_195Z-debug.log
解决方案:在npm install命令后加 -g 参数
npm install -g在install成功之后,执行 npm run start 启动head插件
> elasticsearch-head@0.0.0 start E:\JavaDevelopment\elasticsearch\elasticsearch-head-master> grunt server
>> Local Npm module "grunt-contrib-jasmine" not found. Is it installed?
Running "connect:server" (connect) task
Waiting forever...
Started connect web server on http://localhost:9100
在cmd命令行可以看到 web server 地址,在浏览器访问该地址 :9100,如果出现elasticsearch-head插件连不上elasticsearch服务,需要在elasticsearch安装目录下的config文件夹,找到elasticsearch.yml文件,添加两行配置:
#表示是否支持跨域,默认为falsehttp.cors.enabled: true
#当设置允许跨域,默认为*,表示支持所有域名
http.cors.allow-origin: "*"
三、elasticsearch-head插件的使用
界面概览
集群健康值的颜色说明:
颜色 说明绿色 最健康的状态,代表所有的分片包括备份都可用
黄色 基本的分片可用,但是备份不可用(也可能是没有备份)
红色 部分的分片可用,表明分片有一部分损坏。执行查询部分数据仍然可以查到,遇到这种情况,还是赶快解决比较好
灰色 未连接到elasticsearch服务