单机版的 ES 状态为 Yellow,如何让 Yellow 变成 Green?
在shard层面,ElasticSearch
redstatus表示集群中没有分配特定的shard,yellow表示分配了primary shard但没有分配replicas,green表示所有shard都在分配
查看状态
curl -X GET http://localhost:9200/_cluster/health
输出
{
"cluster_name": "docker-cluster",
"status": "yellow",
"timed_out": false,
"number_of_nodes": 1,
"number_of_data_nodes": 1,
"active_primary_shards": 25,
"active_shards": 25,
"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
}
解决方法
- number_of_replicas 是数据备份数,如果只有一台机器,设置为0
- number_of_shards 是数据分片数,默认为1
curl -X PUT 'http://localhost:9200/_settings' -d '
{
"settings" : {
"number_of_replicas" : 0
}
}'