在elasticsearch中存儲數據的行為就叫做索引(indexing),不過在索引之前,我們需要明確數據應該存儲在哪里。
在elasticsearch中,文檔歸屬於一種類型(type),而這些類型存在於索引(index)中,我們可以畫一些簡單的對比圖來類比傳統的關系型數據庫。
relation DB -- Database --- Tables -- Rows ---Coumns
elasticsearch -- Indices --- Types --Documents--Fields
elasticsearch集群可以包含多個索引(indices)(數據庫),每一個索引可以包含多個類型(types)(表),每一個類型包含多個文檔(documents)(行),然后每個文檔包含多個字段(Fields)(行).
ELK的整套解決方案如下:
其中Metrics主要用來監視CPU等系統資源消耗情況。具體安裝操作如下:
一、安裝metricbeat應用軟件
二、導入beats-dashboards模板
A.在線安裝時,運行如下命令:
./scripts/import_dashboards -es http://XXX:9200
B.離線安裝時,運行如下命令:
./scripts/import_dashboards -file beats-dashboards-5.2.1.zip -es http://XXX:9200
參見:http://wangzhijian.blog.51cto.com/6427016/1878636
一、elasticsearch單機環境搭建
注:elasticsearch對JDK版本這有嚴格的要求,一般建議安裝Java: openjdk version "1.8.0_xx"
配置ElasticSearch
tar -zxvf elasticsearch-5.2.2.tar.gz cd elasticsearch-5.2.2
編輯ES的配置文件,修改以下配置項:
cluster.name=es_cluster node.name=node0 path.data=/tmp/elasticsearch/data path.logs=/tmp/elasticsearch/logs #當前hostname或IP network.host=XXX network.port=9200 bootstrap.memory_lock: false bootstrap.system_call_filter: false
啟動ES:
./bin/elasticsearch或nohup ./bin/elasticsearch &
打開頁面IP:9200,將會看到以下內容:
或者使用命令:curl http://IP:9200來檢查部署是否成功
集群安裝請參見:http://yedward.net/post/416.html
安裝過程中碰到的坑如下: http://blog.csdn.net/qq_21387171/article/details/53577115及http://www.dajiangtai.com/community/18136.do
參數配置可以參見:bigbo.github.io/pages/2015/04/10/elasticsearch_config
另外在安裝5.2.2版本時碰到一個報錯及處理方式如下:
ERROR: bootstrap checks failed system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
解決措施如下:在elasticsearch.yml中配置bootstrap.system_call_filter為false,注意要在Memory下面:
bootstrap.memory_lock: false bootstrap.system_call_filter: false
可以查看issues:https://github.com/elastic/elasticsearch/issues/22899
二、kibana安裝
1、安裝准備
tar -zxvf kibana-5.2.2.tar.gz
2、配置kibana
server.port: 5601 #監聽的端口號 server.host: "172.18.12.XX" #Kibana服務的IP elasticsearch.url: http://172.18.12.XX:9200 #es服務器的http訪問路徑 kibana.index: .kibana #kibana在es中的輔助索引名稱
3、啟動kibana
./bin/kibana
4、驗證kibana是否安裝成功
kibana安裝成功后,通過ps -ef|grep kibana或者ps -ef|grep 5601都找不到,需要通過如下命令來檢測:
fuser -n tcp 5601 kill -9 端口
檢查http://IP:5601是否可以訪問
kibana數據查詢:totalTime: [500 TO *] AND monitorName: "KMID-M3001"