一、下載安裝包
下載Elasticsearch 5.1.1
下載地址:https://www.elastic.co/downloads/elasticsearch
zip和tar格式是各種系統都通用的,解壓之后啟動Elasticsearch即可。
下載elasticsearch-head
下載地址:https://github.com/mobz/elasticsearch-head,下載后解壓縮。
二、安裝node、npm、grunt
node下載地址nodejs.org/
$ node -v
v6.8.1
npm下載地址https://www.npmjs.com
$ npm -v
3.10.8
使用npm安裝grunt:
npm install –g grunt–cli
三、npm 安裝依賴
到elasticsearch-head-master目錄下,運行命令:
npm install
如果速度較慢或者安裝失敗,可以使用國內鏡像:
npm install -g cnpm --registry=https://registry.npm.taobao.org
四、修改Elasticsearch配置文件
編輯elasticsearch-5.1.1/config/elasticsearch.yml,加入以下內容:
http.cors.enabled: true
http.cors.allow-origin: "*"
五、修改Gruntfile.js
打開elasticsearch-head-master/Gruntfile.js,找到下面connect屬性,新增hostname: ‘0.0.0.0’:
connect: {
server: {
options: {
hostname: '0.0.0.0',
port: 9100,
base: '.',
keepalive: true
}
}
}
六、啟動elasticsearch-head
在elasticsearch-head-master/目錄下,運行啟動命令:
grunt server
截圖如下:
訪問9100端口:
七、后台啟動elasticsearch-head
后台啟動grunt server命令;
nohup grunt server &exit
如果想關閉head插件,使用Linux查找進程命令:
ps aux|grep head
結束進程:
kill 進程號