windows下Elasticsearch-head插件的安装
windows下Elasticsearch-head插件的安装
在学习Elasticsearch的过程中,必不可少需要通过一些工具查看es的运行状态以及数据。如果都是通过rest请求,未免太过麻烦,而且也不够人性化。此时,head可以完美的帮助我们快速学习Elasticsearch。
es5以上版本安装head需要安装node和grunt(之前的直接用plugin命令即可安装),我这里安装的es6.0.0。
一、安装
1、安装Node.js
Node.js下载地址:https://nodejs.org/en/download/,下载相应系统的msi,双击安装。我这里是安装在D:\nodejs下的
安装完成后用cmd进入安装目录,执行 node -v可查看版本号
2、安装grunt
进入nodejs目录下,执行命令:npm install -g grunt-cli,将grunt安装为全局命令
安装完成后执行grunt -version查看是否安装成功,会显示安装的版本号
3、安装head
1)在https://github.com/mobz/elasticsearch-head中下载head插件,选择下载zip,解压到指定文件夹
2)进入该文件夹,修改Gruntfile.js 在对应的位置加上hostname:'*'
4、执行npm install
在D:\elasticsearch-6.0.0\elasticsearch-head-master下执行npm install
注意:
1)国外镜像会很慢,可用 get命令查看registry,原版结果为:http://registry.npmjs.org
npm config get registry
2)用set命令换成阿里的镜像就可以了 npm config set registry https://registry.npm.taobao.org
3)再执行命令 npm install
或者直接执行npm install --registry=https://registry.npm.taobao.org
安装完成后执行grunt server 或者npm run start 运行head插件,如果不成功重新安装grunt
二、权限设定
如果想查询集群健康信息,那么需要在elasticsearch配置文件中授权
编辑elasticsearch.yml
http.cors.enabled: true # elasticsearch中启用CORS
http.cors.allow-origin: "*" # 允许访问的IP地址段,*为所有IP都可以访问
5、启动服务
如下图
6、可能出现的问题
如果出现以下问题:
>> 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
三、测试
浏览器下访问:http://localhost:9100
1)可以看到上图中的集群健康值:yellow
通过查询资料,我们了解到head插件会以不同的颜色显示。
1)绿色——最健康的状态,代表所有的主分片和副本分片都可用;
2)黄色——所有的主分片可用,但是部分副本分片不可用;
3)红色——部分主分片不可用。(此时执行查询部分数据仍然可以查到,遇到这种情况,还是赶快解决比较好)
说明:实际上,单节点无论有多少个副本分片(number_of_replicas 的设置)都是 unassigned —— 它们都没有被分配到任何节点。
在同一个节点上既保存原始数据又保存副本是没有意义的,因为一旦失去了那个节点,我们也将丢失该节点上的所有副本数据。
Elasticsearch采用默认配置(5分片,1副本),但实际只部署了单节点集群。由于只有一个节点,因此群集无法放置副本,因此处于黄色状态。
2)查找问题原因
GET _cluster/health?pretty #查看集群状态的各个指标 重点关注unsigned_shards这个指标
GET _cat/indices?v #查看ES中的所有索引 ?v的意思就是给显示结果顶部带上标题
3) 解决方法:
# 重新设置索引分片信息
PUT /索引名/_settings
{
"number_of_replicas": 0
}
此时,再重新访问localhost:9100
参考链接:https://www.cnblogs.com/yszr/p/10278059.html
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)