环境要求
es-head需要nodejs环境编译,先看看机器中是否已经有nodejs环境,如果没有的话我们先要安装nodejs环境
nodejs下载地址
https://nodejs.org/en/download/
#解压
tar xvJf node-v12.17.0-linux-x64.tar.xz
#配置环境变量
mv node-v12.17.0-linux-x64 /opt/app/
vim /etc/profile
#新增下面的内容
export NODE_HOME=/opt/app/node-v12.17.0-linux-x64
export PATH=$NODE_HOME/bin:$PATH
#刷新环境变量
source /etc/profile
es-head下载地址
https://codechina.csdn.net/mirrors/mobz/elasticsearch-head?utm_source=csdn_github_accelerator
解压
[root@76-yace-es soft]# unzip elasticsearch-head-master.zip
编译安装
cd elasticsearch-head-master/
[root@76-yace-es elasticsearch-head-master]# npm install
修改npm源
如果npm install一直卡在fetchMetadata: sill 不动的话,是因为访问的npm registry网络不行,我们可以修改为淘宝的仓库:
#查看npm仓库
npm config get registry
#或
npm info express
#修改为淘宝的源
npm config set registry https://registry.npm.taobao.org
这时候再执行npm install 速度就快很多了
注意:如果这时候出现这个错误
> phantomjs-prebuilt@2.1.16 install /home/wyk/elasticsearch-head-master/node_modules/phantomjs-prebuilt
> node install.js
internal/modules/cjs/loader.js:969
throw err;
^
Error: Cannot find module '/home/wyk/elasticsearch-head-master/node_modules/phantomjs-prebuilt/install.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
at Function.Module._load (internal/modules/cjs/loader.js:842:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
...
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-05-27T03_40_09_380Z-debug.log
忽略phantomjs-prebuilt@2.1.16,修改安装命令再安装就行了
[root@76-yace-es elasticsearch-head-master]# npm install phantomjs-prebuilt@2.1.16 --ignore-scripts
需要在es中加上这两个参数
vim elasticsearchElasticsearch-7.13.2/config/elasticsearch.yml
http.cors.enabled: true
http.cors.allow-origin: "*"
es-head启动
上面修改完es配置后,重启所有es节点,在es-head目录下使用下面的命令启动es-head
[root@76-yace-es elasticsearch-head-master]# npm start >/dev/null 2>&1 &