单机版es中index状态为yellow问题处理

/ 默认分类 / 没有评论 / 839浏览

查询es中index状态

 curl  -X GET  -u  username:password    http://xx.xx.xx.xx:9200/_cluster/health?pretty
{
  "cluster_name" : "es7",
  "status" : "yellow"
}
$ curl  -u username:password    http://xx.xx.xx.xx:9200/_cat/indices
 
yellow open index01    1NCeOgzbQIqIX_OFUv-WTg 3 1   5   1  31.7kb  31.7kb
green  open index02    -ug5H9CWS66n2_Q3_tGoiQ 3 0   0   0    624b    624b
yellow open index03    WHBtQw_tRuOKN05oyPwf9w 1 1  24   7 174.8kb 174.8kb
yellow open index04    tIWbmSlOToOBSoXDp45PgQ 5 1 141 466 421.1kb 421.1kb

ES index状态为yellow状态原因

索引初始化脚本中,设置的 索引的分片副本数为 1 ,而单机版es,索引的分片副本无处安放,导致索引/集群状态为 yellow

处理办法

将相关索引的分片副本数改为0

注意:此管理操作需要使用es集群的 管理员账号

curl -XPUT  'http://xx.xx.xx.xx:9200/${index_name}/_settings' \
 -H 'Content-Type: application/json' \
 -u  username:password   \
-d '{
    "index" : {
               "number_of_replicas": 0
    }
}'

验证

curl  -X GET -s   -u  username:password   http://xx.xx.xx.xx:9200/_cluster/health?pretty

{
  "cluster_name" : "es7",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 1,
  "number_of_data_nodes" : 1,
  "active_primary_shards" : 13,
  "active_shards" : 13,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 0,
  "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" : 100.0
}