一、問題
logstash突然無法對elasticsearch服務進行讀寫操作了,提示elasticsearch的地址有問題,檢測elasticsearch發現端口存在。查看日志發現有報錯。
二、問題原因
有一些索引的數據損壞了
三、解決
官網文檔:https://www.elastic.co/guide/cn/elasticsearch/guide/cn/_cluster_health.html
1、查看索引信息
curl -XGET 'http://localhost:9200/_cluster/health?pretty=true' { "cluster_name" : "test", "status" : "yellow", "timed_out" : false, "number_of_nodes" : 1, "number_of_data_nodes" : 1, "active_primary_shards" : 134, "active_shards" : 134, "relocating_shards" : 0, "initializing_shards" : 0, "unassigned_shards" : 30, "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" : 98.19711538461539 #數據的正常率,100表示一切ok }
2、查看所有所有的狀態
green:所有的主分片和副本分片都已分配。你的集群是 100% 可用的。
yellow:所有的主分片已經分片了,但至少還有一個副本是缺失的。不會有數據丟失,所以搜索結果依然是完整的。不過,你的高可用性在某種程度上被弱化。如果 更多的 分片消失,你就會丟數據了。把 yellow 想象成一個需要及時調查的警告。
red:至少一個主分片(以及它的全部副本)都在缺失中。這意味着你在缺少數據:搜索只能返回部分數據,而分配到這個分片上的寫入請求會返回一個異常。
curl 'localhost:9200/_cat/indices?v'
3、刪除red狀態的索引
curl -XDELETE http://localhost:9200/index_name