武汉地铁计划建设在哪个网站查,看b站视频下载软件,织梦 茶叶网站,给人做阉割手术的网站Elasticsearch集群Yellow亚健康状态修复问题背景排查流程解决办法问题背景
Elasticsearch集群健康状态为Yellow#xff0c;涉及到多个索引。
排查流程
在浏览器打开Kibana Console进行问题排查#xff0c;console地址为#xff1a;
http://{Kibana_IP}:5601/app/dev_too…
Elasticsearch集群Yellow亚健康状态修复问题背景排查流程解决办法问题背景
Elasticsearch集群健康状态为Yellow涉及到多个索引。
排查流程
在浏览器打开Kibana Console进行问题排查console地址为
http://{Kibana_IP}:5601/app/dev_tools#/console在console运行以下API命令来获取基本信息
GET _cat/health?v
GET _cat/master?v
GET _cat/nodes?v
GET _cat/indices?vGET _cat/shards?v
# 输出中各列分别为
# shard分片名称prirep主分片或副本
# state分片状态可以为 INITIALIZING | RELOCATING | STARTED | UNASSIGNED
# docs分片中文档的数量store分片占用的磁盘空间GET _cat/allocation?v
# 获取分配到每个节点的分片数量以及所占用的磁盘空间获取健康状态为Yellow的索引信息
GET _cat/indices?vhealthyellow输出中包含的列有health、status索引状态、index索引名称、uuid、pri主分片数量、rep副本数量、docs.count、docs.deleted、store.size、pro.store.size。
从上面拿到的异常状态索引中任选一个假设为ftimes_infra_migrad_2022-09继续查看该索引的分片信息
GET _cat/shards/ftimes_infra_migrad_2022-09?v输出的列中包含index、shard分片名称、prirepprimary还是replica、state、docs、store分片大小、ip、node分片所在节点。
观察目标索引的各个分片的分配情况。Yellow健康状态下一般这里可以看到有replica分片没有被正确分配即prirepr的行记录对应的分片状态为stateUNASSIGNED。
假设未被正确分配的replica分片名称为0检查该分片分配失败的原因
GET _cluster/allocation/explain
{index: ftimes_infra_migrad_2022-09,shard: 0,primary: false
}检查输出中的explanation部分
...
explanation: shard has exceeded the maximum number of retries [5] on failed
allocation attempts - manually call [/_cluster/reroute?retry_failedtrue] to retry,
...解决办法
下面我们尝试手动分配该replica分片。需要确保replica分片要分配的节点上有足够的磁盘空间并且同一索引的primary分片和replica分片不在同一节点上。
# 查看分片的大小、主分片所在节点
GET _cat/shards/ftimes_infra_migrad_2022-09?v# 查看各节点的磁盘空间使用情况
GET _cat/allocation?v# 将replica分片手动分配到指定节点es_data_21
POST /_cluster/reroute
{command: [{allocation_replica: {index: ftimes_infra_migrad_2022-09,shard: 0,node: es_data_21}}]
}执行后收到下面的报错
...
type: illegal_argument_exception,
reason: [allocation_replica] allocation of [ftimes_infra_migrad_2022-09][0] on
node {es_data_21}{...}{...} is not allowed, reason: [NO(shard has exceeded the
maximum number of retries [5] on failed allocation attempts - manually call
[/_cluster/reroute?retry_failedtrue] to retry, ... )]根据错误提示执行以下命令
POST /_cluster/reroute?retry_failedtrueES集群就会自动重新分配之前分配出错的replica副本。
过一小段时间后检查所有索引健康状态
GET _cat/indices?vhealthyellowMORE …
在Kibana的console API命令中可以使用s来对检索结果按指定的列排序并使用通配符*来匹配任意字符串。
# 获取集群中所有索引信息并按index列排序
GET _cat/indices?vsindex# 获取集群中名称以ftimes开头的所有索引信息并按index列排序
GET _cat/indices/ftimes*?vsindex# 获取集群中名称以gzone开头的索引的所有分片信息
GET _cat/shards/gzone*