head 客户端能够很方便在上面建立索引,类型,文档,还有查询,使用它管理elasticsearch 提升效率.java
在安装head 客户端以前必须安装node.js 环境,由于它是用node.js 编写的.node
在/usr/local/src 下载 : wget https://npm.taobao.org/mirrors/node/v10.8.0/node-v10.8.0-linux-x64.tar.xzlinux
解压 tar -xvf node-v10.8.0-linux-x64.tar.xz git
mv node-v6.10.0-linux-x64 /usr/local/nodejs github
配置下环境变量,编辑/etc/profile添加web
export NODE_HOME=/usr/local/nodejs/node-v10.8.0-linux-x64
export PATH=$PATH:$NODE_HOME/bin
export NODE_PATH=$NODE_HOME/lib/node_modulesnpm
执行 source /etc/profile浏览器
而后验证安装是否成功:安全
[root@localhost ~]# node -v
v10.8.0bash
Grunt-cli 只是一个命令行工具
wget https://github.com/mobz/elasticsearch-head/archive/master.zip
解压:unzip master.zip
而后进入elasticsearch-head-master 目录
修改elasticsearch-head-master文件下的Gruntfile.js文件中,在options节点下添加一行"hostname: '0.0.0.0',"
connect: { server: { options: { hostname: '0.0.0.0', port: 9100, base: '.', keepalive: true } } }
在 elasticsearch-head-master 目录下开始安装
npm install -g cnpm --registry=https://registry.npm.taobao.org
cnpm install
安装成功后,最后修改elasticsearch的elasticsearch.yml
增长参数,使head插件能够访问es
http.cors.enabled: true http.cors.allow-origin: "*"
具体缘由看看github官网的介绍:
链接到elasticsearch 默认状况下,elasticsearch在9200端口上公开一个http rest API, elasticsearch head会链接到该端口。 在elasticsearch启用歌珥 当不做为elasticsearch的插件运行时(版本5中甚至不可能),必须在elasticsearch中启用CORS,不然浏览器会拒绝看起来不安全的请求。 在elasticsearch配置; 添加http.cors。启用:真 您还必须设置http.cors。容许原点,由于默认状况下不容许原点。http.cors。allow-origin:“*”是有效值,可是它被认为是一种安全风险,由于您的集群能够从任何地方跨origin打开。
在 elasticsearch-head-master 路径下执行
grunt server
(node:3089) ExperimentalWarning: The http2 module is an experimental API. Running "connect:server" (connect) task Waiting forever... Started connect web server on http://localhost:9100
输出上面信息表明已经启动成功了,能够在浏览器上输入地址 http://localhost:9100 访问