ES 遇到 unassigned shard如何处理?
解决方法:(1)如果是红色的,可以直接分片shard给你认为有最新(或最多)数据的节点。见下:
摘自:https://discuss.elastic.co/t/how-to-resolve-the-unassigned-shards/87635
Use the reroute command to assign the unassigned shard to a node.
If your cluster is red then you probably have primary shards unassigned. The command below will allow you to reassign a shard that has gone "stale"(腐烂不新鲜的). This means that ES is not sure which copy of the shard has the most recent data and it will not assign one as primary because if another shard with newer data connects to the cluster later it will be overwritten. If your confident that the shard has all of the data you need then you can assign it to a node with the command below. Just be wary of data loss。
curl -XPOST 'localhost:9200/_cluster/reroute?pretty' -H 'Content-Type: application/json' -d'
{
"commands" : [
{
"allocate_stale_primary" : {
"index" : "test", "shard" : 1,
"node" : "node3",
"accept_data_loss" : true
}
}
]
}
'
https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-reroute.html
(2)如果集群是黄色的,可以等其恢复
The status may be one of three values:
green- All primary and replica shards are allocated. Your cluster is 100% operational.
yellow- All primary shards are allocated, but at least one replica is missing. No data is missing, so search results will still be complete. However, your high availability is compromised to some degree. If moreshards disappear, you might lose data. Think of
yellowas a warning that should prompt investigation. red- At least one primary shard (and all of its replicas) is missing. This means that you are missing data: searches will return partial results, and indexing into that shard will return an exception.
The green/yellow/red status is a great way to glance at your cluster and understand what’s going on. The rest of the metrics give you a general summary of your cluster:
number_of_nodesandnumber_of_data_nodesare fairly self-descriptive.active_primary_shardsindicates the number of primary shards in your cluster. This is an aggregate total across all indices.active_shardsis an aggregate total of all shards across all indices, which includes replica shards.relocating_shardsshows the number of shards that are currently moving from one node to another node(现网中遇到,因为kill -9重启es的方法不对,导致node下线,集群重新分配shard). This number is often zero, but can increase when Elasticsearch decides a cluster is not properly balanced, a new node is added, or a node is taken down, for example(原因).initializing_shardsis a count of shards that are being freshly created. For example, when you first create an index, the shards will all briefly reside ininitializingstate. This is typically a transient event, and shards shouldn’t linger ininitializingtoo long. You may also see initializing shards when a node is first restarted: as shards are loaded from disk, they start asinitializing.(现网遇到过)unassigned_shardsare shards that exist in the cluster state, but cannot be found in the cluster itself. A common source of unassigned shards are unassigned replicas. For example, an index with five shards and one replica will have five unassigned replicas in a single-node cluster. Unassigned shards will also be present if your cluster isred(since primaries are missing).
Drilling Deeper: Finding Problematic Indices
Imagine something goes wrong one day, and you notice that your cluster health looks like this:
{
"cluster_name": "elasticsearch_zach",
"status": "red",
"timed_out": false,
"number_of_nodes": 8,
"number_of_data_nodes": 8,
"active_primary_shards": 90,
"active_shards": 180,
"relocating_shards": 0,
"initializing_shards": 0,
"unassigned_shards": 20
}
OK, so what can we deduce from this health status? Well, our cluster is red, which means we are missing data (primary + replicas). We know our cluster has 10 nodes, but see only 8 data nodes listed in the health. Two of our nodes have gone missing. We see that there are 20 unassigned shards.
That’s about all the information we can glean. The nature of those missing shards are still a mystery. Are we missing 20 indices with 1 primary shard each? Or 1 index with 20 primary shards? Or 10 indices with 1 primary + 1 replica? Which index?
To answer these questions, we need to ask cluster-health for a little more information by using the level parameter:
GET _cluster/health?level=indices
This parameter will make the cluster-health API add a list of indices in our cluster and details about each of those indices (status, number of shards, unassigned shards, and so forth):
{
"cluster_name": "elasticsearch_zach",
"status": "red",
"timed_out": false,
"number_of_nodes": 8,
"number_of_data_nodes": 8,
"active_primary_shards": 90,
"active_shards": 180,
"relocating_shards": 0,
"initializing_shards": 0,
"unassigned_shards": 20
"indices": {
"v1": {
"status": "green",
"number_of_shards": 10,
"number_of_replicas": 1,
"active_primary_shards": 10,
"active_shards": 20,
"relocating_shards": 0,
"initializing_shards": 0,
"unassigned_shards": 0
},
"v2": {
"status": "red",
![]()
"number_of_shards": 10,
"number_of_replicas": 1,
"active_primary_shards": 0,
"active_shards": 0,
"relocating_shards": 0,
"initializing_shards": 0,
"unassigned_shards": 20
![]()
},
"v3": {
"status": "green",
"number_of_shards": 10,
"number_of_replicas": 1,
"active_primary_shards": 10,
"active_shards": 20,
"relocating_shards": 0,
"initializing_shards": 0,
"unassigned_shards": 0
},
....
}
}
|
|
We can now see that the |
|
|
And it becomes clear that all 20 missing shards are from this index. |
Once we ask for the indices output, it becomes immediately clear which index is having problems: the v2 index. We also see that the index has 10 primary shards and one replica, and that all 20 shards are missing. Presumably these 20 shards were on the two nodes that are missing from our cluster.
摘自:https://www.elastic.co/guide/en/elasticsearch/guide/current/_cluster_health.html
ES 遇到 unassigned shard如何处理?的更多相关文章
- 处理 unassigned shard
#查看所有分片 GET _cat/shards curl 10.1.2.2:9200/_cat/indices/iis_log* #查看索引的分片状态 #查看第一个unassigned shard的 ...
- 磁盘空间引起ES集群shard unassigned的处理过程
1.问题描述 早上醒来发现手机有很多ES状态为red的告警,集群就前几天加了几个每天有十多亿记录的业务,当时估算过磁盘容量,应该是没有问题的,但是现在集群状态突然变成red了,这就有点懵逼了. 2.查 ...
- Reroute Unassigned Shards——遇到主shard 出现的解决方法就是重新路由
Red Cluster! 摘自:http://blog.kiyanpro.com/2016/03/06/elasticsearch/reroute-unassigned-shards/ There a ...
- 4.ES核心慨念
一. 和lucene的关系 lucene是最先进,功能最强大的搜索库.但是使用复杂(要深入理解其中原理. elasticsearch,基于lucene,隐藏复杂性,提供简单易用的restful api ...
- es故障节点恢复后加入集群导致删除索引重新出现
es的每个shard下的文件都可以看做一个完整的lucene文件,shard数据目录下的segment文件包含了索引的分片数量,副本数量.es shard可以恢复,就是因为每个shard都包含了一份数 ...
- es修改指定的field(partial update)
PUT /index/type/id 创建文档&替换文档,就是一样的语法一般对应到应用程序中,每次的执行流程基本是这样的:1.应用程序发起一个get请求,获取到document,展示到前台界面 ...
- 节点回来shard仍然delayed原因
1:es2 fetch shard data时,存在节点刚加入集群,还没有收到cluster metadata的情况.此时,节点因为没有该索引,返回的sharddata为empty,主节点缓存了该sh ...
- elasticsearch 产生未分配分片的原因(es官网)
Reasons for unassigned shard: These are the possible reasons for a shard to be in a unassigned state ...
- 【Elasticsearch 技术分享】—— 十张图带大家看懂 ES 原理 !明白为什么说:ES 是准实时的!
前言 说到 Elasticsearch ,其中最明显的一个特点就是 near real-time 准实时 -- 当文档存储在Elasticsearch中时,将在1秒内以几乎实时的方式对其进行索引和完全 ...
随机推荐
- c12---数组
// // main.c // 数组基本概念 // // Created by xiaomage on 15/6/9. // Copyright (c) 2015年 itcast. All right ...
- weblogic状态监控脚本
echo "======================================welcome============================================ ...
- SOAPUI 安装及破解
转自:https://blog.csdn.net/henni_719/article/details/79000130 先下载SOAPUI,我这里用的是5.1.2 PRO 版 下载路径:http:/ ...
- 案例分析:大数据平台技术方案及案例(ppt)
大数据平台是为了计算,现今社会所产生的越来越大的数据量,以存储.运算.展现作为目的的平台.大数据技术是指从各种各样类型的数据中,快速获得有价值信息的能力.适用于大数据的技术,包括大规模并行处理(MPP ...
- PHP分页组件:Paginator
安装 composer require "jasongrimes/paginator:~1.0" 使用 <?php require '../vendor/autoload.p ...
- Sentry: Python 实时日志平台
Links https://docs.getsentry.com/on-premise/quickstart/ https://docs.getsentry.com/on-premise/server ...
- Mac Technology Overview
[Mac Technology Overview]https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual ...
- jenkins 展示报告
1.下载插件 HTML Publisher plugin 2.设置说明 3.展示css 下载插件 (1).Startup Trigger: 可实现在Jenkins节点(master/slave)启动时 ...
- node——try-catch与异步操作
//try-catch,用于捕获异常 //try-catch在node中只能捕获同步的异常,不能捕获异步异常 var fs=require('fs'); /*fs.writeFile('./abc.t ...
- TensorFlow+实战Google深度学习框架学习笔记(6)----神经网络经典损失函数
1.分类问题(交叉熵): (1)模型: (2)代码1: 其中,tf.clip_by_value是将一个张量的数值限制在一个范围之内,若小于1e-10则赋值为1e-10,若大于1.0则赋值为1,这样避免 ...