Head插件介紹
Head插件安裝你就必須先安裝Node,因為Head5.0插件就是通過grunt啟動的寒亥。因此需要安裝grunt,grunt是一個很方便的構(gòu)建工具,可以進行打包壓縮剖膳、測試、執(zhí)行等等的工作缚去。
1.直接下載安裝:
記得安裝在沒用的盤:
2.然后打開cmd,進入你安裝的路徑易结,查詢一下是否安裝成功:
3.接著路徑不要改還在當前輸入:
npm install -g grunt-cli
4.-g代表全局安裝枕荞。安裝路徑為C:\Users\yourname\AppData\Roaming\npm,并且自動加入PATH變量搞动。安裝完成后檢查一下:
grunt? -version
會發(fā)現(xiàn):
5.把head插件的源碼Gitclone下來(這里注意沒用過git要先學習git):
git clone git://github.com/mobz/elasticsearch-head.git
6.修改head源碼:
由于head的代碼還是2.6版本的躏精,直接執(zhí)行有很多限制,比如無法跨機器訪問鹦肿。因此需要用戶修改兩個地方:
1.目錄:head/Gruntfile.js:
connect: {
server: {
options: {
port:9100,
hostname:'*',
base:'.',
keepalive:true}
}
}
增加hostname屬性矗烛,設置為*
2.修改連接地址:
目錄: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";
7.運行head
修改一下es使用的參數(shù)箩溃。編輯config/elasticsearch.yml:
# 換個集群的名字瞭吃,免得跟別人的集群混在一起
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:truehttp.cors.allow-origin:"*"
8.啟動Elasticsearch雙擊elasticsearch.bat或者
E:\Elasticsearch\elasticsearch-5.5.2\bin>elasticsearch.bat
9.然后在head源碼目錄中歪架,執(zhí)行npm install 下載的包:
npm install
10.如圖最后止状,在head源代碼目錄下啟動nodejs:
grunt server
效果如圖(圖上還有很多警告):
這個時候,訪問http://localhost:9100就可以訪問head插件了:
11.后臺啟動elasticsearch-head
后臺啟動grunt server命令攒霹;
nohup grunt server &exit
如果想關閉head插件怯疤,使用Linux查找進程命令:
ps aux|grep head
結(jié)束進程:
kill 進程號