【es】索引状态为yellow,unassigned

1.集群状态为yellow 

curl -u elastic:elastic -k https://192.168.1.806:9200/_cluster/health
{"cluster_name":"es-cluster","status":"yellow","timed_out":false,"number_of_nodes":6,"number_of_data_nodes":3,
"active_primary_shards":417,"active_shards":839,"relocating_shards":0,"initializing_shards":0,
"unassigned_shards":2,"delayed_unassigned_shards":0,"number_of_pending_tasks":0,"number_of_in_flight_fetch":0,
"task_max_waiting_in_queue_millis":0,"active_shards_percent_as_number":99.76218787158146}

curl -XGET 'localhost:9200/_cat/indices?v&h=index,status'
yellow open   log_search_index lBeXQQh6TQaMrL5f4Vqodg   2   3      13716 0     37.5mb 10mb

某个索引状态为 yellow; 查看原因 

curl -u elastic:elastic  -k https://192.168.1.806:9200/_cluster/allocation/explain
{
    "note":"No shard was specified in the explain API request, so this response explains a randomly chosen unassigned shard. There may be other unassigned shards in this cluster which cannot be assigned for different reasons. It may not be possible to assign this shard until one of the other shards is assigned correctly. To explain the allocation of other shards (whether assigned or unassigned) you must specify the target shard in the request to this API.",
    "index":"log_search_index",
    "shard":1,
    "primary":false,
    "current_state":"unassigned",
    "unassigned_info":{
        "reason":"INDEX_CREATED",
        "at":"2025-05-29T08:00:04.800Z",
        "last_allocation_status":"no_attempt"
    },
    "can_allocate":"no",
    "allocate_explanation":"cannot allocate because allocation is not permitted to any of the nodes",
    "node_allocation_decisions":[
        {
            "node_id":"xo4a8Fe-TAGWocKin-gStw",
            "node_name":"master_03",
            "transport_address":"192.168.1.808:9300",
            "node_attributes":{
                "ml.machine_memory":"66918821888",
                "ml.max_open_jobs":"512",
                "xpack.installed":"true",
                "ml.max_jvm_size":"17179869184",
                "transform.node":"true"
            },
            "node_decision":"no",
            "weight_ranking":1,
            "deciders":[
                {
                    "decider":"same_shard",
                    "decision":"NO",
                    "explanation":"a copy of this shard is already allocated to this node [[log_search_index][1], node[xo4a8Fe-TAGWocKin-gStw], [R], s[STARTED], a[id=Og3qbC9nS1mLZCoxGpryRQ]]"
                }
            ]
        },
        {
            "node_id":"LLspvxI2S5CN99PVQdZm1Q",
            "node_name":"master_01",
            "transport_address":"192.168.1.806:9300",
            "node_attributes":{
                "ml.machine_memory":"66918821888",
                "ml.max_open_jobs":"512",
                "xpack.installed":"true",
                "ml.max_jvm_size":"17179869184",
                "transform.node":"true"
            },
            "node_decision":"no",
            "weight_ranking":2,
            "deciders":[
                {
                    "decider":"same_shard",
                    "decision":"NO",
                    "explanation":"a copy of this shard is already allocated to this node [[log_search_index][1], node[LLspvxI2S5CN99PVQdZm1Q], [P], s[STARTED], a[id=c1vIg3d2TQS_ot_Mz-MbXA]]"
                }
            ]
        },
        {
            "node_id":"VCf46L9LTV-iP5L1lJGypg",
            "node_name":"master_02",
            "transport_address":"192.168.1.807:9300",
            "node_attributes":{
                "ml.machine_memory":"66918821888",
                "ml.max_open_jobs":"512",
                "xpack.installed":"true",
                "ml.max_jvm_size":"17179869184",
                "transform.node":"true"
            },
            "node_decision":"no",
            "weight_ranking":3,
            "deciders":[
                {
                    "decider":"same_shard",
                    "decision":"NO",
                    "explanation":"a copy of this shard is already allocated to this node [[log_search_index][1], node[VCf46L9LTV-iP5L1lJGypg], [R], s[STARTED], a[id=A51JMuRkQ0iaPxCJLqfHEQ]]"
                }
            ]
        }
    ]
}

GET /user/_settings

某个索引状态为 yellow; 
curl -u elastic:elastic  -k https://192.168.1.806:9200/log_search_index/_settings

{
    "log_search_index":{
        "settings":{
            "index":{
                "routing":{
                    "allocation":{
                        "include":{
                            "_tier_preference":"data_content"
                        }
                    }
                },
                "number_of_shards":"2",
                "provided_name":"log_search_index",
                "creation_date":"1748505604797",
                "number_of_replicas":"3",
                "uuid":"lBeXQQh6TQaMrL5f4Vqodg",
                "version":{
                    "created":"7170099"
                }
            }
        }
    }
}

#设置副本数只有3个节点,副本数最大应该为2,这里副本数为3,所以有一个副本有问题。
#修改副本数为2;
curl -u elastic:elastic  -k -XPUT  https://192.168.1.806:9200/log_search_index/_settings  -H 'Content-Type: application/json' -d '
{

      "number_of_replicas" : 2
}'

[root@localhost ~]# sh es_status.sh 
epoch      timestamp cluster    status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1748511769 09:42:49  es-cluster green           6         3    839 417    0    0        0             0                  -                100.0%

由此可见,设置的副本数超过节点数,就会报yellow 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值