前言
前不久剛烏鴉嘴說完比較閑,就忙成狗,過了很久都沒有更新,趁周末趕緊之前總結的經驗梳理一下。上次我們說完ELK三個組件的安裝和配置,但是看著這枯燥無味的命令行啟動的ELK,可能會讓大家覺得很抽象,只知道安裝成功了,不知道怎么使用,不知道該從何下手;那么我們就可以給ES安裝幾個可視化控件,可以更方便、更直觀的了解ES的結構,以及之后為ES集群擴展做準備。
ps:由于在mac機子上ELK不好擴展,所以往后的教程均在linux系統(tǒng)上實現(xiàn),本文使用的系統(tǒng)為CentOS7。
elasticserch-head 安裝
簡介
關于ElasticSearch-Head官方介紹比較簡單,只有一句話:
ElasticSearch-Head 是一個與Elastic集群(Cluster)相交互的Web前臺。
ES-Head的主要作用
它展現(xiàn)ES集群的拓撲結構,并且可以通過它來進行索引(Index)和節(jié)點(Node)級別的操作
它提供一組針對集群的查詢API,并將結果以json和表格形式返回
它提供一些快捷菜單,用以展現(xiàn)集群的各種狀態(tài)
安裝
一、安裝nodejs
打開終端輸入
curl -sL -o /etc/yum.repos.d/khara-nodejs.repo https://copr.fedoraproject.org/coprs/khara/nodejs/repo/epel-7/khara-nodejs-epel-7.repo
yum install -y nodejs nodejs-npm
二、安裝grunt
grunt是一個很方便的構建工具,可以進行打包壓縮、測試、執(zhí)行等等的工作,5.X里的head插件就是通過grunt啟動的。
npm install grunt-cli #安裝grunt-cli
npm install grunt #安裝grunt
grunt -version #查看版本
三、安裝git
yum remove git #移除之前老的git
git --version #查看是否安裝git
yum install git #安裝git
四、安裝head
新建一個文件夾elasticsearch-head
cd elasticsearch-head
git clone git://github.com/mobz/elasticsearch-head.git
npm install安裝head
可能會遇到的報錯
“查看報錯信息”Error: Cannot find module '/var/lib/elasticsearch/elasticsearch-head/node_modules/phantomjs-prebuilt/install.js'”,未找到” phantomjs-prebuilt/install.js”文件;”
使用 npm install phantomjs-prebuilt@2.1.13 --ignore-scripts 解決
修改/elasticsearch-head/_site/app.js

修改/elasticsearch-head/Gruntfile.js

grunt server & 運行head插件
http://locahost:9100/查看服務

如果“集群健康值: 未連接”
修改elasticsearch目錄下 conf/elasticsearch.yml
elasticsearch/conf目錄下 文件elasticsearch.yml中添加配置如下:
#避免出現(xiàn)跨域問題
http.cors.enabled: true
http.cors.allow-origin: "*"
重啟es 和head即可
ps:這里不著重介紹如何使用插件,大家可以自行去了解或者看我下一篇集群介紹。
elasticserch-kopf 安裝
簡介
Kopf是一個ElasticSearch的管理工具,它也提供了對ES集群操作的API。是一個我非常喜歡,非常強大的工具。

安裝
使用git下載kopf
git clone git://github.com/lmenezes/elasticsearch-kopf.git
下載elasticserch-kopf 完成后會在用戶下創(chuàng)建elasticserch-kopf 文件夾
cd到elasticserch-kopf 目錄下
npm install 安裝kopf npm會自動檢索沒有安裝的插件
可能會遇到的問題
Local Npm module "grunt-contrib-copy" not found.? Is it installed?
Local Npm module "grunt-contrib-uglify" not found.? Is it installed?
Local Npm module "grunt-contrib-jshint" not found.? Is it installed?
Local Npm module "grunt-contrib-less" not found.? Is it installed?
Local Npm module "grunt-contrib-clean" not found.? Is it installed?
Local Npm module "grunt-contrib-watch" not found.? Is it installed?
Local Npm module "grunt-contrib-concurrent" not found.? Is it installed?
Local Npm module "grunt-contrib-nodemon" not found.? Is it installed?
Local Npm module "grunt-contrib-newer" not found.? Is it installed?
Warning: Task "copy:vendor" not found. Use --force to continue.
Aborted due to warnings.
這是因為grunt缺少對應的module
通過命令
npm install module-名字 --save-dev?
把所有缺少的module安裝上即可
安裝完成運行
grunt server &

http://locahost:9000/查看服務

配置kopf 添加elasticserch服務端口即可。
elasticserch-bigdesk 安裝
簡介
Bigdesk為Elastic集群提供動態(tài)的圖表與統(tǒng)計數(shù)據。主要用于監(jiān)控集群性能、CPU使用情況、內存使用率等,方便更好的配置集群節(jié)點等。

安裝
打開終端下載
git clone https://github.com/hlstudio/bigdesk.git
cd 到bigdesk/_site/目錄下
運行
python -m SimpleHTTPServer
而Linux默認是安裝Python的,所以只需要執(zhí)行python -m SimpleHTTPServer。
這就行了,而我們的HTTP服務在8000號端口上偵聽。你會得到下面的信息:
Serving HTTP on 0.0.0.0 port 8000 …
然后打開瀏覽器(IE或Firefox),然后輸入下面的URL:
http://localhost:8000
如果你的目錄下有一個叫 index.html 的文件名的文件,那么這個文件就會成為一個默認頁,如果沒有這個文件,那么,目錄列表就會顯示出來。

部分參考的文獻