Tips:環(huán)境
- 樓主博客:https://zhousiwei.gitee.io/
-
Windows7,JDK-1.8,ElasticSearch-5.5.0,node-v8.1.2,git
windows用戶建議安裝個 TortoiseGit客戶端
下載Elasticsearch 5.5.0 ?? https://www.elastic.co/downloads/elasticsearch
-
zip和tar格式是各種系統(tǒng)都通用的,解壓之后啟動Elasticsearch即可。
1、npm安裝grunt
$ npm install -g grunt-cli
$ grunt -version

注意這里安裝的時候路徑一定要切換到grunt-cli文件夾下面
這些是Grunt file.js中引用的,分別下載
$ npm install grunt-contrib-copy
$ npm install grunt-contrib-concat
$ npm install grunt-contrib-uglify
$ npm install grunt-css
2、下載官方源碼
$ git clone git://github.com/mobz/elasticsearch-head.git
3、修改head源碼
由于head的代碼還是2.6版本的,直接執(zhí)行有很多限制,比如無法跨機器訪問。因此需要用戶修改兩個地方:
目錄:head/Gruntfile.js:
增加hostname屬性,設置為*
connect: {
server: {
options: {
port: 9100,
hostname: '*',
base: '.',
keepalive: true
}
}
3.1、修改連接地址:
目錄:head/_site/app.js
修改head的連接地址:
this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://localhost:9200";
把localhost修改成你es的服務器地址,如:
this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://10.10.10.10:9200";
4、運行Elasticsearch-head
修改elasticsearch的參數(shù)
修改一下es使用的參數(shù)。編輯config/elasticsearch.yml
注意,設置參數(shù)的時候:后面要有空格!
# 換個集群的名字,免得跟別人的集群混在一起
cluster.name: es-5.0-test
# 換個節(jié)點名字
node.name: node-101
# 修改一下ES的監(jiān)聽地址,這樣別的機器也可以訪問
network.host: 0.0.0.0
# 默認的就好
http.port: 9200
# 增加新的參數(shù),這樣head插件可以訪問es
http.cors.enabled: true
http.cors.allow-origin: "*"
開啟ES-5.5.0:ElasticSearch-5.0.0\bin\elasticsearch.bat
然后在head源碼目錄中,執(zhí)行npm install進行安裝:
$ npm install
- 初次運行安裝可能會報警告或錯誤??梢灾匦逻\行一次
npm install
最后,使用grunt命令在head源碼目錄下啟動:
$ grunt server
效果如圖:
