天天看點

Elasticsearch 5.0 —— Head插件部署指南(Head目前支援5.0了!請不要看本篇文章了)

使用ES的基本都會使用過head,但是版本更新到5.0後,head插件就不好使了。下面就看看如何在5.0中啟動Head插件吧!

Running with built in server

enable cors by adding http.cors.enabled: true in elasticsearch configuration. Don’t forget to also set http.cors.allow-origin because no origin allowed by default. http.cors.allow-origin: "*" is valid value, however it’s considered as a security risk as your cluster is open to cross origin from anywhere.

<a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-http.html#modules-http">Check Elasticsearch documentation on this parameter:</a>

This will start a local webserver running on port 9100 serving elasticsearch-head

Best option if you are likely to connect to several different clusters

5.0版本的ES跟之前的版本最大的不同之處就是多了很多環境的校驗,比如jdk,max-files等等。

修改一下es使用的參數:

需要從github上面下載下傳代碼,是以先要安裝git

安裝完成後,就可以直接下載下傳代碼了:

下載下傳後,修改下777權限(簡單粗暴),因為是獨立啟動head的,是以随便放一個位置就行了,參考:

由于head插件本質上還是一個nodejs的工程,是以需要安裝node,使用npm來安裝依賴的包。(npm可以了解為maven)

Elasticsearch 5.0 —— Head插件部署指南(Head目前支援5.0了!請不要看本篇文章了)

下載下傳下來的jar包是xz格式的,一般的linux可能不識别,還需要安裝xz.

然後解壓nodejs的安裝包:

解壓完node的安裝檔案後,需要配置下環境變量,編輯/etc/profile,添加

别忘記立即執行以下

這個時候可以測試一下node是否生效:

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

安裝完成後檢查一下:

由于head的代碼還是2.6版本的,直接執行有很多限制,比如無法跨機器通路。是以需要使用者修改兩個地方:

目錄:head/Gruntfile.js

增加hostname屬性,設定為*

目錄:head/_site/app.js

修改head的連接配接位址:

把localhost修改成你es的伺服器位址,如:

首先開啟5.0 ES。

然後在head目錄中,執行npm install 下載下傳以來的包:

最後,啟動nodejs

這個時候,通路<code>http://xxx:9100</code>就可以通路head插件了.

Elasticsearch 5.0 —— Head插件部署指南(Head目前支援5.0了!請不要看本篇文章了)

<a href="https://github.com/mobz/elasticsearch-head#running-with-built-in-server">head官方文檔</a>