可視化的插件可以提高我們的工作效率,ES常用的視圖插件有head、Kibana,後者是官方提供的web視圖。
安裝Head插件
由於head插件本質上還是一個nodejs的工程,因此需要安裝node,使用npm來安裝依賴的包。
-
安裝Node.js
下載解壓
wget https://nodejs.org/dist/v6.10.2/node-v6.10.2-linux-x64.tar.xz
xz –d node-v6.10.2-linux-x64.tar.xz
tar xvf node-v6.10.2-linux-x64.tar
mv node-v6.10.2-linux-x64 /usr/local/node
配置NODE_HOME並生效
vim /etc/profile
export NODE_HOME=/usr/local/node
export PATH=$PATH:$NODE_HOME/bin
source /etc/profile使配置生效
- 下載head插件
如果未安裝git ,則先安裝git工具
yum install –y git
git clone https://github.com/mobz/elasticsearch-head.git
- 安裝grunt
cd elasticsearch-head
npm install -g grunt --registry=https://registry.npm.taobao.org
- 安裝插件
npm install
以上安裝完成後要做三處修改
1./usr/local/elasticsearch-head/_site/app.js 修改http://localhost:9200字段到本機ES端口與IP,大概在4000行,可以使用:4300定位一下,如下圖
2.修改/usr/local/elasticsearch-head/Gruntfile.js host地址,如下圖
3.最後重要的是要配置一下elasticsearch.yml,在最後加上兩行
http.cors.enabled: true
http.cors.allow-origin: "*"
目的是解決跨域的問題。
啓動head插件 記得切換用戶 要與elastic一個用戶 /elasticsearch-head/node_modules/grunt/bin/grunt server &
看到如下圖就說明安裝成功
顯示green 說明服務器是健康的。