文章目录
es安装elasticsearch-head插件
1. elasticsearch-head需要依赖 node.js
1.1 下载nodeJs
# 下载 nodejs
wget https://nodejs.org/dist/v9.9.0/node-v9.9.0-linux-x64.tar.xz
1.2 解压
# 1. 解压
tar -xf node-v9.9.0-linux-x64.tar.xz
# 2. 解压文件夹重命名
mv node-v9.9.0-linux-x64 nodeJs
1.3 新增到系统环境变量
编辑文件 /etc/profile
# nodejs环境变量/home/head/nodeJs为解压文件夹
export PATH=/home/head/nodeJs/bin:$PATH
# 刷新
source /etc/profile
# node版本查看
[root@localhost head]# node -v
v9.9.0
2 下载head插件
2.1 直接下载
wget https://github.com/mobz/elasticsearch-head/archive/master.zip
2.2 百度网盘下载
https://pan.baidu.com/s/10dFFbLXlLM4x9YKa-ZCp3A
提取码:mrhf
2.3 解压
# 1. 程序包解压
unzip master.zip
# 2. 使用淘宝的镜像库进行下载,速度很快,下载需要写时间,下载成功后续的所有npm可改为cnpm
npm install -g cnpm --registry=https://registry.npm.taobao.org
# 3. 进入解压文件,下载node_module依赖包,在install可能因为确实其他包报错,根据报错信息百度下载解决,在重新执行install
cnpm install 或 npm install
2.4 配置文件
进入解压文件夹下
- 修改 Gruntfile.js文件:hostname: ‘*’
- 修改_site/app.js
找到:app.App = ui.AbstractWidget.extend
- elasticsearch的elasticsearch.yml文件新增
解决http访问es跨域问题,需要重启es
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-methods: OPTIONS, HEAD, GET, POST, PUT, DELETE
http.cors.allow-headers: "X-Requested-With, Content-Type, Content-Length, X-User"
4. head插件启动关闭
4.1 守护进程启动
# 进入该目录启动 /安装目录/node_modules/grunt/bin
[root@localhost bin]# pwd
/home/head/elasticsearch-head-master/node_modules/grunt/bin
# 启动
[root@localhost bin]# nohup ./grunt server >/dev/null 2>&1 &
[1] 9248
4.2 关闭,kill -9 pid
[root@localhost config]# netstat -nltp | grep 9100
tcp6 0 0 :::9100 :::* LISTEN 8784/grunt
[root@localhost config]# kill -9 8784
5 访问
http://xxx.xxx.xxx.xxx:9100/