一、问题

最近在查看线上的 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. 删除部分历史索引

可以看看 elasticsearch定时删除索引第二版

3. 更改es设置

  1. 更改配置文件(需要重启es)
  2. 动态更改(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集群索引无副本的更多相关文章

  1. 主机磁盘使用率超过85%导致es索引变为只读模式

    [ type=cluster_block_exception, reason=index [ index_name ] FORBIDDEN/12/index read-only / allow del ...

  2. Elasticsearch之重要核心概念(cluster(集群)、shards(分配)、replicas(索引副本)、recovery(据恢复或叫数据重新分布)、gateway(es索引的持久化存储方式)、discovery.zen(es的自动发现节点机制机制)、Transport(内部节点或集群与客户端的交互方式)、settings(修改索引库默认配置)和mappings)

    Elasticsearch之重要核心概念如下: 1.cluster 代表一个集群,集群中有多个节点,其中有一个为主节点,这个主节点是可以通过选举产生的,主从节点是对于集群内部来说的.es的一个概念就是 ...

  3. ELasticSearch(五)ES集群原理与搭建

    一.ES集群原理 查看集群健康状况:URL+ /GET _cat/health (1).ES基本概念名词 Cluster 代表一个集群,集群中有多个节点,其中有一个为主节点,这个主节点是可以通过选举产 ...

  4. 教你在Kubernetes中快速部署ES集群

    摘要:ES集群是进行大数据存储和分析,快速检索的利器,本文简述了ES的集群架构,并提供了在Kubernetes中快速部署ES集群的样例:对ES集群的监控运维工具进行了介绍,并提供了部分问题定位经验,最 ...

  5. 本地ES集群数据通过_reindex方式迁移到腾讯云服务器(亲测有效)

    本地ES集群数据通过_reindex方式迁移到腾讯云服务器(亲测有效) 随着业务量的增加,本地的ES集群服务器性能和磁盘空间有点不够使用,项目组考虑使用腾讯云服务器,以下是我测试的使用_reindex ...

  6. ELK学习笔记之简单适用的ES集群监控工具cerebro安装使用

    安装指导及使用简介 1.      下载安装包: https://github.com/lmenezes/cerebro/releases/download/v0.7.3/cerebro-0.7.3. ...

  7. ES集群安装

    环境配置 安装openjdk(依赖) -openjdk.x86_64 安装elasticsearch yum -y install elasticsearch 配置 /etc/elasticsearc ...

  8. elasticsearch系列八:ES 集群管理(集群规划、集群搭建、集群管理)

    一.集群规划 搭建一个集群我们需要考虑如下几个问题: 1. 我们需要多大规模的集群? 2. 集群中的节点角色如何分配? 3. 如何避免脑裂问题? 4. 索引应该设置多少个分片? 5. 分片应该设置几个 ...

  9. elasticsearch(es) 集群恢复触发配置(Local Gateway参数)

    elasticsearch(es) 集群恢复触发配置(Local Gateway) 当你集群重启时,几个配置项影响你的分片恢复的表现. 首先,我们需要明白如果什么也没配置将会发生什么. 想象一下假设你 ...

随机推荐

  1. [***]HZOJ 柱状图

    神仙题. 作者的正解: *logn).   算法三:对于100%的数据:  我们枚举屋顶位置再三分高度的做法,复杂度的瓶颈在于花费的计算.假设屋顶在i处,高度为hi,如果j<i,有hj-j=hi ...

  2. Android中使用lambda表达式

    lambda 语法简介 视频为本篇播客知识点讲解,建议采用超清模式观看, 欢迎点击订阅我的优酷 如果刚学Android,不知道怎么写点击事件可以跳转,传送门 要想在Android中使用lambda语法 ...

  3. 第二次 C++作业

    1.为什么要用函数? 函数是相对独立的,经常使用的功能抽象化表现形式,函数的优势在于,编写之后可以被重复使用,使用时可以只关心函数的功能和使用方法而不必关心函数的具体实现,这样可以有利于代码重用,可以 ...

  4. 在做微信分享到朋友圈时,手机扫码报config:invalid signature,分享后后正常的问题,是url问题

    是按照以下步骤检查的 除了ACCESS_TOKEN没有缓存其他都可以 如果是invalid signature签名错误.建议按如下顺序检查: 1.确认签名算法正确,可用 http://mp.weixi ...

  5. 字符串编辑距离(Edit Distance)

    一.问题描述定义字符串编辑距离(Edit Distance),是俄罗斯科学家 Vladimir Levenshtein 在 1965 年提出的概念,又称 Levenshtein 距离,是指两个字符串之 ...

  6. HMM(隐马尔科夫)用于中文分词

    隐马尔可夫模型(Hidden Markov Model,HMM)是用来描述一个含有隐含未知参数的马尔可夫过程. 本文阅读了2篇blog,理解其中的意思,附上自己的代码,共同学习. 一.理解隐马尔科夫 ...

  7. CSS滤镜 :灰色 ,方便站点哀悼

    html {  -webkit-filter: grayscale(100%); -moz-filter: grayscale(100%); -ms-filter: grayscale(100%); ...

  8. Scrapy项目注意事项

  9. MySQL之Field 'email' doesn't have a default value问题

    MySQL在出现这个Field xxx doesn't have a default value错误的原因是:我们设置了该字段为非空,但是我们没有设置默认值照成的. 比如我们创建一个表: CREATE ...

  10. Lavarel之环境配置 .env

    .env 文件位于项目根目录下,作为全局环境配置文件. 1. 配置参数 // 运行环境名称 APP_ENV=local // 调试模式,开发阶段启用,上线状态禁用. APP_DEBUG=true // ...