elasticsearch 7处于YELLOW状态,未分配分片



我无法获得工作绿色状态的单个主节点集群:elasticsearch: 7.17.0

我猜这是因为我有unassignd_shards比;0

配置:

apiVersion: v1
data:
elasticsearch.yml: |-
discovery:
type: single-node
network:
host: 0.0.0.0
path:
data: /bitnami/elasticsearch/data
xpack:
ml:
enabled: false
kind: ConfigMap
metadata:
labels:
app.kubernetes.io/instance: elasticsearch
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: elasticsearch
argocd.argoproj.io/instance: elasticsearch
helm.sh/chart: elasticsearch-19.5.5
name: elasticsearch
namespace: elasticsearch
kubectl logs elasticsearch-master-0
[2022-12-25T07:52:40,652][INFO ][o.e.c.r.a.AllocationService] [elasticsearch-master-0] Cluster health status changed from [RED] to [YELLOW] (reason: [shards started [[.ds-ilm-history-5-2022.10.28-000014][0], [.ds-ilm-history-5-2022.09.28-000012][0]]]).
[2022-12-25T07:52:40,856][INFO ][o.e.i.g.GeoIpDownloader  ] [elasticsearch-master-0] updating geoip database [GeoLite2-ASN.mmdb]
✗  curl -XGET http://localhost:9200/_cluster/health?pretty=true
{
"cluster_name" : "elasticsearch",
"status" : "yellow",
"timed_out" : false,
"number_of_nodes" : 1,
"number_of_data_nodes" : 1,
"active_primary_shards" : 7,
"active_shards" : 7,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 1,
"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" : 87.5
}
➜ curl -XGET http://localhost:9200/_cat/shards                                                                                         
magento2_product_1_v583                                       0 p STARTED    4868 18.9mb 10.110.4.229 elasticsearch-master-0
.ds-ilm-history-5-2022.10.28-000014                           0 p STARTED                10.110.4.229 elasticsearch-master-0
.ds-ilm-history-5-2022.11.27-000015                           0 p STARTED                10.110.4.229 elasticsearch-master-0
.ds-ilm-history-5-2022.08.29-000010                           0 p STARTED                10.110.4.229 elasticsearch-master-0
.ds-ilm-history-5-2022.09.28-000012                           0 p STARTED                10.110.4.229 elasticsearch-master-0
.geoip_databases                                              0 p STARTED      40 38.1mb 10.110.4.229 elasticsearch-master-0
.ds-.logs-deprecation.elasticsearch-default-2022.12.21-000022 0 p STARTED                10.110.4.229 elasticsearch-master-0
.ds-.logs-deprecation.elasticsearch-default-2022.12.21-000022 0 r UNASSIGNED 

我试图删除它,但面对一个错误

➜ curl -XGET http://localhost:9200/_cat/shards | grep UNASSIGNED | awk {'print $1'} | xargs -i curl -XDELETE "http://localhost:9200/{}"
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Dload  Upload   Total   Spent    Left  Speed
100   986  100   986    0     0   5241      0 --:--:-- --:--:-- --:--:--  5244
{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"index [.ds-.logs-deprecation.elasticsearch-default-2022.12.21-000022] is the write index for data stream [.logs-deprecation.elasticsearch-default] and cannot be deleted"}],"type":"illegal_argument_exception","reason":"index [.ds-.logs-deprecation.elasticsearch-default-2022.12.21-000022] is the write index for data stream [.logs-deprecation.elasticsearch-default] and cannot be deleted"},"status":400}

GET/_cluster/配置/解释:

➜ curl -XGET http://localhost:9200/_cluster/allocation/explain?pretty=true | jq
{
"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": ".ds-.logs-deprecation.elasticsearch-default-2022.12.21-000022",
"shard": 0,
"primary": false,
"current_state": "unassigned",
"unassigned_info": {
"reason": "CLUSTER_RECOVERED",
"at": "2022-12-25T07:52:37.022Z",
"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": "aURccTcnSuqPC3fBfmezCg",
"node_name": "elasticsearch-master-0",
"transport_address": "10.110.4.229:9300",
"node_attributes": {
"xpack.installed": "true",
"transform.node": "true"
},
"node_decision": "no",
"deciders": [
{
"decider": "same_shard",
"decision": "NO",
"explanation": "a copy of this shard is already allocated to this node [[.ds-.logs-deprecation.elasticsearch-default-2022.12.21-000022][0], node[aURccTcnSuqPC3fBfmezCg], [P], s[STARTED], a[id=tsxhnODlSn-i__-vEvJj3A]]"
}
]
}
]

那么在这种情况下可以做什么呢?

curl -v -XPUT "localhost:9200/*/_settings" -H 'Content-Type: application/json' -d '
{
"index" : {
"number_of_replicas" : 0
}
}
'
{"acknowledged":true}

curl -XGET http://localhost:9200/_cat/indices     
green open magento2_product_1_v583 hvYpUxJUT16-g6_YS8qkaA 1 0 4868  0 18.9mb 18.9mb
green open .geoip_databases        tDXBLQRdSFeQyi6Pk5zq2Q 1 0   40 40 38.1mb 38.1mb

如果状态为黄色,表示Elasticsearch集群中有一个或多个replica shards没有分配给节点。当您只有一个节点时,这意味着您的副本数量大于节点数量。Elasticsearch永远不会将副本分配给与主分片相同的节点。因此,如果您只有一个节点,那么您的集群将显示为黄色是完全正常的。但是,如果您不相信并且希望您的集群是绿色的,则将每个索引的副本数量设置为0。

PUT /my-index/_settings
{
"index" : {
"number_of_replicas" : 0
}
}

相关内容

  • 没有找到相关文章

最新更新