解决elasticsearch6.x单机版索引状态显示为yellow

索引状态显示为yellow的原因分析

基本的分片可用,但是备份不可用(或者是没有备份);  这种情况Elasticsearch集群所有的主分片已经分片了,但至少还有一个副本是缺失的。不会有数据丢失,所以搜索结果依然是完整的。不过,你的高可用性在某种程度上被弱化。如果 更多的 分片消失,你就会丢数据了。把 yellow 想象成一个需要及时调查的警告。

解决方案

创建索引模版,指定默认的分片数及副本数,这样在之后同样引用该索引模版的索引将自动使用该设置,无需每次都手动设置每个索引的分片数和副本数,一劳永逸

curl --location --request PUT 'http://127.0.0.1:9200/_template/template_http_request_record' \
--header 'Authorization: Basic xxxxxxx==' \
--header 'Content-Type: application/json' \
--data-raw '{
    "index_patterns": [
        "record-*"
    ],
    "settings": {
        "number_of_shards": 1,
        "number_of_replicas": 0
    }
}'
  • record_*:作用于所有以record_开头的索引
  • number_of_shards:分片数
  • number_of_replicas:副本数

最终效果

https://www.cnblogs.com/gangdou/p/10724674.html
https://www.cnblogs.com/kevingrace/p/10671063.html

posted @ 2020-09-01 16:12  时光走散了故人。  阅读(1378)  评论(0编辑  收藏  举报