ElasticSearch问题排查
查看索引信息
curl -XGET 'http://localhost:9200/_cluster/health?pretty=true'
{
"cluster_name" : "master-node",
"status" : "yellow",
"timed_out" : false,
"number_of_nodes" : 2,
"number_of_data_nodes" : 1,
"active_primary_shards" : 629,
"active_shards" : 629,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 611,
"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" : 50.7258064516129
}
status
: yellow
active_shards_percent_as_number
: 数据的正常率,100表示一切ok
查看所有索引的状态
-
green
所有的主分片和副本分片都已分配。你的集群是 100% 可用的。 -
yellow
所有的主分片已经分片了,但至少还有一个副本是缺失的。不会有数据丢失,所以搜索结果依然是完整的。不过,你的高可用性在某种程度上被弱化。如果 更多的 分片消失,你就会丢数据了。把 yellow 想象成一个需要及时调查的警告。 -
red
至少一个主分片(以及它的全部副本)都在缺失中。这意味着你在缺少数据:搜索只能返回部分数据,而分配到这个分片上的写入请求会返回一个异常。 -
获取所有索引状态
curl 'localhost:9200/_cat/indices?v'
删除red状态的索引
curl -XDELETE http://localhost:9200/index_name