1. 程式人生 > >ElasticSearch-6.2安裝head插件

ElasticSearch-6.2安裝head插件

無法 cal header OS appdata 通過 pat hostname 服務

環境

  • Windows10企業版X64
  • JDK-1.8
  • ElasticSearch-6.2.4
  • node-v10.1
  • git客戶端

步驟

安裝node到K盤。如K:\nodejs。

把NODE_HOME設置到環境變量裏(安裝包也可以自動加入PATH環境變量)。測試一下node是否生效:

技術分享圖片

安裝grunt

grunt是一個很方便的構建工具,可以進行打包壓縮、測試、執行等等的工作,5.0裏的head插件就是通過grunt啟動的。因此需要安裝grunt:

註意:路徑切到K:\Program Files\nodejs下。

npm install -g grunt-cli

-g代表全局安裝。安裝路徑為C:\Users\yourname\AppData\Roaming\npm,並且自動加入PATH變量。安裝完成後檢查一下:

技術分享圖片

把head插件的源碼git clone下來:

git clone git://github.com/mobz/elasticsearch-head.git

備註:以上請切換到任意目錄既可。比如我的是:G:\web\projects\elasticsearch-header

修改head源碼

由於head的代碼還是2.6版本的,直接執行有很多限制,比如無法跨機器訪問。因此需要用戶修改兩個地方:

目錄:G:\web\projects\elasticsearch-header\elasticsearch-head|Gruntfile.js:

connect: {
    server: {
        options: {
            port: 
9100, hostname: *, base: ., keepalive: true } } }

增加hostname屬性,設置為*

修改連接地址:

目錄: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://你的服務器ip:9200";// 這裏我的還是localhost

運行head

然後在head源碼目錄中,執行npm install 下載的包:

 npm install

效果如圖:
技術分享圖片

最後,在head源代碼目錄下啟動nodejs:

grunt server

效果如圖:

技術分享圖片

這個時候,訪問http://localhost:9100就可以訪問head插件了:

技術分享圖片



ElasticSearch-6.2安裝head插件