ElasticSearch-5.0安裝head插件

環境

  • Windows10企業版X64
  • JDK-1.8
  • ElasticSearch-5.0.0
  • node-v4.5.0-x64.msi
  • git客戶端

步驟

安裝node到D盤。如D:\nodejs。html

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

安裝grunt

grunt是一個很方便的構建工具,能夠進行打包壓縮、測試、執行等等的工做,5.0裏的head插件就是經過grunt啓動的。所以須要安裝grunt:git

注意:路徑切到D:\nodejs下。github

npm install -g grunt-cli

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

 

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

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

效果如圖:app

修改head源碼

因爲head的代碼仍是2.6版本的,直接執行有不少限制,好比沒法跨機器訪問。所以須要用戶修改兩個地方:cors

目錄:head/Gruntfile.js:elasticsearch

複製代碼
connect: {
    server: {
        options: {
            port: 9100, hostname: '*', base: '.', keepalive: true } } }
複製代碼

增長hostname屬性,設置爲*grunt

修改鏈接地址:

目錄: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";

運行head

修改elasticsearch的參數

修改一下es使用的參數。編輯config/elasticsearch.yml:

複製代碼
# 換個集羣的名字,省得跟別人的集羣混在一塊兒
cluster.name: es-5.0-test # 換個節點名字 node.name: node-101 # 修改一下ES的監聽地址,這樣別的機器也能夠訪問 network.host: 0.0.0.0 # 默認的就好 http.port: 9200 # 增長新的參數,這樣head插件能夠訪問es http.cors.enabled: true http.cors.allow-origin: "*"
複製代碼

 注意,設置參數的時候:後面要有空格!

開啓ES-5.0.0:

D:\ElasticSearch-5.0.0\bin\elasticsearch.bat

啓動效果:

 

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

 npm install

效果如圖:

初次運行安裝可能會報警告或錯誤。能夠從新運行一次npm install。

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

grunt server

效果如圖:

訪問:target:9100

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

由於以前已在ES中創建了一個索引m8,所以能夠看到數據:

 

 

從 http://www.cnblogs.com/xuxy03/p/6039999.html 轉載

系列文章:ElasticSearch 系列隨筆

相關文章
相關標籤/搜索