Elasticsearch 节点磁盘使用率过高,导致ES集群索引无副本
一、问题
最近在查看线上的 es,发现最近2天的索引没有副本,集群的状态也是为 yellow 的。
二、问题的原因
es 所在的服务器磁盘是还有剩余空间的。只不过磁盘使用了大概 89%,按道理来说应该是会继续使用的,并创建索引的副本的,我们经过查阅官方文档。
cluster.routing.allocation.disk.watermark.low
Controls the low watermark for disk usage. It defaults to 85%, meaning that Elasticsearch will not allocate shards to nodes that have more than 85% disk used. It can also be set to an absolute byte value (like 500mb) to prevent Elasticsearch from allocating shards if less than the specified amount of space is available. This setting has no effect on the primary shards of newly-created indices or, specifically, any shards that have never previously been allocated.
cluster.routing.allocation.disk.watermark.high
Controls the high watermark. It defaults to 90%, meaning that Elasticsearch will attempt to relocate shards away from a node whose disk usage is above 90%. It can also be set to an absolute byte value (similarly to the low watermark) to relocate shards away from a node if it has less than the specified amount of free space. This setting affects the allocation of all shards, whether previously allocated or not.
cluster.routing.allocation.disk.watermark.flood_stage
Controls the flood stage watermark. It defaults to 95%, meaning that Elasticsearch enforces a read-only index block (index.blocks.read_only_allow_delete) on every index that has one or more shards allocated on the node that has at least one disk exceeding the flood stage. This is a last resort to prevent nodes from running out of disk space. The index block must be released manually once there is enough disk space available to allow indexing operations to continue.
我们可以知道,es 集群的默认配置是当集群中的某个节点磁盘达到使用率为 85% 的时候,就不会在该节点进行创建副本,当磁盘使用率达到 90% 的时候,尝试将该节点的副本重分配到其他节点。当磁盘使用率达到95% 的时候,当前节点的所有索引将被设置为只读索引。
三、问题解决的办法
1. 扩大磁盘
……
2. 删除部分历史索引
3. 更改es设置
- 更改配置文件(需要重启es)
- 动态更改(api,无需重启)
es 的设置默认是 85% 和 90 %,我们更改为 90%和 95%。
3.1、更改配置文件(需要重启es)
在elasticsearch.yml 文件配置:
cluster.routing.allocation.disk.threshold_enabled: true
cluster.routing.allocation.disk.watermark.low: 90%
cluster.routing.allocation.disk.watermark.high: 95%
cluster.routing.allocation.disk.watermark.flood_stage: 98%
3.2、动态更改
所谓的动态更改就是通过 es 的 api 进行更改。transient 临时更改,persistent是永久更改。
api 接口 /_cluster/settings
注意 cluster.routing.allocation.disk.watermark.flood_stage 参数是 6.0 版本开始才有的,在5的版本是没有该配置的, 是不支持的,我在修改5.6 的版本的时候添加了该参数,是有错误返回的 "reason":"persistent setting [cluster.routing.allocation.disk.watermark.flood_stage], not dynamically updateable"},"status":4001. 5.6 版本官方文档链接:https://www.elastic.co/guide/en/elasticsearch/reference/5.6/disk-allocator.html
查看es 当前的配置
查看es 当前的配置 get 请求 /_cluster/settings 。
curl 172.1.2.208:9200/_cluster/settings
{
"persistent": {
"xpack": {
"monitoring": {
"collection": {
"enabled": "true"
}
}
}
},
"transient": {
"cluster": {
"routing": {
"allocation": {
"disk": {
"watermark": {
"low": "90%",
"high": "95%"
}
}
}
},
"info": {
"update": {
"interval": "1m"
}
}
}
}
}
永久更改 persistent
重启后不失效。
{"persistent":
{
"cluster.routing.allocation.disk.watermark.low": "90%",
"cluster.routing.allocation.disk.watermark.high": "95%",
"cluster.info.update.interval": "1m"
}
}
临时更改 transient
重启后配置失效。
{"transient":
{
"cluster.routing.allocation.disk.watermark.low": "90%",
"cluster.routing.allocation.disk.watermark.high": "95%",
"cluster.info.update.interval": "1m"
}
}
示例:
root@111:~# curl -H "Content-Type: application/json" -XPUT 172.1.2.208:9200/_cluster/settings -d '{"transient": { "cluster.routing.allocation.disk.watermark.low": "90%", "cluster.routing.allocation.disk.watermark.high": "95%", "cluster.info.update.interval": "1m"}}'
{"acknowledged":true,"persistent":{},"transient":{"cluster":{"routing":{"allocation":{"disk":{"watermark":{"low":"90%","high":"95%"}}}},"info":{"update":{"interval":"1m"}}}}}
四、扩展
其实我们在官方文档也就可以看到,就是我们不仅仅可以使用百分比来进行设置,我们也可以使用空间的大小来进行设置,类似500mb这样。
Elasticsearch 节点磁盘使用率过高,导致ES集群索引无副本的更多相关文章
- 主机磁盘使用率超过85%导致es索引变为只读模式
[ type=cluster_block_exception, reason=index [ index_name ] FORBIDDEN/12/index read-only / allow del ...
- Elasticsearch之重要核心概念(cluster(集群)、shards(分配)、replicas(索引副本)、recovery(据恢复或叫数据重新分布)、gateway(es索引的持久化存储方式)、discovery.zen(es的自动发现节点机制机制)、Transport(内部节点或集群与客户端的交互方式)、settings(修改索引库默认配置)和mappings)
Elasticsearch之重要核心概念如下: 1.cluster 代表一个集群,集群中有多个节点,其中有一个为主节点,这个主节点是可以通过选举产生的,主从节点是对于集群内部来说的.es的一个概念就是 ...
- ELasticSearch(五)ES集群原理与搭建
一.ES集群原理 查看集群健康状况:URL+ /GET _cat/health (1).ES基本概念名词 Cluster 代表一个集群,集群中有多个节点,其中有一个为主节点,这个主节点是可以通过选举产 ...
- 教你在Kubernetes中快速部署ES集群
摘要:ES集群是进行大数据存储和分析,快速检索的利器,本文简述了ES的集群架构,并提供了在Kubernetes中快速部署ES集群的样例:对ES集群的监控运维工具进行了介绍,并提供了部分问题定位经验,最 ...
- 本地ES集群数据通过_reindex方式迁移到腾讯云服务器(亲测有效)
本地ES集群数据通过_reindex方式迁移到腾讯云服务器(亲测有效) 随着业务量的增加,本地的ES集群服务器性能和磁盘空间有点不够使用,项目组考虑使用腾讯云服务器,以下是我测试的使用_reindex ...
- ELK学习笔记之简单适用的ES集群监控工具cerebro安装使用
安装指导及使用简介 1. 下载安装包: https://github.com/lmenezes/cerebro/releases/download/v0.7.3/cerebro-0.7.3. ...
- ES集群安装
环境配置 安装openjdk(依赖) -openjdk.x86_64 安装elasticsearch yum -y install elasticsearch 配置 /etc/elasticsearc ...
- elasticsearch系列八:ES 集群管理(集群规划、集群搭建、集群管理)
一.集群规划 搭建一个集群我们需要考虑如下几个问题: 1. 我们需要多大规模的集群? 2. 集群中的节点角色如何分配? 3. 如何避免脑裂问题? 4. 索引应该设置多少个分片? 5. 分片应该设置几个 ...
- elasticsearch(es) 集群恢复触发配置(Local Gateway参数)
elasticsearch(es) 集群恢复触发配置(Local Gateway) 当你集群重启时,几个配置项影响你的分片恢复的表现. 首先,我们需要明白如果什么也没配置将会发生什么. 想象一下假设你 ...
随机推荐
- part11-LED驱动程序设计-part11.1-字符设备控制
- @总结 - 10@ Miller-Rabin素性测试与Pollard-Rho因数分解
目录 @1 - 素性测试:Miller-Rabin算法@ @1.1 - 算法来源@ @1.2 - 算法描述@ @1.3 - 算法实现@ @2 - 因数分解:Pollard-Rho算法@ @2.0 - ...
- 【[Offer收割]编程练习赛9 B】水陆距离
[题目链接]:http://hihocoder.com/problemset/problem/1478 [题意] [题解] 一开始把所有的水域的位置都加入到队列中去; 然后跑一个bfs. 第一次到达的 ...
- 学习CSS预处理器Less
1.Sass与Less的区别:Sass与Less的区别 2.Less的使用:Less的使用 3.Less的相关网址:Less.js.Less中文网 Less的HSL函数-lighten():HSL函数 ...
- poj 1436 && zoj 1391 Horizontally Visible Segments (Segment Tree)
ZOJ :: Problems :: Show Problem 1436 -- Horizontally Visible Segments 用线段树记录表面能被看见的线段的编号,然后覆盖的时候同时把能 ...
- div+css布局的好处
改版的时候更方便,只需改动CSS文件 页面加载速度更快,结构清晰,页面简洁 表现与结构相分离 有利于SEO,排名更靠前
- LA 5031 Graph and Queries —— Treap名次树
离线做法,逆序执行操作,那么原本的删除边的操作变为加入边的操作,用名次树维护每一个连通分量的名次,加边操作即是连通分量合并操作,每次将结点数小的子树向结点数大的子树合并,那么单次合并复杂度O(n1lo ...
- Python3 dir() 函数
Python dir() 函数 描述 dir() 函数不带参数时,返回当前范围内的变量.方法和定义的类型列表:带参数时,返回参数的属性.方法列表.如果参数包含方法__dir__(),该方法将被调用.如 ...
- H3C 单路径网络中环路产生过程(2)
- 【u233】单词化简
Time Limit: 1 second Memory Limit: 64 MB [问题描述] 最近情报人员得到了一些经过加密的文章,每个单词都很长.破译人员想到先把单词化简一下,方法是把每个单词尽量 ...