最近發現磁盤的占用率趨高,打開可視化工具head檢視了之後發現,es執行個體中生成了好多類似monitoring-es-6-2019.11.27這個的節點。
##查詢叢集總的磁盤使用情況
curl -u elastic -XGET 'localhost:9200/_cat/allocation?v'
##查詢叢集中各索引的磁盤占用情況
curl -u elastic -XGET 'localhost:9200/_cat/indices?v'
ES服務安裝了x-pack之後,會預設保留最近7天的監控索引,此類.monitoring-es-6-*的索引會占用ES執行個體存儲空間。索引的大小跟叢集中索引個數(包含系統索引)節點個數有關系,為了避免ES執行個體大部分空間被監控索引所占用,可通過一下兩種方式優化:
- 一、通過修改elasticsearch.yml的配置設定監控索引保留天數
xpack.monitoring.history.duration: 1d
-
二、設定需要采集監控的索引
可以通過配置檔案的設定,選擇哪些索引需要監控,哪些索引不需要監控,以減少.monitoring-es-6-* 索引所占用磁盤空間。
隻監控einterface,和school索引。
xpack.monitoring.collection.indices: einterface,school
-
三、下面整理了一些可配置的參數
一般監控設定
xpack.monitoring.enabled
設定為false在節點上禁用Elasticsearch的Elasticsearch X-Pack監視。
監控收集設定
這些xpack.monitoring.collection設定控制如何從Elasticsearch節點收集資料。
xpack.monitoring.collection.cluster.stats.timeout
設定收叢集集統計資訊的逾時時間。預設為10s。
xpack.monitoring.collection.indices
控制Monitoring從哪個名額收集資料。預設為所有的索引。例如,将索引名稱指定為以逗号分隔的清單moma,momb,momc。名稱支援通配符的設定如包含通配符mom*,還可以通過+包含索引,-排除索引。
xpack.monitoring.collection.index.stats.timeout
設定收集索引統計資訊的逾時時間。預設為10s。
xpack.monitoring.collection.indices.stats.timeout
設定收集總索引統計資訊的逾時時間。預設為10s。
xpack.monitoring.collection.index.recovery.active_only
控制是否收集所有的回收率。設定為true僅收集主動恢複。預設為false。
xpack.monitoring.collection.index.recovery.timeout
設定收集恢複資訊的逾時時間。預設為10s。
xpack.monitoring.collection.interval
控制收集資料樣本的頻率。預設為10s。如果修改收集時間間隔,請将該xpack.monitoring.min_interval_seconds 選項設定kibana.yml為相同的值。設定為-1暫時禁用資料收集。您可以通過群集更新設定API更新此設定。
xpack.monitoring.history.duration
設定保留持續時間,自動删除由監控導出器建立的索引。預設為7d(7天),做少設定成1d(1天)