1 谷歌瀏覽器安裝elasticsearch-head插件
由於elasticsearch6.0以上版本安裝head需要離線安裝,而且集群安裝比較麻煩,
推薦使用google瀏覽器插件安裝;
#插件下載地址:
https://github.com/TravisTX/elasticsearch-head-chrome
#下載后解壓包,在谷歌瀏覽器里面輸入:
點擊‘加載已解壓的擴展程序’ ,選擇插件的路徑;
點擊右上角小圖標或者瀏覽器輸入地址:
chrome-extension://hpiajdginmnfeeebeihhkipoheekhlbn/elasticsearch-head/index.html
輸入elasticsearch主節點地址,點擊連接:
集群狀態的三種顏色:
顏色 |
意義 |
green |
所有主要分片和復制分片都可用 |
yellow |
所有主要分片可用,但不是所有復制分片都可用 |
red |
不是所有的主要分片都可用 |
2.離線包安裝方法
#可以在節點上安裝該插件;本次安裝在elk2(192.168.1.224)上
1.下載elasticsearch-head-master.zip
下載地址 :https://github.com/mobz/elasticsearch-head
#unzip /home/elasticsearch-head-master.zip
#cd /home/elasticsearch-head-master/
2.下載node.js
#curl https://rpm.nodesource.com/setup_10.x | bash -x
#yum install -y nodejs
#查看是否下載成功
#node -v
#npm -v
3.安裝grunt
#npm install -g grunt-cli
#npm install
如果出現以下報錯
執行:
#npm audit fix
#npm audit fix --force
4.啟動elastichsearch-head
#cp -apr Gruntfile.js Gruntfile.js.bak
#vim Gruntfile.js
添加hostname: '0.0.0.0',
#cp -apr _site/app.js _site/app.js.bak
#vim _site/app.js
將this.prefs.get("app-base_uri") || "http://localhost:9200",修改如下
#注意路徑,在/home/elasticsearch-head-master/下執行
#npm run start
或
#后台啟動
#nohup npm run start &
#驗證elasticsearch-head,在瀏覽器中輸入主機地址和端口
例如:下圖為初始狀態情況
5.修改elasticsearch配置
因為elasticsearch服務與elasticsearch-head之間可能存在跨越,修改elasticsearch配置即可,在所有節點的elastichsearch.yml中添加如下命名即可:
#vi /etc/elasticsearch/elasticsearch.yml
#allow origin
http.cors.enabled: true
http.cors.allow-origin: "*"
#systemctl restart elasticsearch
#后台啟動
# nohup npm run start &
----------------------------------------------------------------------------------------------------------------------------
參考鏈接
https://blog.csdn.net/dkjhl/article/details/95958964
https://blog.csdn.net/mjlfto/article/details/79772848
https://www.cnblogs.com/jcici/p/9888239.html