在企业生产环境中,由于网络安全要求或特殊业务场景,我们经常需要在完全离线的环境下部署Elasticsearch管理工具。本文将详细介绍如何在内网环境中离线安装和使用elasticsearch-head--这款轻量级的Elasticsearch集群可视化工具,帮助您在没有互联网连接的情况下实现高效的集群管理。
1 elasticsearch-head简介
elasticsearch-head是Elasticsearch的一个开源Web前端插件,主要功能包括:
- 实时监控集群健康状态
- 可视化展示节点和分片分布
- 索引管理和数据浏览
- 直接执行REST API命令
相比于Kibana,elasticsearch-head更加轻量,适合快速部署和日常运维使用
2 离线安装准备
2.1 资源下载
2.2 解压elasticsearch-head
# 上传并解压elasticsearch-head-5.0.0.tar.gz
tar -zxvf elasticsearch-head-5.0.0.tar.gz
2.3 解压nodejs
# 上传并解压node-v14.17.6-linux-x64.tar.xz
tar -xvf node-v14.17.6-linux-x64.tar.xz
3 配置nodejs环境变量
echo 'export PATH=$PATH:/export/home/es-head/node-v14.17.6-linux-x64/bin' >> /etc/profile
source /etc/profile
[root@node6 es-head]# npm -v
6.14.15
[root@node6 es-head]# node -v
v14.17.6
[root@node6 es-head]#
4 配置Elasticsearch跨域访问
# 编辑elasticsearch.yml,添加如下内容
http.cors.enabled: true
http.cors.allow-origin: *
http.cors.allow-methods: GET,POST,PUT,DELETE
http.cors.allow-headers: Content-Type,Authorization,X-Requested-With
# 重启elasticsearch
ps -ef |grep elasticsearch|grep -v grep |awk '{print $2}'|xargs kill -9
/export/home/elasticsearch-7.10.1/bin/elasticsearch -d
5 启动服务
# 后台启动
nohup npm run start > /var/log/es-head.log 2>&1 &
6 验证

7 常见问题:缺少依赖
# 在有网络的机器上安装相同依赖,然后打包复制整个node_modules目录到elasticsearch-head-5.0.0目录下解压
npm install