1、安装nodejs
解压
$ tar -xvf node-v12.14.0-linux-x64.tar.xz
配置环境变量
export NODE_HOME=/usr/local/webserver/soft/node-v12.14.0-linux-x64
export PATH=$PATH:$NODE_HOME/bin
export NODE_PATH=$NODE_HOME/lib/node_modules
查看版本
$ npm -v
6.13.4
$ node -v
v12.14.0
2、head插件安装
$ git clone git://github.com/mobz/elasticsearch-head.git
$ cd elasticsearch-head/
$ npm install
#报错
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! phantomjs-prebuilt@2.1.16 install: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the phantomjs-prebuilt@2.1.16 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-01-07T10_13_22_360Z-debug.log
#解决
npm install phantomjs-prebuilt@2.1.16 --ignore-scripts
#启动插件
$ npm run start
#浏览器访问
http://10.180.18.24:9100
#停止运行
$ netstat -tunlp | grep 9100
tcp 0 0 0.0.0.0:9100 0.0.0.0:* LISTEN 13659/grunt
$ kill -9 13659
常见问题:
1、head插件连接不上Elasticsearch,ES正常启动,head插件里面却始终显示“集群健康值:未连接”
这个问题是因为咱们的ES和head插件实际上属于两个不同的进程,这里存在一个跨域问题。要解决这个问题,我们需要首先关闭Elasticsearch,然后在配置文件elasticsearch.yml中添加两行配置:
http.cors.enabled: true
http.cors.allow-origin: "*"