一、安装环境
git地址:https://github.com/mobz/elasticsearch-head
[root@7c264d24ecf3 ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
安装node.js
curl --silent --location https://rpm.nodesource.com/setup_10.x | bash -
yum install -y nodejs
查看版本
[root@4a761b76535f opt]# npm -v && node -v
6.9.0
v10.16.0
二、获取head安装包
yum install -y git
git clone git://github.com/mobz/elasticsearch-head.git
mv elasticsearch-head/ head
三、修改配置文件
3.1 修改head访问端口
vim head/Gruntfile.js
connect: {
server: {
options: {
hostname: '0.0.0.0', #添加主机地址默认0.0.0.0
port: 9100, #改为head访问端口,自定义
base: '.',
keepalive: true
}
}
}
3.2 更改链接ElasticSearch地址
vim head/_site/app.js
地址写外网的ip+端口
init: function(parent) {
this._super();
this.prefs = services.Preferences.instance();
this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://主节点IP:访问端口";
3.3 显示健康值
修改elasticsearch.yml
vim elasticsearch-7.2.0/config/elasticsearch.yml
在末尾添加
http.cors.enabled: true
http.cors.allow-origin: "*"
配置完后重启ES
四、启动
4.1 安装grunt服务
进入head目录后
npm install -g grunt-cli --registry=https://registry.npm.taobao.org
npm install grunt --save-dev --registry=https://registry.npm.taobao.org
npm install --registry=https://registry.npm.taobao.org
4.2 启动head
同样在head目录下执行
npm run start
出现以下结果,就可以访问了
[root@4a761b76535f elasticsearch-head-master]# npm run start
> elasticsearch-head@0.0.0 start /opt/elasticsearch-head-master
> grunt server
Running "connect:server" (connect) task
Waiting forever...
Started connect web server on http://localhost:9100
脚本
#! /bin/bash
kill -9 $(ps -ef|grep grunt|grep -v grep | awk '{print $2}')
nohup npm run start &