1、安装node.js
因为head插件是用node.js开发的,需要先安装运行环境。
直接官网下载https://nodejs.org/en/download/,winscp上传解压;
vi /etc/profile 配置node.js环境变量:
执行source /etc/profile 让配置文件立即生效。
node -v 显示版本号即为配置成功。
2、安装head插件及相关依赖
从github上下载https://github.com/mobz/elasticsearch-head,通过winscp上传unzip解压;
进入到解压后head插件根目录下执行npm install安装插件依赖,默认会安装插件根目录下package.json文件配置的依赖:
安装过程可能会报错:
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 'node install.js'.
没关系,网上有解决方案:
实际上就是执行 npm install phantomjs-prebuilt@2.1.13 --ignore-scripts 后继续执行npm install。
安装完成后修改Gruntfile.js配置,增加服务器监听地址 hostname:'*'或者hostname:'0.0.0.0',让外部能访问:
3、启动head插件
在head插件根目录下通过npm start即可启动head插件,实际执行的是package.json里面的grunt server命令:
要想通过后台启动,得先安装gruntcli:npm -g install grunt-cli,然后通过grunt server & 命令启动,&表示后台启动。
另外要想在界面上看到es集群信息,必须在elasticsearch.yml增加两项配置,重启es:
http.cors.enabled: true 如果启用了 HTTP 端口,那么此属性会指定是否允许跨源 REST 请求。
http.cors.allow-origin: "*" 如果 http.cors.enabled 的值为 true,那么该属性会指定允许 REST 请求来自何处。
看到以下信息即表示安装成功: