Linux下elasticsearch-head环境搭建文档
由于head插件本质上还是一个nodejs的工程,因此需要安装node,使用npm来安装依赖的包。
1、安装Node.js
下载解压
# wget https://nodejs.org/dist/v10.15.3/node-v10.15.3-linux-x64.tar.xz
# xz –d node-v10.15.3-linux-x64.tar.xz # tar xvf node-v10.15.3-linux-x64.tar # mv node-v10.15.3-linux-x64 nodejs
配置并生效
# vim /etc/profile
# nodejs环境变量配置
export NODE_HOME=/home/qdfinance/apps/nodejs
export PATH=$PATH:$NODE_HOME/bin
# source /etc/profile
查看版本验证
# node -v v6.10.2 # npm -v 3.10.10
2、head插件安装
2.1、下载head插件
如果未安装git ,则先安装git工具
# yum install –y git # git clone https://github.com/mobz/elasticsearch-head.git
2.2、安装grunt
# mv elasticsearch-head head
# cd head
# npm install -g grunt --registry=https://registry.npm.taobao.org或者
# npm install -g
2.3、安装插件
在elasticsearch-head目录下node_modules/grunt下如果没有grunt二进制程序,需要执行:
# npm install grunt --save
2.4、修改配置 elasticsearch-head下Gruntfile.js文件
修改connect配置节点
2.5、修改 _site/app.js 修改http://localhost:9200字段到本机ES端口与IP
2.6、修改 elasticsearch配置文件
修改elasticsearch.yml文件加入以下内容:
# 是否支持跨域
http.cors.enabled: true
# *表示支持所有域名
http.cors.allow-origin: "*"
2.7、启动head插件服务(后台运行)
# /head/node_modules/grunt/bin/grunt server &
后台启动
# nohup /head/node_modules/grunt/bin/grunt server &exit
验证: