一、Head插件
elasticsearch-head是elastic search集群的一个web前端。
源代码托管在github.com,地址是:https://github.com/mobz/elasticsearch-head
集群健康值的几种状态如下:
绿色,最健康的状态,代表所有的分片包括备份都可用
黄色,基本的分片可用,但是备份不可用(也可能是没有备份)
红色,部分的分片可用,表明分片有一部分损坏。此时执行查询部分数据仍然可以查到,遇到这种情况,还是赶快解决比较好
灰色,未连接到elasticsearch服务
- 安装
在线安装,Elasticsearch 5.x, 6.x, and 7.x 不支持插件安装,需要独立安装。
[es@localhost elasticsearch]$ ./bin/plugin install mobz/elasticsearch-head
-> Installing mobz/elasticsearch-head...
Trying https://github.com/mobz/elasticsearch-head/archive/master.zip ...
Downloading ....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................DONE
Verifying https://github.com/mobz/elasticsearch-head/archive/master.zip checksums if available ...
NOTE: Unable to verify checksum for downloaded plugin (unable to find .sha1 or .md5 file to verify)
Installed head into /usr/share/elasticsearch/plugins/head
-
浏览访问
http://192.168.169.128:9200/_plugin/head/
- 独立安装
Elasticsearch 5.x, 6.x, and 7.x 不支持插件安装,需要独立安装。
# 下载node.js
[root@localhost elasticsearch-7.3.1]# wget https://cdn.npm.taobao.org/dist/node/v12.10.0/node-v12.10.0-linux-x64.tar.xz
# 创建目录
[root@localhost elasticsearch-7.3.1]# mkdir /usr/local/node
# 解压安装包
[root@localhost elasticsearch-7.3.1]# tar -xvf node-v12.10.0-linux-x64.tar.xz -C /usr/local/node
# 验证
[root@localhost bin]# cd /usr/local/node/node-v12.10.0-linux-x64/
[root@localhost node-v12.10.0-linux-x64]# ./bin/node -v
v12.10.0
# 配置node和npm。注意node所在目录: /usr/local/node/node-v12.10.0-linux-x64/
# 创建硬链接
[root@localhost node-v12.10.0-linux-x64]# ln -s /usr/local/node/node-v12.10.0-linux-x64/bin/node /usr/bin/node
[root@localhost node-v12.10.0-linux-x64]# node -v
v12.10.0
[root@localhost node-v12.10.0-linux-x64]# ln -s /usr/local/node/node-v12.10.0-linux-x64/bin/npm /usr/bin/npm
[root@localhost node-v12.10.0-linux-x64]# npm -v
6.10.3
# 注册模块镜像
[root@localhost elasticsearch-head]# npm set registry https://registry.npm.taobao.org
# 下载插件(一定要下载到es安装目录)
[root@localhost elasticsearch-7.3.1]# git clone git://github.com/mobz/elasticsearch-head.git
# 安装
[root@localhost elasticsearch-7.3.1]# cd /usr/elasticsearch/elasticsearch-7.3.1/elasticsearch-head/
[root@localhost elasticsearch-head]# npm install
# 配置elasticsearch,允许head插件访问
# 进入elasticsearch\config目录 打开 elasticsearch.yml
[root@localhost elasticsearch-7.3.1]# vi config/elasticsearch.yml
# 添加内容
http.cors.enabled: true
http.cors.allow-origin: "*"
# 启动
[root@localhost elasticsearch-head]# npm run start
# 后台运行
[root@localhost elasticsearch-head]# nohup npm run start &
切记,要重启下ES服务。
-
访问测试
http://192.168.77.132:9100
常见错误:
- npm: relocation error: npm: symbol SSL_set_cert_cb, version libssl.so.10 not defined in file libssl.so.10 with link time reference
需更新ssl版本:
[root@localhost elasticsearch-head]# yum update openssl -y
[root@localhost elasticsearch-head]# openssl version
- ENOENT: no such file or directory, open '/usr/elasticsearch/elasticsearch-7.3.1/package.json'
[root@localhost elasticsearch-head]# npm install