elasticsearch-head安装

elasticsearch-head安装

Node.js环境安装

head插件要求Node.js环境,并且Node.js的版本 大于等于 6.0。

下载 Node.js 12.13.0 版本。下载地址:https://nodejs.org/en/download/

配置nodejs环境变量

vim /etc/profile

export NODE_HOME=/home/tom/data/node-v10.15.3-linux-x64
export PATH=$NODE_HOME/bin:$PATH

执行命令 source /etc/profile 使上面的配置生效。然后执行 npm -v,看到输出 6.11.3

head插件安装

在GitHub上找到head插件,地址:https://github.com/mobz/elasticsearch-head

cd /opt/server

unzip elasticsearch-head-master.zip

mv elasticsearch-head-master elasticsearch-head


安装插件;由于需要下载一些依赖包,所以会比较慢。

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.

手动安装phantomjs-prebuilt

npm install phantomjs-prebuilt@2.1.16 --ignore-scripts

重新执行“npm install”

启动head插件

nohup npm run start &

浏览器打开“http://172.16.11.146:9100”,

浏览器报错

Access to XMLHttpRequest at 'http://172.16.11.146:9200/_nodes/stats' from origin 'http://172.16.11.146:9100' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

这个问题是因为ES和head插件存在一个跨域问题。要解决这个问题,我们需要首先关闭Elasticsearch,然后添加两行配置:

http.cors.enabled: true
http.cors.allow-origin: "*"

然后,重新启动ES,刷新 head 插件页面,即可看到现在head插件已经正确查找到了我们的启动那个ES节点

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值