为弹性搜索打开发行版 'source alias does not point to a write index'

open distro for elastic search 'source alias does not point to a write index'

我正在使用 open distro for elasticsearch v7.7.0,我想自动管理索引生命周期,以便在创建新索引时自动附加到 ISM 策略。 但我收到此错误 'source alias does not point to a write index'.

这是我的配置:

1- Logstash 输出

output {
elasticsearch {
hosts => ["http://myelasticsearch"]
user => "someuser"
password => "somepassword-"
#index => "demo"
index => "demo-%{+YYYY.MM.dd.HH-mm}"
       ssl => false
       ssl_certificate_verification => false
       ilm_enabled => false
}
stdout { codec => "dots"}
}

2- ISM 政策

    {
    "policy": {
        "policy_id": "hot warm delete workflow",
        "description": "hot warm delete workflow",
        "last_updated_time": 1595417446751,
        "schema_version": 1,
        "error_notification": null,
        "default_state": "hot",
        "states": [
            {
                "name": "hot",
                "actions": [
                    {
                        "rollover": {
                            "min_index_age": "1d"
                        }
                    }
                ],
                "transitions": [
                    {
                        "state_name": "warm"
                    }
                ]
            },
            {
                "name": "warm",
                "actions": [
                    {
                        "replica_count": {
                            "number_of_replicas": 0
                        }
                    }
                ],
                "transitions": [
                    {
                        "state_name": "delete",
                        "conditions": {
                            "min_index_age": "30d"
                        }
                    }
                ]
            },
            {
                "name": "delete",
                "actions": [
                    {
                        "delete": {}
                    }
                ],
                "transitions": []
            }
        ]
    }
}

3- 索引模板

  PUT _template/my_template
{
"alias": {
    "demo": {"is_write_index": true }
  },
  "index_patterns": ["demo*"],                 
  "settings": {
    "number_of_shards": 1,
    "number_of_replicas": 1,
    "opendistro.index_state_management.policy_id": "hot warm delete workflow",      
    "opendistro.index_state_management.rollover_alias": "demo"  
    
  }
}

我注意到创建别名时它没有获得 'is_write_index": true' 属性。

如有任何有用的意见,我们将不胜感激。

我自己解决了这个问题。

对于遇到同样问题的人,这里是解决方案。

1- 首先创建一个模板:

PUT _template/my_template
{
  "index_patterns": ["demo*"],                 
  "settings": {
    "number_of_shards": 1,
    "number_of_replicas": 1,
    "opendistro.index_state_management.policy_id": "hot warm delete workflow",      
    "opendistro.index_state_management.rollover_alias": "demo"  
    
  }
}

2- 您需要 bootstrap 一个初始索引并将其指定为索引模板中指定的翻转别名的写入索引:

PUT demo-000001
{
  "aliases": {
    "demo": {
      "is_write_index": true
    }
  }
}

3- Logstash 输出:

output {
elasticsearch {
hosts => ["http://myelasticsearch"]
user => "someuser"
password => "somepassword-"
index => "demo"
       ssl => false
       ssl_certificate_verification => false
       ilm_enabled => false      
}
stdout { codec => "dots"}
}