nodejs 安装
访问 nodejs官网,在Download
页选择合适的版本下载:
解压缩后配置环境变量:
# vim /etc/profile,在文件末尾配置路径
[root@localhost node-v10.16.3]# export NODE_HOME=/app//app/node-v10.16.3
[root@localhost node-v10.16.3]# export PATH=$NODE_HOME/bin:$PATH
# 保存退出
[root@localhost node-v10.16.3]# source /etc/profile
# 验证 nodejs 全局配置生效
[root@localhost node-v10.16.3]# node -v
v10.16.3
[root@localhost node-v10.16.3]#
elasticsearch-head 安装
自5.x
版本后,head
只能作为一个独立服务运行,在此之前,它是以es
的一个插件的方式运行。本文是基于6.x
版本的安装部署手册,如需了解老版本插件安装方式,可访问github
仓库学习。
访问仓库,下载 head 插件,或者使用git
命令下载:
git clone git://github.com/mobz/elasticsearch-head.git
cd elasticsearch-head
npm install
npm run start
npm install
执行时可能会报错:
npm WARN deprecated phantomjs-prebuilt@2.1.16: this package is now deprecated
……
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/2019-09-02T13_59_51_703Z-debug.log
通过安装提示可知phantomjs-prebuilt@2.1.16
已被废弃,忽略它安装即可,修改安装命令如下:
[root@localhost elasticsearch-head]# npm install phantomjs-prebuilt@2.1.16 --ignore-scripts
npm WARN deprecated phantomjs-prebuilt@2.1.16: this package is now deprecated
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN elasticsearch-head@0.0.0 license should be a valid SPDX license expression
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
+ phantomjs-prebuilt@2.1.16
added 62 packages from 64 contributors, removed 4 packages and audited 1734 packages in 34.933s
found 37 vulnerabilities (18 low, 2 moderate, 17 high)
run `npm audit fix` to fix them, or `npm audit` for details
启动 head
npm run start
访问head:
http://localhost:9100/,在地址栏里输入es
服务器地址,点击连接按钮访问head
首页
如果浏览器一直没有响应,应该是存在跨域问题:
编辑
elasticsearch.yml
,在配置中添加如下配置重启es
即可:
#allow origin
http.cors.enabled: true
http.cors.allow-origin: "*"