1、操作系统版本
2、下载elasticsearch-head插件
下载地址:https://github.com/mobz/elasticsearch-head
3、下载node.js
https://cdn.npm.taobao.org/dist/node/v14.3.0/node-v14.3.0-linux-x64.tar.xz
4、安装node.js
解压 node-v14.3.0-linux-x64.tar.xz
export NODE_HOME=/u01/node-v14.3.0-linux-x64
export PATH=$PATH:$NODE_HOME/bin
export NODE_PATH=$NODE_HOME/lib/node_modules
查看是否安装成功
node -v 查看版本号
5、安装 elasticsearch-head
unzip elasticsearch-head-master.zip
mv elasticsearch-head-master elasticsearch-head
安装epel源
yum -y install epel-release
yum -y install npm
cd elasticsearch-head
npm install --如若报错
npm ERR! Linux 3.10.0-693.el7.x86_64
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! node v6.17.1
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
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 ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the phantomjs-prebuilt package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node install.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs phantomjs-prebuilt
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls phantomjs-prebuilt
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /opt/software/elasticsearch-head/npm-debug.log
npm ERR! code 1
说明是网络源有问题
查看网络源
[root@microservice-test2 elasticsearch-head]# npm config get registry
https://registry.npmjs.org/
果然为国外源 设置为阿里
[root@microservice-test2 elasticsearch-head]# npm config set registry http://registry.npm.taobao.org
[root@microservice-test2 elasticsearch-head]# npm config get registry
http://registry.npm.taobao.org/
问题
用npm安装模块时,npm 报了这样的一个错误ERR! registry error parsing json。
方法
npm config delete registry 删除registry,继续安装模块就可以了
用 npm install 安装还报错,换成下面的命令成功:
npm install phantomjs-prebuilt@2.1.14 --ignore-scripts
安装这个项目会花费大量的时间
安装完后,会生成一个node_modes文件夹
可以通过grunt -version查看grunt版本号
6、 配置相关文件
1) 修改elasticsearch.yml,增加跨域的配置(需要重启es才能生效)
vi /etc/elasticsearch/elasticsearch.yml
加入配置:
http.cors.enabled: true
http.cors.allow-origin: “*”
2) 修改Gruntfile.js文件,修改服务监听地址(增加hostname属性,将其值设置为’0.0.0.0’)
92行添加:hostname:‘0.0.0.0’,
7、 重启elasticsearch服务、启动head插件服务
启动head插件服务:npm run start
后台启动:
nohup npm run start >> output.log 2>&1 &